@reown/walletkit 1.2.1 → 1.2.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +14 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function($t,Ct){typeof exports=="object"&&typeof module<"u"?Ct(exports):typeof define=="function"&&define.amd?define(["exports"],Ct):($t=typeof globalThis<"u"?globalThis:$t||self,Ct($t["@reown/walletkit"]={}))})(this,function($t){"use strict";var Ct=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function La(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}var Ot={exports:{}},ln=typeof Reflect=="object"?Reflect:null,wu=ln&&typeof ln.apply=="function"?ln.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},lo;ln&&typeof ln.ownKeys=="function"?lo=ln.ownKeys:Object.getOwnPropertySymbols?lo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:lo=function(e){return Object.getOwnPropertyNames(e)};function k1(t){console&&console.warn&&console.warn(t)}var _u=Number.isNaN||function(e){return e!==e};function de(){de.init.call(this)}Ot.exports=de,Ot.exports.once=H1,de.EventEmitter=de,de.prototype._events=void 0,de.prototype._eventsCount=0,de.prototype._maxListeners=void 0;var xu=10;function po(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(de,"defaultMaxListeners",{enumerable:!0,get:function(){return xu},set:function(t){if(typeof t!="number"||t<0||_u(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");xu=t}}),de.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},de.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||_u(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Eu(t){return t._maxListeners===void 0?de.defaultMaxListeners:t._maxListeners}de.prototype.getMaxListeners=function(){return Eu(this)},de.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")wu(c,this,r);else for(var f=c.length,h=$u(c,f),i=0;i<f;++i)wu(h[i],this,r);return!0};function Su(t,e,r,i){var n,s,o;if(po(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Eu(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,k1(a)}return t}de.prototype.addListener=function(e,r){return Su(this,e,r,!1)},de.prototype.on=de.prototype.addListener,de.prototype.prependListener=function(e,r){return Su(this,e,r,!0)};function j1(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Iu(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=j1.bind(i);return n.listener=r,i.wrapFn=n,n}de.prototype.once=function(e,r){return po(r),this.on(e,Iu(this,e,r)),this},de.prototype.prependOnceListener=function(e,r){return po(r),this.prependListener(e,Iu(this,e,r)),this},de.prototype.removeListener=function(e,r){var i,n,s,o,a;if(po(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():K1(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},de.prototype.off=de.prototype.removeListener,de.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function Au(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?V1(n):$u(n,n.length)}de.prototype.listeners=function(e){return Au(this,e,!0)},de.prototype.rawListeners=function(e){return Au(this,e,!1)},de.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Du.call(t,e)},de.prototype.listenerCount=Du;function Du(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}de.prototype.eventNames=function(){return this._eventsCount>0?lo(this._events):[]};function $u(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function K1(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function V1(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function H1(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}Ou(t,e,s,{once:!0}),e!=="error"&&W1(t,n,{once:!0})})}function W1(t,e,r){typeof t.on=="function"&&Ou(t,"error",e,r)}function Ou(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const Mu="wc",G1=2,qa="WalletKit",Y1=`${Mu}@2:${qa}:`,J1={database:":memory:"},Z1="request";var V={};/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -11,23 +11,19 @@
|
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */var Oa=function(t,e){return Oa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Oa(t,e)};function Vp(t,e){Oa(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Pa=function(){return Pa=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Pa.apply(this,arguments)};function Hp(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Wp(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Gp(t,e){return function(r,i){e(r,i,t)}}function Jp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Yp(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{h(i.next(l))}catch(y){o(y)}}function c(l){try{h(i.throw(l))}catch(y){o(y)}}function h(l){l.done?s(l.value):n(l.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function Zp(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(l){return c([h,l])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,n=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Xp(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Qp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function $a(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function oh(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function e1(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(oh(arguments[e]));return t}function t1(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function ms(t){return this instanceof ms?(this.v=t,this):new ms(t)}function r1(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(M){i[M]&&(n[M]=function(I){return new Promise(function(S,D){s.push([M,I,S,D])>1||a(M,I)})})}function a(M,I){try{c(i[M](I))}catch(S){y(s[0][3],S)}}function c(M){M.value instanceof ms?Promise.resolve(M.value.v).then(h,l):y(s[0][2],M)}function h(M){a("next",M)}function l(M){a("throw",M)}function y(M,I){M(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function i1(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:ms(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function n1(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof $a=="function"?$a(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(h){s({value:h,done:a})},o)}}function s1(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function o1(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function a1(t){return t&&t.__esModule?t:{default:t}}function f1(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function c1(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var h1=Object.freeze({__proto__:null,__extends:Vp,get __assign(){return Pa},__rest:Hp,__decorate:Wp,__param:Gp,__metadata:Jp,__awaiter:Yp,__generator:Zp,__createBinding:Xp,__exportStar:Qp,__values:$a,__read:oh,__spread:e1,__spreadArrays:t1,__await:ms,__asyncGenerator:r1,__asyncDelegator:i1,__asyncValues:n1,__makeTemplateObject:s1,__importStar:o1,__importDefault:a1,__classPrivateFieldGet:f1,__classPrivateFieldSet:c1}),go=Aa(h1),Ra={},ws={},ah;function u1(){if(ah)return ws;ah=1,Object.defineProperty(ws,"__esModule",{value:!0}),ws.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ws.delay=t,ws}var ln={},Na={},pn={},fh;function d1(){return fh||(fh=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.ONE_THOUSAND=pn.ONE_HUNDRED=void 0,pn.ONE_HUNDRED=100,pn.ONE_THOUSAND=1e3),pn}var Ta={},ch;function l1(){return ch||(ch=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(Ta)),Ta}var hh;function uh(){return hh||(hh=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(d1(),t),e.__exportStar(l1(),t)}(Na)),Na}var dh;function p1(){if(dh)return ln;dh=1,Object.defineProperty(ln,"__esModule",{value:!0}),ln.fromMiliseconds=ln.toMiliseconds=void 0;const t=uh();function e(i){return i*t.ONE_THOUSAND}ln.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return ln.fromMiliseconds=r,ln}var lh;function g1(){return lh||(lh=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(u1(),t),e.__exportStar(p1(),t)}(Ra)),Ra}var Un={},ph;function b1(){if(ph)return Un;ph=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return Un.Watch=t,Un.default=t,Un}var Fa={},_s={},gh;function v1(){if(gh)return _s;gh=1,Object.defineProperty(_s,"__esModule",{value:!0}),_s.IWatch=void 0;class t{}return _s.IWatch=t,_s}var bh;function y1(){return bh||(bh=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),go.__exportStar(v1(),t)}(Fa)),Fa}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(g1(),t),e.__exportStar(b1(),t),e.__exportStar(y1(),t),e.__exportStar(uh(),t)})(Z);class gn{}class m1 extends gn{constructor(e){super()}}const vh=Z.FIVE_SECONDS,zn={pulse:"heartbeat_pulse"};class Ca extends m1{constructor(e){super(e),this.events=new Qt.exports.EventEmitter,this.interval=vh,this.interval=e?.interval||vh}static async init(e){const r=new Ca(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),Z.toMiliseconds(this.interval))}pulse(){this.events.emit(zn.pulse)}}const w1=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,_1=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,x1=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function E1(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){S1(t);return}return e}function S1(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function bo(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!x1.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(w1.test(t)||_1.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,E1)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function M1(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function $t(t,...e){try{return M1(t(...e))}catch(r){return Promise.reject(r)}}function I1(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function A1(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function vo(t){if(I1(t))return String(t);if(A1(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return vo(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function yh(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ba="base64:";function D1(t){if(typeof t=="string")return t;yh();const e=Buffer.from(t).toString("base64");return Ba+e}function O1(t){return typeof t!="string"||!t.startsWith(Ba)?t:(yh(),Buffer.from(t.slice(Ba.length),"base64"))}function ur(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function P1(...t){return ur(t.join(":"))}function yo(t){return t=ur(t),t?t+":":""}function wE(t){return t}const $1="memory",R1=()=>{const t=new Map;return{name:$1,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function N1(t={}){const e={mounts:{"":t.driver||R1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=h=>{for(const l of e.mountpoints)if(h.startsWith(l))return{base:l,relativeKey:h.slice(l.length),driver:e.mounts[l]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,l)=>e.mountpoints.filter(y=>y.startsWith(h)||l&&h.startsWith(y)).map(y=>({relativeBase:h.length>y.length?h.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(h,l)=>{if(e.watching){l=ur(l);for(const y of e.watchListeners)y(h,l)}},s=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await mh(e.mounts[h],n,h)}},o=async()=>{if(e.watching){for(const h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},a=(h,l,y)=>{const M=new Map,I=S=>{let D=M.get(S.base);return D||(D={driver:S.driver,base:S.base,items:[]},M.set(S.base,D)),D};for(const S of h){const D=typeof S=="string",R=ur(D?S:S.key),$=D?void 0:S.value,N=D||!S.options?l:{...l,...S.options},C=r(R);I(C).items.push({key:R,value:$,relativeKey:C.relativeKey,options:N})}return Promise.all([...M.values()].map(S=>y(S))).then(S=>S.flat())},c={hasItem(h,l={}){h=ur(h);const{relativeKey:y,driver:M}=r(h);return $t(M.hasItem,y,l)},getItem(h,l={}){h=ur(h);const{relativeKey:y,driver:M}=r(h);return $t(M.getItem,y,l).then(I=>bo(I))},getItems(h,l){return a(h,l,y=>y.driver.getItems?$t(y.driver.getItems,y.items.map(M=>({key:M.relativeKey,options:M.options})),l).then(M=>M.map(I=>({key:P1(y.base,I.key),value:bo(I.value)}))):Promise.all(y.items.map(M=>$t(y.driver.getItem,M.relativeKey,M.options).then(I=>({key:M.key,value:bo(I)})))))},getItemRaw(h,l={}){h=ur(h);const{relativeKey:y,driver:M}=r(h);return M.getItemRaw?$t(M.getItemRaw,y,l):$t(M.getItem,y,l).then(I=>O1(I))},async setItem(h,l,y={}){if(l===void 0)return c.removeItem(h);h=ur(h);const{relativeKey:M,driver:I}=r(h);I.setItem&&(await $t(I.setItem,M,vo(l),y),I.watch||n("update",h))},async setItems(h,l){await a(h,l,async y=>{if(y.driver.setItems)return $t(y.driver.setItems,y.items.map(M=>({key:M.relativeKey,value:vo(M.value),options:M.options})),l);y.driver.setItem&&await Promise.all(y.items.map(M=>$t(y.driver.setItem,M.relativeKey,vo(M.value),M.options)))})},async setItemRaw(h,l,y={}){if(l===void 0)return c.removeItem(h,y);h=ur(h);const{relativeKey:M,driver:I}=r(h);if(I.setItemRaw)await $t(I.setItemRaw,M,l,y);else if(I.setItem)await $t(I.setItem,M,D1(l),y);else return;I.watch||n("update",h)},async removeItem(h,l={}){typeof l=="boolean"&&(l={removeMeta:l}),h=ur(h);const{relativeKey:y,driver:M}=r(h);M.removeItem&&(await $t(M.removeItem,y,l),(l.removeMeta||l.removeMata)&&await $t(M.removeItem,y+"$",l),M.watch||n("remove",h))},async getMeta(h,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),h=ur(h);const{relativeKey:y,driver:M}=r(h),I=Object.create(null);if(M.getMeta&&Object.assign(I,await $t(M.getMeta,y,l)),!l.nativeOnly){const S=await $t(M.getItem,y+"$",l).then(D=>bo(D));S&&typeof S=="object"&&(typeof S.atime=="string"&&(S.atime=new Date(S.atime)),typeof S.mtime=="string"&&(S.mtime=new Date(S.mtime)),Object.assign(I,S))}return I},setMeta(h,l,y={}){return this.setItem(h+"$",l,y)},removeMeta(h,l={}){return this.removeItem(h+"$",l)},async getKeys(h,l={}){h=yo(h);const y=i(h,!0);let M=[];const I=[];for(const S of y){const D=await $t(S.driver.getKeys,S.relativeBase,l);for(const R of D){const $=S.mountpoint+ur(R);M.some(N=>$.startsWith(N))||I.push($)}M=[S.mountpoint,...M.filter(R=>!R.startsWith(S.mountpoint))]}return h?I.filter(S=>S.startsWith(h)&&S[S.length-1]!=="$"):I.filter(S=>S[S.length-1]!=="$")},async clear(h,l={}){h=yo(h),await Promise.all(i(h,!1).map(async y=>{if(y.driver.clear)return $t(y.driver.clear,y.relativeBase,l);if(y.driver.removeItem){const M=await y.driver.getKeys(y.relativeBase||"",l);return Promise.all(M.map(I=>y.driver.removeItem(I,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>wh(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(l=>l!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,l){if(h=yo(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((y,M)=>M.length-y.length)),e.mounts[h]=l,e.watching&&Promise.resolve(mh(l,n,h)).then(y=>{e.unwatch[h]=y}).catch(console.error),c},async unmount(h,l=!0){h=yo(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),l&&await wh(e.mounts[h]),e.mountpoints=e.mountpoints.filter(y=>y!==h),delete e.mounts[h])},getMount(h=""){h=ur(h)+":";const l=r(h);return{driver:l.driver,base:l.base}},getMounts(h="",l={}){return h=ur(h),i(h,l.parents).map(M=>({driver:M.driver,base:M.mountpoint}))},keys:(h,l={})=>c.getKeys(h,l),get:(h,l={})=>c.getItem(h,l),set:(h,l,y={})=>c.setItem(h,l,y),has:(h,l={})=>c.hasItem(h,l),del:(h,l={})=>c.removeItem(h,l),remove:(h,l={})=>c.removeItem(h,l)};return c}function mh(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function wh(t){typeof t.dispose=="function"&&await $t(t.dispose)}function bn(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function _h(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=bn(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let La;function xs(){return La||(La=_h("keyval-store","keyval")),La}function xh(t,e=xs()){return e("readonly",r=>bn(r.get(t)))}function T1(t,e,r=xs()){return r("readwrite",i=>(i.put(e,t),bn(i.transaction)))}function F1(t,e=xs()){return e("readwrite",r=>(r.delete(t),bn(r.transaction)))}function C1(t=xs()){return t("readwrite",e=>(e.clear(),bn(e.transaction)))}function B1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},bn(t.transaction)}function L1(t=xs()){return t("readonly",e=>{if(e.getAllKeys)return bn(e.getAllKeys());const r=[];return B1(e,i=>r.push(i.key)).then(()=>r)})}const q1=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),U1=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function kn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return U1(t)}catch{return t}}function vn(t){return typeof t=="string"?t:q1(t)||""}const z1="idb-keyval";var k1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=_h(t.dbName,t.storeName)),{name:z1,options:t,async hasItem(n){return!(typeof await xh(r(n),i)>"u")},async getItem(n){return await xh(r(n),i)??null},setItem(n,s){return T1(r(n),s,i)},removeItem(n){return F1(r(n),i)},getKeys(){return L1(i)},clear(){return C1(i)}}};const j1="WALLET_CONNECT_V2_INDEXED_DB",K1="keyvaluestorage";class V1{constructor(){this.indexedDb=N1({driver:k1({dbName:j1,storeName:K1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,vn(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var qa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},mo={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof qa<"u"&&qa.localStorage?mo.exports=qa.localStorage:typeof window<"u"&&window.localStorage?mo.exports=window.localStorage:mo.exports=new e})();function H1(t){var e;return[t[0],kn((e=t[1])!=null?e:"")]}class W1{constructor(){this.localStorage=mo.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(H1)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return kn(r)}async setItem(e,r){this.localStorage.setItem(e,vn(r))}async removeItem(e){this.localStorage.removeItem(e)}}const G1="wc_storage_version",Eh=1,J1=async(t,e,r)=>{const i=G1,n=await e.getItem(i);if(n&&n>=Eh){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const h=await t.getItem(a);await e.setItem(a,h),o.push(a)}}await e.setItem(i,Eh),r(e),Y1(t,o)},Y1=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class Z1{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new W1;this.storage=e;try{const r=new V1;J1(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}function X1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Q1=eg;function eg(t,e,r){var i=r&&r.stringify||X1,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a<s;a++)o[a]=i(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var h="",l=1-n,y=-1,M=t&&t.length||0,I=0;I<M;){if(t.charCodeAt(I)===37&&I+1<M){switch(y=y>-1?y:0,t.charCodeAt(I+1)){case 100:case 102:if(l>=c||e[l]==null)break;y<I&&(h+=t.slice(y,I)),h+=Number(e[l]),y=I+2,I++;break;case 105:if(l>=c||e[l]==null)break;y<I&&(h+=t.slice(y,I)),h+=Math.floor(Number(e[l])),y=I+2,I++;break;case 79:case 111:case 106:if(l>=c||e[l]===void 0)break;y<I&&(h+=t.slice(y,I));var S=typeof e[l];if(S==="string"){h+="'"+e[l]+"'",y=I+2,I++;break}if(S==="function"){h+=e[l].name||"<anonymous>",y=I+2,I++;break}h+=i(e[l]),y=I+2,I++;break;case 115:if(l>=c)break;y<I&&(h+=t.slice(y,I)),h+=String(e[l]),y=I+2,I++;break;case 37:y<I&&(h+=t.slice(y,I)),h+="%",y=I+2,I++,l--;break}++l}++I}return y===-1?t:(y<M&&(h+=t.slice(y)),h)}const Sh=Q1;var xi=ii;const Es=hg().console||{},tg={mapHttpRequest:_o,mapHttpResponse:_o,wrapRequestSerializer:za,wrapResponseSerializer:za,wrapErrorSerializer:za,req:_o,res:_o,err:og};function rg(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function ii(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||Es;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=rg(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=Ss),Object.defineProperty(c,"levelVal",{get:l}),Object.defineProperty(c,"level",{get:y,set:M});const h={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:ag(t)};c.levels=ii.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=Ss,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=I,e&&(c._logEvent=Ua());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function M(S){if(S!=="silent"&&!this.levels.values[S])throw Error("unknown level "+S);this._level=S,jn(h,c,"error","log"),jn(h,c,"fatal","error"),jn(h,c,"warn","error"),jn(h,c,"info","log"),jn(h,c,"debug","log"),jn(h,c,"trace","log")}function I(S,D){if(!S)throw new Error("missing bindings for child Pino");D=D||{},n&&S.serializers&&(D.serializers=S.serializers);const R=D.serializers;if(n&&R){var $=Object.assign({},i,R),N=t.browser.serialize===!0?Object.keys($):n;delete S.serializers,wo([S],N,$,this._stdErrSerialize)}function C(L){this._childLevel=(L._childLevel|0)+1,this.error=Kn(L,S,"error"),this.fatal=Kn(L,S,"fatal"),this.warn=Kn(L,S,"warn"),this.info=Kn(L,S,"info"),this.debug=Kn(L,S,"debug"),this.trace=Kn(L,S,"trace"),$&&(this.serializers=$,this._serialize=N),e&&(this._logEvent=Ua([].concat(L._logEvent.bindings,S)))}return C.prototype=this,new C(this)}return c}ii.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},ii.stdSerializers=tg,ii.stdTimeFunctions=Object.assign({},{nullTime:Mh,epochTime:Ih,unixTime:fg,isoTime:cg});function jn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ss:n[r]?n[r]:Es[r]||Es[i]||Ss,ig(t,e,r)}function ig(t,e,r){!t.transmit&&e[r]===Ss||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Es?Es:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&wo(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,ng(this,r,o,s)):i.apply(a,o),t.transmit){const h=t.transmit.level||e.level,l=ii.levels.values[h],y=ii.levels.values[r];if(y<l)return;sg(this,{ts:s,methodLevel:r,methodValue:y,transmitLevel:h,transmitValue:ii.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function ng(t,e,r,i){t._serialize&&wo(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=ii.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Sh(n.shift(),n):void 0}else typeof s=="string"&&(s=Sh(n.shift(),n));return s!==void 0&&(o.msg=s),o}function wo(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=ii.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function Kn(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function sg(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;wo(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(h){return c.indexOf(h)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=Ua(c)}function Ua(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function og(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function ag(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Mh:Ih}function _o(){return{}}function za(t){return t}function Ss(){}function Mh(){return!1}function Ih(){return Date.now()}function fg(){return Math.round(Date.now()/1e3)}function cg(){return new Date(Date.now()).toISOString()}function hg(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const ug={level:"info"},Ms="custom_context",ka=1e3*1024;class dg{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class Ah{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new dg(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}}class Dh{constructor(e,r=ka){this.level=e??"error",this.levelValue=xi.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Ah(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===xi.levels.values.error?console.error(e):r===xi.levels.values.warn?console.warn(e):r===xi.levels.values.debug?console.debug(e):r===xi.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(vn({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new Ah(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(vn({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class lg{constructor(e,r=ka){this.baseChunkLogger=new Dh(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}}class pg{constructor(e,r=ka){this.baseChunkLogger=new Dh(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var gg=Object.defineProperty,bg=Object.defineProperties,vg=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,yg=Object.prototype.hasOwnProperty,mg=Object.prototype.propertyIsEnumerable,Ph=(t,e,r)=>e in t?gg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xo=(t,e)=>{for(var r in e||(e={}))yg.call(e,r)&&Ph(t,r,e[r]);if(Oh)for(var r of Oh(e))mg.call(e,r)&&Ph(t,r,e[r]);return t},Eo=(t,e)=>bg(t,vg(e));function ja(t){return Eo(xo({},t),{level:t?.level||ug.level})}function wg(t,e=Ms){return t[e]||""}function _g(t,e,r=Ms){return t[r]=e,t}function dr(t,e=Ms){let r="";return typeof t.bindings>"u"?r=wg(t,e):r=t.bindings().context||"",r}function xg(t,e,r=Ms){const i=dr(t,r);return i.trim()?`${i}/${e}`:e}function or(t,e,r=Ms){const i=xg(t,e,r),n=t.child({context:i});return _g(n,i,r)}function Eg(t){var e,r;const i=new lg((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:xi(Eo(xo({},t.opts),{level:"trace",browser:Eo(xo({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function Sg(t){var e;const r=new pg((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:xi(Eo(xo({},t.opts),{level:"trace"})),chunkLoggerController:r}}function Mg(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Eg(t):Sg(t)}var Ig=Object.defineProperty,Ag=(t,e,r)=>e in t?Ig(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$h=(t,e,r)=>Ag(t,typeof e!="symbol"?e+"":e,r);class Dg extends gn{constructor(e){super(),this.opts=e,$h(this,"protocol","wc"),$h(this,"version",2)}}var Og=Object.defineProperty,Pg=(t,e,r)=>e in t?Og(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$g=(t,e,r)=>Pg(t,typeof e!="symbol"?e+"":e,r);class Rg extends gn{constructor(e,r){super(),this.core=e,this.logger=r,$g(this,"records",new Map)}}class Ng{constructor(e,r){this.logger=e,this.core=r}}class Tg extends gn{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Fg extends gn{constructor(e){super()}}class Cg{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Bg extends gn{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Lg extends gn{constructor(e,r){super(),this.core=e,this.logger=r}}class qg{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class Ug{constructor(e,r){this.projectId=e,this.logger=r}}class zg{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}var kg=Object.defineProperty,jg=(t,e,r)=>e in t?kg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rh=(t,e,r)=>jg(t,typeof e!="symbol"?e+"":e,r);class Kg{constructor(e){this.opts=e,Rh(this,"protocol","wc"),Rh(this,"version",2)}}class Vg{constructor(e){this.client=e}}function Hg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Nh(t,...e){if(!Hg(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Th(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Wg(t,e){Nh(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Vn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ka=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Gg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Fh(t){return typeof t=="string"&&(t=Gg(t)),Nh(t),t}class Jg{clone(){return this._cloneInto()}}function Yg(t){const e=i=>t().update(Fh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ch(t=32){if(Vn&&typeof Vn.getRandomValues=="function")return Vn.getRandomValues(new Uint8Array(t));if(Vn&&typeof Vn.randomBytes=="function")return Vn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Zg(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}class Xg extends Jg{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ka(this.buffer)}update(e){Th(this);const{view:r,buffer:i,blockLen:n}=this;e=Fh(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Ka(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Th(this),Wg(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let y=o;y<n;y++)r[y]=0;Zg(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Ka(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,l=this.get();if(h>l.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)a.setUint32(4*y,l[y],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const So=BigInt(2**32-1),Va=BigInt(32);function Bh(t,e=!1){return e?{h:Number(t&So),l:Number(t>>Va&So)}:{h:Number(t>>Va&So)|0,l:Number(t&So)|0}}function Qg(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=Bh(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const eb=(t,e)=>BigInt(t>>>0)<<Va|BigInt(e>>>0),tb=(t,e,r)=>t>>>r,rb=(t,e,r)=>t<<32-r|e>>>r,ib=(t,e,r)=>t>>>r|e<<32-r,nb=(t,e,r)=>t<<32-r|e>>>r,sb=(t,e,r)=>t<<64-r|e>>>r-32,ob=(t,e,r)=>t>>>r-32|e<<64-r,ab=(t,e)=>e,fb=(t,e)=>t,cb=(t,e,r)=>t<<r|e>>>32-r,hb=(t,e,r)=>e<<r|t>>>32-r,ub=(t,e,r)=>e<<r-32|t>>>64-r,db=(t,e,r)=>t<<r-32|e>>>64-r;function lb(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const pb=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),gb=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,bb=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),vb=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,yb=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),mb=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,xe={fromBig:Bh,split:Qg,toBig:eb,shrSH:tb,shrSL:rb,rotrSH:ib,rotrSL:nb,rotrBH:sb,rotrBL:ob,rotr32H:ab,rotr32L:fb,rotlSH:cb,rotlSL:hb,rotlBH:ub,rotlBL:db,add:lb,add3L:pb,add3H:gb,add4L:bb,add4H:vb,add5H:mb,add5L:yb},[wb,_b]=(()=>xe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),Gi=new Uint32Array(80),Ji=new Uint32Array(80);class xb extends Xg{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:h,El:l,Fh:y,Fl:M,Gh:I,Gl:S,Hh:D,Hl:R}=this;return[e,r,i,n,s,o,a,c,h,l,y,M,I,S,D,R]}set(e,r,i,n,s,o,a,c,h,l,y,M,I,S,D,R){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=h|0,this.El=l|0,this.Fh=y|0,this.Fl=M|0,this.Gh=I|0,this.Gl=S|0,this.Hh=D|0,this.Hl=R|0}process(e,r){for(let C=0;C<16;C++,r+=4)Gi[C]=e.getUint32(r),Ji[C]=e.getUint32(r+=4);for(let C=16;C<80;C++){const L=Gi[C-15]|0,k=Ji[C-15]|0,j=xe.rotrSH(L,k,1)^xe.rotrSH(L,k,8)^xe.shrSH(L,k,7),G=xe.rotrSL(L,k,1)^xe.rotrSL(L,k,8)^xe.shrSL(L,k,7),K=Gi[C-2]|0,V=Ji[C-2]|0,ie=xe.rotrSH(K,V,19)^xe.rotrBH(K,V,61)^xe.shrSH(K,V,6),O=xe.rotrSL(K,V,19)^xe.rotrBL(K,V,61)^xe.shrSL(K,V,6),g=xe.add4L(G,O,Ji[C-7],Ji[C-16]),p=xe.add4H(g,j,ie,Gi[C-7],Gi[C-16]);Gi[C]=p|0,Ji[C]=g|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:h,Dl:l,Eh:y,El:M,Fh:I,Fl:S,Gh:D,Gl:R,Hh:$,Hl:N}=this;for(let C=0;C<80;C++){const L=xe.rotrSH(y,M,14)^xe.rotrSH(y,M,18)^xe.rotrBH(y,M,41),k=xe.rotrSL(y,M,14)^xe.rotrSL(y,M,18)^xe.rotrBL(y,M,41),j=y&I^~y&D,G=M&S^~M&R,K=xe.add5L(N,k,G,_b[C],Ji[C]),V=xe.add5H(K,$,L,j,wb[C],Gi[C]),ie=K|0,O=xe.rotrSH(i,n,28)^xe.rotrBH(i,n,34)^xe.rotrBH(i,n,39),g=xe.rotrSL(i,n,28)^xe.rotrBL(i,n,34)^xe.rotrBL(i,n,39),p=i&s^i&a^s&a,f=n&o^n&c^o&c;$=D|0,N=R|0,D=I|0,R=S|0,I=y|0,S=M|0,{h:y,l:M}=xe.add(h|0,l|0,V|0,ie|0),h=a|0,l=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const u=xe.add3L(ie,g,f);i=xe.add3H(u,V,O,p),n=u|0}({h:i,l:n}=xe.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=xe.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=xe.add(this.Ch|0,this.Cl|0,a|0,c|0),{h,l}=xe.add(this.Dh|0,this.Dl|0,h|0,l|0),{h:y,l:M}=xe.add(this.Eh|0,this.El|0,y|0,M|0),{h:I,l:S}=xe.add(this.Fh|0,this.Fl|0,I|0,S|0),{h:D,l:R}=xe.add(this.Gh|0,this.Gl|0,D|0,R|0),{h:$,l:N}=xe.add(this.Hh|0,this.Hl|0,$|0,N|0),this.set(i,n,s,o,a,c,h,l,y,M,I,S,D,R,$,N)}roundClean(){Gi.fill(0),Ji.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Eb=Yg(()=>new xb);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ha=BigInt(0),Lh=BigInt(1),Sb=BigInt(2);function Wa(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ga(t){if(!Wa(t))throw new Error("Uint8Array expected")}function Ja(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Mb=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ya(t){Ga(t);let e="";for(let r=0;r<t.length;r++)e+=Mb[t[r]];return e}function qh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ha:BigInt("0x"+t)}const Ei={_0:48,_9:57,A:65,F:70,a:97,f:102};function Uh(t){if(t>=Ei._0&&t<=Ei._9)return t-Ei._0;if(t>=Ei.A&&t<=Ei.F)return t-(Ei.A-10);if(t>=Ei.a&&t<=Ei.f)return t-(Ei.a-10)}function zh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=Uh(t.charCodeAt(s)),a=Uh(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Ib(t){return qh(Ya(t))}function Mo(t){return Ga(t),qh(Ya(Uint8Array.from(t).reverse()))}function kh(t,e){return zh(t.toString(16).padStart(e*2,"0"))}function Za(t,e){return kh(t,e).reverse()}function Si(t,e,r){let i;if(typeof e=="string")try{i=zh(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Wa(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function jh(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Ga(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const Xa=t=>typeof t=="bigint"&&Ha<=t;function Ab(t,e,r){return Xa(t)&&Xa(e)&&Xa(r)&&e<=t&&t<r}function Is(t,e,r,i){if(!Ab(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Db(t){let e;for(e=0;t>Ha;t>>=Lh,e+=1);return e}const Ob=t=>(Sb<<BigInt(t-1))-Lh,Pb={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Wa(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Qa(t,e,r={}){const i=(n,s,o)=>{const a=Pb[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function Kh(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const Rt=BigInt(0),Et=BigInt(1),yn=BigInt(2),$b=BigInt(3),ef=BigInt(4),Vh=BigInt(5),Hh=BigInt(8);function Dt(t,e){const r=t%e;return r>=Rt?r:e+r}function Rb(t,e,r){if(e<Rt)throw new Error("invalid exponent, negatives unsupported");if(r<=Rt)throw new Error("invalid modulus");if(r===Et)return Rt;let i=Et;for(;e>Rt;)e&Et&&(i=i*t%r),t=t*t%r,e>>=Et;return i}function ni(t,e,r){let i=t;for(;e-- >Rt;)i*=i,i%=r;return i}function Wh(t,e){if(t===Rt)throw new Error("invert: expected non-zero number");if(e<=Rt)throw new Error("invert: expected positive modulus, got "+e);let r=Dt(t,e),i=e,n=Rt,s=Et;for(;r!==Rt;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==Et)throw new Error("invert: does not exist");return Dt(n,e)}function Nb(t){const e=(t-Et)/yn;let r,i,n;for(r=t-Et,i=0;r%yn===Rt;r/=yn,i++);for(n=yn;n<t&&Rb(n,e,t)!==t-Et;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+Et)/ef;return function(a,c){const h=a.pow(c,o);if(!a.eql(a.sqr(h),c))throw new Error("Cannot find square root");return h}}const s=(r+Et)/yn;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,h=o.pow(o.mul(o.ONE,n),r),l=o.pow(a,s),y=o.pow(a,r);for(;!o.eql(y,o.ONE);){if(o.eql(y,o.ZERO))return o.ZERO;let M=1;for(let S=o.sqr(y);M<c&&!o.eql(S,o.ONE);M++)S=o.sqr(S);const I=o.pow(h,Et<<BigInt(c-M-1));h=o.sqr(I),l=o.mul(l,I),y=o.mul(y,h),c=M}return l}}function Tb(t){if(t%ef===$b){const e=(t+Et)/ef;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%Hh===Vh){const e=(t-Vh)/Hh;return function(r,i){const n=r.mul(i,yn),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,yn),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return Nb(t)}const Fb=(t,e)=>(Dt(t,e)&Et)===Et,Cb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bb(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Cb.reduce((i,n)=>(i[n]="function",i),e);return Qa(t,r)}function Lb(t,e,r){if(r<Rt)throw new Error("invalid exponent, negatives unsupported");if(r===Rt)return t.ONE;if(r===Et)return e;let i=t.ONE,n=e;for(;r>Rt;)r&Et&&(i=t.mul(i,n)),n=t.sqr(n),r>>=Et;return i}function qb(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function Gh(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Jh(t,e,r=!1,i={}){if(t<=Rt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=Gh(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:Ob(n),ZERO:Rt,ONE:Et,create:c=>Dt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Rt<=c&&c<t},is0:c=>c===Rt,isOdd:c=>(c&Et)===Et,neg:c=>Dt(-c,t),eql:(c,h)=>c===h,sqr:c=>Dt(c*c,t),add:(c,h)=>Dt(c+h,t),sub:(c,h)=>Dt(c-h,t),mul:(c,h)=>Dt(c*h,t),pow:(c,h)=>Lb(a,c,h),div:(c,h)=>Dt(c*Wh(h,t),t),sqrN:c=>c*c,addN:(c,h)=>c+h,subN:(c,h)=>c-h,mulN:(c,h)=>c*h,inv:c=>Wh(c,t),sqrt:i.sqrt||(c=>(o||(o=Tb(t)),o(a,c))),invertBatch:c=>qb(a,c),cmov:(c,h,l)=>l?h:c,toBytes:c=>r?Za(c,s):kh(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Mo(c):Ib(c)}});return Object.freeze(a)}const Yh=BigInt(0),Io=BigInt(1);function tf(t,e){const r=e.negate();return t?r:e}function Zh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function rf(t,e){Zh(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function Ub(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function zb(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const nf=new WeakMap,Xh=new WeakMap;function sf(t){return Xh.get(t)||1}function kb(t,e){return{constTimeNegate:tf,hasPrecomputes(r){return sf(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Yh;)i&Io&&(n=n.add(s)),s=s.double(),i>>=Io;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=rf(i,e),o=[];let a=r,c=a;for(let h=0;h<n;h++){c=a,o.push(c);for(let l=1;l<s;l++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=rf(r,e);let a=t.ZERO,c=t.BASE;const h=BigInt(2**r-1),l=2**r,y=BigInt(r);for(let M=0;M<s;M++){const I=M*o;let S=Number(n&h);n>>=y,S>o&&(S-=l,n+=Io);const D=I,R=I+Math.abs(S)-1,$=M%2!==0,N=S<0;S===0?c=c.add(tf($,i[D])):a=a.add(tf(N,i[R]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=rf(r,e),c=BigInt(2**r-1),h=2**r,l=BigInt(r);for(let y=0;y<o;y++){const M=y*a;if(n===Yh)break;let I=Number(n&c);if(n>>=l,I>a&&(I-=h,n+=Io),I===0)continue;let S=i[M+Math.abs(I)-1];I<0&&(S=S.negate()),s=s.add(S)}return s},getPrecomputes(r,i,n){let s=nf.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&nf.set(i,n(s))),s},wNAFCached(r,i,n){const s=sf(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=sf(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){Zh(i,e),Xh.set(r,i),nf.delete(r)}}}function jb(t,e,r,i){if(Ub(r,t),zb(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=Db(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),h=Math.floor((e.BITS-1)/o)*o;let l=n;for(let y=h;y>=0;y-=o){c.fill(n);for(let I=0;I<i.length;I++){const S=i[I],D=Number(S>>BigInt(y)&BigInt(a));c[D]=c[D].add(r[I])}let M=n;for(let I=c.length-1,S=n;I>0;I--)S=S.add(c[I]),M=M.add(S);if(l=l.add(M),y!==0)for(let I=0;I<o;I++)l=l.double()}return l}function Kb(t){return Bb(t.Fp),Qa(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Gh(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Hr=BigInt(0),lr=BigInt(1),Ao=BigInt(2),Vb=BigInt(8),Hb={zip215:!0};function Wb(t){const e=Kb(t);return Qa(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Gb(t){const e=Wb(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,h=Ao<<BigInt(a*8)-lr,l=r.create,y=Jh(e.n,e.nBitLength),M=e.uvRatio||((u,b)=>{try{return{isValid:!0,value:r.sqrt(u*r.inv(b))}}catch{return{isValid:!1,value:Hr}}}),I=e.adjustScalarBytes||(u=>u),S=e.domain||((u,b,_)=>{if(Ja("phflag",_),b.length||_)throw new Error("Contexts/pre-hash are not supported");return u});function D(u,b){Is("coordinate "+u,b,Hr,h)}function R(u){if(!(u instanceof C))throw new Error("ExtendedPoint expected")}const $=Kh((u,b)=>{const{ex:_,ey:E,ez:w}=u,d=u.is0();b==null&&(b=d?Vb:r.inv(w));const m=l(_*b),v=l(E*b),A=l(w*b);if(d)return{x:Hr,y:lr};if(A!==lr)throw new Error("invZ was invalid");return{x:m,y:v}}),N=Kh(u=>{const{a:b,d:_}=e;if(u.is0())throw new Error("bad point: ZERO");const{ex:E,ey:w,ez:d,et:m}=u,v=l(E*E),A=l(w*w),U=l(d*d),x=l(U*U),T=l(v*b),B=l(U*l(T+A)),q=l(x+l(_*l(v*A)));if(B!==q)throw new Error("bad point: equation left != right (1)");const z=l(E*w),Y=l(d*m);if(z!==Y)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(b,_,E,w){this.ex=b,this.ey=_,this.ez=E,this.et=w,D("x",b),D("y",_),D("z",E),D("t",w),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof C)throw new Error("extended point not allowed");const{x:_,y:E}=b||{};return D("x",_),D("y",E),new C(_,E,lr,l(_*E))}static normalizeZ(b){const _=r.invertBatch(b.map(E=>E.ez));return b.map((E,w)=>E.toAffine(_[w])).map(C.fromAffine)}static msm(b,_){return jb(C,y,b,_)}_setWindowSize(b){j.setWindowSize(this,b)}assertValidity(){N(this)}equals(b){R(b);const{ex:_,ey:E,ez:w}=this,{ex:d,ey:m,ez:v}=b,A=l(_*v),U=l(d*w),x=l(E*v),T=l(m*w);return A===U&&x===T}is0(){return this.equals(C.ZERO)}negate(){return new C(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:b}=e,{ex:_,ey:E,ez:w}=this,d=l(_*_),m=l(E*E),v=l(Ao*l(w*w)),A=l(b*d),U=_+E,x=l(l(U*U)-d-m),T=A+m,B=T-v,q=A-m,z=l(x*B),Y=l(T*q),X=l(x*q),W=l(B*T);return new C(z,Y,W,X)}add(b){R(b);const{a:_,d:E}=e,{ex:w,ey:d,ez:m,et:v}=this,{ex:A,ey:U,ez:x,et:T}=b;if(_===BigInt(-1)){const Ne=l((d-w)*(U+A)),Te=l((d+w)*(U-A)),fe=l(Te-Ne);if(fe===Hr)return this.double();const Fe=l(m*Ao*T),Ce=l(v*Ao*x),he=Ce+Fe,Be=Te+Ne,Le=Ce-Fe,ae=l(he*fe),$e=l(Be*Le),qe=l(he*Le),ne=l(fe*Be);return new C(ae,$e,ne,qe)}const B=l(w*A),q=l(d*U),z=l(v*E*T),Y=l(m*x),X=l((w+d)*(A+U)-B-q),W=Y-z,se=Y+z,ee=l(q-_*B),te=l(X*W),ke=l(se*ee),je=l(X*ee),ue=l(W*se);return new C(te,ke,ue,je)}subtract(b){return this.add(b.negate())}wNAF(b){return j.wNAFCached(this,b,C.normalizeZ)}multiply(b){const _=b;Is("scalar",_,lr,i);const{p:E,f:w}=this.wNAF(_);return C.normalizeZ([E,w])[0]}multiplyUnsafe(b,_=C.ZERO){const E=b;return Is("scalar",E,Hr,i),E===Hr?k:this.is0()||E===lr?this:j.wNAFCachedUnsafe(this,E,C.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return j.unsafeLadder(this,i).is0()}toAffine(b){return $(this,b)}clearCofactor(){const{h:b}=e;return b===lr?this:this.multiplyUnsafe(b)}static fromHex(b,_=!1){const{d:E,a:w}=e,d=r.BYTES;b=Si("pointHex",b,d),Ja("zip215",_);const m=b.slice(),v=b[d-1];m[d-1]=v&-129;const A=Mo(m),U=_?h:r.ORDER;Is("pointHex.y",A,Hr,U);const x=l(A*A),T=l(x-lr),B=l(E*x-w);let{isValid:q,value:z}=M(T,B);if(!q)throw new Error("Point.fromHex: invalid y coordinate");const Y=(z&lr)===lr,X=(v&128)!==0;if(!_&&z===Hr&&X)throw new Error("Point.fromHex: x=0 and x_0=1");return X!==Y&&(z=l(-z)),C.fromAffine({x:z,y:A})}static fromPrivateKey(b){return V(b).point}toRawBytes(){const{x:b,y:_}=this.toAffine(),E=Za(_,r.BYTES);return E[E.length-1]|=b&lr?128:0,E}toHex(){return Ya(this.toRawBytes())}}C.BASE=new C(e.Gx,e.Gy,lr,l(e.Gx*e.Gy)),C.ZERO=new C(Hr,lr,lr,Hr);const{BASE:L,ZERO:k}=C,j=kb(C,a*8);function G(u){return Dt(u,i)}function K(u){return G(Mo(u))}function V(u){const b=r.BYTES;u=Si("private key",u,b);const _=Si("hashed private key",s(u),2*b),E=I(_.slice(0,b)),w=_.slice(b,2*b),d=K(E),m=L.multiply(d),v=m.toRawBytes();return{head:E,prefix:w,scalar:d,point:m,pointBytes:v}}function ie(u){return V(u).pointBytes}function O(u=new Uint8Array,...b){const _=jh(...b);return K(s(S(_,Si("context",u),!!n)))}function g(u,b,_={}){u=Si("message",u),n&&(u=n(u));const{prefix:E,scalar:w,pointBytes:d}=V(b),m=O(_.context,E,u),v=L.multiply(m).toRawBytes(),A=O(_.context,v,d,u),U=G(m+A*w);Is("signature.s",U,Hr,i);const x=jh(v,Za(U,r.BYTES));return Si("result",x,r.BYTES*2)}const p=Hb;function f(u,b,_,E=p){const{context:w,zip215:d}=E,m=r.BYTES;u=Si("signature",u,2*m),b=Si("message",b),_=Si("publicKey",_,m),d!==void 0&&Ja("zip215",d),n&&(b=n(b));const v=Mo(u.slice(m,2*m));let A,U,x;try{A=C.fromHex(_,d),U=C.fromHex(u.slice(0,m),d),x=L.multiplyUnsafe(v)}catch{return!1}if(!d&&A.isSmallOrder())return!1;const T=O(w,U.toRawBytes(),A.toRawBytes(),b);return U.add(A.multiplyUnsafe(T)).subtract(x).clearCofactor().equals(C.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:g,verify:f,ExtendedPoint:C,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(r.BYTES),precompute(u=8,b=C.BASE){return b._setWindowSize(u),b.multiply(BigInt(3)),b}}}}BigInt(0),BigInt(1);const of=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Qh=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Jb=BigInt(1),eu=BigInt(2);BigInt(3);const Yb=BigInt(5),Zb=BigInt(8);function Xb(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=of,o=t*t%s*t%s,a=ni(o,eu,s)*o%s,c=ni(a,Jb,s)*t%s,h=ni(c,Yb,s)*c%s,l=ni(h,e,s)*h%s,y=ni(l,r,s)*l%s,M=ni(y,i,s)*y%s,I=ni(M,n,s)*M%s,S=ni(I,n,s)*M%s,D=ni(S,e,s)*h%s;return{pow_p_5_8:ni(D,eu,s)*t%s,b2:o}}function Qb(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function ev(t,e){const r=of,i=Dt(e*e*e,r),n=Dt(i*i*e,r),s=Xb(t*n).pow_p_5_8;let o=Dt(t*i*s,r);const a=Dt(e*o*o,r),c=o,h=Dt(o*Qh,r),l=a===t,y=a===Dt(-t,r),M=a===Dt(-t*Qh,r);return l&&(o=c),(y||M)&&(o=h),Fb(o,r)&&(o=Dt(-o,r)),{isValid:l||y,value:o}}const tv=(()=>Jh(of,void 0,!0))(),rv=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:tv,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Zb,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Eb,randomBytes:Ch,adjustScalarBytes:Qb,uvRatio:ev}))(),tu=(()=>Gb(rv))(),iv="EdDSA",nv="JWT",Do=".",Oo="base64url",ru="utf8",iu="utf8",sv=":",ov="did",av="key",nu="base58btc",fv="z",cv="K36",hv=32;function af(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function su(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?af(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function ou(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=su(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return af(r)}function uv(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var D=0,R=0,$=0,N=S.length;$!==N&&S[$]===0;)$++,D++;for(var C=(N-$)*l+1>>>0,L=new Uint8Array(C);$!==N;){for(var k=S[$],j=0,G=C-1;(k!==0||j<R)&&G!==-1;G--,j++)k+=256*L[G]>>>0,L[G]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");R=j,$++}for(var K=C-R;K!==C&&L[K]===0;)K++;for(var V=c.repeat(D);K<C;++K)V+=t.charAt(L[K]);return V}function M(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var D=0;if(S[D]!==" "){for(var R=0,$=0;S[D]===c;)R++,D++;for(var N=(S.length-D)*h+1>>>0,C=new Uint8Array(N);S[D];){var L=r[S.charCodeAt(D)];if(L===255)return;for(var k=0,j=N-1;(L!==0||k<$)&&j!==-1;j--,k++)L+=a*C[j]>>>0,C[j]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");$=k,D++}if(S[D]!==" "){for(var G=N-$;G!==N&&C[G]===0;)G++;for(var K=new Uint8Array(R+(N-G)),V=R;G!==N;)K[V++]=C[G++];return K}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:M,decode:I}}var dv=uv,lv=dv;const au=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},pv=t=>new TextEncoder().encode(t),gv=t=>new TextDecoder().decode(t);class bv{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class vv{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return fu(this,e)}}class yv{constructor(e){this.decoders=e}or(e){return fu(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const fu=(t,e)=>new yv({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class mv{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new bv(e,r,i),this.decoder=new vv(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Po=({name:t,prefix:e,encode:r,decode:i})=>new mv(t,e,r,i),As=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=lv(r,e);return Po({prefix:t,name:e,encode:i,decode:s=>au(n(s))})},wv=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let l=0;l<s;++l){const y=n[t[l]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|y,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},_v=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},kt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Po({prefix:e,name:t,encode(n){return _v(n,i,r)},decode(n){return wv(n,i,r,t)}}),xv=Po({prefix:"\0",name:"identity",encode:t=>gv(t),decode:t=>pv(t)});var Ev=Object.freeze({__proto__:null,identity:xv});const Sv=kt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mv=Object.freeze({__proto__:null,base2:Sv});const Iv=kt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Av=Object.freeze({__proto__:null,base8:Iv});const Dv=As({prefix:"9",name:"base10",alphabet:"0123456789"});var Ov=Object.freeze({__proto__:null,base10:Dv});const Pv=kt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$v=kt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rv=Object.freeze({__proto__:null,base16:Pv,base16upper:$v});const Nv=kt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tv=kt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fv=kt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Cv=kt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bv=kt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lv=kt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qv=kt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Uv=kt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zv=kt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kv=Object.freeze({__proto__:null,base32:Nv,base32upper:Tv,base32pad:Fv,base32padupper:Cv,base32hex:Bv,base32hexupper:Lv,base32hexpad:qv,base32hexpadupper:Uv,base32z:zv});const jv=As({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Kv=As({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vv=Object.freeze({__proto__:null,base36:jv,base36upper:Kv});const Hv=As({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wv=As({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gv=Object.freeze({__proto__:null,base58btc:Hv,base58flickr:Wv});const Jv=kt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yv=kt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zv=kt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xv=kt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qv=Object.freeze({__proto__:null,base64:Jv,base64pad:Yv,base64url:Zv,base64urlpad:Xv});const cu=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ey=cu.reduce((t,e,r)=>(t[r]=e,t),[]),ty=cu.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function ry(t){return t.reduce((e,r)=>(e+=ey[r],e),"")}function iy(t){const e=[];for(const r of t){const i=ty[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const ny=Po({prefix:"\u{1F680}",name:"base256emoji",encode:ry,decode:iy});var sy=Object.freeze({__proto__:null,base256emoji:ny}),oy=uu,hu=128,ay=127,fy=~ay,cy=Math.pow(2,31);function uu(t,e,r){e=e||[],r=r||0;for(var i=r;t>=cy;)e[r++]=t&255|hu,t/=128;for(;t&fy;)e[r++]=t&255|hu,t>>>=7;return e[r]=t|0,uu.bytes=r-i+1,e}var hy=ff,uy=128,du=127;function ff(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw ff.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&du)<<n:(o&du)*Math.pow(2,n),n+=7}while(o>=uy);return ff.bytes=s-i,r}var dy=Math.pow(2,7),ly=Math.pow(2,14),py=Math.pow(2,21),gy=Math.pow(2,28),by=Math.pow(2,35),vy=Math.pow(2,42),yy=Math.pow(2,49),my=Math.pow(2,56),wy=Math.pow(2,63),_y=function(t){return t<dy?1:t<ly?2:t<py?3:t<gy?4:t<by?5:t<vy?6:t<yy?7:t<my?8:t<wy?9:10},xy={encode:oy,decode:hy,encodingLength:_y},lu=xy;const pu=(t,e,r=0)=>(lu.encode(t,e,r),e),gu=t=>lu.encodingLength(t),cf=(t,e)=>{const r=e.byteLength,i=gu(t),n=i+gu(r),s=new Uint8Array(n+r);return pu(t,s,0),pu(r,s,i),s.set(e,n),new Ey(t,r,e,s)};class Ey{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const bu=({name:t,code:e,encode:r})=>new Sy(t,e,r);class Sy{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?cf(this.code,r):r.then(i=>cf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const vu=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),My=bu({name:"sha2-256",code:18,encode:vu("SHA-256")}),Iy=bu({name:"sha2-512",code:19,encode:vu("SHA-512")});var Ay=Object.freeze({__proto__:null,sha256:My,sha512:Iy});const yu=0,Dy="identity",mu=au;var Oy=Object.freeze({__proto__:null,identity:{code:yu,name:Dy,encode:mu,digest:t=>cf(yu,mu(t))}});new TextEncoder,new TextDecoder;const wu={...Ev,...Mv,...Av,...Ov,...Rv,...kv,...Vv,...Gv,...Qv,...sy};({...Ay,...Oy});function _u(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const xu=_u("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),hf=_u("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=su(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Eu={utf8:xu,"utf-8":xu,hex:wu.base16,latin1:hf,ascii:hf,binary:hf,...wu};function $o(t,e="utf8"){const r=Eu[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function Hn(t,e="utf8"){const r=Eu[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?af(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Su(t){return kn($o(Hn(t,Oo),ru))}function Ro(t){return $o(Hn(vn(t),ru),Oo)}function Mu(t){const e=Hn(cv,nu),r=fv+$o(ou([e,t]),nu);return[ov,av,r].join(sv)}function Py(t){return $o(t,Oo)}function $y(t){return Hn(t,Oo)}function Ry(t){return Hn([Ro(t.header),Ro(t.payload)].join(Do),iu)}function Ny(t){return[Ro(t.header),Ro(t.payload),Py(t.signature)].join(Do)}function uf(t){const e=t.split(Do),r=Su(e[0]),i=Su(e[1]),n=$y(e[2]),s=Hn(e.slice(0,2).join(Do),iu);return{header:r,payload:i,signature:n,data:s}}function Iu(t=Ch(hv)){const e=tu.getPublicKey(t);return{secretKey:ou([t,e]),publicKey:e}}async function Ty(t,e,r,i,n=Z.fromMiliseconds(Date.now())){const s={alg:iv,typ:nv},o=Mu(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},h=Ry({header:s,payload:c}),l=tu.sign(h,i.secretKey.slice(0,32));return Ny({header:s,payload:c,signature:l})}var Au=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},Fy=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Cy=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),By=function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t}(),Ly=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),qy=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Uy=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,zy=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Du=3,ky=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Uy]],Ou=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function jy(t){return t?Pu(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new qy:typeof navigator<"u"?Pu(navigator.userAgent):Hy()}function Ky(t){return t!==""&&ky.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function Pu(t){var e=Ky(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Ly;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Du&&(n=Au(Au([],n,!0),Wy(Du-n.length),!0)):n=[];var s=n.join("."),o=Vy(t),a=zy.exec(t);return a&&a[1]?new By(r,s,o,a[1]):new Fy(r,s,o)}function Vy(t){for(var e=0,r=Ou.length;e<r;e++){var i=Ou[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Hy(){var t=typeof process<"u"&&process.version;return t?new Cy(process.version.slice(1)):null}function Wy(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.getLocalStorage=dt.getLocalStorageOrThrow=dt.getCrypto=dt.getCryptoOrThrow=$u=dt.getLocation=dt.getLocationOrThrow=df=dt.getNavigator=dt.getNavigatorOrThrow=Ds=dt.getDocument=dt.getDocumentOrThrow=dt.getFromWindowOrThrow=dt.getFromWindow=void 0;function mn(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}dt.getFromWindow=mn;function Wn(t){const e=mn(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}dt.getFromWindowOrThrow=Wn;function Gy(){return Wn("document")}dt.getDocumentOrThrow=Gy;function Jy(){return mn("document")}var Ds=dt.getDocument=Jy;function Yy(){return Wn("navigator")}dt.getNavigatorOrThrow=Yy;function Zy(){return mn("navigator")}var df=dt.getNavigator=Zy;function Xy(){return Wn("location")}dt.getLocationOrThrow=Xy;function Qy(){return mn("location")}var $u=dt.getLocation=Qy;function em(){return Wn("crypto")}dt.getCryptoOrThrow=em;function tm(){return mn("crypto")}dt.getCrypto=tm;function rm(){return Wn("localStorage")}dt.getLocalStorageOrThrow=rm;function im(){return mn("localStorage")}dt.getLocalStorage=im;var lf={};Object.defineProperty(lf,"__esModule",{value:!0});var Ru=lf.getWindowMetadata=void 0;const Nu=dt;function nm(){let t,e;try{t=Nu.getDocumentOrThrow(),e=Nu.getLocationOrThrow()}catch{return null}function r(){const y=t.getElementsByTagName("link"),M=[];for(let I=0;I<y.length;I++){const S=y[I],D=S.getAttribute("rel");if(D&&D.toLowerCase().indexOf("icon")>-1){const R=S.getAttribute("href");if(R)if(R.toLowerCase().indexOf("https:")===-1&&R.toLowerCase().indexOf("http:")===-1&&R.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(R.indexOf("/")===0)$+=R;else{const N=e.pathname.split("/");N.pop();const C=N.join("/");$+=C+"/"+R}M.push($)}else if(R.indexOf("//")===0){const $=e.protocol+R;M.push($)}else M.push(R)}}return M}function i(...y){const M=t.getElementsByTagName("meta");for(let I=0;I<M.length;I++){const S=M[I],D=["itemprop","property","name"].map(R=>S.getAttribute(R)).filter(R=>R?y.includes(R):!1);if(D.length&&D){const R=S.getAttribute("content");if(R)return R}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=t.title),y}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,h=r();return{description:a,url:c,icons:h,name:o}}Ru=lf.getWindowMetadata=nm;const sm="logger/5.7.0";let Tu=!1,Fu=!1;const No={debug:1,default:2,info:2,warning:3,error:4,off:5};let Cu=No.default,pf=null;function om(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}const Bu=om();var gf;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(gf||(gf={}));var Wr;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(Wr||(Wr={}));const Lu="0123456789abcdef";class Se{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();No[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Cu>No[i])&&console.log.apply(console,r)}debug(...e){this._log(Se.levels.DEBUG,e)}info(...e){this._log(Se.levels.INFO,e)}warn(...e){this._log(Se.levels.WARNING,e)}makeError(e,r,i){if(Fu)return this.makeError("censored error",r,{});r||(r=Se.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(c=>{const h=i[c];try{if(h instanceof Uint8Array){let l="";for(let y=0;y<h.length;y++)l+=Lu[h[y]>>4],l+=Lu[h[y]&15];n.push(c+"=Uint8Array(0x"+l+")")}else n.push(c+"="+JSON.stringify(h))}catch{n.push(c+"="+JSON.stringify(i[c].toString()))}}),n.push(`code=${r}`),n.push(`version=${this.version}`);const s=e;let o="";switch(r){case Wr.NUMERIC_FAULT:{o="NUMERIC_FAULT";const c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Wr.CALL_EXCEPTION:case Wr.INSUFFICIENT_FUNDS:case Wr.MISSING_NEW:case Wr.NONCE_EXPIRED:case Wr.REPLACEMENT_UNDERPRICED:case Wr.TRANSACTION_REPLACED:case Wr.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=r,Object.keys(i).forEach(function(c){a[c]=i[c]}),a}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,Se.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(e,r,i,n){e||this.throwError(r,i,n)}assertArgument(e,r,i,n){e||this.throwArgumentError(r,i,n)}checkNormalize(e){Bu&&this.throwError("platform missing String.prototype.normalize",Se.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bu})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Se.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Se.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,i){i?i=": "+i:i="",e<r&&this.throwError("missing argument"+i,Se.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,Se.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Se.errors.MISSING_NEW,{name:r.name})}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",Se.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Se.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return pf||(pf=new Se(sm)),pf}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Se.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Tu){if(!e)return;this.globalLogger().throwError("error censorship permanent",Se.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Fu=!!e,Tu=!!r}static setLogLevel(e){const r=No[e.toLowerCase()];if(r==null){Se.globalLogger().warn("invalid log level - "+e);return}Cu=r}static from(e){return new Se(e)}}Se.errors=Wr,Se.levels=gf;const am="bytes/5.7.0",St=new Se(am);function qu(t){return!!t.toHexString}function Os(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Os(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function fm(t){return Sr(t)&&!(t.length%2)||Gn(t)}function Uu(t){return typeof t=="number"&&t==t&&t%1===0}function Gn(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!Uu(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!Uu(r)||r<0||r>=256)return!1}return!0}function Ot(t,e){if(e||(e={}),typeof t=="number"){St.checkSafeUint53(t,"invalid arrayify value");const r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),Os(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),qu(t)&&(t=t.toHexString()),Sr(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":St.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let n=0;n<r.length;n+=2)i.push(parseInt(r.substring(n,n+2),16));return Os(new Uint8Array(i))}return Gn(t)?Os(new Uint8Array(t)):St.throwArgumentError("invalid arrayify value","value",t)}function cm(t,e){t=Ot(t),t.length>e&&St.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),Os(r)}function Sr(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const bf="0123456789abcdef";function ar(t,e){if(e||(e={}),typeof t=="number"){St.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=bf[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),qu(t))return t.toHexString();if(Sr(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":St.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Gn(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=bf[(n&240)>>4]+bf[n&15]}return r}return St.throwArgumentError("invalid hexlify value","value",t)}function hm(t){if(typeof t!="string")t=ar(t);else if(!Sr(t)||t.length%2)return null;return(t.length-2)/2}function zu(t,e,r){return typeof t!="string"?t=ar(t):(!Sr(t)||t.length%2)&&St.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Yi(t,e){for(typeof t!="string"?t=ar(t):Sr(t)||St.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&St.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function ku(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(fm(t)){let r=Ot(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=ar(r.slice(0,32)),e.s=ar(r.slice(32,64))):r.length===65?(e.r=ar(r.slice(0,32)),e.s=ar(r.slice(32,64)),e.v=r[64]):St.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:St.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=ar(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){const n=cm(Ot(e._vs),32);e._vs=ar(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&St.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=ar(n);e.s==null?e.s=o:e.s!==o&&St.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?St.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&St.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Sr(e.r)?St.throwArgumentError("signature missing or invalid r","signature",t):e.r=Yi(e.r,32),e.s==null||!Sr(e.s)?St.throwArgumentError("signature missing or invalid s","signature",t):e.s=Yi(e.s,32);const r=Ot(e.s);r[0]>=128&&St.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=ar(r);e._vs&&(Sr(e._vs)||St.throwArgumentError("signature invalid _vs","signature",t),e._vs=Yi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&St.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var ju={exports:{}},um={},dm=Object.freeze({__proto__:null,default:um}),vf=Aa(dm);(function(t){(function(e,r){function i(p,f){if(!p)throw new Error(f||"Assertion failed")}function n(p,f){p.super_=f;var u=function(){};u.prototype=f.prototype,p.prototype=new u,p.prototype.constructor=p}function s(p,f,u){if(s.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((f==="le"||f==="be")&&(u=f,f=10),this._init(p||0,f||10,u||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=vf.Buffer}catch{}s.isBN=function(f){return f instanceof s?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===s.wordSize&&Array.isArray(f.words)},s.max=function(f,u){return f.cmp(u)>0?f:u},s.min=function(f,u){return f.cmp(u)<0?f:u},s.prototype._init=function(f,u,b){if(typeof f=="number")return this._initNumber(f,u,b);if(typeof f=="object")return this._initArray(f,u,b);u==="hex"&&(u=16),i(u===(u|0)&&u>=2&&u<=36),f=f.toString().replace(/\s+/g,"");var _=0;f[0]==="-"&&(_++,this.negative=1),_<f.length&&(u===16?this._parseHex(f,_,b):(this._parseBase(f,u,_),b==="le"&&this._initArray(this.toArray(),u,b)))},s.prototype._initNumber=function(f,u,b){f<0&&(this.negative=1,f=-f),f<67108864?(this.words=[f&67108863],this.length=1):f<4503599627370496?(this.words=[f&67108863,f/67108864&67108863],this.length=2):(i(f<9007199254740992),this.words=[f&67108863,f/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),u,b)},s.prototype._initArray=function(f,u,b){if(i(typeof f.length=="number"),f.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(f.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var E,w,d=0;if(b==="be")for(_=f.length-1,E=0;_>=0;_-=3)w=f[_]|f[_-1]<<8|f[_-2]<<16,this.words[E]|=w<<d&67108863,this.words[E+1]=w>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);else if(b==="le")for(_=0,E=0;_<f.length;_+=3)w=f[_]|f[_+1]<<8|f[_+2]<<16,this.words[E]|=w<<d&67108863,this.words[E+1]=w>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);return this._strip()};function a(p,f){var u=p.charCodeAt(f);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;i(!1,"Invalid character in "+p)}function c(p,f,u){var b=a(p,u);return u-1>=f&&(b|=a(p,u-1)<<4),b}s.prototype._parseHex=function(f,u,b){this.length=Math.ceil((f.length-u)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var E=0,w=0,d;if(b==="be")for(_=f.length-1;_>=u;_-=2)d=c(f,u,_)<<E,this.words[w]|=d&67108863,E>=18?(E-=18,w+=1,this.words[w]|=d>>>26):E+=8;else{var m=f.length-u;for(_=m%2===0?u+1:u;_<f.length;_+=2)d=c(f,u,_)<<E,this.words[w]|=d&67108863,E>=18?(E-=18,w+=1,this.words[w]|=d>>>26):E+=8}this._strip()};function h(p,f,u,b){for(var _=0,E=0,w=Math.min(p.length,u),d=f;d<w;d++){var m=p.charCodeAt(d)-48;_*=b,m>=49?E=m-49+10:m>=17?E=m-17+10:E=m,i(m>=0&&E<b,"Invalid character"),_+=E}return _}s.prototype._parseBase=function(f,u,b){this.words=[0],this.length=1;for(var _=0,E=1;E<=67108863;E*=u)_++;_--,E=E/u|0;for(var w=f.length-b,d=w%_,m=Math.min(w,w-d)+b,v=0,A=b;A<m;A+=_)v=h(f,A,A+_,u),this.imuln(E),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v);if(d!==0){var U=1;for(v=h(f,A,f.length,u),A=0;A<d;A++)U*=u;this.imuln(U),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v)}this._strip()},s.prototype.copy=function(f){f.words=new Array(this.length);for(var u=0;u<this.length;u++)f.words[u]=this.words[u];f.length=this.length,f.negative=this.negative,f.red=this.red};function l(p,f){p.words=f.words,p.length=f.length,p.negative=f.negative,p.red=f.red}if(s.prototype._move=function(f){l(f,this)},s.prototype.clone=function(){var f=new s(null);return this.copy(f),f},s.prototype._expand=function(f){for(;this.length<f;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var M=["","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"],I=[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],S=[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];s.prototype.toString=function(f,u){f=f||10,u=u|0||1;var b;if(f===16||f==="hex"){b="";for(var _=0,E=0,w=0;w<this.length;w++){var d=this.words[w],m=((d<<_|E)&16777215).toString(16);E=d>>>24-_&16777215,_+=2,_>=26&&(_-=26,w--),E!==0||w!==this.length-1?b=M[6-m.length]+m+b:b=m+b}for(E!==0&&(b=E.toString(16)+b);b.length%u!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(f===(f|0)&&f>=2&&f<=36){var v=I[f],A=S[f];b="";var U=this.clone();for(U.negative=0;!U.isZero();){var x=U.modrn(A).toString(f);U=U.idivn(A),U.isZero()?b=x+b:b=M[v-x.length]+x+b}for(this.isZero()&&(b="0"+b);b.length%u!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(f,u){return this.toArrayLike(o,f,u)}),s.prototype.toArray=function(f,u){return this.toArrayLike(Array,f,u)};var D=function(f,u){return f.allocUnsafe?f.allocUnsafe(u):new f(u)};s.prototype.toArrayLike=function(f,u,b){this._strip();var _=this.byteLength(),E=b||Math.max(1,_);i(_<=E,"byte array longer than desired length"),i(E>0,"Requested array length <= 0");var w=D(f,E),d=u==="le"?"LE":"BE";return this["_toArrayLike"+d](w,_),w},s.prototype._toArrayLikeLE=function(f,u){for(var b=0,_=0,E=0,w=0;E<this.length;E++){var d=this.words[E]<<w|_;f[b++]=d&255,b<f.length&&(f[b++]=d>>8&255),b<f.length&&(f[b++]=d>>16&255),w===6?(b<f.length&&(f[b++]=d>>24&255),_=0,w=0):(_=d>>>24,w+=2)}if(b<f.length)for(f[b++]=_;b<f.length;)f[b++]=0},s.prototype._toArrayLikeBE=function(f,u){for(var b=f.length-1,_=0,E=0,w=0;E<this.length;E++){var d=this.words[E]<<w|_;f[b--]=d&255,b>=0&&(f[b--]=d>>8&255),b>=0&&(f[b--]=d>>16&255),w===6?(b>=0&&(f[b--]=d>>24&255),_=0,w=0):(_=d>>>24,w+=2)}if(b>=0)for(f[b--]=_;b>=0;)f[b--]=0},Math.clz32?s.prototype._countBits=function(f){return 32-Math.clz32(f)}:s.prototype._countBits=function(f){var u=f,b=0;return u>=4096&&(b+=13,u>>>=13),u>=64&&(b+=7,u>>>=7),u>=8&&(b+=4,u>>>=4),u>=2&&(b+=2,u>>>=2),b+u},s.prototype._zeroBits=function(f){if(f===0)return 26;var u=f,b=0;return u&8191||(b+=13,u>>>=13),u&127||(b+=7,u>>>=7),u&15||(b+=4,u>>>=4),u&3||(b+=2,u>>>=2),u&1||b++,b},s.prototype.bitLength=function(){var f=this.words[this.length-1],u=this._countBits(f);return(this.length-1)*26+u};function R(p){for(var f=new Array(p.bitLength()),u=0;u<f.length;u++){var b=u/26|0,_=u%26;f[u]=p.words[b]>>>_&1}return f}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,u=0;u<this.length;u++){var b=this._zeroBits(this.words[u]);if(f+=b,b!==26)break}return f},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(f){return this.negative!==0?this.abs().inotn(f).iaddn(1):this.clone()},s.prototype.fromTwos=function(f){return this.testn(f-1)?this.notn(f).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(f){for(;this.length<f.length;)this.words[this.length++]=0;for(var u=0;u<f.length;u++)this.words[u]=this.words[u]|f.words[u];return this._strip()},s.prototype.ior=function(f){return i((this.negative|f.negative)===0),this.iuor(f)},s.prototype.or=function(f){return this.length>f.length?this.clone().ior(f):f.clone().ior(this)},s.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},s.prototype.iuand=function(f){var u;this.length>f.length?u=f:u=this;for(var b=0;b<u.length;b++)this.words[b]=this.words[b]&f.words[b];return this.length=u.length,this._strip()},s.prototype.iand=function(f){return i((this.negative|f.negative)===0),this.iuand(f)},s.prototype.and=function(f){return this.length>f.length?this.clone().iand(f):f.clone().iand(this)},s.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},s.prototype.iuxor=function(f){var u,b;this.length>f.length?(u=this,b=f):(u=f,b=this);for(var _=0;_<b.length;_++)this.words[_]=u.words[_]^b.words[_];if(this!==u)for(;_<u.length;_++)this.words[_]=u.words[_];return this.length=u.length,this._strip()},s.prototype.ixor=function(f){return i((this.negative|f.negative)===0),this.iuxor(f)},s.prototype.xor=function(f){return this.length>f.length?this.clone().ixor(f):f.clone().ixor(this)},s.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},s.prototype.inotn=function(f){i(typeof f=="number"&&f>=0);var u=Math.ceil(f/26)|0,b=f%26;this._expand(u),b>0&&u--;for(var _=0;_<u;_++)this.words[_]=~this.words[_]&67108863;return b>0&&(this.words[_]=~this.words[_]&67108863>>26-b),this._strip()},s.prototype.notn=function(f){return this.clone().inotn(f)},s.prototype.setn=function(f,u){i(typeof f=="number"&&f>=0);var b=f/26|0,_=f%26;return this._expand(b+1),u?this.words[b]=this.words[b]|1<<_:this.words[b]=this.words[b]&~(1<<_),this._strip()},s.prototype.iadd=function(f){var u;if(this.negative!==0&&f.negative===0)return this.negative=0,u=this.isub(f),this.negative^=1,this._normSign();if(this.negative===0&&f.negative!==0)return f.negative=0,u=this.isub(f),f.negative=1,u._normSign();var b,_;this.length>f.length?(b=this,_=f):(b=f,_=this);for(var E=0,w=0;w<_.length;w++)u=(b.words[w]|0)+(_.words[w]|0)+E,this.words[w]=u&67108863,E=u>>>26;for(;E!==0&&w<b.length;w++)u=(b.words[w]|0)+E,this.words[w]=u&67108863,E=u>>>26;if(this.length=b.length,E!==0)this.words[this.length]=E,this.length++;else if(b!==this)for(;w<b.length;w++)this.words[w]=b.words[w];return this},s.prototype.add=function(f){var u;return f.negative!==0&&this.negative===0?(f.negative=0,u=this.sub(f),f.negative^=1,u):f.negative===0&&this.negative!==0?(this.negative=0,u=f.sub(this),this.negative=1,u):this.length>f.length?this.clone().iadd(f):f.clone().iadd(this)},s.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var u=this.iadd(f);return f.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var b=this.cmp(f);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,E;b>0?(_=this,E=f):(_=f,E=this);for(var w=0,d=0;d<E.length;d++)u=(_.words[d]|0)-(E.words[d]|0)+w,w=u>>26,this.words[d]=u&67108863;for(;w!==0&&d<_.length;d++)u=(_.words[d]|0)+w,w=u>>26,this.words[d]=u&67108863;if(w===0&&d<_.length&&_!==this)for(;d<_.length;d++)this.words[d]=_.words[d];return this.length=Math.max(this.length,d),_!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(f){return this.clone().isub(f)};function $(p,f,u){u.negative=f.negative^p.negative;var b=p.length+f.length|0;u.length=b,b=b-1|0;var _=p.words[0]|0,E=f.words[0]|0,w=_*E,d=w&67108863,m=w/67108864|0;u.words[0]=d;for(var v=1;v<b;v++){for(var A=m>>>26,U=m&67108863,x=Math.min(v,f.length-1),T=Math.max(0,v-p.length+1);T<=x;T++){var B=v-T|0;_=p.words[B]|0,E=f.words[T]|0,w=_*E+U,A+=w/67108864|0,U=w&67108863}u.words[v]=U|0,m=A|0}return m!==0?u.words[v]=m|0:u.length--,u._strip()}var N=function(f,u,b){var _=f.words,E=u.words,w=b.words,d=0,m,v,A,U=_[0]|0,x=U&8191,T=U>>>13,B=_[1]|0,q=B&8191,z=B>>>13,Y=_[2]|0,X=Y&8191,W=Y>>>13,se=_[3]|0,ee=se&8191,te=se>>>13,ke=_[4]|0,je=ke&8191,ue=ke>>>13,Ne=_[5]|0,Te=Ne&8191,fe=Ne>>>13,Fe=_[6]|0,Ce=Fe&8191,he=Fe>>>13,Be=_[7]|0,Le=Be&8191,ae=Be>>>13,$e=_[8]|0,qe=$e&8191,ne=$e>>>13,Je=_[9]|0,Ye=Je&8191,ge=Je>>>13,Ze=E[0]|0,Ue=Ze&8191,le=Ze>>>13,Xe=E[1]|0,tt=Xe&8191,oe=Xe>>>13,Qe=E[2]|0,rt=Qe&8191,be=Qe>>>13,Ke=E[3]|0,Re=Ke&8191,de=Ke>>>13,Ve=E[4]|0,He=Ve&8191,ce=Ve>>>13,it=E[5]|0,nt=it&8191,ve=it>>>13,st=E[6]|0,ot=st&8191,pe=st>>>13,We=E[7]|0,De=We&8191,ye=We>>>13,at=E[8]|0,ft=at&8191,me=at>>>13,ct=E[9]|0,Ee=ct&8191,et=ct>>>13;b.negative=f.negative^u.negative,b.length=19,m=Math.imul(x,Ue),v=Math.imul(x,le),v=v+Math.imul(T,Ue)|0,A=Math.imul(T,le);var wr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(wr>>>26)|0,wr&=67108863,m=Math.imul(q,Ue),v=Math.imul(q,le),v=v+Math.imul(z,Ue)|0,A=Math.imul(z,le),m=m+Math.imul(x,tt)|0,v=v+Math.imul(x,oe)|0,v=v+Math.imul(T,tt)|0,A=A+Math.imul(T,oe)|0;var _r=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(_r>>>26)|0,_r&=67108863,m=Math.imul(X,Ue),v=Math.imul(X,le),v=v+Math.imul(W,Ue)|0,A=Math.imul(W,le),m=m+Math.imul(q,tt)|0,v=v+Math.imul(q,oe)|0,v=v+Math.imul(z,tt)|0,A=A+Math.imul(z,oe)|0,m=m+Math.imul(x,rt)|0,v=v+Math.imul(x,be)|0,v=v+Math.imul(T,rt)|0,A=A+Math.imul(T,be)|0;var xr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(xr>>>26)|0,xr&=67108863,m=Math.imul(ee,Ue),v=Math.imul(ee,le),v=v+Math.imul(te,Ue)|0,A=Math.imul(te,le),m=m+Math.imul(X,tt)|0,v=v+Math.imul(X,oe)|0,v=v+Math.imul(W,tt)|0,A=A+Math.imul(W,oe)|0,m=m+Math.imul(q,rt)|0,v=v+Math.imul(q,be)|0,v=v+Math.imul(z,rt)|0,A=A+Math.imul(z,be)|0,m=m+Math.imul(x,Re)|0,v=v+Math.imul(x,de)|0,v=v+Math.imul(T,Re)|0,A=A+Math.imul(T,de)|0;var Er=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Er>>>26)|0,Er&=67108863,m=Math.imul(je,Ue),v=Math.imul(je,le),v=v+Math.imul(ue,Ue)|0,A=Math.imul(ue,le),m=m+Math.imul(ee,tt)|0,v=v+Math.imul(ee,oe)|0,v=v+Math.imul(te,tt)|0,A=A+Math.imul(te,oe)|0,m=m+Math.imul(X,rt)|0,v=v+Math.imul(X,be)|0,v=v+Math.imul(W,rt)|0,A=A+Math.imul(W,be)|0,m=m+Math.imul(q,Re)|0,v=v+Math.imul(q,de)|0,v=v+Math.imul(z,Re)|0,A=A+Math.imul(z,de)|0,m=m+Math.imul(x,He)|0,v=v+Math.imul(x,ce)|0,v=v+Math.imul(T,He)|0,A=A+Math.imul(T,ce)|0;var At=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(At>>>26)|0,At&=67108863,m=Math.imul(Te,Ue),v=Math.imul(Te,le),v=v+Math.imul(fe,Ue)|0,A=Math.imul(fe,le),m=m+Math.imul(je,tt)|0,v=v+Math.imul(je,oe)|0,v=v+Math.imul(ue,tt)|0,A=A+Math.imul(ue,oe)|0,m=m+Math.imul(ee,rt)|0,v=v+Math.imul(ee,be)|0,v=v+Math.imul(te,rt)|0,A=A+Math.imul(te,be)|0,m=m+Math.imul(X,Re)|0,v=v+Math.imul(X,de)|0,v=v+Math.imul(W,Re)|0,A=A+Math.imul(W,de)|0,m=m+Math.imul(q,He)|0,v=v+Math.imul(q,ce)|0,v=v+Math.imul(z,He)|0,A=A+Math.imul(z,ce)|0,m=m+Math.imul(x,nt)|0,v=v+Math.imul(x,ve)|0,v=v+Math.imul(T,nt)|0,A=A+Math.imul(T,ve)|0;var Bi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,m=Math.imul(Ce,Ue),v=Math.imul(Ce,le),v=v+Math.imul(he,Ue)|0,A=Math.imul(he,le),m=m+Math.imul(Te,tt)|0,v=v+Math.imul(Te,oe)|0,v=v+Math.imul(fe,tt)|0,A=A+Math.imul(fe,oe)|0,m=m+Math.imul(je,rt)|0,v=v+Math.imul(je,be)|0,v=v+Math.imul(ue,rt)|0,A=A+Math.imul(ue,be)|0,m=m+Math.imul(ee,Re)|0,v=v+Math.imul(ee,de)|0,v=v+Math.imul(te,Re)|0,A=A+Math.imul(te,de)|0,m=m+Math.imul(X,He)|0,v=v+Math.imul(X,ce)|0,v=v+Math.imul(W,He)|0,A=A+Math.imul(W,ce)|0,m=m+Math.imul(q,nt)|0,v=v+Math.imul(q,ve)|0,v=v+Math.imul(z,nt)|0,A=A+Math.imul(z,ve)|0,m=m+Math.imul(x,ot)|0,v=v+Math.imul(x,pe)|0,v=v+Math.imul(T,ot)|0,A=A+Math.imul(T,pe)|0;var Li=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Li>>>26)|0,Li&=67108863,m=Math.imul(Le,Ue),v=Math.imul(Le,le),v=v+Math.imul(ae,Ue)|0,A=Math.imul(ae,le),m=m+Math.imul(Ce,tt)|0,v=v+Math.imul(Ce,oe)|0,v=v+Math.imul(he,tt)|0,A=A+Math.imul(he,oe)|0,m=m+Math.imul(Te,rt)|0,v=v+Math.imul(Te,be)|0,v=v+Math.imul(fe,rt)|0,A=A+Math.imul(fe,be)|0,m=m+Math.imul(je,Re)|0,v=v+Math.imul(je,de)|0,v=v+Math.imul(ue,Re)|0,A=A+Math.imul(ue,de)|0,m=m+Math.imul(ee,He)|0,v=v+Math.imul(ee,ce)|0,v=v+Math.imul(te,He)|0,A=A+Math.imul(te,ce)|0,m=m+Math.imul(X,nt)|0,v=v+Math.imul(X,ve)|0,v=v+Math.imul(W,nt)|0,A=A+Math.imul(W,ve)|0,m=m+Math.imul(q,ot)|0,v=v+Math.imul(q,pe)|0,v=v+Math.imul(z,ot)|0,A=A+Math.imul(z,pe)|0,m=m+Math.imul(x,De)|0,v=v+Math.imul(x,ye)|0,v=v+Math.imul(T,De)|0,A=A+Math.imul(T,ye)|0;var qi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(qi>>>26)|0,qi&=67108863,m=Math.imul(qe,Ue),v=Math.imul(qe,le),v=v+Math.imul(ne,Ue)|0,A=Math.imul(ne,le),m=m+Math.imul(Le,tt)|0,v=v+Math.imul(Le,oe)|0,v=v+Math.imul(ae,tt)|0,A=A+Math.imul(ae,oe)|0,m=m+Math.imul(Ce,rt)|0,v=v+Math.imul(Ce,be)|0,v=v+Math.imul(he,rt)|0,A=A+Math.imul(he,be)|0,m=m+Math.imul(Te,Re)|0,v=v+Math.imul(Te,de)|0,v=v+Math.imul(fe,Re)|0,A=A+Math.imul(fe,de)|0,m=m+Math.imul(je,He)|0,v=v+Math.imul(je,ce)|0,v=v+Math.imul(ue,He)|0,A=A+Math.imul(ue,ce)|0,m=m+Math.imul(ee,nt)|0,v=v+Math.imul(ee,ve)|0,v=v+Math.imul(te,nt)|0,A=A+Math.imul(te,ve)|0,m=m+Math.imul(X,ot)|0,v=v+Math.imul(X,pe)|0,v=v+Math.imul(W,ot)|0,A=A+Math.imul(W,pe)|0,m=m+Math.imul(q,De)|0,v=v+Math.imul(q,ye)|0,v=v+Math.imul(z,De)|0,A=A+Math.imul(z,ye)|0,m=m+Math.imul(x,ft)|0,v=v+Math.imul(x,me)|0,v=v+Math.imul(T,ft)|0,A=A+Math.imul(T,me)|0;var Ui=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,m=Math.imul(Ye,Ue),v=Math.imul(Ye,le),v=v+Math.imul(ge,Ue)|0,A=Math.imul(ge,le),m=m+Math.imul(qe,tt)|0,v=v+Math.imul(qe,oe)|0,v=v+Math.imul(ne,tt)|0,A=A+Math.imul(ne,oe)|0,m=m+Math.imul(Le,rt)|0,v=v+Math.imul(Le,be)|0,v=v+Math.imul(ae,rt)|0,A=A+Math.imul(ae,be)|0,m=m+Math.imul(Ce,Re)|0,v=v+Math.imul(Ce,de)|0,v=v+Math.imul(he,Re)|0,A=A+Math.imul(he,de)|0,m=m+Math.imul(Te,He)|0,v=v+Math.imul(Te,ce)|0,v=v+Math.imul(fe,He)|0,A=A+Math.imul(fe,ce)|0,m=m+Math.imul(je,nt)|0,v=v+Math.imul(je,ve)|0,v=v+Math.imul(ue,nt)|0,A=A+Math.imul(ue,ve)|0,m=m+Math.imul(ee,ot)|0,v=v+Math.imul(ee,pe)|0,v=v+Math.imul(te,ot)|0,A=A+Math.imul(te,pe)|0,m=m+Math.imul(X,De)|0,v=v+Math.imul(X,ye)|0,v=v+Math.imul(W,De)|0,A=A+Math.imul(W,ye)|0,m=m+Math.imul(q,ft)|0,v=v+Math.imul(q,me)|0,v=v+Math.imul(z,ft)|0,A=A+Math.imul(z,me)|0,m=m+Math.imul(x,Ee)|0,v=v+Math.imul(x,et)|0,v=v+Math.imul(T,Ee)|0,A=A+Math.imul(T,et)|0;var zi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(zi>>>26)|0,zi&=67108863,m=Math.imul(Ye,tt),v=Math.imul(Ye,oe),v=v+Math.imul(ge,tt)|0,A=Math.imul(ge,oe),m=m+Math.imul(qe,rt)|0,v=v+Math.imul(qe,be)|0,v=v+Math.imul(ne,rt)|0,A=A+Math.imul(ne,be)|0,m=m+Math.imul(Le,Re)|0,v=v+Math.imul(Le,de)|0,v=v+Math.imul(ae,Re)|0,A=A+Math.imul(ae,de)|0,m=m+Math.imul(Ce,He)|0,v=v+Math.imul(Ce,ce)|0,v=v+Math.imul(he,He)|0,A=A+Math.imul(he,ce)|0,m=m+Math.imul(Te,nt)|0,v=v+Math.imul(Te,ve)|0,v=v+Math.imul(fe,nt)|0,A=A+Math.imul(fe,ve)|0,m=m+Math.imul(je,ot)|0,v=v+Math.imul(je,pe)|0,v=v+Math.imul(ue,ot)|0,A=A+Math.imul(ue,pe)|0,m=m+Math.imul(ee,De)|0,v=v+Math.imul(ee,ye)|0,v=v+Math.imul(te,De)|0,A=A+Math.imul(te,ye)|0,m=m+Math.imul(X,ft)|0,v=v+Math.imul(X,me)|0,v=v+Math.imul(W,ft)|0,A=A+Math.imul(W,me)|0,m=m+Math.imul(q,Ee)|0,v=v+Math.imul(q,et)|0,v=v+Math.imul(z,Ee)|0,A=A+Math.imul(z,et)|0;var jr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(jr>>>26)|0,jr&=67108863,m=Math.imul(Ye,rt),v=Math.imul(Ye,be),v=v+Math.imul(ge,rt)|0,A=Math.imul(ge,be),m=m+Math.imul(qe,Re)|0,v=v+Math.imul(qe,de)|0,v=v+Math.imul(ne,Re)|0,A=A+Math.imul(ne,de)|0,m=m+Math.imul(Le,He)|0,v=v+Math.imul(Le,ce)|0,v=v+Math.imul(ae,He)|0,A=A+Math.imul(ae,ce)|0,m=m+Math.imul(Ce,nt)|0,v=v+Math.imul(Ce,ve)|0,v=v+Math.imul(he,nt)|0,A=A+Math.imul(he,ve)|0,m=m+Math.imul(Te,ot)|0,v=v+Math.imul(Te,pe)|0,v=v+Math.imul(fe,ot)|0,A=A+Math.imul(fe,pe)|0,m=m+Math.imul(je,De)|0,v=v+Math.imul(je,ye)|0,v=v+Math.imul(ue,De)|0,A=A+Math.imul(ue,ye)|0,m=m+Math.imul(ee,ft)|0,v=v+Math.imul(ee,me)|0,v=v+Math.imul(te,ft)|0,A=A+Math.imul(te,me)|0,m=m+Math.imul(X,Ee)|0,v=v+Math.imul(X,et)|0,v=v+Math.imul(W,Ee)|0,A=A+Math.imul(W,et)|0;var ki=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(ki>>>26)|0,ki&=67108863,m=Math.imul(Ye,Re),v=Math.imul(Ye,de),v=v+Math.imul(ge,Re)|0,A=Math.imul(ge,de),m=m+Math.imul(qe,He)|0,v=v+Math.imul(qe,ce)|0,v=v+Math.imul(ne,He)|0,A=A+Math.imul(ne,ce)|0,m=m+Math.imul(Le,nt)|0,v=v+Math.imul(Le,ve)|0,v=v+Math.imul(ae,nt)|0,A=A+Math.imul(ae,ve)|0,m=m+Math.imul(Ce,ot)|0,v=v+Math.imul(Ce,pe)|0,v=v+Math.imul(he,ot)|0,A=A+Math.imul(he,pe)|0,m=m+Math.imul(Te,De)|0,v=v+Math.imul(Te,ye)|0,v=v+Math.imul(fe,De)|0,A=A+Math.imul(fe,ye)|0,m=m+Math.imul(je,ft)|0,v=v+Math.imul(je,me)|0,v=v+Math.imul(ue,ft)|0,A=A+Math.imul(ue,me)|0,m=m+Math.imul(ee,Ee)|0,v=v+Math.imul(ee,et)|0,v=v+Math.imul(te,Ee)|0,A=A+Math.imul(te,et)|0;var ji=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(ji>>>26)|0,ji&=67108863,m=Math.imul(Ye,He),v=Math.imul(Ye,ce),v=v+Math.imul(ge,He)|0,A=Math.imul(ge,ce),m=m+Math.imul(qe,nt)|0,v=v+Math.imul(qe,ve)|0,v=v+Math.imul(ne,nt)|0,A=A+Math.imul(ne,ve)|0,m=m+Math.imul(Le,ot)|0,v=v+Math.imul(Le,pe)|0,v=v+Math.imul(ae,ot)|0,A=A+Math.imul(ae,pe)|0,m=m+Math.imul(Ce,De)|0,v=v+Math.imul(Ce,ye)|0,v=v+Math.imul(he,De)|0,A=A+Math.imul(he,ye)|0,m=m+Math.imul(Te,ft)|0,v=v+Math.imul(Te,me)|0,v=v+Math.imul(fe,ft)|0,A=A+Math.imul(fe,me)|0,m=m+Math.imul(je,Ee)|0,v=v+Math.imul(je,et)|0,v=v+Math.imul(ue,Ee)|0,A=A+Math.imul(ue,et)|0;var nr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(nr>>>26)|0,nr&=67108863,m=Math.imul(Ye,nt),v=Math.imul(Ye,ve),v=v+Math.imul(ge,nt)|0,A=Math.imul(ge,ve),m=m+Math.imul(qe,ot)|0,v=v+Math.imul(qe,pe)|0,v=v+Math.imul(ne,ot)|0,A=A+Math.imul(ne,pe)|0,m=m+Math.imul(Le,De)|0,v=v+Math.imul(Le,ye)|0,v=v+Math.imul(ae,De)|0,A=A+Math.imul(ae,ye)|0,m=m+Math.imul(Ce,ft)|0,v=v+Math.imul(Ce,me)|0,v=v+Math.imul(he,ft)|0,A=A+Math.imul(he,me)|0,m=m+Math.imul(Te,Ee)|0,v=v+Math.imul(Te,et)|0,v=v+Math.imul(fe,Ee)|0,A=A+Math.imul(fe,et)|0;var Ki=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,m=Math.imul(Ye,ot),v=Math.imul(Ye,pe),v=v+Math.imul(ge,ot)|0,A=Math.imul(ge,pe),m=m+Math.imul(qe,De)|0,v=v+Math.imul(qe,ye)|0,v=v+Math.imul(ne,De)|0,A=A+Math.imul(ne,ye)|0,m=m+Math.imul(Le,ft)|0,v=v+Math.imul(Le,me)|0,v=v+Math.imul(ae,ft)|0,A=A+Math.imul(ae,me)|0,m=m+Math.imul(Ce,Ee)|0,v=v+Math.imul(Ce,et)|0,v=v+Math.imul(he,Ee)|0,A=A+Math.imul(he,et)|0;var Vi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,m=Math.imul(Ye,De),v=Math.imul(Ye,ye),v=v+Math.imul(ge,De)|0,A=Math.imul(ge,ye),m=m+Math.imul(qe,ft)|0,v=v+Math.imul(qe,me)|0,v=v+Math.imul(ne,ft)|0,A=A+Math.imul(ne,me)|0,m=m+Math.imul(Le,Ee)|0,v=v+Math.imul(Le,et)|0,v=v+Math.imul(ae,Ee)|0,A=A+Math.imul(ae,et)|0;var Hi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,m=Math.imul(Ye,ft),v=Math.imul(Ye,me),v=v+Math.imul(ge,ft)|0,A=Math.imul(ge,me),m=m+Math.imul(qe,Ee)|0,v=v+Math.imul(qe,et)|0,v=v+Math.imul(ne,Ee)|0,A=A+Math.imul(ne,et)|0;var fo=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(fo>>>26)|0,fo&=67108863,m=Math.imul(Ye,Ee),v=Math.imul(Ye,et),v=v+Math.imul(ge,Ee)|0,A=Math.imul(ge,et);var co=(d+m|0)+((v&8191)<<13)|0;return d=(A+(v>>>13)|0)+(co>>>26)|0,co&=67108863,w[0]=wr,w[1]=_r,w[2]=xr,w[3]=Er,w[4]=At,w[5]=Bi,w[6]=Li,w[7]=qi,w[8]=Ui,w[9]=zi,w[10]=jr,w[11]=ki,w[12]=ji,w[13]=nr,w[14]=Ki,w[15]=Vi,w[16]=Hi,w[17]=fo,w[18]=co,d!==0&&(w[19]=d,b.length++),b};Math.imul||(N=$);function C(p,f,u){u.negative=f.negative^p.negative,u.length=p.length+f.length;for(var b=0,_=0,E=0;E<u.length-1;E++){var w=_;_=0;for(var d=b&67108863,m=Math.min(E,f.length-1),v=Math.max(0,E-p.length+1);v<=m;v++){var A=E-v,U=p.words[A]|0,x=f.words[v]|0,T=U*x,B=T&67108863;w=w+(T/67108864|0)|0,B=B+d|0,d=B&67108863,w=w+(B>>>26)|0,_+=w>>>26,w&=67108863}u.words[E]=d,b=w,w=_}return b!==0?u.words[E]=b:u.length--,u._strip()}function L(p,f,u){return C(p,f,u)}s.prototype.mulTo=function(f,u){var b,_=this.length+f.length;return this.length===10&&f.length===10?b=N(this,f,u):_<63?b=$(this,f,u):_<1024?b=C(this,f,u):b=L(this,f,u),b},s.prototype.mul=function(f){var u=new s(null);return u.words=new Array(this.length+f.length),this.mulTo(f,u)},s.prototype.mulf=function(f){var u=new s(null);return u.words=new Array(this.length+f.length),L(this,f,u)},s.prototype.imul=function(f){return this.clone().mulTo(f,this)},s.prototype.imuln=function(f){var u=f<0;u&&(f=-f),i(typeof f=="number"),i(f<67108864);for(var b=0,_=0;_<this.length;_++){var E=(this.words[_]|0)*f,w=(E&67108863)+(b&67108863);b>>=26,b+=E/67108864|0,b+=w>>>26,this.words[_]=w&67108863}return b!==0&&(this.words[_]=b,this.length++),u?this.ineg():this},s.prototype.muln=function(f){return this.clone().imuln(f)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(f){var u=R(f);if(u.length===0)return new s(1);for(var b=this,_=0;_<u.length&&u[_]===0;_++,b=b.sqr());if(++_<u.length)for(var E=b.sqr();_<u.length;_++,E=E.sqr())u[_]!==0&&(b=b.mul(E));return b},s.prototype.iushln=function(f){i(typeof f=="number"&&f>=0);var u=f%26,b=(f-u)/26,_=67108863>>>26-u<<26-u,E;if(u!==0){var w=0;for(E=0;E<this.length;E++){var d=this.words[E]&_,m=(this.words[E]|0)-d<<u;this.words[E]=m|w,w=d>>>26-u}w&&(this.words[E]=w,this.length++)}if(b!==0){for(E=this.length-1;E>=0;E--)this.words[E+b]=this.words[E];for(E=0;E<b;E++)this.words[E]=0;this.length+=b}return this._strip()},s.prototype.ishln=function(f){return i(this.negative===0),this.iushln(f)},s.prototype.iushrn=function(f,u,b){i(typeof f=="number"&&f>=0);var _;u?_=(u-u%26)/26:_=0;var E=f%26,w=Math.min((f-E)/26,this.length),d=67108863^67108863>>>E<<E,m=b;if(_-=w,_=Math.max(0,_),m){for(var v=0;v<w;v++)m.words[v]=this.words[v];m.length=w}if(w!==0)if(this.length>w)for(this.length-=w,v=0;v<this.length;v++)this.words[v]=this.words[v+w];else this.words[0]=0,this.length=1;var A=0;for(v=this.length-1;v>=0&&(A!==0||v>=_);v--){var U=this.words[v]|0;this.words[v]=A<<26-E|U>>>E,A=U&d}return m&&A!==0&&(m.words[m.length++]=A),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(f,u,b){return i(this.negative===0),this.iushrn(f,u,b)},s.prototype.shln=function(f){return this.clone().ishln(f)},s.prototype.ushln=function(f){return this.clone().iushln(f)},s.prototype.shrn=function(f){return this.clone().ishrn(f)},s.prototype.ushrn=function(f){return this.clone().iushrn(f)},s.prototype.testn=function(f){i(typeof f=="number"&&f>=0);var u=f%26,b=(f-u)/26,_=1<<u;if(this.length<=b)return!1;var E=this.words[b];return!!(E&_)},s.prototype.imaskn=function(f){i(typeof f=="number"&&f>=0);var u=f%26,b=(f-u)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(u!==0&&b++,this.length=Math.min(b,this.length),u!==0){var _=67108863^67108863>>>u<<u;this.words[this.length-1]&=_}return this._strip()},s.prototype.maskn=function(f){return this.clone().imaskn(f)},s.prototype.iaddn=function(f){return i(typeof f=="number"),i(f<67108864),f<0?this.isubn(-f):this.negative!==0?this.length===1&&(this.words[0]|0)<=f?(this.words[0]=f-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(f),this.negative=1,this):this._iaddn(f)},s.prototype._iaddn=function(f){this.words[0]+=f;for(var u=0;u<this.length&&this.words[u]>=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},s.prototype.isubn=function(f){if(i(typeof f=="number"),i(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u<this.length&&this.words[u]<0;u++)this.words[u]+=67108864,this.words[u+1]-=1;return this._strip()},s.prototype.addn=function(f){return this.clone().iaddn(f)},s.prototype.subn=function(f){return this.clone().isubn(f)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(f,u,b){var _=f.length+b,E;this._expand(_);var w,d=0;for(E=0;E<f.length;E++){w=(this.words[E+b]|0)+d;var m=(f.words[E]|0)*u;w-=m&67108863,d=(w>>26)-(m/67108864|0),this.words[E+b]=w&67108863}for(;E<this.length-b;E++)w=(this.words[E+b]|0)+d,d=w>>26,this.words[E+b]=w&67108863;if(d===0)return this._strip();for(i(d===-1),d=0,E=0;E<this.length;E++)w=-(this.words[E]|0)+d,d=w>>26,this.words[E]=w&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(f,u){var b=this.length-f.length,_=this.clone(),E=f,w=E.words[E.length-1]|0,d=this._countBits(w);b=26-d,b!==0&&(E=E.ushln(b),_.iushln(b),w=E.words[E.length-1]|0);var m=_.length-E.length,v;if(u!=="mod"){v=new s(null),v.length=m+1,v.words=new Array(v.length);for(var A=0;A<v.length;A++)v.words[A]=0}var U=_.clone()._ishlnsubmul(E,1,m);U.negative===0&&(_=U,v&&(v.words[m]=1));for(var x=m-1;x>=0;x--){var T=(_.words[E.length+x]|0)*67108864+(_.words[E.length+x-1]|0);for(T=Math.min(T/w|0,67108863),_._ishlnsubmul(E,T,x);_.negative!==0;)T--,_.negative=0,_._ishlnsubmul(E,1,x),_.isZero()||(_.negative^=1);v&&(v.words[x]=T)}return v&&v._strip(),_._strip(),u!=="div"&&b!==0&&_.iushrn(b),{div:v||null,mod:_}},s.prototype.divmod=function(f,u,b){if(i(!f.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var _,E,w;return this.negative!==0&&f.negative===0?(w=this.neg().divmod(f,u),u!=="mod"&&(_=w.div.neg()),u!=="div"&&(E=w.mod.neg(),b&&E.negative!==0&&E.iadd(f)),{div:_,mod:E}):this.negative===0&&f.negative!==0?(w=this.divmod(f.neg(),u),u!=="mod"&&(_=w.div.neg()),{div:_,mod:w.mod}):this.negative&f.negative?(w=this.neg().divmod(f.neg(),u),u!=="div"&&(E=w.mod.neg(),b&&E.negative!==0&&E.isub(f)),{div:w.div,mod:E}):f.length>this.length||this.cmp(f)<0?{div:new s(0),mod:this}:f.length===1?u==="div"?{div:this.divn(f.words[0]),mod:null}:u==="mod"?{div:null,mod:new s(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new s(this.modrn(f.words[0]))}:this._wordDiv(f,u)},s.prototype.div=function(f){return this.divmod(f,"div",!1).div},s.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},s.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},s.prototype.divRound=function(f){var u=this.divmod(f);if(u.mod.isZero())return u.div;var b=u.div.negative!==0?u.mod.isub(f):u.mod,_=f.ushrn(1),E=f.andln(1),w=b.cmp(_);return w<0||E===1&&w===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},s.prototype.modrn=function(f){var u=f<0;u&&(f=-f),i(f<=67108863);for(var b=(1<<26)%f,_=0,E=this.length-1;E>=0;E--)_=(b*_+(this.words[E]|0))%f;return u?-_:_},s.prototype.modn=function(f){return this.modrn(f)},s.prototype.idivn=function(f){var u=f<0;u&&(f=-f),i(f<=67108863);for(var b=0,_=this.length-1;_>=0;_--){var E=(this.words[_]|0)+b*67108864;this.words[_]=E/f|0,b=E%f}return this._strip(),u?this.ineg():this},s.prototype.divn=function(f){return this.clone().idivn(f)},s.prototype.egcd=function(f){i(f.negative===0),i(!f.isZero());var u=this,b=f.clone();u.negative!==0?u=u.umod(f):u=u.clone();for(var _=new s(1),E=new s(0),w=new s(0),d=new s(1),m=0;u.isEven()&&b.isEven();)u.iushrn(1),b.iushrn(1),++m;for(var v=b.clone(),A=u.clone();!u.isZero();){for(var U=0,x=1;!(u.words[0]&x)&&U<26;++U,x<<=1);if(U>0)for(u.iushrn(U);U-- >0;)(_.isOdd()||E.isOdd())&&(_.iadd(v),E.isub(A)),_.iushrn(1),E.iushrn(1);for(var T=0,B=1;!(b.words[0]&B)&&T<26;++T,B<<=1);if(T>0)for(b.iushrn(T);T-- >0;)(w.isOdd()||d.isOdd())&&(w.iadd(v),d.isub(A)),w.iushrn(1),d.iushrn(1);u.cmp(b)>=0?(u.isub(b),_.isub(w),E.isub(d)):(b.isub(u),w.isub(_),d.isub(E))}return{a:w,b:d,gcd:b.iushln(m)}},s.prototype._invmp=function(f){i(f.negative===0),i(!f.isZero());var u=this,b=f.clone();u.negative!==0?u=u.umod(f):u=u.clone();for(var _=new s(1),E=new s(0),w=b.clone();u.cmpn(1)>0&&b.cmpn(1)>0;){for(var d=0,m=1;!(u.words[0]&m)&&d<26;++d,m<<=1);if(d>0)for(u.iushrn(d);d-- >0;)_.isOdd()&&_.iadd(w),_.iushrn(1);for(var v=0,A=1;!(b.words[0]&A)&&v<26;++v,A<<=1);if(v>0)for(b.iushrn(v);v-- >0;)E.isOdd()&&E.iadd(w),E.iushrn(1);u.cmp(b)>=0?(u.isub(b),_.isub(E)):(b.isub(u),E.isub(_))}var U;return u.cmpn(1)===0?U=_:U=E,U.cmpn(0)<0&&U.iadd(f),U},s.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var u=this.clone(),b=f.clone();u.negative=0,b.negative=0;for(var _=0;u.isEven()&&b.isEven();_++)u.iushrn(1),b.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;b.isEven();)b.iushrn(1);var E=u.cmp(b);if(E<0){var w=u;u=b,b=w}else if(E===0||b.cmpn(1)===0)break;u.isub(b)}while(!0);return b.iushln(_)},s.prototype.invm=function(f){return this.egcd(f).a.umod(f)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(f){return this.words[0]&f},s.prototype.bincn=function(f){i(typeof f=="number");var u=f%26,b=(f-u)/26,_=1<<u;if(this.length<=b)return this._expand(b+1),this.words[b]|=_,this;for(var E=_,w=b;E!==0&&w<this.length;w++){var d=this.words[w]|0;d+=E,E=d>>>26,d&=67108863,this.words[w]=d}return E!==0&&(this.words[w]=E,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(f){var u=f<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var b;if(this.length>1)b=1;else{u&&(f=-f),i(f<=67108863,"Number is too big");var _=this.words[0]|0;b=_===f?0:_<f?-1:1}return this.negative!==0?-b|0:b},s.prototype.cmp=function(f){if(this.negative!==0&&f.negative===0)return-1;if(this.negative===0&&f.negative!==0)return 1;var u=this.ucmp(f);return this.negative!==0?-u|0:u},s.prototype.ucmp=function(f){if(this.length>f.length)return 1;if(this.length<f.length)return-1;for(var u=0,b=this.length-1;b>=0;b--){var _=this.words[b]|0,E=f.words[b]|0;if(_!==E){_<E?u=-1:_>E&&(u=1);break}}return u},s.prototype.gtn=function(f){return this.cmpn(f)===1},s.prototype.gt=function(f){return this.cmp(f)===1},s.prototype.gten=function(f){return this.cmpn(f)>=0},s.prototype.gte=function(f){return this.cmp(f)>=0},s.prototype.ltn=function(f){return this.cmpn(f)===-1},s.prototype.lt=function(f){return this.cmp(f)===-1},s.prototype.lten=function(f){return this.cmpn(f)<=0},s.prototype.lte=function(f){return this.cmp(f)<=0},s.prototype.eqn=function(f){return this.cmpn(f)===0},s.prototype.eq=function(f){return this.cmp(f)===0},s.red=function(f){return new O(f)},s.prototype.toRed=function(f){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(f){return this.red=f,this},s.prototype.forceRed=function(f){return i(!this.red,"Already a number in reduction context"),this._forceRed(f)},s.prototype.redAdd=function(f){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},s.prototype.redIAdd=function(f){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},s.prototype.redSub=function(f){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},s.prototype.redISub=function(f){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},s.prototype.redShl=function(f){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},s.prototype.redMul=function(f){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},s.prototype.redIMul=function(f){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(f){return i(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var k={k256:null,p224:null,p192:null,p25519:null};function j(p,f){this.name=p,this.p=new s(f,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}j.prototype._tmp=function(){var f=new s(null);return f.words=new Array(Math.ceil(this.n/13)),f},j.prototype.ireduce=function(f){var u=f,b;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),b=u.bitLength();while(b>this.n);var _=b<this.n?-1:u.ucmp(this.p);return _===0?(u.words[0]=0,u.length=1):_>0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},j.prototype.split=function(f,u){f.iushrn(this.n,0,u)},j.prototype.imulK=function(f){return f.imul(this.k)};function G(){j.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(G,j),G.prototype.split=function(f,u){for(var b=4194303,_=Math.min(f.length,9),E=0;E<_;E++)u.words[E]=f.words[E];if(u.length=_,f.length<=9){f.words[0]=0,f.length=1;return}var w=f.words[9];for(u.words[u.length++]=w&b,E=10;E<f.length;E++){var d=f.words[E]|0;f.words[E-10]=(d&b)<<4|w>>>22,w=d}w>>>=22,f.words[E-10]=w,w===0&&f.length>10?f.length-=10:f.length-=9},G.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var u=0,b=0;b<f.length;b++){var _=f.words[b]|0;u+=_*977,f.words[b]=u&67108863,u=_*64+(u/67108864|0)}return f.words[f.length-1]===0&&(f.length--,f.words[f.length-1]===0&&f.length--),f};function K(){j.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(K,j);function V(){j.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(V,j);function ie(){j.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(ie,j),ie.prototype.imulK=function(f){for(var u=0,b=0;b<f.length;b++){var _=(f.words[b]|0)*19+u,E=_&67108863;_>>>=26,f.words[b]=E,u=_}return u!==0&&(f.words[f.length++]=u),f},s._prime=function(f){if(k[f])return k[f];var u;if(f==="k256")u=new G;else if(f==="p224")u=new K;else if(f==="p192")u=new V;else if(f==="p25519")u=new ie;else throw new Error("Unknown prime "+f);return k[f]=u,u};function O(p){if(typeof p=="string"){var f=s._prime(p);this.m=f.p,this.prime=f}else i(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}O.prototype._verify1=function(f){i(f.negative===0,"red works only with positives"),i(f.red,"red works only with red numbers")},O.prototype._verify2=function(f,u){i((f.negative|u.negative)===0,"red works only with positives"),i(f.red&&f.red===u.red,"red works only with red numbers")},O.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(l(f,f.umod(this.m)._forceRed(this)),f)},O.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},O.prototype.add=function(f,u){this._verify2(f,u);var b=f.add(u);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},O.prototype.iadd=function(f,u){this._verify2(f,u);var b=f.iadd(u);return b.cmp(this.m)>=0&&b.isub(this.m),b},O.prototype.sub=function(f,u){this._verify2(f,u);var b=f.sub(u);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},O.prototype.isub=function(f,u){this._verify2(f,u);var b=f.isub(u);return b.cmpn(0)<0&&b.iadd(this.m),b},O.prototype.shl=function(f,u){return this._verify1(f),this.imod(f.ushln(u))},O.prototype.imul=function(f,u){return this._verify2(f,u),this.imod(f.imul(u))},O.prototype.mul=function(f,u){return this._verify2(f,u),this.imod(f.mul(u))},O.prototype.isqr=function(f){return this.imul(f,f.clone())},O.prototype.sqr=function(f){return this.mul(f,f)},O.prototype.sqrt=function(f){if(f.isZero())return f.clone();var u=this.m.andln(3);if(i(u%2===1),u===3){var b=this.m.add(new s(1)).iushrn(2);return this.pow(f,b)}for(var _=this.m.subn(1),E=0;!_.isZero()&&_.andln(1)===0;)E++,_.iushrn(1);i(!_.isZero());var w=new s(1).toRed(this),d=w.redNeg(),m=this.m.subn(1).iushrn(1),v=this.m.bitLength();for(v=new s(2*v*v).toRed(this);this.pow(v,m).cmp(d)!==0;)v.redIAdd(d);for(var A=this.pow(v,_),U=this.pow(f,_.addn(1).iushrn(1)),x=this.pow(f,_),T=E;x.cmp(w)!==0;){for(var B=x,q=0;B.cmp(w)!==0;q++)B=B.redSqr();i(q<T);var z=this.pow(A,new s(1).iushln(T-q-1));U=U.redMul(z),A=z.redSqr(),x=x.redMul(A),T=q}return U},O.prototype.invm=function(f){var u=f._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},O.prototype.pow=function(f,u){if(u.isZero())return new s(1).toRed(this);if(u.cmpn(1)===0)return f.clone();var b=4,_=new Array(1<<b);_[0]=new s(1).toRed(this),_[1]=f;for(var E=2;E<_.length;E++)_[E]=this.mul(_[E-1],f);var w=_[0],d=0,m=0,v=u.bitLength()%26;for(v===0&&(v=26),E=u.length-1;E>=0;E--){for(var A=u.words[E],U=v-1;U>=0;U--){var x=A>>U&1;if(w!==_[0]&&(w=this.sqr(w)),x===0&&d===0){m=0;continue}d<<=1,d|=x,m++,!(m!==b&&(E!==0||U!==0))&&(w=this.mul(w,_[d]),m=0,d=0)}v=26}return w},O.prototype.convertTo=function(f){var u=f.umod(this.m);return u===f?u.clone():u},O.prototype.convertFrom=function(f){var u=f.clone();return u.red=null,u},s.mont=function(f){return new g(f)};function g(p){O.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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)}n(g,O),g.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},g.prototype.convertFrom=function(f){var u=this.imod(f.mul(this.rinv));return u.red=null,u},g.prototype.imul=function(f,u){if(f.isZero()||u.isZero())return f.words[0]=0,f.length=1,f;var b=f.imul(u),_=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(_).iushrn(this.shift),w=E;return E.cmp(this.m)>=0?w=E.isub(this.m):E.cmpn(0)<0&&(w=E.iadd(this.m)),w._forceRed(this)},g.prototype.mul=function(f,u){if(f.isZero()||u.isZero())return new s(0)._forceRed(this);var b=f.mul(u),_=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(_).iushrn(this.shift),w=E;return E.cmp(this.m)>=0?w=E.isub(this.m):E.cmpn(0)<0&&(w=E.iadd(this.m)),w._forceRed(this)},g.prototype.invm=function(f){var u=this.imod(f._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(t,zt)})(ju);var we=ju.exports;const Ku="bignumber/5.7.0";var To=we.BN;const Mi=new Se(Ku),yf={},Vu=9007199254740991;function lm(t){return t!=null&&(wt.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||Sr(t)||typeof t=="bigint"||Gn(t))}let Hu=!1;class wt{constructor(e,r){e!==yf&&Mi.throwError("cannot call constructor directly; use BigNumber.from",Se.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return pr(Ie(this).fromTwos(e))}toTwos(e){return pr(Ie(this).toTwos(e))}abs(){return this._hex[0]==="-"?wt.from(this._hex.substring(1)):this}add(e){return pr(Ie(this).add(Ie(e)))}sub(e){return pr(Ie(this).sub(Ie(e)))}div(e){return wt.from(e).isZero()&&Rr("division-by-zero","div"),pr(Ie(this).div(Ie(e)))}mul(e){return pr(Ie(this).mul(Ie(e)))}mod(e){const r=Ie(e);return r.isNeg()&&Rr("division-by-zero","mod"),pr(Ie(this).umod(r))}pow(e){const r=Ie(e);return r.isNeg()&&Rr("negative-power","pow"),pr(Ie(this).pow(r))}and(e){const r=Ie(e);return(this.isNegative()||r.isNeg())&&Rr("unbound-bitwise-result","and"),pr(Ie(this).and(r))}or(e){const r=Ie(e);return(this.isNegative()||r.isNeg())&&Rr("unbound-bitwise-result","or"),pr(Ie(this).or(r))}xor(e){const r=Ie(e);return(this.isNegative()||r.isNeg())&&Rr("unbound-bitwise-result","xor"),pr(Ie(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&Rr("negative-width","mask"),pr(Ie(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Rr("negative-width","shl"),pr(Ie(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Rr("negative-width","shr"),pr(Ie(this).shrn(e))}eq(e){return Ie(this).eq(Ie(e))}lt(e){return Ie(this).lt(Ie(e))}lte(e){return Ie(this).lte(Ie(e))}gt(e){return Ie(this).gt(Ie(e))}gte(e){return Ie(this).gte(Ie(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ie(this).isZero()}toNumber(){try{return Ie(this).toNumber()}catch{Rr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Mi.throwError("this platform does not support BigInt",Se.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Hu||(Hu=!0,Mi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Mi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Se.errors.UNEXPECTED_ARGUMENT,{}):Mi.throwError("BigNumber.toString does not accept parameters",Se.errors.UNEXPECTED_ARGUMENT,{})),Ie(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof wt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new wt(yf,Ps(e)):e.match(/^-?[0-9]+$/)?new wt(yf,Ps(new To(e))):Mi.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Rr("underflow","BigNumber.from",e),(e>=Vu||e<=-Vu)&&Rr("overflow","BigNumber.from",e),wt.from(String(e));const r=e;if(typeof r=="bigint")return wt.from(r.toString());if(Gn(r))return wt.from(ar(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return wt.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(Sr(i)||i[0]==="-"&&Sr(i.substring(1))))return wt.from(i)}return Mi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function Ps(t){if(typeof t!="string")return Ps(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&Mi.throwArgumentError("invalid hex","value",t),t=Ps(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function pr(t){return wt.from(Ps(t))}function Ie(t){const e=wt.from(t).toHexString();return e[0]==="-"?new To("-"+e.substring(3),16):new To(e.substring(2),16)}function Rr(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),Mi.throwError(t,Se.errors.NUMERIC_FAULT,i)}function pm(t){return new To(t,36).toString(16)}const fr=new Se(Ku),$s={},Wu=wt.from(0),Gu=wt.from(-1);function Ju(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),fr.throwError(t,Se.errors.NUMERIC_FAULT,n)}let Rs="0";for(;Rs.length<256;)Rs+=Rs;function mf(t){if(typeof t!="number")try{t=wt.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+Rs.substring(0,t):fr.throwArgumentError("invalid decimal size","decimals",t)}function wf(t,e){e==null&&(e=0);const r=mf(e);t=wt.from(t);const i=t.lt(Wu);i&&(t=t.mul(Gu));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=t.div(r).toString();return r.length===1?t=s:t=s+"."+n,i&&(t="-"+t),t}function Ii(t,e){e==null&&(e=0);const r=mf(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&fr.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&fr.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&fr.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");o[o.length-1]==="0";)o=o.substring(0,o.length-1);for(o.length>r.length-1&&Ju("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const a=wt.from(s),c=wt.from(o);let h=a.mul(r).add(c);return i&&(h=h.mul(Gu)),h}class Jn{constructor(e,r,i,n){e!==$s&&fr.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Se.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=r,this.width=i,this.decimals=n,this.name=(r?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=mf(n),Object.freeze(this)}static from(e){if(e instanceof Jn)return e;typeof e=="number"&&(e=`fixed128x${e}`);let r=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")r=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||fr.throwArgumentError("invalid fixed format","format",e),r=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,a,c)=>e[o]==null?c:(typeof e[o]!==a&&fr.throwArgumentError("invalid fixed format ("+o+" not "+a+")","format."+o,e[o]),e[o]);r=s("signed","boolean",r),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&fr.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&fr.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Jn($s,r,i,n)}}class jt{constructor(e,r,i,n){e!==$s&&fr.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Se.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=r,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&fr.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=Ii(this._value,this.format.decimals),i=Ii(e._value,e.format.decimals);return jt.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=Ii(this._value,this.format.decimals),i=Ii(e._value,e.format.decimals);return jt.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=Ii(this._value,this.format.decimals),i=Ii(e._value,e.format.decimals);return jt.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=Ii(this._value,this.format.decimals),i=Ii(e._value,e.format.decimals);return jt.fromValue(r.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=jt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(r=r.subUnsafe(Yu.toFormat(r.format))),r}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=jt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(r=r.addUnsafe(Yu.toFormat(r.format))),r}round(e){e==null&&(e=0);const r=this.toString().split(".");if(r.length===1&&r.push("0"),(e<0||e>80||e%1)&&fr.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=jt.from("1"+Rs.substring(0,e),this.format),n=gm.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&fr.throwArgumentError("invalid byte width","width",e);const r=wt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Yi(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return jt.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!lm(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),jt.fromString(wf(e,r),Jn.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=Jn.from(r),n=Ii(e,i.decimals);!i.signed&&n.lt(Wu)&&Ju("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Yi(s,i.width/8));const o=wf(n,i.decimals);return new jt($s,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=Jn.from(r);if(Ot(e).length>i.width/8)throw new Error("overflow");let n=wt.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=wf(n,i.decimals);return new jt($s,s,o,i)}static from(e,r){if(typeof e=="string")return jt.fromString(e,r);if(Gn(e))return jt.fromBytes(e,r);try{return jt.fromValue(e,0,r)}catch(i){if(i.code!==Se.errors.INVALID_ARGUMENT)throw i}return fr.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const Yu=jt.from(1),gm=jt.from("0.5");var Zu={exports:{}};/**
|
|
15
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
16
|
-
*
|
|
17
|
-
* @version 0.8.0
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @license MIT
|
|
21
|
-
*/(function(t){(function(){var e="input is invalid type",r="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",o=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?n=zt:s&&(n=self);var a=!n.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,c=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),l=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],M=[1,256,65536,16777216],I=[6,1536,393216,100663296],S=[0,8,16,24],D=[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],R=[224,256,384,512],$=[128,256],N=["hex","buffer","arrayBuffer","array","digest"],C={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}),c&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(x){return typeof x=="object"&&x.buffer&&x.buffer.constructor===ArrayBuffer});for(var L=function(x,T,B){return function(q){return new v(x,T,x).update(q)[B]()}},k=function(x,T,B){return function(q,z){return new v(x,T,z).update(q)[B]()}},j=function(x,T,B){return function(q,z,Y,X){return f["cshake"+x].update(q,z,Y,X)[B]()}},G=function(x,T,B){return function(q,z,Y,X){return f["kmac"+x].update(q,z,Y,X)[B]()}},K=function(x,T,B,q){for(var z=0;z<N.length;++z){var Y=N[z];x[Y]=T(B,q,Y)}return x},V=function(x,T){var B=L(x,T,"hex");return B.create=function(){return new v(x,T,x)},B.update=function(q){return B.create().update(q)},K(B,L,x,T)},ie=function(x,T){var B=k(x,T,"hex");return B.create=function(q){return new v(x,T,q)},B.update=function(q,z){return B.create(z).update(q)},K(B,k,x,T)},O=function(x,T){var B=C[x],q=j(x,T,"hex");return q.create=function(z,Y,X){return!Y&&!X?f["shake"+x].create(z):new v(x,T,z).bytepad([Y,X],B)},q.update=function(z,Y,X,W){return q.create(Y,X,W).update(z)},K(q,j,x,T)},g=function(x,T){var B=C[x],q=G(x,T,"hex");return q.create=function(z,Y,X){return new A(x,T,Y).bytepad(["KMAC",X],B).bytepad([z],B)},q.update=function(z,Y,X,W){return q.create(z,X,W).update(Y)},K(q,G,x,T)},p=[{name:"keccak",padding:M,bits:R,createMethod:V},{name:"sha3",padding:I,bits:R,createMethod:V},{name:"shake",padding:l,bits:$,createMethod:ie},{name:"cshake",padding:y,bits:$,createMethod:O},{name:"kmac",padding:y,bits:$,createMethod:g}],f={},u=[],b=0;b<p.length;++b)for(var _=p[b],E=_.bits,w=0;w<E.length;++w){var d=_.name+"_"+E[w];if(u.push(d),f[d]=_.createMethod(E[w],_.padding),_.name!=="sha3"){var m=_.name+E[w];u.push(m),f[m]=f[d]}}function v(x,T,B){this.blocks=[],this.s=[],this.padding=T,this.outputBits=B,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(x<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=B>>5,this.extraBytes=(B&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}v.prototype.update=function(x){if(this.finalized)throw new Error(r);var T,B=typeof x;if(B!=="string"){if(B==="object"){if(x===null)throw new Error(e);if(c&&x.constructor===ArrayBuffer)x=new Uint8Array(x);else if(!Array.isArray(x)&&(!c||!ArrayBuffer.isView(x)))throw new Error(e)}else throw new Error(e);T=!0}for(var q=this.blocks,z=this.byteCount,Y=x.length,X=this.blockCount,W=0,se=this.s,ee,te;W<Y;){if(this.reset)for(this.reset=!1,q[0]=this.block,ee=1;ee<X+1;++ee)q[ee]=0;if(T)for(ee=this.start;W<Y&&ee<z;++W)q[ee>>2]|=x[W]<<S[ee++&3];else for(ee=this.start;W<Y&&ee<z;++W)te=x.charCodeAt(W),te<128?q[ee>>2]|=te<<S[ee++&3]:te<2048?(q[ee>>2]|=(192|te>>6)<<S[ee++&3],q[ee>>2]|=(128|te&63)<<S[ee++&3]):te<55296||te>=57344?(q[ee>>2]|=(224|te>>12)<<S[ee++&3],q[ee>>2]|=(128|te>>6&63)<<S[ee++&3],q[ee>>2]|=(128|te&63)<<S[ee++&3]):(te=65536+((te&1023)<<10|x.charCodeAt(++W)&1023),q[ee>>2]|=(240|te>>18)<<S[ee++&3],q[ee>>2]|=(128|te>>12&63)<<S[ee++&3],q[ee>>2]|=(128|te>>6&63)<<S[ee++&3],q[ee>>2]|=(128|te&63)<<S[ee++&3]);if(this.lastByteIndex=ee,ee>=z){for(this.start=ee-z,this.block=q[X],ee=0;ee<X;++ee)se[ee]^=q[ee];U(se),this.reset=!0}else this.start=ee}return this},v.prototype.encode=function(x,T){var B=x&255,q=1,z=[B];for(x=x>>8,B=x&255;B>0;)z.unshift(B),x=x>>8,B=x&255,++q;return T?z.push(q):z.unshift(q),this.update(z),z.length},v.prototype.encodeString=function(x){var T,B=typeof x;if(B!=="string"){if(B==="object"){if(x===null)throw new Error(e);if(c&&x.constructor===ArrayBuffer)x=new Uint8Array(x);else if(!Array.isArray(x)&&(!c||!ArrayBuffer.isView(x)))throw new Error(e)}else throw new Error(e);T=!0}var q=0,z=x.length;if(T)q=z;else for(var Y=0;Y<x.length;++Y){var X=x.charCodeAt(Y);X<128?q+=1:X<2048?q+=2:X<55296||X>=57344?q+=3:(X=65536+((X&1023)<<10|x.charCodeAt(++Y)&1023),q+=4)}return q+=this.encode(q*8),this.update(x),q},v.prototype.bytepad=function(x,T){for(var B=this.encode(T),q=0;q<x.length;++q)B+=this.encodeString(x[q]);var z=T-B%T,Y=[];return Y.length=z,this.update(Y),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var x=this.blocks,T=this.lastByteIndex,B=this.blockCount,q=this.s;if(x[T>>2]|=this.padding[T&3],this.lastByteIndex===this.byteCount)for(x[0]=x[B],T=1;T<B+1;++T)x[T]=0;for(x[B-1]|=2147483648,T=0;T<B;++T)q[T]^=x[T];U(q)}},v.prototype.toString=v.prototype.hex=function(){this.finalize();for(var x=this.blockCount,T=this.s,B=this.outputBlocks,q=this.extraBytes,z=0,Y=0,X="",W;Y<B;){for(z=0;z<x&&Y<B;++z,++Y)W=T[z],X+=h[W>>4&15]+h[W&15]+h[W>>12&15]+h[W>>8&15]+h[W>>20&15]+h[W>>16&15]+h[W>>28&15]+h[W>>24&15];Y%x===0&&(U(T),z=0)}return q&&(W=T[z],X+=h[W>>4&15]+h[W&15],q>1&&(X+=h[W>>12&15]+h[W>>8&15]),q>2&&(X+=h[W>>20&15]+h[W>>16&15])),X},v.prototype.arrayBuffer=function(){this.finalize();var x=this.blockCount,T=this.s,B=this.outputBlocks,q=this.extraBytes,z=0,Y=0,X=this.outputBits>>3,W;q?W=new ArrayBuffer(B+1<<2):W=new ArrayBuffer(X);for(var se=new Uint32Array(W);Y<B;){for(z=0;z<x&&Y<B;++z,++Y)se[Y]=T[z];Y%x===0&&U(T)}return q&&(se[z]=T[z],W=W.slice(0,X)),W},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.digest=v.prototype.array=function(){this.finalize();for(var x=this.blockCount,T=this.s,B=this.outputBlocks,q=this.extraBytes,z=0,Y=0,X=[],W,se;Y<B;){for(z=0;z<x&&Y<B;++z,++Y)W=Y<<2,se=T[z],X[W]=se&255,X[W+1]=se>>8&255,X[W+2]=se>>16&255,X[W+3]=se>>24&255;Y%x===0&&U(T)}return q&&(W=Y<<2,se=T[z],X[W]=se&255,q>1&&(X[W+1]=se>>8&255),q>2&&(X[W+2]=se>>16&255)),X};function A(x,T,B){v.call(this,x,T,B)}A.prototype=new v,A.prototype.finalize=function(){return this.encode(this.outputBits,!0),v.prototype.finalize.call(this)};var U=function(x){var T,B,q,z,Y,X,W,se,ee,te,ke,je,ue,Ne,Te,fe,Fe,Ce,he,Be,Le,ae,$e,qe,ne,Je,Ye,ge,Ze,Ue,le,Xe,tt,oe,Qe,rt,be,Ke,Re,de,Ve,He,ce,it,nt,ve,st,ot,pe,We,De,ye,at,ft,me,ct,Ee,et,wr,_r,xr,Er,At;for(q=0;q<48;q+=2)z=x[0]^x[10]^x[20]^x[30]^x[40],Y=x[1]^x[11]^x[21]^x[31]^x[41],X=x[2]^x[12]^x[22]^x[32]^x[42],W=x[3]^x[13]^x[23]^x[33]^x[43],se=x[4]^x[14]^x[24]^x[34]^x[44],ee=x[5]^x[15]^x[25]^x[35]^x[45],te=x[6]^x[16]^x[26]^x[36]^x[46],ke=x[7]^x[17]^x[27]^x[37]^x[47],je=x[8]^x[18]^x[28]^x[38]^x[48],ue=x[9]^x[19]^x[29]^x[39]^x[49],T=je^(X<<1|W>>>31),B=ue^(W<<1|X>>>31),x[0]^=T,x[1]^=B,x[10]^=T,x[11]^=B,x[20]^=T,x[21]^=B,x[30]^=T,x[31]^=B,x[40]^=T,x[41]^=B,T=z^(se<<1|ee>>>31),B=Y^(ee<<1|se>>>31),x[2]^=T,x[3]^=B,x[12]^=T,x[13]^=B,x[22]^=T,x[23]^=B,x[32]^=T,x[33]^=B,x[42]^=T,x[43]^=B,T=X^(te<<1|ke>>>31),B=W^(ke<<1|te>>>31),x[4]^=T,x[5]^=B,x[14]^=T,x[15]^=B,x[24]^=T,x[25]^=B,x[34]^=T,x[35]^=B,x[44]^=T,x[45]^=B,T=se^(je<<1|ue>>>31),B=ee^(ue<<1|je>>>31),x[6]^=T,x[7]^=B,x[16]^=T,x[17]^=B,x[26]^=T,x[27]^=B,x[36]^=T,x[37]^=B,x[46]^=T,x[47]^=B,T=te^(z<<1|Y>>>31),B=ke^(Y<<1|z>>>31),x[8]^=T,x[9]^=B,x[18]^=T,x[19]^=B,x[28]^=T,x[29]^=B,x[38]^=T,x[39]^=B,x[48]^=T,x[49]^=B,Ne=x[0],Te=x[1],ve=x[11]<<4|x[10]>>>28,st=x[10]<<4|x[11]>>>28,ge=x[20]<<3|x[21]>>>29,Ze=x[21]<<3|x[20]>>>29,_r=x[31]<<9|x[30]>>>23,xr=x[30]<<9|x[31]>>>23,He=x[40]<<18|x[41]>>>14,ce=x[41]<<18|x[40]>>>14,oe=x[2]<<1|x[3]>>>31,Qe=x[3]<<1|x[2]>>>31,fe=x[13]<<12|x[12]>>>20,Fe=x[12]<<12|x[13]>>>20,ot=x[22]<<10|x[23]>>>22,pe=x[23]<<10|x[22]>>>22,Ue=x[33]<<13|x[32]>>>19,le=x[32]<<13|x[33]>>>19,Er=x[42]<<2|x[43]>>>30,At=x[43]<<2|x[42]>>>30,ft=x[5]<<30|x[4]>>>2,me=x[4]<<30|x[5]>>>2,rt=x[14]<<6|x[15]>>>26,be=x[15]<<6|x[14]>>>26,Ce=x[25]<<11|x[24]>>>21,he=x[24]<<11|x[25]>>>21,We=x[34]<<15|x[35]>>>17,De=x[35]<<15|x[34]>>>17,Xe=x[45]<<29|x[44]>>>3,tt=x[44]<<29|x[45]>>>3,qe=x[6]<<28|x[7]>>>4,ne=x[7]<<28|x[6]>>>4,ct=x[17]<<23|x[16]>>>9,Ee=x[16]<<23|x[17]>>>9,Ke=x[26]<<25|x[27]>>>7,Re=x[27]<<25|x[26]>>>7,Be=x[36]<<21|x[37]>>>11,Le=x[37]<<21|x[36]>>>11,ye=x[47]<<24|x[46]>>>8,at=x[46]<<24|x[47]>>>8,it=x[8]<<27|x[9]>>>5,nt=x[9]<<27|x[8]>>>5,Je=x[18]<<20|x[19]>>>12,Ye=x[19]<<20|x[18]>>>12,et=x[29]<<7|x[28]>>>25,wr=x[28]<<7|x[29]>>>25,de=x[38]<<8|x[39]>>>24,Ve=x[39]<<8|x[38]>>>24,ae=x[48]<<14|x[49]>>>18,$e=x[49]<<14|x[48]>>>18,x[0]=Ne^~fe&Ce,x[1]=Te^~Fe&he,x[10]=qe^~Je&ge,x[11]=ne^~Ye&Ze,x[20]=oe^~rt&Ke,x[21]=Qe^~be&Re,x[30]=it^~ve&ot,x[31]=nt^~st&pe,x[40]=ft^~ct&et,x[41]=me^~Ee&wr,x[2]=fe^~Ce&Be,x[3]=Fe^~he&Le,x[12]=Je^~ge&Ue,x[13]=Ye^~Ze&le,x[22]=rt^~Ke&de,x[23]=be^~Re&Ve,x[32]=ve^~ot&We,x[33]=st^~pe&De,x[42]=ct^~et&_r,x[43]=Ee^~wr&xr,x[4]=Ce^~Be&ae,x[5]=he^~Le&$e,x[14]=ge^~Ue&Xe,x[15]=Ze^~le&tt,x[24]=Ke^~de&He,x[25]=Re^~Ve&ce,x[34]=ot^~We&ye,x[35]=pe^~De&at,x[44]=et^~_r&Er,x[45]=wr^~xr&At,x[6]=Be^~ae&Ne,x[7]=Le^~$e&Te,x[16]=Ue^~Xe&qe,x[17]=le^~tt&ne,x[26]=de^~He&oe,x[27]=Ve^~ce&Qe,x[36]=We^~ye&it,x[37]=De^~at&nt,x[46]=_r^~Er&ft,x[47]=xr^~At&me,x[8]=ae^~Ne&fe,x[9]=$e^~Te&Fe,x[18]=Xe^~qe&Je,x[19]=tt^~ne&Ye,x[28]=He^~oe&rt,x[29]=ce^~Qe&be,x[38]=ye^~it&ve,x[39]=at^~nt&st,x[48]=Er^~ft&ct,x[49]=At^~me&Ee,x[0]^=D[q],x[1]^=D[q+1]};if(a)t.exports=f;else for(b=0;b<u.length;++b)n[u[b]]=f[u[b]]})()})(Zu);var bm=Zu.exports;function Xu(t){return"0x"+bm.keccak_256(Ot(t))}const vm="rlp/5.7.0";new Se(vm);const ym="address/5.7.0",Ns=new Se(ym);function Qu(t){Sr(t,20)||Ns.throwArgumentError("invalid address","address",t),t=t.toLowerCase();const e=t.substring(2).split(""),r=new Uint8Array(40);for(let n=0;n<40;n++)r[n]=e[n].charCodeAt(0);const i=Ot(Xu(r));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const mm=9007199254740991;function wm(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const _f={};for(let t=0;t<10;t++)_f[String(t)]=String(t);for(let t=0;t<26;t++)_f[String.fromCharCode(65+t)]=String(10+t);const ed=Math.floor(wm(mm));function _m(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>_f[i]).join("");for(;e.length>=ed;){let i=e.substring(0,ed);e=parseInt(i,10)%97+e.substring(i.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function xm(t){let e=null;if(typeof t!="string"&&Ns.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=Qu(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Ns.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==_m(t)&&Ns.throwArgumentError("bad icap checksum","address",t),e=pm(t.substring(4));e.length<40;)e="0"+e;e=Qu("0x"+e)}else Ns.throwArgumentError("invalid address","address",t);return e}const Em="properties/5.7.0";new Se(Em);function Ts(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}var Mr={},Ae={},wn=td;function td(t,e){if(!t)throw new Error(e||"Assertion failed")}td.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var Yn={exports:{}};typeof Object.create=="function"?Yn.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Yn.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var Sm=wn,Mm=Yn.exports;Ae.inherits=Mm;function Im(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function Am(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):Im(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}Ae.toArray=Am;function Dm(t){for(var e="",r=0;r<t.length;r++)e+=id(t[r].toString(16));return e}Ae.toHex=Dm;function rd(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Ae.htonl=rd;function Om(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=rd(n)),r+=nd(n.toString(16))}return r}Ae.toHex32=Om;function id(t){return t.length===1?"0"+t:t}Ae.zero2=id;function nd(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}Ae.zero8=nd;function Pm(t,e,r,i){var n=r-e;Sm(n%4===0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;i==="big"?c=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:c=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s}Ae.join32=Pm;function $m(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}Ae.split32=$m;function Rm(t,e){return t>>>e|t<<32-e}Ae.rotr32=Rm;function Nm(t,e){return t<<e|t>>>32-e}Ae.rotl32=Nm;function Tm(t,e){return t+e>>>0}Ae.sum32=Tm;function Fm(t,e,r){return t+e+r>>>0}Ae.sum32_3=Fm;function Cm(t,e,r,i){return t+e+r+i>>>0}Ae.sum32_4=Cm;function Bm(t,e,r,i,n){return t+e+r+i+n>>>0}Ae.sum32_5=Bm;function Lm(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o}Ae.sum64=Lm;function qm(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}Ae.sum64_hi=qm;function Um(t,e,r,i){var n=e+i;return n>>>0}Ae.sum64_lo=Um;function zm(t,e,r,i,n,s,o,a){var c=0,h=e;h=h+i>>>0,c+=h<e?1:0,h=h+s>>>0,c+=h<s?1:0,h=h+a>>>0,c+=h<a?1:0;var l=t+r+n+o+c;return l>>>0}Ae.sum64_4_hi=zm;function km(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}Ae.sum64_4_lo=km;function jm(t,e,r,i,n,s,o,a,c,h){var l=0,y=e;y=y+i>>>0,l+=y<e?1:0,y=y+s>>>0,l+=y<s?1:0,y=y+a>>>0,l+=y<a?1:0,y=y+h>>>0,l+=y<h?1:0;var M=t+r+n+o+c+l;return M>>>0}Ae.sum64_5_hi=jm;function Km(t,e,r,i,n,s,o,a,c,h){var l=e+i+s+a+h;return l>>>0}Ae.sum64_5_lo=Km;function Vm(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}Ae.rotr64_hi=Vm;function Hm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Ae.rotr64_lo=Hm;function Wm(t,e,r){return t>>>r}Ae.shr64_hi=Wm;function Gm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Ae.shr64_lo=Gm;var Zn={},sd=Ae,Jm=wn;function Fo(){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}Zn.BlockHash=Fo,Fo.prototype.update=function(e,r){if(e=sd.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=sd.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},Fo.prototype.digest=function(e){return this.update(this._pad()),Jm(this.pending===null),this._digest(e)},Fo.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,i=r-(e+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var Xn={},si={},Ym=Ae,oi=Ym.rotr32;function Zm(t,e,r,i){if(t===0)return od(e,r,i);if(t===1||t===3)return fd(e,r,i);if(t===2)return ad(e,r,i)}si.ft_1=Zm;function od(t,e,r){return t&e^~t&r}si.ch32=od;function ad(t,e,r){return t&e^t&r^e&r}si.maj32=ad;function fd(t,e,r){return t^e^r}si.p32=fd;function Xm(t){return oi(t,2)^oi(t,13)^oi(t,22)}si.s0_256=Xm;function Qm(t){return oi(t,6)^oi(t,11)^oi(t,25)}si.s1_256=Qm;function e2(t){return oi(t,7)^oi(t,18)^t>>>3}si.g0_256=e2;function t2(t){return oi(t,17)^oi(t,19)^t>>>10}si.g1_256=t2;var Qn=Ae,r2=Zn,i2=si,xf=Qn.rotl32,Fs=Qn.sum32,n2=Qn.sum32_5,s2=i2.ft_1,cd=r2.BlockHash,o2=[1518500249,1859775393,2400959708,3395469782];function ai(){if(!(this instanceof ai))return new ai;cd.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Qn.inherits(ai,cd);var a2=ai;ai.blockSize=512,ai.outSize=160,ai.hmacStrength=80,ai.padLength=64,ai.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=xf(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],h=this.h[4];for(n=0;n<i.length;n++){var l=~~(n/20),y=n2(xf(s,5),s2(l,o,a,c),h,i[n],o2[l]);h=c,c=a,a=xf(o,30),o=s,s=y}this.h[0]=Fs(this.h[0],s),this.h[1]=Fs(this.h[1],o),this.h[2]=Fs(this.h[2],a),this.h[3]=Fs(this.h[3],c),this.h[4]=Fs(this.h[4],h)},ai.prototype._digest=function(e){return e==="hex"?Qn.toHex32(this.h,"big"):Qn.split32(this.h,"big")};var es=Ae,f2=Zn,ts=si,c2=wn,Gr=es.sum32,h2=es.sum32_4,u2=es.sum32_5,d2=ts.ch32,l2=ts.maj32,p2=ts.s0_256,g2=ts.s1_256,b2=ts.g0_256,v2=ts.g1_256,hd=f2.BlockHash,y2=[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 fi(){if(!(this instanceof fi))return new fi;hd.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y2,this.W=new Array(64)}es.inherits(fi,hd);var ud=fi;fi.blockSize=512,fi.outSize=256,fi.hmacStrength=192,fi.padLength=64,fi.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=h2(v2(i[n-2]),i[n-7],b2(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],h=this.h[4],l=this.h[5],y=this.h[6],M=this.h[7];for(c2(this.k.length===i.length),n=0;n<i.length;n++){var I=u2(M,g2(h),d2(h,l,y),this.k[n],i[n]),S=Gr(p2(s),l2(s,o,a));M=y,y=l,l=h,h=Gr(c,I),c=a,a=o,o=s,s=Gr(I,S)}this.h[0]=Gr(this.h[0],s),this.h[1]=Gr(this.h[1],o),this.h[2]=Gr(this.h[2],a),this.h[3]=Gr(this.h[3],c),this.h[4]=Gr(this.h[4],h),this.h[5]=Gr(this.h[5],l),this.h[6]=Gr(this.h[6],y),this.h[7]=Gr(this.h[7],M)},fi.prototype._digest=function(e){return e==="hex"?es.toHex32(this.h,"big"):es.split32(this.h,"big")};var Ef=Ae,dd=ud;function Ai(){if(!(this instanceof Ai))return new Ai;dd.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Ef.inherits(Ai,dd);var m2=Ai;Ai.blockSize=512,Ai.outSize=224,Ai.hmacStrength=192,Ai.padLength=64,Ai.prototype._digest=function(e){return e==="hex"?Ef.toHex32(this.h.slice(0,7),"big"):Ef.split32(this.h.slice(0,7),"big")};var gr=Ae,w2=Zn,_2=wn,ci=gr.rotr64_hi,hi=gr.rotr64_lo,ld=gr.shr64_hi,pd=gr.shr64_lo,Zi=gr.sum64,Sf=gr.sum64_hi,Mf=gr.sum64_lo,x2=gr.sum64_4_hi,E2=gr.sum64_4_lo,S2=gr.sum64_5_hi,M2=gr.sum64_5_lo,gd=w2.BlockHash,I2=[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 Jr(){if(!(this instanceof Jr))return new Jr;gd.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=I2,this.W=new Array(160)}gr.inherits(Jr,gd);var bd=Jr;Jr.blockSize=1024,Jr.outSize=512,Jr.hmacStrength=192,Jr.padLength=128,Jr.prototype._prepareBlock=function(e,r){for(var i=this.W,n=0;n<32;n++)i[n]=e[r+n];for(;n<i.length;n+=2){var s=B2(i[n-4],i[n-3]),o=L2(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],h=F2(i[n-30],i[n-29]),l=C2(i[n-30],i[n-29]),y=i[n-32],M=i[n-31];i[n]=x2(s,o,a,c,h,l,y,M),i[n+1]=E2(s,o,a,c,h,l,y,M)}},Jr.prototype._update=function(e,r){this._prepareBlock(e,r);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],h=this.h[5],l=this.h[6],y=this.h[7],M=this.h[8],I=this.h[9],S=this.h[10],D=this.h[11],R=this.h[12],$=this.h[13],N=this.h[14],C=this.h[15];_2(this.k.length===i.length);for(var L=0;L<i.length;L+=2){var k=N,j=C,G=N2(M,I),K=T2(M,I),V=A2(M,I,S,D,R),ie=D2(M,I,S,D,R,$),O=this.k[L],g=this.k[L+1],p=i[L],f=i[L+1],u=S2(k,j,G,K,V,ie,O,g,p,f),b=M2(k,j,G,K,V,ie,O,g,p,f);k=$2(n,s),j=R2(n,s),G=O2(n,s,o,a,c),K=P2(n,s,o,a,c,h);var _=Sf(k,j,G,K),E=Mf(k,j,G,K);N=R,C=$,R=S,$=D,S=M,D=I,M=Sf(l,y,u,b),I=Mf(y,y,u,b),l=c,y=h,c=o,h=a,o=n,a=s,n=Sf(u,b,_,E),s=Mf(u,b,_,E)}Zi(this.h,0,n,s),Zi(this.h,2,o,a),Zi(this.h,4,c,h),Zi(this.h,6,l,y),Zi(this.h,8,M,I),Zi(this.h,10,S,D),Zi(this.h,12,R,$),Zi(this.h,14,N,C)},Jr.prototype._digest=function(e){return e==="hex"?gr.toHex32(this.h,"big"):gr.split32(this.h,"big")};function A2(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function D2(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function O2(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function P2(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function $2(t,e){var r=ci(t,e,28),i=ci(e,t,2),n=ci(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function R2(t,e){var r=hi(t,e,28),i=hi(e,t,2),n=hi(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function N2(t,e){var r=ci(t,e,14),i=ci(t,e,18),n=ci(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function T2(t,e){var r=hi(t,e,14),i=hi(t,e,18),n=hi(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function F2(t,e){var r=ci(t,e,1),i=ci(t,e,8),n=ld(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function C2(t,e){var r=hi(t,e,1),i=hi(t,e,8),n=pd(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function B2(t,e){var r=ci(t,e,19),i=ci(e,t,29),n=ld(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function L2(t,e){var r=hi(t,e,19),i=hi(e,t,29),n=pd(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var If=Ae,vd=bd;function Di(){if(!(this instanceof Di))return new Di;vd.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}If.inherits(Di,vd);var q2=Di;Di.blockSize=1024,Di.outSize=384,Di.hmacStrength=192,Di.padLength=128,Di.prototype._digest=function(e){return e==="hex"?If.toHex32(this.h.slice(0,12),"big"):If.split32(this.h.slice(0,12),"big")},Xn.sha1=a2,Xn.sha224=m2,Xn.sha256=ud,Xn.sha384=q2,Xn.sha512=bd;var yd={},_n=Ae,U2=Zn,Co=_n.rotl32,md=_n.sum32,Cs=_n.sum32_3,wd=_n.sum32_4,_d=U2.BlockHash;function ui(){if(!(this instanceof ui))return new ui;_d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}_n.inherits(ui,_d),yd.ripemd160=ui,ui.blockSize=512,ui.outSize=160,ui.hmacStrength=192,ui.padLength=64,ui.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=i,h=n,l=s,y=o,M=a,I=0;I<80;I++){var S=md(Co(wd(i,xd(I,n,s,o),e[j2[I]+r],z2(I)),V2[I]),a);i=a,a=o,o=Co(s,10),s=n,n=S,S=md(Co(wd(c,xd(79-I,h,l,y),e[K2[I]+r],k2(I)),H2[I]),M),c=M,M=y,y=Co(l,10),l=h,h=S}S=Cs(this.h[1],s,y),this.h[1]=Cs(this.h[2],o,M),this.h[2]=Cs(this.h[3],a,c),this.h[3]=Cs(this.h[4],i,h),this.h[4]=Cs(this.h[0],n,l),this.h[0]=S},ui.prototype._digest=function(e){return e==="hex"?_n.toHex32(this.h,"little"):_n.split32(this.h,"little")};function xd(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function z2(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function k2(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var j2=[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],K2=[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],V2=[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],H2=[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],W2=Ae,G2=wn;function rs(t,e,r){if(!(this instanceof rs))return new rs(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(W2.toArray(e,r))}var J2=rs;rs.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),G2(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)},rs.prototype.update=function(e,r){return this.inner.update(e,r),this},rs.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=Ae,e.common=Zn,e.sha=Xn,e.ripemd=yd,e.hmac=J2,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(Mr);function is(t,e,r){return r={path:e,exports:{},require:function(i,n){return Y2(i,n??r.path)}},t(r,r.exports),r.exports}function Y2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Af=Ed;function Ed(t,e){if(!t)throw new Error(e||"Assertion failed")}Ed.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var Yr=is(function(t,e){var r=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var c=[];if(typeof o!="string"){for(var h=0;h<o.length;h++)c[h]=o[h]|0;return c}if(a==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var h=0;h<o.length;h+=2)c.push(parseInt(o[h]+o[h+1],16))}else for(var h=0;h<o.length;h++){var l=o.charCodeAt(h),y=l>>8,M=l&255;y?c.push(y,M):c.push(M)}return c}r.toArray=i;function n(o){return o.length===1?"0"+o:o}r.zero2=n;function s(o){for(var a="",c=0;c<o.length;c++)a+=n(o[c].toString(16));return a}r.toHex=s,r.encode=function(a,c){return c==="hex"?s(a):a}}),Ir=is(function(t,e){var r=e;r.assert=Af,r.toArray=Yr.toArray,r.zero2=Yr.zero2,r.toHex=Yr.toHex,r.encode=Yr.encode;function i(c,h,l){var y=new Array(Math.max(c.bitLength(),l)+1);y.fill(0);for(var M=1<<h+1,I=c.clone(),S=0;S<y.length;S++){var D,R=I.andln(M-1);I.isOdd()?(R>(M>>1)-1?D=(M>>1)-R:D=R,I.isubn(D)):D=0,y[S]=D,I.iushrn(1)}return y}r.getNAF=i;function n(c,h){var l=[[],[]];c=c.clone(),h=h.clone();for(var y=0,M=0,I;c.cmpn(-y)>0||h.cmpn(-M)>0;){var S=c.andln(3)+y&3,D=h.andln(3)+M&3;S===3&&(S=-1),D===3&&(D=-1);var R;S&1?(I=c.andln(7)+y&7,(I===3||I===5)&&D===2?R=-S:R=S):R=0,l[0].push(R);var $;D&1?(I=h.andln(7)+M&7,(I===3||I===5)&&S===2?$=-D:$=D):$=0,l[1].push($),2*y===R+1&&(y=1-y),2*M===$+1&&(M=1-M),c.iushrn(1),h.iushrn(1)}return l}r.getJSF=n;function s(c,h,l){var y="_"+h;c.prototype[h]=function(){return this[y]!==void 0?this[y]:this[y]=l.call(this)}}r.cachedProperty=s;function o(c){return typeof c=="string"?r.toArray(c,"hex"):c}r.parseBytes=o;function a(c){return new we(c,"hex","le")}r.intFromLE=a}),Bo=Ir.getNAF,Z2=Ir.getJSF,Lo=Ir.assert;function Xi(t,e){this.type=t,this.p=new we(e.p,16),this.red=e.prime?we.red(e.prime):we.mont(this.p),this.zero=new we(0).toRed(this.red),this.one=new we(1).toRed(this.red),this.two=new we(2).toRed(this.red),this.n=e.n&&new we(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xn=Xi;Xi.prototype.point=function(){throw new Error("Not implemented")},Xi.prototype.validate=function(){throw new Error("Not implemented")},Xi.prototype._fixedNafMul=function(e,r){Lo(e.precomputed);var i=e._getDoubles(),n=Bo(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var h=a+i.step-1;h>=a;h--)c=(c<<1)+n[h];o.push(c)}for(var l=this.jpoint(null,null,null),y=this.jpoint(null,null,null),M=s;M>0;M--){for(a=0;a<o.length;a++)c=o[a],c===M?y=y.mixedAdd(i.points[a]):c===-M&&(y=y.mixedAdd(i.points[a].neg()));l=l.add(y)}return l.toP()},Xi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Bo(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var h=0;c>=0&&o[c]===0;c--)h++;if(c>=0&&h++,a=a.dblp(h),c<0)break;var l=o[c];Lo(l!==0),e.type==="affine"?l>0?a=a.mixedAdd(s[l-1>>1]):a=a.mixedAdd(s[-l-1>>1].neg()):l>0?a=a.add(s[l-1>>1]):a=a.add(s[-l-1>>1].neg())}return e.type==="affine"?a.toP():a},Xi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,h=0,l,y,M;for(l=0;l<n;l++){M=r[l];var I=M._getNAFPoints(e);o[l]=I.wnd,a[l]=I.points}for(l=n-1;l>=1;l-=2){var S=l-1,D=l;if(o[S]!==1||o[D]!==1){c[S]=Bo(i[S],o[S],this._bitLength),c[D]=Bo(i[D],o[D],this._bitLength),h=Math.max(c[S].length,h),h=Math.max(c[D].length,h);continue}var R=[r[S],null,null,r[D]];r[S].y.cmp(r[D].y)===0?(R[1]=r[S].add(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg())):r[S].y.cmp(r[D].y.redNeg())===0?(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].add(r[D].neg())):(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg()));var $=[-3,-1,-5,-7,0,7,5,1,3],N=Z2(i[S],i[D]);for(h=Math.max(N[0].length,h),c[S]=new Array(h),c[D]=new Array(h),y=0;y<h;y++){var C=N[0][y]|0,L=N[1][y]|0;c[S][y]=$[(C+1)*3+(L+1)],c[D][y]=0,a[S]=R}}var k=this.jpoint(null,null,null),j=this._wnafT4;for(l=h;l>=0;l--){for(var G=0;l>=0;){var K=!0;for(y=0;y<n;y++)j[y]=c[y][l]|0,j[y]!==0&&(K=!1);if(!K)break;G++,l--}if(l>=0&&G++,k=k.dblp(G),l<0)break;for(y=0;y<n;y++){var V=j[y];V!==0&&(V>0?M=a[y][V-1>>1]:V<0&&(M=a[y][-V-1>>1].neg()),M.type==="affine"?k=k.mixedAdd(M):k=k.add(M))}}for(l=0;l<n;l++)a[l]=null;return s?k:k.toP()};function Nr(t,e){this.curve=t,this.type=e,this.precomputed=null}Xi.BasePoint=Nr,Nr.prototype.eq=function(){throw new Error("Not implemented")},Nr.prototype.validate=function(){return this.curve.validate(this)},Xi.prototype.decodePoint=function(e,r){e=Ir.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Lo(e[e.length-1]%2===0):e[0]===7&&Lo(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},Nr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},Nr.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},Nr.prototype.encode=function(e,r){return Ir.encode(this._encode(r),e)},Nr.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},Nr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},Nr.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},Nr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},Nr.prototype._getBeta=function(){return null},Nr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var Df=is(function(t){typeof Object.create=="function"?t.exports=function(r,i){i&&(r.super_=i,r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(r,i){if(i){r.super_=i;var n=function(){};n.prototype=i.prototype,r.prototype=new n,r.prototype.constructor=r}}}),X2=Ir.assert;function Tr(t){xn.call(this,"short",t),this.a=new we(t.a,16).toRed(this.red),this.b=new we(t.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(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Df(Tr,xn);var Q2=Tr;Tr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new we(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new we(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],X2(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new we(a.a,16),b:new we(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},Tr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:we.mont(e),i=new we(2).toRed(r).redInvm(),n=i.redNeg(),s=new we(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},Tr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new we(1),o=new we(0),a=new we(0),c=new we(1),h,l,y,M,I,S,D,R=0,$,N;i.cmpn(0)!==0;){var C=n.div(i);$=n.sub(C.mul(i)),N=a.sub(C.mul(s));var L=c.sub(C.mul(o));if(!y&&$.cmp(r)<0)h=D.neg(),l=s,y=$.neg(),M=N;else if(y&&++R===2)break;D=$,n=i,i=$,a=s,s=N,c=o,o=L}I=$.neg(),S=N;var k=y.sqr().add(M.sqr()),j=I.sqr().add(S.sqr());return j.cmp(k)>=0&&(I=h,S=l),y.negative&&(y=y.neg(),M=M.neg()),I.negative&&(I=I.neg(),S=S.neg()),[{a:y,b:M},{a:I,b:S}]},Tr.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),h=s.mul(i.b),l=o.mul(n.b),y=e.sub(a).sub(c),M=h.add(l).neg();return{k1:y,k2:M}},Tr.prototype.pointFromX=function(e,r){e=new we(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},Tr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},Tr.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],h=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),h=h.neg(!0)),n[o*2]=c,n[o*2+1]=h,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var l=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return l};function Nt(t,e,r,i){xn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new we(e,16),this.y=new we(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Df(Nt,xn.BasePoint),Tr.prototype.point=function(e,r,i){return new Nt(this,e,r,i)},Tr.prototype.pointFromJSON=function(e,r){return Nt.fromJSON(this,e,r)},Nt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},Nt.prototype.toJSON=function(){return this.precomputed?[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)}}]:[this.x,this.y]},Nt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Nt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Nt.prototype.isInfinity=function(){return this.inf},Nt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Nt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Nt.prototype.getX=function(){return this.x.fromRed()},Nt.prototype.getY=function(){return this.y.fromRed()},Nt.prototype.mul=function(e){return e=new we(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Nt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Nt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Nt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Nt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},Nt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Kt(t,e,r,i){xn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new we(0)):(this.x=new we(e,16),this.y=new we(r,16),this.z=new we(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Df(Kt,xn.BasePoint),Tr.prototype.jpoint=function(e,r,i){return new Kt(this,e,r,i)},Kt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},Kt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Kt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),h=o.redSub(a);if(c.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=c.redSqr(),y=l.redMul(c),M=n.redMul(l),I=h.redSqr().redIAdd(y).redISub(M).redISub(M),S=h.redMul(M.redISub(I)).redISub(o.redMul(y)),D=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,S,D)},Kt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),y=i.redMul(h),M=c.redSqr().redIAdd(l).redISub(y).redISub(y),I=c.redMul(y.redISub(M)).redISub(s.redMul(l)),S=this.z.redMul(a);return this.curve.jpoint(M,I,S)},Kt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,h=c.redSqr().redSqr(),l=a.redAdd(a);for(r=0;r<e;r++){var y=o.redSqr(),M=l.redSqr(),I=M.redSqr(),S=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),D=o.redMul(M),R=S.redSqr().redISub(D.redAdd(D)),$=D.redISub(R),N=S.redMul($);N=N.redIAdd(N).redISub(I);var C=l.redMul(c);r+1<e&&(h=h.redMul(I)),o=R,c=C,l=N}return this.curve.jpoint(o,l.redMul(s),c)},Kt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Kt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),h=c.redSqr().redISub(a).redISub(a),l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),e=h,r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),M=this.y.redSqr(),I=M.redSqr(),S=this.x.redAdd(M).redSqr().redISub(y).redISub(I);S=S.redIAdd(S);var D=y.redAdd(y).redIAdd(y),R=D.redSqr(),$=I.redIAdd(I);$=$.redIAdd($),$=$.redIAdd($),e=R.redISub(S).redISub(S),r=D.redMul(S.redISub(e)).redISub($),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Kt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=c.redSqr().redISub(a).redISub(a);e=h;var l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),M=this.y.redSqr(),I=this.x.redMul(M),S=this.x.redSub(y).redMul(this.x.redAdd(y));S=S.redAdd(S).redIAdd(S);var D=I.redIAdd(I);D=D.redIAdd(D);var R=D.redAdd(D);e=S.redSqr().redISub(R),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(y);var $=M.redSqr();$=$.redIAdd($),$=$.redIAdd($),$=$.redIAdd($),r=S.redMul(D.redISub(e)).redISub($)}return this.curve.jpoint(e,r,i)},Kt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=r.redAdd(r);h=h.redIAdd(h);var l=h.redMul(a),y=c.redSqr().redISub(l.redAdd(l)),M=l.redISub(y),I=a.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=c.redMul(M).redISub(I),D=i.redAdd(i).redMul(n);return this.curve.jpoint(y,S,D)},Kt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var l=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(h),y=r.redMul(l);y=y.redIAdd(y),y=y.redIAdd(y);var M=this.x.redMul(c).redISub(y);M=M.redIAdd(M),M=M.redIAdd(M);var I=this.y.redMul(l.redMul(h.redISub(l)).redISub(a.redMul(c)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(M,I,S)},Kt.prototype.mul=function(e,r){return e=new we(e,r),this.curve._wnafMul(this,e)},Kt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Kt.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Kt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Kt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var qo=is(function(t,e){var r=e;r.base=xn,r.short=Q2,r.mont=null,r.edwards=null}),Uo=is(function(t,e){var r=e,i=Ir.assert;function n(a){a.type==="short"?this.curve=new qo.short(a):a.type==="edwards"?this.curve=new qo.edwards(a):this.curve=new qo.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=n;function s(a,c){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var h=new n(c);return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,value:h}),h}})}s("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:Mr.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("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:Mr.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("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:Mr.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("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:Mr.sha384,gRed:!1,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"]}),s("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:Mr.sha512,gRed:!1,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"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Mr.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Mr.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("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:Mr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Qi(t){if(!(this instanceof Qi))return new Qi(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Yr.toArray(t.entropy,t.entropyEnc||"hex"),r=Yr.toArray(t.nonce,t.nonceEnc||"hex"),i=Yr.toArray(t.pers,t.persEnc||"hex");Af(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Sd=Qi;Qi.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Qi.prototype._hmac=function(){return new Mr.hmac(this.hash,this.K)},Qi.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Qi.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=Yr.toArray(e,r),i=Yr.toArray(i,n),Af(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Qi.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=Yr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Yr.encode(o,r)};var Of=Ir.assert;function er(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Pf=er;er.fromPublic=function(e,r,i){return r instanceof er?r:new er(e,{pub:r,pubEnc:i})},er.fromPrivate=function(e,r,i){return r instanceof er?r:new er(e,{priv:r,privEnc:i})},er.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},er.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},er.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},er.prototype._importPrivate=function(e,r){this.priv=new we(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},er.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?Of(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Of(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},er.prototype.derive=function(e){return e.validate()||Of(e.validate(),"public point not validated"),e.mul(this.priv).getX()},er.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},er.prototype.verify=function(e,r){return this.ec.verify(e,r,this)},er.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var e3=Ir.assert;function zo(t,e){if(t instanceof zo)return t;this._importDER(t,e)||(e3(t.r&&t.s,"Signature without r or s"),this.r=new we(t.r,16),this.s=new we(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var ko=zo;function t3(){this.place=0}function $f(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Md(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}zo.prototype._importDER=function(e,r){e=Ir.toArray(e,r);var i=new t3;if(e[i.place++]!==48)return!1;var n=$f(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=$f(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=$f(e,i);if(a===!1||e.length!==a+i.place)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new we(o),this.s=new we(c),this.recoveryParam=null,!0};function Rf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}zo.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=Md(r),i=Md(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Rf(n,r.length),n=n.concat(r),n.push(2),Rf(n,i.length);var s=n.concat(i),o=[48];return Rf(o,s.length),o=o.concat(s),Ir.encode(o,e)};var r3=function(){throw new Error("unsupported")},Id=Ir.assert;function Fr(t){if(!(this instanceof Fr))return new Fr(t);typeof t=="string"&&(Id(Object.prototype.hasOwnProperty.call(Uo,t),"Unknown curve "+t),t=Uo[t]),t instanceof Uo.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var i3=Fr;Fr.prototype.keyPair=function(e){return new Pf(this,e)},Fr.prototype.keyFromPrivate=function(e,r){return Pf.fromPrivate(this,e,r)},Fr.prototype.keyFromPublic=function(e,r){return Pf.fromPublic(this,e,r)},Fr.prototype.genKeyPair=function(e){e||(e={});for(var r=new Sd({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||r3(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new we(2));;){var s=new we(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Fr.prototype._truncateToN=function(e,r){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},Fr.prototype.sign=function(e,r,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),r=this.keyFromPrivate(r,i),e=this._truncateToN(new we(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),c=new Sd({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new we(1)),l=0;;l++){var y=n.k?n.k(l):new we(c.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var M=this.g.mul(y);if(!M.isInfinity()){var I=M.getX(),S=I.umod(this.n);if(S.cmpn(0)!==0){var D=y.invm(this.n).mul(S.mul(r.getPrivate()).iadd(e));if(D=D.umod(this.n),D.cmpn(0)!==0){var R=(M.getY().isOdd()?1:0)|(I.cmp(S)!==0?2:0);return n.canonical&&D.cmp(this.nh)>0&&(D=this.n.sub(D),R^=1),new ko({r:S,s:D,recoveryParam:R})}}}}}},Fr.prototype.verify=function(e,r,i,n){e=this._truncateToN(new we(e,16)),i=this.keyFromPublic(i,n),r=new ko(r,"hex");var s=r.r,o=r.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),c=a.mul(e).umod(this.n),h=a.mul(s).umod(this.n),l;return this.curve._maxwellTrick?(l=this.g.jmulAdd(c,i.getPublic(),h),l.isInfinity()?!1:l.eqXToP(s)):(l=this.g.mulAdd(c,i.getPublic(),h),l.isInfinity()?!1:l.getX().umod(this.n).cmp(s)===0)},Fr.prototype.recoverPubKey=function(t,e,r,i){Id((3&r)===r,"The recovery param is more than two bits"),e=new ko(e,i);var n=this.n,s=new we(t),o=e.r,a=e.s,c=r&1,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var l=e.r.invm(n),y=n.sub(s).mul(l).umod(n),M=a.mul(l).umod(n);return this.g.mulAdd(y,o,M)},Fr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new ko(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var n3=is(function(t,e){var r=e;r.version="6.5.4",r.utils=Ir,r.rand=function(){throw new Error("unsupported")},r.curve=qo,r.curves=Uo,r.ec=i3,r.eddsa=null}),s3=n3.ec;const o3="signing-key/5.7.0",Nf=new Se(o3);let Tf=null;function di(){return Tf||(Tf=new s3("secp256k1")),Tf}class a3{constructor(e){Ts(this,"curve","secp256k1"),Ts(this,"privateKey",ar(e)),hm(this.privateKey)!==32&&Nf.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=di().keyFromPrivate(Ot(this.privateKey));Ts(this,"publicKey","0x"+r.getPublic(!1,"hex")),Ts(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),Ts(this,"_isSigningKey",!0)}_addPoint(e){const r=di().keyFromPublic(Ot(this.publicKey)),i=di().keyFromPublic(Ot(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=di().keyFromPrivate(Ot(this.privateKey)),i=Ot(e);i.length!==32&&Nf.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return ku({recoveryParam:n.recoveryParam,r:Yi("0x"+n.r.toString(16),32),s:Yi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=di().keyFromPrivate(Ot(this.privateKey)),i=di().keyFromPublic(Ot(Ad(e)));return Yi("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function f3(t,e){const r=ku(e),i={r:Ot(r.r),s:Ot(r.s)};return"0x"+di().recoverPubKey(Ot(t),i,r.recoveryParam).encode("hex",!1)}function Ad(t,e){const r=Ot(t);if(r.length===32){const i=new a3(r);return e?"0x"+di().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?ar(r):"0x"+di().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+di().keyFromPublic(r).getPublic(!0,"hex"):ar(r)}return Nf.throwArgumentError("invalid public or private key","key","[REDACTED]")}const c3="transactions/5.7.0";new Se(c3);var Dd;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(Dd||(Dd={}));function h3(t){const e=Ad(t);return xm(zu(Xu(zu(e,1)),12))}function u3(t,e){return h3(f3(Ot(t),e))}function Od(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ff(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Od(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function d3(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var D=0,R=0,$=0,N=S.length;$!==N&&S[$]===0;)$++,D++;for(var C=(N-$)*l+1>>>0,L=new Uint8Array(C);$!==N;){for(var k=S[$],j=0,G=C-1;(k!==0||j<R)&&G!==-1;G--,j++)k+=256*L[G]>>>0,L[G]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");R=j,$++}for(var K=C-R;K!==C&&L[K]===0;)K++;for(var V=c.repeat(D);K<C;++K)V+=t.charAt(L[K]);return V}function M(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var D=0;if(S[D]!==" "){for(var R=0,$=0;S[D]===c;)R++,D++;for(var N=(S.length-D)*h+1>>>0,C=new Uint8Array(N);S[D];){var L=r[S.charCodeAt(D)];if(L===255)return;for(var k=0,j=N-1;(L!==0||k<$)&&j!==-1;j--,k++)L+=a*C[j]>>>0,C[j]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");$=k,D++}if(S[D]!==" "){for(var G=N-$;G!==N&&C[G]===0;)G++;for(var K=new Uint8Array(R+(N-G)),V=R;G!==N;)K[V++]=C[G++];return K}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:M,decode:I}}var l3=d3,p3=l3;const Pd=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},g3=t=>new TextEncoder().encode(t),b3=t=>new TextDecoder().decode(t);class v3{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class y3{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return $d(this,e)}}class m3{constructor(e){this.decoders=e}or(e){return $d(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const $d=(t,e)=>new m3({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class w3{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new v3(e,r,i),this.decoder=new y3(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const jo=({name:t,prefix:e,encode:r,decode:i})=>new w3(t,e,r,i),Bs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=p3(r,e);return jo({prefix:t,name:e,encode:i,decode:s=>Pd(n(s))})},_3=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let l=0;l<s;++l){const y=n[t[l]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|y,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},x3=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Vt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>jo({prefix:e,name:t,encode(n){return x3(n,i,r)},decode(n){return _3(n,i,r,t)}}),E3=jo({prefix:"\0",name:"identity",encode:t=>b3(t),decode:t=>g3(t)});var S3=Object.freeze({__proto__:null,identity:E3});const M3=Vt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var I3=Object.freeze({__proto__:null,base2:M3});const A3=Vt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var D3=Object.freeze({__proto__:null,base8:A3});const O3=Bs({prefix:"9",name:"base10",alphabet:"0123456789"});var P3=Object.freeze({__proto__:null,base10:O3});const $3=Vt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),R3=Vt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var N3=Object.freeze({__proto__:null,base16:$3,base16upper:R3});const T3=Vt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),F3=Vt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),C3=Vt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),B3=Vt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),L3=Vt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),q3=Vt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),U3=Vt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),z3=Vt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),k3=Vt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var j3=Object.freeze({__proto__:null,base32:T3,base32upper:F3,base32pad:C3,base32padupper:B3,base32hex:L3,base32hexupper:q3,base32hexpad:U3,base32hexpadupper:z3,base32z:k3});const K3=Bs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),V3=Bs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var H3=Object.freeze({__proto__:null,base36:K3,base36upper:V3});const W3=Bs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),G3=Bs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var J3=Object.freeze({__proto__:null,base58btc:W3,base58flickr:G3});const Y3=Vt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Z3=Vt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),X3=Vt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Q3=Vt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ew=Object.freeze({__proto__:null,base64:Y3,base64pad:Z3,base64url:X3,base64urlpad:Q3});const Rd=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),tw=Rd.reduce((t,e,r)=>(t[r]=e,t),[]),rw=Rd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function iw(t){return t.reduce((e,r)=>(e+=tw[r],e),"")}function nw(t){const e=[];for(const r of t){const i=rw[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const sw=jo({prefix:"\u{1F680}",name:"base256emoji",encode:iw,decode:nw});var ow=Object.freeze({__proto__:null,base256emoji:sw}),aw=Td,Nd=128,fw=127,cw=~fw,hw=Math.pow(2,31);function Td(t,e,r){e=e||[],r=r||0;for(var i=r;t>=hw;)e[r++]=t&255|Nd,t/=128;for(;t&cw;)e[r++]=t&255|Nd,t>>>=7;return e[r]=t|0,Td.bytes=r-i+1,e}var uw=Cf,dw=128,Fd=127;function Cf(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Cf.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Fd)<<n:(o&Fd)*Math.pow(2,n),n+=7}while(o>=dw);return Cf.bytes=s-i,r}var lw=Math.pow(2,7),pw=Math.pow(2,14),gw=Math.pow(2,21),bw=Math.pow(2,28),vw=Math.pow(2,35),yw=Math.pow(2,42),mw=Math.pow(2,49),ww=Math.pow(2,56),_w=Math.pow(2,63),xw=function(t){return t<lw?1:t<pw?2:t<gw?3:t<bw?4:t<vw?5:t<yw?6:t<mw?7:t<ww?8:t<_w?9:10},Ew={encode:aw,decode:uw,encodingLength:xw},Cd=Ew;const Bd=(t,e,r=0)=>(Cd.encode(t,e,r),e),Ld=t=>Cd.encodingLength(t),Bf=(t,e)=>{const r=e.byteLength,i=Ld(t),n=i+Ld(r),s=new Uint8Array(n+r);return Bd(t,s,0),Bd(r,s,i),s.set(e,n),new Sw(t,r,e,s)};class Sw{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const qd=({name:t,code:e,encode:r})=>new Mw(t,e,r);class Mw{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Bf(this.code,r):r.then(i=>Bf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Ud=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Iw=qd({name:"sha2-256",code:18,encode:Ud("SHA-256")}),Aw=qd({name:"sha2-512",code:19,encode:Ud("SHA-512")});var Dw=Object.freeze({__proto__:null,sha256:Iw,sha512:Aw});const zd=0,Ow="identity",kd=Pd;var Pw=Object.freeze({__proto__:null,identity:{code:zd,name:Ow,encode:kd,digest:t=>Bf(zd,kd(t))}});new TextEncoder,new TextDecoder;const jd={...S3,...I3,...D3,...P3,...N3,...j3,...H3,...J3,...ew,...ow};({...Dw,...Pw});function Kd(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Vd=Kd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Lf=Kd("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Od(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Hd={utf8:Vd,"utf-8":Vd,hex:jd.base16,latin1:Lf,ascii:Lf,binary:Lf,...jd};function Cr(t,e="utf8"){const r=Hd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function cr(t,e="utf8"){const r=Hd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Wd={},$w="elliptic",Rw="6.6.1",Nw="EC cryptography",Tw="lib/elliptic.js",Fw=["lib"],Cw={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},Bw={type:"git",url:"git@github.com:indutny/elliptic"},Lw=["EC","Elliptic","curve","Cryptography"],qw="Fedor Indutny <fedor@indutny.com>",Uw="MIT",zw={url:"https://github.com/indutny/elliptic/issues"},kw="https://github.com/indutny/elliptic",jw={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},Kw={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},Vw={name:$w,version:Rw,description:Nw,main:Tw,files:Fw,scripts:Cw,repository:Bw,keywords:Lw,author:qw,license:Uw,bugs:zw,homepage:kw,devDependencies:jw,dependencies:Kw},Ar={},li={exports:{}};(function(t){(function(e,r){function i(O,g){if(!O)throw new Error(g||"Assertion failed")}function n(O,g){O.super_=g;var p=function(){};p.prototype=g.prototype,O.prototype=new p,O.prototype.constructor=O}function s(O,g,p){if(s.isBN(O))return O;this.negative=0,this.words=null,this.length=0,this.red=null,O!==null&&((g==="le"||g==="be")&&(p=g,g=10),this._init(O||0,g||10,p||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=vf.Buffer}catch{}s.isBN=function(g){return g instanceof s?!0:g!==null&&typeof g=="object"&&g.constructor.wordSize===s.wordSize&&Array.isArray(g.words)},s.max=function(g,p){return g.cmp(p)>0?g:p},s.min=function(g,p){return g.cmp(p)<0?g:p},s.prototype._init=function(g,p,f){if(typeof g=="number")return this._initNumber(g,p,f);if(typeof g=="object")return this._initArray(g,p,f);p==="hex"&&(p=16),i(p===(p|0)&&p>=2&&p<=36),g=g.toString().replace(/\s+/g,"");var u=0;g[0]==="-"&&(u++,this.negative=1),u<g.length&&(p===16?this._parseHex(g,u,f):(this._parseBase(g,p,u),f==="le"&&this._initArray(this.toArray(),p,f)))},s.prototype._initNumber=function(g,p,f){g<0&&(this.negative=1,g=-g),g<67108864?(this.words=[g&67108863],this.length=1):g<4503599627370496?(this.words=[g&67108863,g/67108864&67108863],this.length=2):(i(g<9007199254740992),this.words=[g&67108863,g/67108864&67108863,1],this.length=3),f==="le"&&this._initArray(this.toArray(),p,f)},s.prototype._initArray=function(g,p,f){if(i(typeof g.length=="number"),g.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(g.length/3),this.words=new Array(this.length);for(var u=0;u<this.length;u++)this.words[u]=0;var b,_,E=0;if(f==="be")for(u=g.length-1,b=0;u>=0;u-=3)_=g[u]|g[u-1]<<8|g[u-2]<<16,this.words[b]|=_<<E&67108863,this.words[b+1]=_>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);else if(f==="le")for(u=0,b=0;u<g.length;u+=3)_=g[u]|g[u+1]<<8|g[u+2]<<16,this.words[b]|=_<<E&67108863,this.words[b+1]=_>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);return this.strip()};function a(O,g){var p=O.charCodeAt(g);return p>=65&&p<=70?p-55:p>=97&&p<=102?p-87:p-48&15}function c(O,g,p){var f=a(O,p);return p-1>=g&&(f|=a(O,p-1)<<4),f}s.prototype._parseHex=function(g,p,f){this.length=Math.ceil((g.length-p)/6),this.words=new Array(this.length);for(var u=0;u<this.length;u++)this.words[u]=0;var b=0,_=0,E;if(f==="be")for(u=g.length-1;u>=p;u-=2)E=c(g,p,u)<<b,this.words[_]|=E&67108863,b>=18?(b-=18,_+=1,this.words[_]|=E>>>26):b+=8;else{var w=g.length-p;for(u=w%2===0?p+1:p;u<g.length;u+=2)E=c(g,p,u)<<b,this.words[_]|=E&67108863,b>=18?(b-=18,_+=1,this.words[_]|=E>>>26):b+=8}this.strip()};function h(O,g,p,f){for(var u=0,b=Math.min(O.length,p),_=g;_<b;_++){var E=O.charCodeAt(_)-48;u*=f,E>=49?u+=E-49+10:E>=17?u+=E-17+10:u+=E}return u}s.prototype._parseBase=function(g,p,f){this.words=[0],this.length=1;for(var u=0,b=1;b<=67108863;b*=p)u++;u--,b=b/p|0;for(var _=g.length-f,E=_%u,w=Math.min(_,_-E)+f,d=0,m=f;m<w;m+=u)d=h(g,m,m+u,p),this.imuln(b),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(E!==0){var v=1;for(d=h(g,m,g.length,p),m=0;m<E;m++)v*=p;this.imuln(v),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(g){g.words=new Array(this.length);for(var p=0;p<this.length;p++)g.words[p]=this.words[p];g.length=this.length,g.negative=this.negative,g.red=this.red},s.prototype.clone=function(){var g=new s(null);return this.copy(g),g},s.prototype._expand=function(g){for(;this.length<g;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","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"],y=[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],M=[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];s.prototype.toString=function(g,p){g=g||10,p=p|0||1;var f;if(g===16||g==="hex"){f="";for(var u=0,b=0,_=0;_<this.length;_++){var E=this.words[_],w=((E<<u|b)&16777215).toString(16);b=E>>>24-u&16777215,u+=2,u>=26&&(u-=26,_--),b!==0||_!==this.length-1?f=l[6-w.length]+w+f:f=w+f}for(b!==0&&(f=b.toString(16)+f);f.length%p!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(g===(g|0)&&g>=2&&g<=36){var d=y[g],m=M[g];f="";var v=this.clone();for(v.negative=0;!v.isZero();){var A=v.modn(m).toString(g);v=v.idivn(m),v.isZero()?f=A+f:f=l[d-A.length]+A+f}for(this.isZero()&&(f="0"+f);f.length%p!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var g=this.words[0];return this.length===2?g+=this.words[1]*67108864:this.length===3&&this.words[2]===1?g+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-g:g},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(g,p){return i(typeof o<"u"),this.toArrayLike(o,g,p)},s.prototype.toArray=function(g,p){return this.toArrayLike(Array,g,p)},s.prototype.toArrayLike=function(g,p,f){var u=this.byteLength(),b=f||Math.max(1,u);i(u<=b,"byte array longer than desired length"),i(b>0,"Requested array length <= 0"),this.strip();var _=p==="le",E=new g(b),w,d,m=this.clone();if(_){for(d=0;!m.isZero();d++)w=m.andln(255),m.iushrn(8),E[d]=w;for(;d<b;d++)E[d]=0}else{for(d=0;d<b-u;d++)E[d]=0;for(d=0;!m.isZero();d++)w=m.andln(255),m.iushrn(8),E[b-d-1]=w}return E},Math.clz32?s.prototype._countBits=function(g){return 32-Math.clz32(g)}:s.prototype._countBits=function(g){var p=g,f=0;return p>=4096&&(f+=13,p>>>=13),p>=64&&(f+=7,p>>>=7),p>=8&&(f+=4,p>>>=4),p>=2&&(f+=2,p>>>=2),f+p},s.prototype._zeroBits=function(g){if(g===0)return 26;var p=g,f=0;return p&8191||(f+=13,p>>>=13),p&127||(f+=7,p>>>=7),p&15||(f+=4,p>>>=4),p&3||(f+=2,p>>>=2),p&1||f++,f},s.prototype.bitLength=function(){var g=this.words[this.length-1],p=this._countBits(g);return(this.length-1)*26+p};function I(O){for(var g=new Array(O.bitLength()),p=0;p<g.length;p++){var f=p/26|0,u=p%26;g[p]=(O.words[f]&1<<u)>>>u}return g}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,p=0;p<this.length;p++){var f=this._zeroBits(this.words[p]);if(g+=f,f!==26)break}return g},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(g){return this.negative!==0?this.abs().inotn(g).iaddn(1):this.clone()},s.prototype.fromTwos=function(g){return this.testn(g-1)?this.notn(g).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(g){for(;this.length<g.length;)this.words[this.length++]=0;for(var p=0;p<g.length;p++)this.words[p]=this.words[p]|g.words[p];return this.strip()},s.prototype.ior=function(g){return i((this.negative|g.negative)===0),this.iuor(g)},s.prototype.or=function(g){return this.length>g.length?this.clone().ior(g):g.clone().ior(this)},s.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},s.prototype.iuand=function(g){var p;this.length>g.length?p=g:p=this;for(var f=0;f<p.length;f++)this.words[f]=this.words[f]&g.words[f];return this.length=p.length,this.strip()},s.prototype.iand=function(g){return i((this.negative|g.negative)===0),this.iuand(g)},s.prototype.and=function(g){return this.length>g.length?this.clone().iand(g):g.clone().iand(this)},s.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},s.prototype.iuxor=function(g){var p,f;this.length>g.length?(p=this,f=g):(p=g,f=this);for(var u=0;u<f.length;u++)this.words[u]=p.words[u]^f.words[u];if(this!==p)for(;u<p.length;u++)this.words[u]=p.words[u];return this.length=p.length,this.strip()},s.prototype.ixor=function(g){return i((this.negative|g.negative)===0),this.iuxor(g)},s.prototype.xor=function(g){return this.length>g.length?this.clone().ixor(g):g.clone().ixor(this)},s.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},s.prototype.inotn=function(g){i(typeof g=="number"&&g>=0);var p=Math.ceil(g/26)|0,f=g%26;this._expand(p),f>0&&p--;for(var u=0;u<p;u++)this.words[u]=~this.words[u]&67108863;return f>0&&(this.words[u]=~this.words[u]&67108863>>26-f),this.strip()},s.prototype.notn=function(g){return this.clone().inotn(g)},s.prototype.setn=function(g,p){i(typeof g=="number"&&g>=0);var f=g/26|0,u=g%26;return this._expand(f+1),p?this.words[f]=this.words[f]|1<<u:this.words[f]=this.words[f]&~(1<<u),this.strip()},s.prototype.iadd=function(g){var p;if(this.negative!==0&&g.negative===0)return this.negative=0,p=this.isub(g),this.negative^=1,this._normSign();if(this.negative===0&&g.negative!==0)return g.negative=0,p=this.isub(g),g.negative=1,p._normSign();var f,u;this.length>g.length?(f=this,u=g):(f=g,u=this);for(var b=0,_=0;_<u.length;_++)p=(f.words[_]|0)+(u.words[_]|0)+b,this.words[_]=p&67108863,b=p>>>26;for(;b!==0&&_<f.length;_++)p=(f.words[_]|0)+b,this.words[_]=p&67108863,b=p>>>26;if(this.length=f.length,b!==0)this.words[this.length]=b,this.length++;else if(f!==this)for(;_<f.length;_++)this.words[_]=f.words[_];return this},s.prototype.add=function(g){var p;return g.negative!==0&&this.negative===0?(g.negative=0,p=this.sub(g),g.negative^=1,p):g.negative===0&&this.negative!==0?(this.negative=0,p=g.sub(this),this.negative=1,p):this.length>g.length?this.clone().iadd(g):g.clone().iadd(this)},s.prototype.isub=function(g){if(g.negative!==0){g.negative=0;var p=this.iadd(g);return g.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var f=this.cmp(g);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var u,b;f>0?(u=this,b=g):(u=g,b=this);for(var _=0,E=0;E<b.length;E++)p=(u.words[E]|0)-(b.words[E]|0)+_,_=p>>26,this.words[E]=p&67108863;for(;_!==0&&E<u.length;E++)p=(u.words[E]|0)+_,_=p>>26,this.words[E]=p&67108863;if(_===0&&E<u.length&&u!==this)for(;E<u.length;E++)this.words[E]=u.words[E];return this.length=Math.max(this.length,E),u!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(g){return this.clone().isub(g)};function S(O,g,p){p.negative=g.negative^O.negative;var f=O.length+g.length|0;p.length=f,f=f-1|0;var u=O.words[0]|0,b=g.words[0]|0,_=u*b,E=_&67108863,w=_/67108864|0;p.words[0]=E;for(var d=1;d<f;d++){for(var m=w>>>26,v=w&67108863,A=Math.min(d,g.length-1),U=Math.max(0,d-O.length+1);U<=A;U++){var x=d-U|0;u=O.words[x]|0,b=g.words[U]|0,_=u*b+v,m+=_/67108864|0,v=_&67108863}p.words[d]=v|0,w=m|0}return w!==0?p.words[d]=w|0:p.length--,p.strip()}var D=function(g,p,f){var u=g.words,b=p.words,_=f.words,E=0,w,d,m,v=u[0]|0,A=v&8191,U=v>>>13,x=u[1]|0,T=x&8191,B=x>>>13,q=u[2]|0,z=q&8191,Y=q>>>13,X=u[3]|0,W=X&8191,se=X>>>13,ee=u[4]|0,te=ee&8191,ke=ee>>>13,je=u[5]|0,ue=je&8191,Ne=je>>>13,Te=u[6]|0,fe=Te&8191,Fe=Te>>>13,Ce=u[7]|0,he=Ce&8191,Be=Ce>>>13,Le=u[8]|0,ae=Le&8191,$e=Le>>>13,qe=u[9]|0,ne=qe&8191,Je=qe>>>13,Ye=b[0]|0,ge=Ye&8191,Ze=Ye>>>13,Ue=b[1]|0,le=Ue&8191,Xe=Ue>>>13,tt=b[2]|0,oe=tt&8191,Qe=tt>>>13,rt=b[3]|0,be=rt&8191,Ke=rt>>>13,Re=b[4]|0,de=Re&8191,Ve=Re>>>13,He=b[5]|0,ce=He&8191,it=He>>>13,nt=b[6]|0,ve=nt&8191,st=nt>>>13,ot=b[7]|0,pe=ot&8191,We=ot>>>13,De=b[8]|0,ye=De&8191,at=De>>>13,ft=b[9]|0,me=ft&8191,ct=ft>>>13;f.negative=g.negative^p.negative,f.length=19,w=Math.imul(A,ge),d=Math.imul(A,Ze),d=d+Math.imul(U,ge)|0,m=Math.imul(U,Ze);var Ee=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,w=Math.imul(T,ge),d=Math.imul(T,Ze),d=d+Math.imul(B,ge)|0,m=Math.imul(B,Ze),w=w+Math.imul(A,le)|0,d=d+Math.imul(A,Xe)|0,d=d+Math.imul(U,le)|0,m=m+Math.imul(U,Xe)|0;var et=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(et>>>26)|0,et&=67108863,w=Math.imul(z,ge),d=Math.imul(z,Ze),d=d+Math.imul(Y,ge)|0,m=Math.imul(Y,Ze),w=w+Math.imul(T,le)|0,d=d+Math.imul(T,Xe)|0,d=d+Math.imul(B,le)|0,m=m+Math.imul(B,Xe)|0,w=w+Math.imul(A,oe)|0,d=d+Math.imul(A,Qe)|0,d=d+Math.imul(U,oe)|0,m=m+Math.imul(U,Qe)|0;var wr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(wr>>>26)|0,wr&=67108863,w=Math.imul(W,ge),d=Math.imul(W,Ze),d=d+Math.imul(se,ge)|0,m=Math.imul(se,Ze),w=w+Math.imul(z,le)|0,d=d+Math.imul(z,Xe)|0,d=d+Math.imul(Y,le)|0,m=m+Math.imul(Y,Xe)|0,w=w+Math.imul(T,oe)|0,d=d+Math.imul(T,Qe)|0,d=d+Math.imul(B,oe)|0,m=m+Math.imul(B,Qe)|0,w=w+Math.imul(A,be)|0,d=d+Math.imul(A,Ke)|0,d=d+Math.imul(U,be)|0,m=m+Math.imul(U,Ke)|0;var _r=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(_r>>>26)|0,_r&=67108863,w=Math.imul(te,ge),d=Math.imul(te,Ze),d=d+Math.imul(ke,ge)|0,m=Math.imul(ke,Ze),w=w+Math.imul(W,le)|0,d=d+Math.imul(W,Xe)|0,d=d+Math.imul(se,le)|0,m=m+Math.imul(se,Xe)|0,w=w+Math.imul(z,oe)|0,d=d+Math.imul(z,Qe)|0,d=d+Math.imul(Y,oe)|0,m=m+Math.imul(Y,Qe)|0,w=w+Math.imul(T,be)|0,d=d+Math.imul(T,Ke)|0,d=d+Math.imul(B,be)|0,m=m+Math.imul(B,Ke)|0,w=w+Math.imul(A,de)|0,d=d+Math.imul(A,Ve)|0,d=d+Math.imul(U,de)|0,m=m+Math.imul(U,Ve)|0;var xr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(xr>>>26)|0,xr&=67108863,w=Math.imul(ue,ge),d=Math.imul(ue,Ze),d=d+Math.imul(Ne,ge)|0,m=Math.imul(Ne,Ze),w=w+Math.imul(te,le)|0,d=d+Math.imul(te,Xe)|0,d=d+Math.imul(ke,le)|0,m=m+Math.imul(ke,Xe)|0,w=w+Math.imul(W,oe)|0,d=d+Math.imul(W,Qe)|0,d=d+Math.imul(se,oe)|0,m=m+Math.imul(se,Qe)|0,w=w+Math.imul(z,be)|0,d=d+Math.imul(z,Ke)|0,d=d+Math.imul(Y,be)|0,m=m+Math.imul(Y,Ke)|0,w=w+Math.imul(T,de)|0,d=d+Math.imul(T,Ve)|0,d=d+Math.imul(B,de)|0,m=m+Math.imul(B,Ve)|0,w=w+Math.imul(A,ce)|0,d=d+Math.imul(A,it)|0,d=d+Math.imul(U,ce)|0,m=m+Math.imul(U,it)|0;var Er=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Er>>>26)|0,Er&=67108863,w=Math.imul(fe,ge),d=Math.imul(fe,Ze),d=d+Math.imul(Fe,ge)|0,m=Math.imul(Fe,Ze),w=w+Math.imul(ue,le)|0,d=d+Math.imul(ue,Xe)|0,d=d+Math.imul(Ne,le)|0,m=m+Math.imul(Ne,Xe)|0,w=w+Math.imul(te,oe)|0,d=d+Math.imul(te,Qe)|0,d=d+Math.imul(ke,oe)|0,m=m+Math.imul(ke,Qe)|0,w=w+Math.imul(W,be)|0,d=d+Math.imul(W,Ke)|0,d=d+Math.imul(se,be)|0,m=m+Math.imul(se,Ke)|0,w=w+Math.imul(z,de)|0,d=d+Math.imul(z,Ve)|0,d=d+Math.imul(Y,de)|0,m=m+Math.imul(Y,Ve)|0,w=w+Math.imul(T,ce)|0,d=d+Math.imul(T,it)|0,d=d+Math.imul(B,ce)|0,m=m+Math.imul(B,it)|0,w=w+Math.imul(A,ve)|0,d=d+Math.imul(A,st)|0,d=d+Math.imul(U,ve)|0,m=m+Math.imul(U,st)|0;var At=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(At>>>26)|0,At&=67108863,w=Math.imul(he,ge),d=Math.imul(he,Ze),d=d+Math.imul(Be,ge)|0,m=Math.imul(Be,Ze),w=w+Math.imul(fe,le)|0,d=d+Math.imul(fe,Xe)|0,d=d+Math.imul(Fe,le)|0,m=m+Math.imul(Fe,Xe)|0,w=w+Math.imul(ue,oe)|0,d=d+Math.imul(ue,Qe)|0,d=d+Math.imul(Ne,oe)|0,m=m+Math.imul(Ne,Qe)|0,w=w+Math.imul(te,be)|0,d=d+Math.imul(te,Ke)|0,d=d+Math.imul(ke,be)|0,m=m+Math.imul(ke,Ke)|0,w=w+Math.imul(W,de)|0,d=d+Math.imul(W,Ve)|0,d=d+Math.imul(se,de)|0,m=m+Math.imul(se,Ve)|0,w=w+Math.imul(z,ce)|0,d=d+Math.imul(z,it)|0,d=d+Math.imul(Y,ce)|0,m=m+Math.imul(Y,it)|0,w=w+Math.imul(T,ve)|0,d=d+Math.imul(T,st)|0,d=d+Math.imul(B,ve)|0,m=m+Math.imul(B,st)|0,w=w+Math.imul(A,pe)|0,d=d+Math.imul(A,We)|0,d=d+Math.imul(U,pe)|0,m=m+Math.imul(U,We)|0;var Bi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Bi>>>26)|0,Bi&=67108863,w=Math.imul(ae,ge),d=Math.imul(ae,Ze),d=d+Math.imul($e,ge)|0,m=Math.imul($e,Ze),w=w+Math.imul(he,le)|0,d=d+Math.imul(he,Xe)|0,d=d+Math.imul(Be,le)|0,m=m+Math.imul(Be,Xe)|0,w=w+Math.imul(fe,oe)|0,d=d+Math.imul(fe,Qe)|0,d=d+Math.imul(Fe,oe)|0,m=m+Math.imul(Fe,Qe)|0,w=w+Math.imul(ue,be)|0,d=d+Math.imul(ue,Ke)|0,d=d+Math.imul(Ne,be)|0,m=m+Math.imul(Ne,Ke)|0,w=w+Math.imul(te,de)|0,d=d+Math.imul(te,Ve)|0,d=d+Math.imul(ke,de)|0,m=m+Math.imul(ke,Ve)|0,w=w+Math.imul(W,ce)|0,d=d+Math.imul(W,it)|0,d=d+Math.imul(se,ce)|0,m=m+Math.imul(se,it)|0,w=w+Math.imul(z,ve)|0,d=d+Math.imul(z,st)|0,d=d+Math.imul(Y,ve)|0,m=m+Math.imul(Y,st)|0,w=w+Math.imul(T,pe)|0,d=d+Math.imul(T,We)|0,d=d+Math.imul(B,pe)|0,m=m+Math.imul(B,We)|0,w=w+Math.imul(A,ye)|0,d=d+Math.imul(A,at)|0,d=d+Math.imul(U,ye)|0,m=m+Math.imul(U,at)|0;var Li=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Li>>>26)|0,Li&=67108863,w=Math.imul(ne,ge),d=Math.imul(ne,Ze),d=d+Math.imul(Je,ge)|0,m=Math.imul(Je,Ze),w=w+Math.imul(ae,le)|0,d=d+Math.imul(ae,Xe)|0,d=d+Math.imul($e,le)|0,m=m+Math.imul($e,Xe)|0,w=w+Math.imul(he,oe)|0,d=d+Math.imul(he,Qe)|0,d=d+Math.imul(Be,oe)|0,m=m+Math.imul(Be,Qe)|0,w=w+Math.imul(fe,be)|0,d=d+Math.imul(fe,Ke)|0,d=d+Math.imul(Fe,be)|0,m=m+Math.imul(Fe,Ke)|0,w=w+Math.imul(ue,de)|0,d=d+Math.imul(ue,Ve)|0,d=d+Math.imul(Ne,de)|0,m=m+Math.imul(Ne,Ve)|0,w=w+Math.imul(te,ce)|0,d=d+Math.imul(te,it)|0,d=d+Math.imul(ke,ce)|0,m=m+Math.imul(ke,it)|0,w=w+Math.imul(W,ve)|0,d=d+Math.imul(W,st)|0,d=d+Math.imul(se,ve)|0,m=m+Math.imul(se,st)|0,w=w+Math.imul(z,pe)|0,d=d+Math.imul(z,We)|0,d=d+Math.imul(Y,pe)|0,m=m+Math.imul(Y,We)|0,w=w+Math.imul(T,ye)|0,d=d+Math.imul(T,at)|0,d=d+Math.imul(B,ye)|0,m=m+Math.imul(B,at)|0,w=w+Math.imul(A,me)|0,d=d+Math.imul(A,ct)|0,d=d+Math.imul(U,me)|0,m=m+Math.imul(U,ct)|0;var qi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(qi>>>26)|0,qi&=67108863,w=Math.imul(ne,le),d=Math.imul(ne,Xe),d=d+Math.imul(Je,le)|0,m=Math.imul(Je,Xe),w=w+Math.imul(ae,oe)|0,d=d+Math.imul(ae,Qe)|0,d=d+Math.imul($e,oe)|0,m=m+Math.imul($e,Qe)|0,w=w+Math.imul(he,be)|0,d=d+Math.imul(he,Ke)|0,d=d+Math.imul(Be,be)|0,m=m+Math.imul(Be,Ke)|0,w=w+Math.imul(fe,de)|0,d=d+Math.imul(fe,Ve)|0,d=d+Math.imul(Fe,de)|0,m=m+Math.imul(Fe,Ve)|0,w=w+Math.imul(ue,ce)|0,d=d+Math.imul(ue,it)|0,d=d+Math.imul(Ne,ce)|0,m=m+Math.imul(Ne,it)|0,w=w+Math.imul(te,ve)|0,d=d+Math.imul(te,st)|0,d=d+Math.imul(ke,ve)|0,m=m+Math.imul(ke,st)|0,w=w+Math.imul(W,pe)|0,d=d+Math.imul(W,We)|0,d=d+Math.imul(se,pe)|0,m=m+Math.imul(se,We)|0,w=w+Math.imul(z,ye)|0,d=d+Math.imul(z,at)|0,d=d+Math.imul(Y,ye)|0,m=m+Math.imul(Y,at)|0,w=w+Math.imul(T,me)|0,d=d+Math.imul(T,ct)|0,d=d+Math.imul(B,me)|0,m=m+Math.imul(B,ct)|0;var Ui=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,w=Math.imul(ne,oe),d=Math.imul(ne,Qe),d=d+Math.imul(Je,oe)|0,m=Math.imul(Je,Qe),w=w+Math.imul(ae,be)|0,d=d+Math.imul(ae,Ke)|0,d=d+Math.imul($e,be)|0,m=m+Math.imul($e,Ke)|0,w=w+Math.imul(he,de)|0,d=d+Math.imul(he,Ve)|0,d=d+Math.imul(Be,de)|0,m=m+Math.imul(Be,Ve)|0,w=w+Math.imul(fe,ce)|0,d=d+Math.imul(fe,it)|0,d=d+Math.imul(Fe,ce)|0,m=m+Math.imul(Fe,it)|0,w=w+Math.imul(ue,ve)|0,d=d+Math.imul(ue,st)|0,d=d+Math.imul(Ne,ve)|0,m=m+Math.imul(Ne,st)|0,w=w+Math.imul(te,pe)|0,d=d+Math.imul(te,We)|0,d=d+Math.imul(ke,pe)|0,m=m+Math.imul(ke,We)|0,w=w+Math.imul(W,ye)|0,d=d+Math.imul(W,at)|0,d=d+Math.imul(se,ye)|0,m=m+Math.imul(se,at)|0,w=w+Math.imul(z,me)|0,d=d+Math.imul(z,ct)|0,d=d+Math.imul(Y,me)|0,m=m+Math.imul(Y,ct)|0;var zi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(zi>>>26)|0,zi&=67108863,w=Math.imul(ne,be),d=Math.imul(ne,Ke),d=d+Math.imul(Je,be)|0,m=Math.imul(Je,Ke),w=w+Math.imul(ae,de)|0,d=d+Math.imul(ae,Ve)|0,d=d+Math.imul($e,de)|0,m=m+Math.imul($e,Ve)|0,w=w+Math.imul(he,ce)|0,d=d+Math.imul(he,it)|0,d=d+Math.imul(Be,ce)|0,m=m+Math.imul(Be,it)|0,w=w+Math.imul(fe,ve)|0,d=d+Math.imul(fe,st)|0,d=d+Math.imul(Fe,ve)|0,m=m+Math.imul(Fe,st)|0,w=w+Math.imul(ue,pe)|0,d=d+Math.imul(ue,We)|0,d=d+Math.imul(Ne,pe)|0,m=m+Math.imul(Ne,We)|0,w=w+Math.imul(te,ye)|0,d=d+Math.imul(te,at)|0,d=d+Math.imul(ke,ye)|0,m=m+Math.imul(ke,at)|0,w=w+Math.imul(W,me)|0,d=d+Math.imul(W,ct)|0,d=d+Math.imul(se,me)|0,m=m+Math.imul(se,ct)|0;var jr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(jr>>>26)|0,jr&=67108863,w=Math.imul(ne,de),d=Math.imul(ne,Ve),d=d+Math.imul(Je,de)|0,m=Math.imul(Je,Ve),w=w+Math.imul(ae,ce)|0,d=d+Math.imul(ae,it)|0,d=d+Math.imul($e,ce)|0,m=m+Math.imul($e,it)|0,w=w+Math.imul(he,ve)|0,d=d+Math.imul(he,st)|0,d=d+Math.imul(Be,ve)|0,m=m+Math.imul(Be,st)|0,w=w+Math.imul(fe,pe)|0,d=d+Math.imul(fe,We)|0,d=d+Math.imul(Fe,pe)|0,m=m+Math.imul(Fe,We)|0,w=w+Math.imul(ue,ye)|0,d=d+Math.imul(ue,at)|0,d=d+Math.imul(Ne,ye)|0,m=m+Math.imul(Ne,at)|0,w=w+Math.imul(te,me)|0,d=d+Math.imul(te,ct)|0,d=d+Math.imul(ke,me)|0,m=m+Math.imul(ke,ct)|0;var ki=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(ki>>>26)|0,ki&=67108863,w=Math.imul(ne,ce),d=Math.imul(ne,it),d=d+Math.imul(Je,ce)|0,m=Math.imul(Je,it),w=w+Math.imul(ae,ve)|0,d=d+Math.imul(ae,st)|0,d=d+Math.imul($e,ve)|0,m=m+Math.imul($e,st)|0,w=w+Math.imul(he,pe)|0,d=d+Math.imul(he,We)|0,d=d+Math.imul(Be,pe)|0,m=m+Math.imul(Be,We)|0,w=w+Math.imul(fe,ye)|0,d=d+Math.imul(fe,at)|0,d=d+Math.imul(Fe,ye)|0,m=m+Math.imul(Fe,at)|0,w=w+Math.imul(ue,me)|0,d=d+Math.imul(ue,ct)|0,d=d+Math.imul(Ne,me)|0,m=m+Math.imul(Ne,ct)|0;var ji=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(ji>>>26)|0,ji&=67108863,w=Math.imul(ne,ve),d=Math.imul(ne,st),d=d+Math.imul(Je,ve)|0,m=Math.imul(Je,st),w=w+Math.imul(ae,pe)|0,d=d+Math.imul(ae,We)|0,d=d+Math.imul($e,pe)|0,m=m+Math.imul($e,We)|0,w=w+Math.imul(he,ye)|0,d=d+Math.imul(he,at)|0,d=d+Math.imul(Be,ye)|0,m=m+Math.imul(Be,at)|0,w=w+Math.imul(fe,me)|0,d=d+Math.imul(fe,ct)|0,d=d+Math.imul(Fe,me)|0,m=m+Math.imul(Fe,ct)|0;var nr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(nr>>>26)|0,nr&=67108863,w=Math.imul(ne,pe),d=Math.imul(ne,We),d=d+Math.imul(Je,pe)|0,m=Math.imul(Je,We),w=w+Math.imul(ae,ye)|0,d=d+Math.imul(ae,at)|0,d=d+Math.imul($e,ye)|0,m=m+Math.imul($e,at)|0,w=w+Math.imul(he,me)|0,d=d+Math.imul(he,ct)|0,d=d+Math.imul(Be,me)|0,m=m+Math.imul(Be,ct)|0;var Ki=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,w=Math.imul(ne,ye),d=Math.imul(ne,at),d=d+Math.imul(Je,ye)|0,m=Math.imul(Je,at),w=w+Math.imul(ae,me)|0,d=d+Math.imul(ae,ct)|0,d=d+Math.imul($e,me)|0,m=m+Math.imul($e,ct)|0;var Vi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,w=Math.imul(ne,me),d=Math.imul(ne,ct),d=d+Math.imul(Je,me)|0,m=Math.imul(Je,ct);var Hi=(E+w|0)+((d&8191)<<13)|0;return E=(m+(d>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,_[0]=Ee,_[1]=et,_[2]=wr,_[3]=_r,_[4]=xr,_[5]=Er,_[6]=At,_[7]=Bi,_[8]=Li,_[9]=qi,_[10]=Ui,_[11]=zi,_[12]=jr,_[13]=ki,_[14]=ji,_[15]=nr,_[16]=Ki,_[17]=Vi,_[18]=Hi,E!==0&&(_[19]=E,f.length++),f};Math.imul||(D=S);function R(O,g,p){p.negative=g.negative^O.negative,p.length=O.length+g.length;for(var f=0,u=0,b=0;b<p.length-1;b++){var _=u;u=0;for(var E=f&67108863,w=Math.min(b,g.length-1),d=Math.max(0,b-O.length+1);d<=w;d++){var m=b-d,v=O.words[m]|0,A=g.words[d]|0,U=v*A,x=U&67108863;_=_+(U/67108864|0)|0,x=x+E|0,E=x&67108863,_=_+(x>>>26)|0,u+=_>>>26,_&=67108863}p.words[b]=E,f=_,_=u}return f!==0?p.words[b]=f:p.length--,p.strip()}function $(O,g,p){var f=new N;return f.mulp(O,g,p)}s.prototype.mulTo=function(g,p){var f,u=this.length+g.length;return this.length===10&&g.length===10?f=D(this,g,p):u<63?f=S(this,g,p):u<1024?f=R(this,g,p):f=$(this,g,p),f};function N(O,g){this.x=O,this.y=g}N.prototype.makeRBT=function(g){for(var p=new Array(g),f=s.prototype._countBits(g)-1,u=0;u<g;u++)p[u]=this.revBin(u,f,g);return p},N.prototype.revBin=function(g,p,f){if(g===0||g===f-1)return g;for(var u=0,b=0;b<p;b++)u|=(g&1)<<p-b-1,g>>=1;return u},N.prototype.permute=function(g,p,f,u,b,_){for(var E=0;E<_;E++)u[E]=p[g[E]],b[E]=f[g[E]]},N.prototype.transform=function(g,p,f,u,b,_){this.permute(_,g,p,f,u,b);for(var E=1;E<b;E<<=1)for(var w=E<<1,d=Math.cos(2*Math.PI/w),m=Math.sin(2*Math.PI/w),v=0;v<b;v+=w)for(var A=d,U=m,x=0;x<E;x++){var T=f[v+x],B=u[v+x],q=f[v+x+E],z=u[v+x+E],Y=A*q-U*z;z=A*z+U*q,q=Y,f[v+x]=T+q,u[v+x]=B+z,f[v+x+E]=T-q,u[v+x+E]=B-z,x!==w&&(Y=d*A-m*U,U=d*U+m*A,A=Y)}},N.prototype.guessLen13b=function(g,p){var f=Math.max(p,g)|1,u=f&1,b=0;for(f=f/2|0;f;f=f>>>1)b++;return 1<<b+1+u},N.prototype.conjugate=function(g,p,f){if(!(f<=1))for(var u=0;u<f/2;u++){var b=g[u];g[u]=g[f-u-1],g[f-u-1]=b,b=p[u],p[u]=-p[f-u-1],p[f-u-1]=-b}},N.prototype.normalize13b=function(g,p){for(var f=0,u=0;u<p/2;u++){var b=Math.round(g[2*u+1]/p)*8192+Math.round(g[2*u]/p)+f;g[u]=b&67108863,b<67108864?f=0:f=b/67108864|0}return g},N.prototype.convert13b=function(g,p,f,u){for(var b=0,_=0;_<p;_++)b=b+(g[_]|0),f[2*_]=b&8191,b=b>>>13,f[2*_+1]=b&8191,b=b>>>13;for(_=2*p;_<u;++_)f[_]=0;i(b===0),i((b&-8192)===0)},N.prototype.stub=function(g){for(var p=new Array(g),f=0;f<g;f++)p[f]=0;return p},N.prototype.mulp=function(g,p,f){var u=2*this.guessLen13b(g.length,p.length),b=this.makeRBT(u),_=this.stub(u),E=new Array(u),w=new Array(u),d=new Array(u),m=new Array(u),v=new Array(u),A=new Array(u),U=f.words;U.length=u,this.convert13b(g.words,g.length,E,u),this.convert13b(p.words,p.length,m,u),this.transform(E,_,w,d,u,b),this.transform(m,_,v,A,u,b);for(var x=0;x<u;x++){var T=w[x]*v[x]-d[x]*A[x];d[x]=w[x]*A[x]+d[x]*v[x],w[x]=T}return this.conjugate(w,d,u),this.transform(w,d,U,_,u,b),this.conjugate(U,_,u),this.normalize13b(U,u),f.negative=g.negative^p.negative,f.length=g.length+p.length,f.strip()},s.prototype.mul=function(g){var p=new s(null);return p.words=new Array(this.length+g.length),this.mulTo(g,p)},s.prototype.mulf=function(g){var p=new s(null);return p.words=new Array(this.length+g.length),$(this,g,p)},s.prototype.imul=function(g){return this.clone().mulTo(g,this)},s.prototype.imuln=function(g){i(typeof g=="number"),i(g<67108864);for(var p=0,f=0;f<this.length;f++){var u=(this.words[f]|0)*g,b=(u&67108863)+(p&67108863);p>>=26,p+=u/67108864|0,p+=b>>>26,this.words[f]=b&67108863}return p!==0&&(this.words[f]=p,this.length++),this},s.prototype.muln=function(g){return this.clone().imuln(g)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(g){var p=I(g);if(p.length===0)return new s(1);for(var f=this,u=0;u<p.length&&p[u]===0;u++,f=f.sqr());if(++u<p.length)for(var b=f.sqr();u<p.length;u++,b=b.sqr())p[u]!==0&&(f=f.mul(b));return f},s.prototype.iushln=function(g){i(typeof g=="number"&&g>=0);var p=g%26,f=(g-p)/26,u=67108863>>>26-p<<26-p,b;if(p!==0){var _=0;for(b=0;b<this.length;b++){var E=this.words[b]&u,w=(this.words[b]|0)-E<<p;this.words[b]=w|_,_=E>>>26-p}_&&(this.words[b]=_,this.length++)}if(f!==0){for(b=this.length-1;b>=0;b--)this.words[b+f]=this.words[b];for(b=0;b<f;b++)this.words[b]=0;this.length+=f}return this.strip()},s.prototype.ishln=function(g){return i(this.negative===0),this.iushln(g)},s.prototype.iushrn=function(g,p,f){i(typeof g=="number"&&g>=0);var u;p?u=(p-p%26)/26:u=0;var b=g%26,_=Math.min((g-b)/26,this.length),E=67108863^67108863>>>b<<b,w=f;if(u-=_,u=Math.max(0,u),w){for(var d=0;d<_;d++)w.words[d]=this.words[d];w.length=_}if(_!==0)if(this.length>_)for(this.length-=_,d=0;d<this.length;d++)this.words[d]=this.words[d+_];else this.words[0]=0,this.length=1;var m=0;for(d=this.length-1;d>=0&&(m!==0||d>=u);d--){var v=this.words[d]|0;this.words[d]=m<<26-b|v>>>b,m=v&E}return w&&m!==0&&(w.words[w.length++]=m),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(g,p,f){return i(this.negative===0),this.iushrn(g,p,f)},s.prototype.shln=function(g){return this.clone().ishln(g)},s.prototype.ushln=function(g){return this.clone().iushln(g)},s.prototype.shrn=function(g){return this.clone().ishrn(g)},s.prototype.ushrn=function(g){return this.clone().iushrn(g)},s.prototype.testn=function(g){i(typeof g=="number"&&g>=0);var p=g%26,f=(g-p)/26,u=1<<p;if(this.length<=f)return!1;var b=this.words[f];return!!(b&u)},s.prototype.imaskn=function(g){i(typeof g=="number"&&g>=0);var p=g%26,f=(g-p)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(p!==0&&f++,this.length=Math.min(f,this.length),p!==0){var u=67108863^67108863>>>p<<p;this.words[this.length-1]&=u}return this.strip()},s.prototype.maskn=function(g){return this.clone().imaskn(g)},s.prototype.iaddn=function(g){return i(typeof g=="number"),i(g<67108864),g<0?this.isubn(-g):this.negative!==0?this.length===1&&(this.words[0]|0)<g?(this.words[0]=g-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(g),this.negative=1,this):this._iaddn(g)},s.prototype._iaddn=function(g){this.words[0]+=g;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},s.prototype.isubn=function(g){if(i(typeof g=="number"),i(g<67108864),g<0)return this.iaddn(-g);if(this.negative!==0)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this.strip()},s.prototype.addn=function(g){return this.clone().iaddn(g)},s.prototype.subn=function(g){return this.clone().isubn(g)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(g,p,f){var u=g.length+f,b;this._expand(u);var _,E=0;for(b=0;b<g.length;b++){_=(this.words[b+f]|0)+E;var w=(g.words[b]|0)*p;_-=w&67108863,E=(_>>26)-(w/67108864|0),this.words[b+f]=_&67108863}for(;b<this.length-f;b++)_=(this.words[b+f]|0)+E,E=_>>26,this.words[b+f]=_&67108863;if(E===0)return this.strip();for(i(E===-1),E=0,b=0;b<this.length;b++)_=-(this.words[b]|0)+E,E=_>>26,this.words[b]=_&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(g,p){var f=this.length-g.length,u=this.clone(),b=g,_=b.words[b.length-1]|0,E=this._countBits(_);f=26-E,f!==0&&(b=b.ushln(f),u.iushln(f),_=b.words[b.length-1]|0);var w=u.length-b.length,d;if(p!=="mod"){d=new s(null),d.length=w+1,d.words=new Array(d.length);for(var m=0;m<d.length;m++)d.words[m]=0}var v=u.clone()._ishlnsubmul(b,1,w);v.negative===0&&(u=v,d&&(d.words[w]=1));for(var A=w-1;A>=0;A--){var U=(u.words[b.length+A]|0)*67108864+(u.words[b.length+A-1]|0);for(U=Math.min(U/_|0,67108863),u._ishlnsubmul(b,U,A);u.negative!==0;)U--,u.negative=0,u._ishlnsubmul(b,1,A),u.isZero()||(u.negative^=1);d&&(d.words[A]=U)}return d&&d.strip(),u.strip(),p!=="div"&&f!==0&&u.iushrn(f),{div:d||null,mod:u}},s.prototype.divmod=function(g,p,f){if(i(!g.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var u,b,_;return this.negative!==0&&g.negative===0?(_=this.neg().divmod(g,p),p!=="mod"&&(u=_.div.neg()),p!=="div"&&(b=_.mod.neg(),f&&b.negative!==0&&b.iadd(g)),{div:u,mod:b}):this.negative===0&&g.negative!==0?(_=this.divmod(g.neg(),p),p!=="mod"&&(u=_.div.neg()),{div:u,mod:_.mod}):this.negative&g.negative?(_=this.neg().divmod(g.neg(),p),p!=="div"&&(b=_.mod.neg(),f&&b.negative!==0&&b.isub(g)),{div:_.div,mod:b}):g.length>this.length||this.cmp(g)<0?{div:new s(0),mod:this}:g.length===1?p==="div"?{div:this.divn(g.words[0]),mod:null}:p==="mod"?{div:null,mod:new s(this.modn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new s(this.modn(g.words[0]))}:this._wordDiv(g,p)},s.prototype.div=function(g){return this.divmod(g,"div",!1).div},s.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},s.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},s.prototype.divRound=function(g){var p=this.divmod(g);if(p.mod.isZero())return p.div;var f=p.div.negative!==0?p.mod.isub(g):p.mod,u=g.ushrn(1),b=g.andln(1),_=f.cmp(u);return _<0||b===1&&_===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},s.prototype.modn=function(g){i(g<=67108863);for(var p=(1<<26)%g,f=0,u=this.length-1;u>=0;u--)f=(p*f+(this.words[u]|0))%g;return f},s.prototype.idivn=function(g){i(g<=67108863);for(var p=0,f=this.length-1;f>=0;f--){var u=(this.words[f]|0)+p*67108864;this.words[f]=u/g|0,p=u%g}return this.strip()},s.prototype.divn=function(g){return this.clone().idivn(g)},s.prototype.egcd=function(g){i(g.negative===0),i(!g.isZero());var p=this,f=g.clone();p.negative!==0?p=p.umod(g):p=p.clone();for(var u=new s(1),b=new s(0),_=new s(0),E=new s(1),w=0;p.isEven()&&f.isEven();)p.iushrn(1),f.iushrn(1),++w;for(var d=f.clone(),m=p.clone();!p.isZero();){for(var v=0,A=1;!(p.words[0]&A)&&v<26;++v,A<<=1);if(v>0)for(p.iushrn(v);v-- >0;)(u.isOdd()||b.isOdd())&&(u.iadd(d),b.isub(m)),u.iushrn(1),b.iushrn(1);for(var U=0,x=1;!(f.words[0]&x)&&U<26;++U,x<<=1);if(U>0)for(f.iushrn(U);U-- >0;)(_.isOdd()||E.isOdd())&&(_.iadd(d),E.isub(m)),_.iushrn(1),E.iushrn(1);p.cmp(f)>=0?(p.isub(f),u.isub(_),b.isub(E)):(f.isub(p),_.isub(u),E.isub(b))}return{a:_,b:E,gcd:f.iushln(w)}},s.prototype._invmp=function(g){i(g.negative===0),i(!g.isZero());var p=this,f=g.clone();p.negative!==0?p=p.umod(g):p=p.clone();for(var u=new s(1),b=new s(0),_=f.clone();p.cmpn(1)>0&&f.cmpn(1)>0;){for(var E=0,w=1;!(p.words[0]&w)&&E<26;++E,w<<=1);if(E>0)for(p.iushrn(E);E-- >0;)u.isOdd()&&u.iadd(_),u.iushrn(1);for(var d=0,m=1;!(f.words[0]&m)&&d<26;++d,m<<=1);if(d>0)for(f.iushrn(d);d-- >0;)b.isOdd()&&b.iadd(_),b.iushrn(1);p.cmp(f)>=0?(p.isub(f),u.isub(b)):(f.isub(p),b.isub(u))}var v;return p.cmpn(1)===0?v=u:v=b,v.cmpn(0)<0&&v.iadd(g),v},s.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var p=this.clone(),f=g.clone();p.negative=0,f.negative=0;for(var u=0;p.isEven()&&f.isEven();u++)p.iushrn(1),f.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;f.isEven();)f.iushrn(1);var b=p.cmp(f);if(b<0){var _=p;p=f,f=_}else if(b===0||f.cmpn(1)===0)break;p.isub(f)}while(!0);return f.iushln(u)},s.prototype.invm=function(g){return this.egcd(g).a.umod(g)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(g){return this.words[0]&g},s.prototype.bincn=function(g){i(typeof g=="number");var p=g%26,f=(g-p)/26,u=1<<p;if(this.length<=f)return this._expand(f+1),this.words[f]|=u,this;for(var b=u,_=f;b!==0&&_<this.length;_++){var E=this.words[_]|0;E+=b,b=E>>>26,E&=67108863,this.words[_]=E}return b!==0&&(this.words[_]=b,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(g){var p=g<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this.strip();var f;if(this.length>1)f=1;else{p&&(g=-g),i(g<=67108863,"Number is too big");var u=this.words[0]|0;f=u===g?0:u<g?-1:1}return this.negative!==0?-f|0:f},s.prototype.cmp=function(g){if(this.negative!==0&&g.negative===0)return-1;if(this.negative===0&&g.negative!==0)return 1;var p=this.ucmp(g);return this.negative!==0?-p|0:p},s.prototype.ucmp=function(g){if(this.length>g.length)return 1;if(this.length<g.length)return-1;for(var p=0,f=this.length-1;f>=0;f--){var u=this.words[f]|0,b=g.words[f]|0;if(u!==b){u<b?p=-1:u>b&&(p=1);break}}return p},s.prototype.gtn=function(g){return this.cmpn(g)===1},s.prototype.gt=function(g){return this.cmp(g)===1},s.prototype.gten=function(g){return this.cmpn(g)>=0},s.prototype.gte=function(g){return this.cmp(g)>=0},s.prototype.ltn=function(g){return this.cmpn(g)===-1},s.prototype.lt=function(g){return this.cmp(g)===-1},s.prototype.lten=function(g){return this.cmpn(g)<=0},s.prototype.lte=function(g){return this.cmp(g)<=0},s.prototype.eqn=function(g){return this.cmpn(g)===0},s.prototype.eq=function(g){return this.cmp(g)===0},s.red=function(g){return new V(g)},s.prototype.toRed=function(g){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),g.convertTo(this)._forceRed(g)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(g){return this.red=g,this},s.prototype.forceRed=function(g){return i(!this.red,"Already a number in reduction context"),this._forceRed(g)},s.prototype.redAdd=function(g){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},s.prototype.redIAdd=function(g){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},s.prototype.redSub=function(g){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},s.prototype.redISub=function(g){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},s.prototype.redShl=function(g){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},s.prototype.redMul=function(g){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},s.prototype.redIMul=function(g){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(g){return i(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var C={k256:null,p224:null,p192:null,p25519:null};function L(O,g){this.name=O,this.p=new s(g,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var g=new s(null);return g.words=new Array(Math.ceil(this.n/13)),g},L.prototype.ireduce=function(g){var p=g,f;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),f=p.bitLength();while(f>this.n);var u=f<this.n?-1:p.ucmp(this.p);return u===0?(p.words[0]=0,p.length=1):u>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},L.prototype.split=function(g,p){g.iushrn(this.n,0,p)},L.prototype.imulK=function(g){return g.imul(this.k)};function k(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(k,L),k.prototype.split=function(g,p){for(var f=4194303,u=Math.min(g.length,9),b=0;b<u;b++)p.words[b]=g.words[b];if(p.length=u,g.length<=9){g.words[0]=0,g.length=1;return}var _=g.words[9];for(p.words[p.length++]=_&f,b=10;b<g.length;b++){var E=g.words[b]|0;g.words[b-10]=(E&f)<<4|_>>>22,_=E}_>>>=22,g.words[b-10]=_,_===0&&g.length>10?g.length-=10:g.length-=9},k.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var p=0,f=0;f<g.length;f++){var u=g.words[f]|0;p+=u*977,g.words[f]=p&67108863,p=u*64+(p/67108864|0)}return g.words[g.length-1]===0&&(g.length--,g.words[g.length-1]===0&&g.length--),g};function j(){L.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(j,L);function G(){L.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(G,L);function K(){L.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(K,L),K.prototype.imulK=function(g){for(var p=0,f=0;f<g.length;f++){var u=(g.words[f]|0)*19+p,b=u&67108863;u>>>=26,g.words[f]=b,p=u}return p!==0&&(g.words[g.length++]=p),g},s._prime=function(g){if(C[g])return C[g];var p;if(g==="k256")p=new k;else if(g==="p224")p=new j;else if(g==="p192")p=new G;else if(g==="p25519")p=new K;else throw new Error("Unknown prime "+g);return C[g]=p,p};function V(O){if(typeof O=="string"){var g=s._prime(O);this.m=g.p,this.prime=g}else i(O.gtn(1),"modulus must be greater than 1"),this.m=O,this.prime=null}V.prototype._verify1=function(g){i(g.negative===0,"red works only with positives"),i(g.red,"red works only with red numbers")},V.prototype._verify2=function(g,p){i((g.negative|p.negative)===0,"red works only with positives"),i(g.red&&g.red===p.red,"red works only with red numbers")},V.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},V.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},V.prototype.add=function(g,p){this._verify2(g,p);var f=g.add(p);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},V.prototype.iadd=function(g,p){this._verify2(g,p);var f=g.iadd(p);return f.cmp(this.m)>=0&&f.isub(this.m),f},V.prototype.sub=function(g,p){this._verify2(g,p);var f=g.sub(p);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},V.prototype.isub=function(g,p){this._verify2(g,p);var f=g.isub(p);return f.cmpn(0)<0&&f.iadd(this.m),f},V.prototype.shl=function(g,p){return this._verify1(g),this.imod(g.ushln(p))},V.prototype.imul=function(g,p){return this._verify2(g,p),this.imod(g.imul(p))},V.prototype.mul=function(g,p){return this._verify2(g,p),this.imod(g.mul(p))},V.prototype.isqr=function(g){return this.imul(g,g.clone())},V.prototype.sqr=function(g){return this.mul(g,g)},V.prototype.sqrt=function(g){if(g.isZero())return g.clone();var p=this.m.andln(3);if(i(p%2===1),p===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(g,f)}for(var u=this.m.subn(1),b=0;!u.isZero()&&u.andln(1)===0;)b++,u.iushrn(1);i(!u.isZero());var _=new s(1).toRed(this),E=_.redNeg(),w=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,w).cmp(E)!==0;)d.redIAdd(E);for(var m=this.pow(d,u),v=this.pow(g,u.addn(1).iushrn(1)),A=this.pow(g,u),U=b;A.cmp(_)!==0;){for(var x=A,T=0;x.cmp(_)!==0;T++)x=x.redSqr();i(T<U);var B=this.pow(m,new s(1).iushln(U-T-1));v=v.redMul(B),m=B.redSqr(),A=A.redMul(m),U=T}return v},V.prototype.invm=function(g){var p=g._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(g,p){if(p.isZero())return new s(1).toRed(this);if(p.cmpn(1)===0)return g.clone();var f=4,u=new Array(1<<f);u[0]=new s(1).toRed(this),u[1]=g;for(var b=2;b<u.length;b++)u[b]=this.mul(u[b-1],g);var _=u[0],E=0,w=0,d=p.bitLength()%26;for(d===0&&(d=26),b=p.length-1;b>=0;b--){for(var m=p.words[b],v=d-1;v>=0;v--){var A=m>>v&1;if(_!==u[0]&&(_=this.sqr(_)),A===0&&E===0){w=0;continue}E<<=1,E|=A,w++,!(w!==f&&(b!==0||v!==0))&&(_=this.mul(_,u[E]),w=0,E=0)}d=26}return _},V.prototype.convertTo=function(g){var p=g.umod(this.m);return p===g?p.clone():p},V.prototype.convertFrom=function(g){var p=g.clone();return p.red=null,p},s.mont=function(g){return new ie(g)};function ie(O){V.call(this,O),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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)}n(ie,V),ie.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},ie.prototype.convertFrom=function(g){var p=this.imod(g.mul(this.rinv));return p.red=null,p},ie.prototype.imul=function(g,p){if(g.isZero()||p.isZero())return g.words[0]=0,g.length=1,g;var f=g.imul(p),u=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=f.isub(u).iushrn(this.shift),_=b;return b.cmp(this.m)>=0?_=b.isub(this.m):b.cmpn(0)<0&&(_=b.iadd(this.m)),_._forceRed(this)},ie.prototype.mul=function(g,p){if(g.isZero()||p.isZero())return new s(0)._forceRed(this);var f=g.mul(p),u=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=f.isub(u).iushrn(this.shift),_=b;return b.cmp(this.m)>=0?_=b.isub(this.m):b.cmpn(0)<0&&(_=b.iadd(this.m)),_._forceRed(this)},ie.prototype.invm=function(g){var p=this.imod(g._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,zt)})(li);var qf={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var c=0;c<s.length;c++)a[c]=s[c]|0;return a}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var c=0;c<s.length;c+=2)a.push(parseInt(s[c]+s[c+1],16))}else for(var c=0;c<s.length;c++){var h=s.charCodeAt(c),l=h>>8,y=h&255;l?a.push(l,y):a.push(y)}return a}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",a=0;a<s.length;a++)o+=i(s[a].toString(16));return o}e.toHex=n,e.encode=function(o,a){return a==="hex"?n(o):o}})(qf),function(t){var e=t,r=li.exports,i=wn,n=qf;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(l,y,M){var I=new Array(Math.max(l.bitLength(),M)+1),S;for(S=0;S<I.length;S+=1)I[S]=0;var D=1<<y+1,R=l.clone();for(S=0;S<I.length;S++){var $,N=R.andln(D-1);R.isOdd()?(N>(D>>1)-1?$=(D>>1)-N:$=N,R.isubn($)):$=0,I[S]=$,R.iushrn(1)}return I}e.getNAF=s;function o(l,y){var M=[[],[]];l=l.clone(),y=y.clone();for(var I=0,S=0,D;l.cmpn(-I)>0||y.cmpn(-S)>0;){var R=l.andln(3)+I&3,$=y.andln(3)+S&3;R===3&&(R=-1),$===3&&($=-1);var N;R&1?(D=l.andln(7)+I&7,(D===3||D===5)&&$===2?N=-R:N=R):N=0,M[0].push(N);var C;$&1?(D=y.andln(7)+S&7,(D===3||D===5)&&R===2?C=-$:C=$):C=0,M[1].push(C),2*I===N+1&&(I=1-I),2*S===C+1&&(S=1-S),l.iushrn(1),y.iushrn(1)}return M}e.getJSF=o;function a(l,y,M){var I="_"+y;l.prototype[y]=function(){return this[I]!==void 0?this[I]:this[I]=M.call(this)}}e.cachedProperty=a;function c(l){return typeof l=="string"?e.toArray(l,"hex"):l}e.parseBytes=c;function h(l){return new r(l,"hex","le")}e.intFromLE=h}(Ar);var Ko={exports:{}},Uf;Ko.exports=function(e){return Uf||(Uf=new en(null)),Uf.generate(e)};function en(t){this.rand=t}if(Ko.exports.Rand=en,en.prototype.generate=function(e){return this._rand(e)},en.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i<r.length;i++)r[i]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?en.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?en.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(en.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var Gd=vf;if(typeof Gd.randomBytes!="function")throw new Error("Not supported");en.prototype._rand=function(e){return Gd.randomBytes(e)}}catch{}var zf={},En=li.exports,Ls=Ar,Vo=Ls.getNAF,Hw=Ls.getJSF,Ho=Ls.assert;function tn(t,e){this.type=t,this.p=new En(e.p,16),this.red=e.prime?En.red(e.prime):En.mont(this.p),this.zero=new En(0).toRed(this.red),this.one=new En(1).toRed(this.red),this.two=new En(2).toRed(this.red),this.n=e.n&&new En(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Wo=tn;tn.prototype.point=function(){throw new Error("Not implemented")},tn.prototype.validate=function(){throw new Error("Not implemented")},tn.prototype._fixedNafMul=function(e,r){Ho(e.precomputed);var i=e._getDoubles(),n=Vo(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var h=a+i.step-1;h>=a;h--)c=(c<<1)+n[h];o.push(c)}for(var l=this.jpoint(null,null,null),y=this.jpoint(null,null,null),M=s;M>0;M--){for(a=0;a<o.length;a++)c=o[a],c===M?y=y.mixedAdd(i.points[a]):c===-M&&(y=y.mixedAdd(i.points[a].neg()));l=l.add(y)}return l.toP()},tn.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Vo(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var h=0;c>=0&&o[c]===0;c--)h++;if(c>=0&&h++,a=a.dblp(h),c<0)break;var l=o[c];Ho(l!==0),e.type==="affine"?l>0?a=a.mixedAdd(s[l-1>>1]):a=a.mixedAdd(s[-l-1>>1].neg()):l>0?a=a.add(s[l-1>>1]):a=a.add(s[-l-1>>1].neg())}return e.type==="affine"?a.toP():a},tn.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,h=0,l,y,M;for(l=0;l<n;l++){M=r[l];var I=M._getNAFPoints(e);o[l]=I.wnd,a[l]=I.points}for(l=n-1;l>=1;l-=2){var S=l-1,D=l;if(o[S]!==1||o[D]!==1){c[S]=Vo(i[S],o[S],this._bitLength),c[D]=Vo(i[D],o[D],this._bitLength),h=Math.max(c[S].length,h),h=Math.max(c[D].length,h);continue}var R=[r[S],null,null,r[D]];r[S].y.cmp(r[D].y)===0?(R[1]=r[S].add(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg())):r[S].y.cmp(r[D].y.redNeg())===0?(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].add(r[D].neg())):(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg()));var $=[-3,-1,-5,-7,0,7,5,1,3],N=Hw(i[S],i[D]);for(h=Math.max(N[0].length,h),c[S]=new Array(h),c[D]=new Array(h),y=0;y<h;y++){var C=N[0][y]|0,L=N[1][y]|0;c[S][y]=$[(C+1)*3+(L+1)],c[D][y]=0,a[S]=R}}var k=this.jpoint(null,null,null),j=this._wnafT4;for(l=h;l>=0;l--){for(var G=0;l>=0;){var K=!0;for(y=0;y<n;y++)j[y]=c[y][l]|0,j[y]!==0&&(K=!1);if(!K)break;G++,l--}if(l>=0&&G++,k=k.dblp(G),l<0)break;for(y=0;y<n;y++){var V=j[y];V!==0&&(V>0?M=a[y][V-1>>1]:V<0&&(M=a[y][-V-1>>1].neg()),M.type==="affine"?k=k.mixedAdd(M):k=k.add(M))}}for(l=0;l<n;l++)a[l]=null;return s?k:k.toP()};function Br(t,e){this.curve=t,this.type=e,this.precomputed=null}tn.BasePoint=Br,Br.prototype.eq=function(){throw new Error("Not implemented")},Br.prototype.validate=function(){return this.curve.validate(this)},tn.prototype.decodePoint=function(e,r){e=Ls.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Ho(e[e.length-1]%2===0):e[0]===7&&Ho(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},Br.prototype.encodeCompressed=function(e){return this.encode(e,!0)},Br.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},Br.prototype.encode=function(e,r){return Ls.encode(this._encode(r),e)},Br.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},Br.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},Br.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},Br.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},Br.prototype._getBeta=function(){return null},Br.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var Ww=Ar,_t=li.exports,kf=Yn.exports,ns=Wo,Gw=Ww.assert;function Lr(t){ns.call(this,"short",t),this.a=new _t(t.a,16).toRed(this.red),this.b=new _t(t.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(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}kf(Lr,ns);var Jw=Lr;Lr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new _t(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new _t(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],Gw(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new _t(a.a,16),b:new _t(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},Lr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:_t.mont(e),i=new _t(2).toRed(r).redInvm(),n=i.redNeg(),s=new _t(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},Lr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new _t(1),o=new _t(0),a=new _t(0),c=new _t(1),h,l,y,M,I,S,D,R=0,$,N;i.cmpn(0)!==0;){var C=n.div(i);$=n.sub(C.mul(i)),N=a.sub(C.mul(s));var L=c.sub(C.mul(o));if(!y&&$.cmp(r)<0)h=D.neg(),l=s,y=$.neg(),M=N;else if(y&&++R===2)break;D=$,n=i,i=$,a=s,s=N,c=o,o=L}I=$.neg(),S=N;var k=y.sqr().add(M.sqr()),j=I.sqr().add(S.sqr());return j.cmp(k)>=0&&(I=h,S=l),y.negative&&(y=y.neg(),M=M.neg()),I.negative&&(I=I.neg(),S=S.neg()),[{a:y,b:M},{a:I,b:S}]},Lr.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),h=s.mul(i.b),l=o.mul(n.b),y=e.sub(a).sub(c),M=h.add(l).neg();return{k1:y,k2:M}},Lr.prototype.pointFromX=function(e,r){e=new _t(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},Lr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},Lr.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],h=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),h=h.neg(!0)),n[o*2]=c,n[o*2+1]=h,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var l=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return l};function Tt(t,e,r,i){ns.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new _t(e,16),this.y=new _t(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}kf(Tt,ns.BasePoint),Lr.prototype.point=function(e,r,i){return new Tt(this,e,r,i)},Lr.prototype.pointFromJSON=function(e,r){return Tt.fromJSON(this,e,r)},Tt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},Tt.prototype.toJSON=function(){return this.precomputed?[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)}}]:[this.x,this.y]},Tt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Tt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Tt.prototype.isInfinity=function(){return this.inf},Tt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Tt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Tt.prototype.getX=function(){return this.x.fromRed()},Tt.prototype.getY=function(){return this.y.fromRed()},Tt.prototype.mul=function(e){return e=new _t(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Tt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Tt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Tt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Tt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},Tt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Ht(t,e,r,i){ns.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new _t(0)):(this.x=new _t(e,16),this.y=new _t(r,16),this.z=new _t(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}kf(Ht,ns.BasePoint),Lr.prototype.jpoint=function(e,r,i){return new Ht(this,e,r,i)},Ht.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},Ht.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ht.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),h=o.redSub(a);if(c.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=c.redSqr(),y=l.redMul(c),M=n.redMul(l),I=h.redSqr().redIAdd(y).redISub(M).redISub(M),S=h.redMul(M.redISub(I)).redISub(o.redMul(y)),D=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,S,D)},Ht.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),y=i.redMul(h),M=c.redSqr().redIAdd(l).redISub(y).redISub(y),I=c.redMul(y.redISub(M)).redISub(s.redMul(l)),S=this.z.redMul(a);return this.curve.jpoint(M,I,S)},Ht.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,h=c.redSqr().redSqr(),l=a.redAdd(a);for(r=0;r<e;r++){var y=o.redSqr(),M=l.redSqr(),I=M.redSqr(),S=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),D=o.redMul(M),R=S.redSqr().redISub(D.redAdd(D)),$=D.redISub(R),N=S.redMul($);N=N.redIAdd(N).redISub(I);var C=l.redMul(c);r+1<e&&(h=h.redMul(I)),o=R,c=C,l=N}return this.curve.jpoint(o,l.redMul(s),c)},Ht.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Ht.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),h=c.redSqr().redISub(a).redISub(a),l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),e=h,r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),M=this.y.redSqr(),I=M.redSqr(),S=this.x.redAdd(M).redSqr().redISub(y).redISub(I);S=S.redIAdd(S);var D=y.redAdd(y).redIAdd(y),R=D.redSqr(),$=I.redIAdd(I);$=$.redIAdd($),$=$.redIAdd($),e=R.redISub(S).redISub(S),r=D.redMul(S.redISub(e)).redISub($),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Ht.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=c.redSqr().redISub(a).redISub(a);e=h;var l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),M=this.y.redSqr(),I=this.x.redMul(M),S=this.x.redSub(y).redMul(this.x.redAdd(y));S=S.redAdd(S).redIAdd(S);var D=I.redIAdd(I);D=D.redIAdd(D);var R=D.redAdd(D);e=S.redSqr().redISub(R),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(y);var $=M.redSqr();$=$.redIAdd($),$=$.redIAdd($),$=$.redIAdd($),r=S.redMul(D.redISub(e)).redISub($)}return this.curve.jpoint(e,r,i)},Ht.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=r.redAdd(r);h=h.redIAdd(h);var l=h.redMul(a),y=c.redSqr().redISub(l.redAdd(l)),M=l.redISub(y),I=a.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=c.redMul(M).redISub(I),D=i.redAdd(i).redMul(n);return this.curve.jpoint(y,S,D)},Ht.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var l=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(h),y=r.redMul(l);y=y.redIAdd(y),y=y.redIAdd(y);var M=this.x.redMul(c).redISub(y);M=M.redIAdd(M),M=M.redIAdd(M);var I=this.y.redMul(l.redMul(h.redISub(l)).redISub(a.redMul(c)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(M,I,S)},Ht.prototype.mul=function(e,r){return e=new _t(e,r),this.curve._wnafMul(this,e)},Ht.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Ht.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Ht.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ss=li.exports,Jd=Yn.exports,Go=Wo,Yw=Ar;function os(t){Go.call(this,"mont",t),this.a=new ss(t.a,16).toRed(this.red),this.b=new ss(t.b,16).toRed(this.red),this.i4=new ss(4).toRed(this.red).redInvm(),this.two=new ss(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Jd(os,Go);var Zw=os;os.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),n=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),s=n.redSqrt();return s.redSqr().cmp(n)===0};function Ft(t,e,r){Go.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new ss(e,16),this.z=new ss(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Jd(Ft,Go.BasePoint),os.prototype.decodePoint=function(e,r){return this.point(Yw.toArray(e,r),1)},os.prototype.point=function(e,r){return new Ft(this,e,r)},os.prototype.pointFromJSON=function(e){return Ft.fromJSON(this,e)},Ft.prototype.precompute=function(){},Ft.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Ft.fromJSON=function(e,r){return new Ft(e,r[0],r[1]||e.one)},Ft.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Ft.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Ft.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=r.redSub(n),o=r.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},Ft.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Ft.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),c=s.redMul(n),h=r.z.redMul(a.redAdd(c).redSqr()),l=r.x.redMul(a.redISub(c).redSqr());return this.curve.point(h,l)},Ft.prototype.mul=function(e){for(var r=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Ft.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Ft.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Ft.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Ft.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Ft.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Xw=Ar,Oi=li.exports,Yd=Yn.exports,Jo=Wo,Qw=Xw.assert;function pi(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Jo.call(this,"edwards",t),this.a=new Oi(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Oi(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Oi(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Qw(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}Yd(pi,Jo);var e6=pi;pi.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},pi.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},pi.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},pi.prototype.pointFromX=function(e,r){e=new Oi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=a.fromRed().isOdd();return(r&&!c||!r&&c)&&(a=a.redNeg()),this.point(e,a)},pi.prototype.pointFromY=function(e,r){e=new Oi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)},pi.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),n=r.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return n.cmp(s)===0};function lt(t,e,r,i,n){Jo.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Oi(e,16),this.y=new Oi(r,16),this.z=i?new Oi(i,16):this.curve.one,this.t=n&&new Oi(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Yd(lt,Jo.BasePoint),pi.prototype.pointFromJSON=function(e){return lt.fromJSON(this,e)},pi.prototype.point=function(e,r,i,n){return new lt(this,e,r,i,n)},lt.fromJSON=function(e,r){return new lt(e,r[0],r[1],r[2])},lt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},lt.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},lt.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=n.redAdd(r),a=o.redSub(i),c=n.redSub(r),h=s.redMul(a),l=o.redMul(c),y=s.redMul(c),M=a.redMul(o);return this.curve.point(h,l,M,y)},lt.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,c,h;if(this.curve.twisted){a=this.curve._mulA(r);var l=a.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(l.redSub(this.curve.two)),s=l.redMul(a.redSub(i)),o=l.redSqr().redSub(l).redSub(l)):(c=this.z.redSqr(),h=l.redSub(c).redISub(c),n=e.redSub(r).redISub(i).redMul(h),s=l.redMul(a.redSub(i)),o=l.redMul(h))}else a=r.redAdd(i),c=this.curve._mulC(this.z).redSqr(),h=a.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(a)).redMul(h),s=this.curve._mulC(a).redMul(r.redISub(i)),o=a.redMul(h);return this.curve.point(n,s,o)},lt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},lt.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(r),a=s.redSub(n),c=s.redAdd(n),h=i.redAdd(r),l=o.redMul(a),y=c.redMul(h),M=o.redMul(h),I=a.redMul(c);return this.curve.point(l,y,I,M)},lt.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),c=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),l=r.redMul(a).redMul(h),y,M;return this.curve.twisted?(y=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),M=a.redMul(c)):(y=r.redMul(c).redMul(s.redSub(n)),M=this.curve._mulC(a).redMul(c)),this.curve.point(l,y,M)},lt.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},lt.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},lt.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},lt.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},lt.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},lt.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},lt.prototype.getX=function(){return this.normalize(),this.x.fromRed()},lt.prototype.getY=function(){return this.normalize(),this.y.fromRed()},lt.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},lt.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},lt.prototype.toP=lt.prototype.normalize,lt.prototype.mixedAdd=lt.prototype.add,function(t){var e=t;e.base=Wo,e.short=Jw,e.mont=Zw,e.edwards=e6}(zf);var Yo={},jf,Zd;function t6(){return Zd||(Zd=1,jf={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),jf}(function(t){var e=t,r=Mr,i=zf,n=Ar,s=n.assert;function o(h){h.type==="short"?this.curve=new i.short(h):h.type==="edwards"?this.curve=new i.edwards(h):this.curve=new i.mont(h),this.g=this.curve.g,this.n=this.curve.n,this.hash=h.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(h,l){Object.defineProperty(e,h,{configurable:!0,enumerable:!0,get:function(){var y=new o(l);return Object.defineProperty(e,h,{configurable:!0,enumerable:!0,value:y}),y}})}a("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:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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:r.sha384,gRed:!1,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"]}),a("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:r.sha512,gRed:!1,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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=t6()}catch{c=void 0}a("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:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})})(Yo);var r6=Mr,Sn=qf,Xd=wn;function rn(t){if(!(this instanceof rn))return new rn(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sn.toArray(t.entropy,t.entropyEnc||"hex"),r=Sn.toArray(t.nonce,t.nonceEnc||"hex"),i=Sn.toArray(t.pers,t.persEnc||"hex");Xd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var i6=rn;rn.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},rn.prototype._hmac=function(){return new r6.hmac(this.hash,this.K)},rn.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},rn.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=Sn.toArray(e,r),i=Sn.toArray(i,n),Xd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},rn.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=Sn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Sn.encode(o,r)};var n6=li.exports,s6=Ar,Kf=s6.assert;function tr(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var o6=tr;tr.fromPublic=function(e,r,i){return r instanceof tr?r:new tr(e,{pub:r,pubEnc:i})},tr.fromPrivate=function(e,r,i){return r instanceof tr?r:new tr(e,{priv:r,privEnc:i})},tr.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},tr.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},tr.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},tr.prototype._importPrivate=function(e,r){this.priv=new n6(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},tr.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?Kf(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Kf(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},tr.prototype.derive=function(e){return e.validate()||Kf(e.validate(),"public point not validated"),e.mul(this.priv).getX()},tr.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},tr.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},tr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Zo=li.exports,Vf=Ar,a6=Vf.assert;function Xo(t,e){if(t instanceof Xo)return t;this._importDER(t,e)||(a6(t.r&&t.s,"Signature without r or s"),this.r=new Zo(t.r,16),this.s=new Zo(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var f6=Xo;function c6(){this.place=0}function Hf(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4||t[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Qd(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}Xo.prototype._importDER=function(e,r){e=Vf.toArray(e,r);var i=new c6;if(e[i.place++]!==48)return!1;var n=Hf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Hf(e,i);if(s===!1||e[i.place]&128)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=Hf(e,i);if(a===!1||e.length!==a+i.place||e[i.place]&128)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new Zo(o),this.s=new Zo(c),this.recoveryParam=null,!0};function Wf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Xo.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=Qd(r),i=Qd(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Wf(n,r.length),n=n.concat(r),n.push(2),Wf(n,i.length);var s=n.concat(i),o=[48];return Wf(o,s.length),o=o.concat(s),Vf.encode(o,e)};var Zr=li.exports,el=i6,h6=Ar,Gf=Yo,u6=Ko.exports,Mn=h6.assert,Jf=o6,Qo=f6;function qr(t){if(!(this instanceof qr))return new qr(t);typeof t=="string"&&(Mn(Object.prototype.hasOwnProperty.call(Gf,t),"Unknown curve "+t),t=Gf[t]),t instanceof Gf.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var d6=qr;qr.prototype.keyPair=function(e){return new Jf(this,e)},qr.prototype.keyFromPrivate=function(e,r){return Jf.fromPrivate(this,e,r)},qr.prototype.keyFromPublic=function(e,r){return Jf.fromPublic(this,e,r)},qr.prototype.genKeyPair=function(e){e||(e={});for(var r=new el({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||u6(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Zr(2));;){var s=new Zr(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},qr.prototype._truncateToN=function(e,r,i){var n;if(Zr.isBN(e)||typeof e=="number")e=new Zr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Zr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Zr(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},qr.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Zr.isBN(e)){Mn(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),Mn(e.length>>>0===e.length);for(var s=0;s<e.length;s++)Mn((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),Mn(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);Mn(new Zr(c).eq(e),"Can not sign message");for(var h=new el({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new Zr(1)),y=0;;y++){var M=n.k?n.k(y):new Zr(h.generate(this.n.byteLength()));if(M=this._truncateToN(M,!0),!(M.cmpn(1)<=0||M.cmp(l)>=0)){var I=this.g.mul(M);if(!I.isInfinity()){var S=I.getX(),D=S.umod(this.n);if(D.cmpn(0)!==0){var R=M.invm(this.n).mul(D.mul(r.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var $=(I.getY().isOdd()?1:0)|(S.cmp(D)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),$^=1),new Qo({r:D,s:R,recoveryParam:$})}}}}}},qr.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new Qo(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),h=c.mul(e).umod(this.n),l=c.mul(o).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(h,i.getPublic(),l),y.isInfinity()?!1:y.eqXToP(o)):(y=this.g.mulAdd(h,i.getPublic(),l),y.isInfinity()?!1:y.getX().umod(this.n).cmp(o)===0)},qr.prototype.recoverPubKey=function(t,e,r,i){Mn((3&r)===r,"The recovery param is more than two bits"),e=new Qo(e,i);var n=this.n,s=new Zr(t),o=e.r,a=e.s,c=r&1,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var l=e.r.invm(n),y=n.sub(s).mul(l).umod(n),M=a.mul(l).umod(n);return this.g.mulAdd(y,o,M)},qr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Qo(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var qs=Ar,tl=qs.assert,rl=qs.parseBytes,as=qs.cachedProperty;function Ct(t,e){this.eddsa=t,this._secret=rl(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=rl(e.pub)}Ct.fromPublic=function(e,r){return r instanceof Ct?r:new Ct(e,{pub:r})},Ct.fromSecret=function(e,r){return r instanceof Ct?r:new Ct(e,{secret:r})},Ct.prototype.secret=function(){return this._secret},as(Ct,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),as(Ct,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),as(Ct,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,n=r.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),as(Ct,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),as(Ct,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),as(Ct,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Ct.prototype.sign=function(e){return tl(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Ct.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},Ct.prototype.getSecret=function(e){return tl(this._secret,"KeyPair is public only"),qs.encode(this.secret(),e)},Ct.prototype.getPublic=function(e){return qs.encode(this.pubBytes(),e)};var l6=Ct,p6=li.exports,ea=Ar,il=ea.assert,ta=ea.cachedProperty,g6=ea.parseBytes;function In(t,e){this.eddsa=t,typeof e!="object"&&(e=g6(e)),Array.isArray(e)&&(il(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),il(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof p6&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}ta(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),ta(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),ta(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),ta(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},In.prototype.toHex=function(){return ea.encode(this.toBytes(),"hex").toUpperCase()};var b6=In,v6=Mr,y6=Yo,fs=Ar,m6=fs.assert,nl=fs.parseBytes,sl=l6,ol=b6;function br(t){if(m6(t==="ed25519","only tested with ed25519 so far"),!(this instanceof br))return new br(t);t=y6[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=v6.sha512}var w6=br;br.prototype.sign=function(e,r){e=nl(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})},br.prototype.verify=function(e,r,i){if(e=nl(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(r.Rencoded(),n.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(n.pub().mul(s));return a.eq(o)},br.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return fs.intFromLE(e.digest()).umod(this.curve.n)},br.prototype.keyFromPublic=function(e){return sl.fromPublic(this,e)},br.prototype.keyFromSecret=function(e){return sl.fromSecret(this,e)},br.prototype.makeSignature=function(e){return e instanceof ol?e:new ol(this,e)},br.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},br.prototype.decodePoint=function(e){e=fs.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=fs.intFromLE(i);return this.curve.pointFromY(s,n)},br.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},br.prototype.decodeInt=function(e){return fs.intFromLE(e)},br.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=Vw.version,e.utils=Ar,e.rand=Ko.exports,e.curve=zf,e.curves=Yo,e.ec=d6,e.eddsa=w6}(Wd);const _6={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},x6=":";function ra(t){const[e,r]=t.split(x6);return{namespace:e,reference:r}}function al(t,e){return t.includes(":")?[t]:e.chains||[]}const E6="ReactNative",Dr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},S6="js";function ia(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function nn(){return!Ds()&&!!df()&&navigator.product===E6}function M6(){return nn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function I6(){return nn()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Us(){return!ia()&&!!df()&&!!Ds()}function zs(){return nn()?Dr.reactNative:ia()?Dr.node:Us()?Dr.browser:Dr.unknown}function fl(){var t;try{return nn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function A6(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&r.set(i,n)}return r.toString()}function cl(){return Ru()||{name:"",description:"",url:"",icons:[""]}}function D6(){if(zs()===Dr.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=jy();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function O6(){var t;const e=zs();return e===Dr.browser?[e,((t=$u())==null?void 0:t.host)||"unknown"].join(":"):e}function hl(t,e,r){const i=D6(),n=O6();return[[t,e].join("-"),[S6,r].join("-"),i,n].join("/")}function P6({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=r.split("?"),l=hl(t,e,i),y={auth:n,ua:l,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},M=A6(h[1]||"",y);return h[0]+"?"+M}function An(t,e){return t.filter(r=>e.includes(r)).length===t.length}function ul(t){return Object.fromEntries(t.entries())}function dl(t){return new Map(Object.entries(t))}function Dn(t=Z.FIVE_MINUTES,e){const r=Z.toMiliseconds(t||Z.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const h=new Error(e);o=Promise.reject(h),c(h)},r),i=a,n=c})}}function sn(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function ll(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function $6(t){return ll("topic",t)}function R6(t){return ll("id",t)}function pl(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function Pt(t,e){return Z.fromMiliseconds((e||Date.now())+Z.toMiliseconds(t))}function on(t){return Date.now()>=Z.toMiliseconds(t)}function Me(t,e){return`${t}${e?`:${e}`:""}`}function N6(t=[],e=[]){return[...new Set([...t,...e])]}async function T6({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r,s=n?.href;if(typeof s!="string")return;const o=F6(s,t,e),a=zs();if(a===Dr.browser){if(!((i=Ds())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}C6(o)}else a===Dr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function F6(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${U6(i,!0)}`}else n=`${n}/wc?${i}`;return n}function C6(t){let e="_self";q6()?e="_top":(L6()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function B6(t,e){let r="";try{if(Us()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function gl(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function bl(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Yf(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function L6(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function q6(){try{return window.self!==window.top}catch{return!1}}function U6(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function vl(t){return Buffer.from(t,"base64").toString("utf-8")}function z6(t){return new Promise(e=>setTimeout(e,t))}function ks(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function k6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function na(t,...e){if(!k6(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Zf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ks(t.outputLen),ks(t.blockLen)}function cs(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function yl(t,e){na(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const sa=BigInt(2**32-1),ml=BigInt(32);function j6(t,e=!1){return e?{h:Number(t&sa),l:Number(t>>ml&sa)}:{h:Number(t>>ml&sa)|0,l:Number(t&sa)|0}}function K6(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=j6(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const V6=(t,e,r)=>t<<r|e>>>32-r,H6=(t,e,r)=>e<<r|t>>>32-r,W6=(t,e,r)=>e<<r-32|t>>>64-r,G6=(t,e,r)=>t<<r-32|e>>>64-r,hs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function J6(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Xf(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function gi(t,e){return t<<32-e|t>>>e}const wl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Y6(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function _l(t){for(let e=0;e<t.length;e++)t[e]=Y6(t[e])}function Z6(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function us(t){return typeof t=="string"&&(t=Z6(t)),na(t),t}class Qf{clone(){return this._cloneInto()}}function xl(t){const e=i=>t().update(us(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function js(t=32){if(hs&&typeof hs.getRandomValues=="function")return hs.getRandomValues(new Uint8Array(t));if(hs&&typeof hs.randomBytes=="function")return hs.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const El=[],Sl=[],Ml=[],X6=BigInt(0),Ks=BigInt(1),Q6=BigInt(2),e4=BigInt(7),t4=BigInt(256),r4=BigInt(113);for(let t=0,e=Ks,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],El.push(2*(5*i+r)),Sl.push((t+1)*(t+2)/2%64);let n=X6;for(let s=0;s<7;s++)e=(e<<Ks^(e>>e4)*r4)%t4,e&Q6&&(n^=Ks<<(Ks<<BigInt(s))-Ks);Ml.push(n)}const[i4,n4]=K6(Ml,!0),Il=(t,e,r)=>r>32?W6(t,e,r):V6(t,e,r),Al=(t,e,r)=>r>32?G6(t,e,r):H6(t,e,r);function s4(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,h=r[c],l=r[c+1],y=Il(h,l,1)^r[a],M=Al(h,l,1)^r[a+1];for(let I=0;I<50;I+=10)t[o+I]^=y,t[o+I+1]^=M}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Sl[o],c=Il(n,s,a),h=Al(n,s,a),l=El[o];n=t[l],s=t[l+1],t[l]=c,t[l+1]=h}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=i4[i],t[1]^=n4[i]}r.fill(0)}class ec extends Qf{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ks(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=J6(this.state)}keccak(){wl||_l(this.state32),s4(this.state32,this.rounds),wl||_l(this.state32),this.posOut=0,this.pos=0}update(e){cs(this);const{blockLen:r,state:i}=this;e=us(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){cs(this,!1),na(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ks(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(yl(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new ec(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const o4=(t,e,r)=>xl(()=>new ec(e,t,r)),a4=o4(1,136,256/8),f4="https://rpc.walletconnect.org/v1";function Dl(t){const e=`Ethereum Signed Message:
|
|
22
|
-
${
|
|
23
|
-
- ${D}`).join("")}`:void 0,S=aa(t.resources);if(S){const D=Vs(S);n=P4(n,D)}return[r,i,"",n,"",s,o,a,c,h,l,y,M,I].filter(D=>D!=null).join(`
|
|
24
|
-
`)};function x4(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function E4(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function On(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function S4(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:M4(e,r,i)}}}function M4(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function Nl(t){return On(t),`urn:recap:${x4(t).replace(/=/g,"")}`}function Vs(t){const e=E4(t.replace("urn:recap:",""));return On(e),e}function I4(t,e,r){const i=S4(t,e,r);return Nl(i)}function A4(t){return t&&t.includes("urn:recap:")}function D4(t,e){const r=Vs(t),i=Vs(e),n=O4(r,i);return Nl(n)}function O4(t,e){On(t),On(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,h;i.att[n]=m4(y4({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((h=e.att[n])==null?void 0:h[a])})})}),i}function P4(t="",e){On(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));c.sort((y,M)=>y.action.localeCompare(M.action));const h={};c.forEach(y=>{h[y.ability]||(h[y.ability]=[]),h[y.ability].push(y.action)});const l=Object.keys(h).map(y=>(n++,`(${n}) '${y}': '${h[y].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function Tl(t){var e;const r=Vs(t);On(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Fl(t){const e=Vs(t);On(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function aa(t){if(!t)return;const e=t?.[t.length-1];return A4(e)?e:void 0}function ic(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Cl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Or(t,...e){if(!Cl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Bl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function $4(t,e){Or(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ll(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const an=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),R4=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function N4(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function nc(t){if(typeof t=="string")t=N4(t);else if(Cl(t))t=sc(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function T4(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function F4(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const C4=(t,e)=>{function r(i,...n){if(Or(i),t.nonceLength!==void 0){const h=n[0];if(!h)throw new Error("nonce / iv required");t.varSizeNonce?Or(h):Or(h,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&Or(n[1]);const o=e(i,...n),a=(h,l)=>{if(l!==void 0){if(h!==2)throw new Error("cipher output not supported");Or(l)}};let c=!1;return{encrypt(h,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Or(h),a(o.encrypt.length,l),o.encrypt(h,l)},decrypt(h,l){if(Or(h),s&&h.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,l),o.decrypt(h,l)}}}return Object.assign(r,t),r};function ql(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!B4(e))throw new Error("invalid output, must be aligned");return e}function Ul(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}function B4(t){return t.byteOffset%4===0}function sc(t){return Uint8Array.from(t)}function ds(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const zl=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),L4=zl("expand 16-byte k"),q4=zl("expand 32-byte k"),U4=an(L4),z4=an(q4);function ze(t,e){return t<<e|t>>>32-e}function oc(t){return t.byteOffset%4===0}const fa=64,k4=16,kl=2**32-1,jl=new Uint32Array;function j4(t,e,r,i,n,s,o,a){const c=n.length,h=new Uint8Array(fa),l=an(h),y=oc(n)&&oc(s),M=y?an(n):jl,I=y?an(s):jl;for(let S=0;S<c;o++){if(t(e,r,i,l,o,a),o>=kl)throw new Error("arx: counter overflow");const D=Math.min(fa,c-S);if(y&&D===fa){const R=S/4;if(S%4!==0)throw new Error("arx: invalid block position");for(let $=0,N;$<k4;$++)N=R+$,I[N]=M[N]^l[$];S+=fa;continue}for(let R=0,$;R<D;R++)$=S+R,s[$]=n[$]^h[R];S+=D}}function K4(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=T4({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return ic(n),ic(o),Ll(s),Ll(r),(a,c,h,l,y=0)=>{Or(a),Or(c),Or(h);const M=h.length;if(l===void 0&&(l=new Uint8Array(M)),Or(l),ic(y),y<0||y>=kl)throw new Error("arx: counter overflow");if(l.length<M)throw new Error(`arx: output (${l.length}) is shorter than data (${M})`);const I=[];let S=a.length,D,R;if(S===32)I.push(D=sc(a)),R=z4;else if(S===16&&r)D=new Uint8Array(32),D.set(a),D.set(a,16),R=U4,I.push(D);else throw new Error(`arx: invalid 32-byte key, got length=${S}`);oc(c)||I.push(c=sc(c));const $=an(D);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(R,$,an(c.subarray(0,16)),$),c=c.subarray(16)}const N=16-n;if(N!==c.length)throw new Error(`arx: nonce must be ${N} or 16 bytes`);if(N!==12){const L=new Uint8Array(12);L.set(c,s?0:12-c.length),c=L,I.push(c)}const C=an(c);return j4(t,R,$,C,h,l,y,o),ds(...I),l}}const Wt=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class V4{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=nc(e),Or(e,32);const r=Wt(e,0),i=Wt(e,2),n=Wt(e,4),s=Wt(e,6),o=Wt(e,8),a=Wt(e,10),c=Wt(e,12),h=Wt(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|h<<8)&8191,this.r[9]=h>>>5&127;for(let l=0;l<8;l++)this.pad[l]=Wt(e,16+2*l)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],h=o[2],l=o[3],y=o[4],M=o[5],I=o[6],S=o[7],D=o[8],R=o[9],$=Wt(e,r+0),N=Wt(e,r+2),C=Wt(e,r+4),L=Wt(e,r+6),k=Wt(e,r+8),j=Wt(e,r+10),G=Wt(e,r+12),K=Wt(e,r+14);let V=s[0]+($&8191),ie=s[1]+(($>>>13|N<<3)&8191),O=s[2]+((N>>>10|C<<6)&8191),g=s[3]+((C>>>7|L<<9)&8191),p=s[4]+((L>>>4|k<<12)&8191),f=s[5]+(k>>>1&8191),u=s[6]+((k>>>14|j<<2)&8191),b=s[7]+((j>>>11|G<<5)&8191),_=s[8]+((G>>>8|K<<8)&8191),E=s[9]+(K>>>5|n),w=0,d=w+V*a+ie*(5*R)+O*(5*D)+g*(5*S)+p*(5*I);w=d>>>13,d&=8191,d+=f*(5*M)+u*(5*y)+b*(5*l)+_*(5*h)+E*(5*c),w+=d>>>13,d&=8191;let m=w+V*c+ie*a+O*(5*R)+g*(5*D)+p*(5*S);w=m>>>13,m&=8191,m+=f*(5*I)+u*(5*M)+b*(5*y)+_*(5*l)+E*(5*h),w+=m>>>13,m&=8191;let v=w+V*h+ie*c+O*a+g*(5*R)+p*(5*D);w=v>>>13,v&=8191,v+=f*(5*S)+u*(5*I)+b*(5*M)+_*(5*y)+E*(5*l),w+=v>>>13,v&=8191;let A=w+V*l+ie*h+O*c+g*a+p*(5*R);w=A>>>13,A&=8191,A+=f*(5*D)+u*(5*S)+b*(5*I)+_*(5*M)+E*(5*y),w+=A>>>13,A&=8191;let U=w+V*y+ie*l+O*h+g*c+p*a;w=U>>>13,U&=8191,U+=f*(5*R)+u*(5*D)+b*(5*S)+_*(5*I)+E*(5*M),w+=U>>>13,U&=8191;let x=w+V*M+ie*y+O*l+g*h+p*c;w=x>>>13,x&=8191,x+=f*a+u*(5*R)+b*(5*D)+_*(5*S)+E*(5*I),w+=x>>>13,x&=8191;let T=w+V*I+ie*M+O*y+g*l+p*h;w=T>>>13,T&=8191,T+=f*c+u*a+b*(5*R)+_*(5*D)+E*(5*S),w+=T>>>13,T&=8191;let B=w+V*S+ie*I+O*M+g*y+p*l;w=B>>>13,B&=8191,B+=f*h+u*c+b*a+_*(5*R)+E*(5*D),w+=B>>>13,B&=8191;let q=w+V*D+ie*S+O*I+g*M+p*y;w=q>>>13,q&=8191,q+=f*l+u*h+b*c+_*a+E*(5*R),w+=q>>>13,q&=8191;let z=w+V*R+ie*D+O*S+g*I+p*M;w=z>>>13,z&=8191,z+=f*y+u*l+b*h+_*c+E*a,w+=z>>>13,z&=8191,w=(w<<2)+w|0,w=w+d|0,d=w&8191,w=w>>>13,m+=w,s[0]=d,s[1]=m,s[2]=v,s[3]=A,s[4]=U,s[5]=x,s[6]=T,s[7]=B,s[8]=q,s[9]=z}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;ds(i)}update(e){Bl(this);const{buffer:r,blockLen:i}=this;e=nc(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){ds(this.h,this.r,this.buffer,this.pad)}digestInto(e){Bl(this),$4(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:n}=this;if(n){for(r[n++]=1;n<16;n++)r[n]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function H4(t){const e=(i,n)=>t(n).update(nc(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const W4=H4(t=>new V4(t));function G4(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],h=t[3],l=e[0],y=e[1],M=e[2],I=e[3],S=e[4],D=e[5],R=e[6],$=e[7],N=n,C=r[0],L=r[1],k=r[2],j=o,G=a,K=c,V=h,ie=l,O=y,g=M,p=I,f=S,u=D,b=R,_=$,E=N,w=C,d=L,m=k;for(let A=0;A<s;A+=2)j=j+ie|0,E=ze(E^j,16),f=f+E|0,ie=ze(ie^f,12),j=j+ie|0,E=ze(E^j,8),f=f+E|0,ie=ze(ie^f,7),G=G+O|0,w=ze(w^G,16),u=u+w|0,O=ze(O^u,12),G=G+O|0,w=ze(w^G,8),u=u+w|0,O=ze(O^u,7),K=K+g|0,d=ze(d^K,16),b=b+d|0,g=ze(g^b,12),K=K+g|0,d=ze(d^K,8),b=b+d|0,g=ze(g^b,7),V=V+p|0,m=ze(m^V,16),_=_+m|0,p=ze(p^_,12),V=V+p|0,m=ze(m^V,8),_=_+m|0,p=ze(p^_,7),j=j+O|0,m=ze(m^j,16),b=b+m|0,O=ze(O^b,12),j=j+O|0,m=ze(m^j,8),b=b+m|0,O=ze(O^b,7),G=G+g|0,E=ze(E^G,16),_=_+E|0,g=ze(g^_,12),G=G+g|0,E=ze(E^G,8),_=_+E|0,g=ze(g^_,7),K=K+p|0,w=ze(w^K,16),f=f+w|0,p=ze(p^f,12),K=K+p|0,w=ze(w^K,8),f=f+w|0,p=ze(p^f,7),V=V+ie|0,d=ze(d^V,16),u=u+d|0,ie=ze(ie^u,12),V=V+ie|0,d=ze(d^V,8),u=u+d|0,ie=ze(ie^u,7);let v=0;i[v++]=o+j|0,i[v++]=a+G|0,i[v++]=c+K|0,i[v++]=h+V|0,i[v++]=l+ie|0,i[v++]=y+O|0,i[v++]=M+g|0,i[v++]=I+p|0,i[v++]=S+f|0,i[v++]=D+u|0,i[v++]=R+b|0,i[v++]=$+_|0,i[v++]=N+E|0,i[v++]=C+w|0,i[v++]=L+d|0,i[v++]=k+m|0}const J4=K4(G4,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Y4=new Uint8Array(16),Kl=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(Y4.subarray(r))},Z4=new Uint8Array(32);function Vl(t,e,r,i,n){const s=t(e,r,Z4),o=W4.create(s);n&&Kl(o,n),Kl(o,i);const a=new Uint8Array(16),c=R4(a);Ul(c,0,BigInt(n?n.length:0),!0),Ul(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return ds(s,a),h}const X4=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=ql(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=Vl(t,e,r,a,i);return s.set(c,o),ds(c),s},decrypt(n,s){s=ql(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Vl(t,e,r,o,i);if(!F4(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),ds(c),s}}),Hl=C4({blockSize:64,nonceLength:12,tagLength:16},X4(J4));class Wl extends Qf{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Zf(e);const i=us(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return cs(this),this.iHash.update(e),this}digestInto(e){cs(this),na(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ac=(t,e,r)=>new Wl(t,e).update(r).digest();ac.create=(t,e)=>new Wl(t,e);function Q4(t,e,r){return Zf(t),r===void 0&&(r=new Uint8Array(t.outputLen)),ac(t,us(r),us(e))}const fc=new Uint8Array([0]),Gl=new Uint8Array;function e8(t,e,r,i=32){if(Zf(t),ks(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=Gl);const s=new Uint8Array(n*t.outputLen),o=ac.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let h=0;h<n;h++)fc[0]=h+1,a.update(h===0?Gl:c).update(r).update(fc).digestInto(c),s.set(c,t.outputLen*h),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),fc.fill(0),s.slice(0,i)}const t8=(t,e,r,i,n)=>e8(t,Q4(t,e,r),i,n);function r8(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}function i8(t,e,r){return t&e^~t&r}function n8(t,e,r){return t&e^t&r^e&r}class s8 extends Qf{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Xf(this.buffer)}update(e){cs(this);const{view:r,buffer:i,blockLen:n}=this;e=us(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Xf(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){cs(this),yl(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let y=o;y<n;y++)r[y]=0;r8(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Xf(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,l=this.get();if(h>l.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)a.setUint32(4*y,l[y],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const o8=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]),fn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),cn=new Uint32Array(64);class a8 extends s8{constructor(){super(64,32,8,!1),this.A=fn[0]|0,this.B=fn[1]|0,this.C=fn[2]|0,this.D=fn[3]|0,this.E=fn[4]|0,this.F=fn[5]|0,this.G=fn[6]|0,this.H=fn[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let y=0;y<16;y++,r+=4)cn[y]=e.getUint32(r,!1);for(let y=16;y<64;y++){const M=cn[y-15],I=cn[y-2],S=gi(M,7)^gi(M,18)^M>>>3,D=gi(I,17)^gi(I,19)^I>>>10;cn[y]=D+cn[y-7]+S+cn[y-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:h,H:l}=this;for(let y=0;y<64;y++){const M=gi(a,6)^gi(a,11)^gi(a,25),I=l+M+i8(a,c,h)+o8[y]+cn[y]|0,S=(gi(i,2)^gi(i,13)^gi(i,22))+n8(i,n,s)|0;l=h,h=c,c=a,a=o+I|0,o=s,s=n,n=i,i=I+S|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,l=l+this.H|0,this.set(i,n,s,o,a,c,h,l)}roundClean(){cn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ca=xl(()=>new a8);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jl=BigInt(0);function cc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Yl(t){if(!cc(t))throw new Error("Uint8Array expected")}const f8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function c8(t){Yl(t);let e="";for(let r=0;r<t.length;r++)e+=f8[t[r]];return e}function h8(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Jl:BigInt("0x"+t)}const Pi={_0:48,_9:57,A:65,F:70,a:97,f:102};function Zl(t){if(t>=Pi._0&&t<=Pi._9)return t-Pi._0;if(t>=Pi.A&&t<=Pi.F)return t-(Pi.A-10);if(t>=Pi.a&&t<=Pi.f)return t-(Pi.a-10)}function Xl(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=Zl(t.charCodeAt(s)),a=Zl(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Ql(t){return Yl(t),h8(c8(Uint8Array.from(t).reverse()))}function u8(t,e){return Xl(t.toString(16).padStart(e*2,"0"))}function d8(t,e){return u8(t,e).reverse()}function e0(t,e,r){let i;if(typeof e=="string")try{i=Xl(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(cc(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}const hc=t=>typeof t=="bigint"&&Jl<=t;function l8(t,e,r){return hc(t)&&hc(e)&&hc(r)&&e<=t&&t<r}function t0(t,e,r,i){if(!l8(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const p8={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||cc(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function g8(t,e,r={}){const i=(n,s,o)=>{const a=p8[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const ls=BigInt(0),ha=BigInt(1);function r0(t,e){const r=t%e;return r>=ls?r:e+r}function b8(t,e,r){if(e<ls)throw new Error("invalid exponent, negatives unsupported");if(r<=ls)throw new Error("invalid modulus");if(r===ha)return ls;let i=ha;for(;e>ls;)e&ha&&(i=i*t%r),t=t*t%r,e>>=ha;return i}function Xr(t,e,r){let i=t;for(;e-- >ls;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const ps=BigInt(0),uc=BigInt(1);function v8(t){return g8(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function y8(t){const e=v8(t),{P:r}=e,i=N=>r0(N,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(N=>N),c=e.powPminus2||(N=>b8(N,r-BigInt(2),r));function h(N,C,L){const k=i(N*(C-L));return C=i(C-k),L=i(L+k),[C,L]}const l=(e.a-BigInt(2))/BigInt(4);function y(N,C){t0("u",N,ps,r),t0("scalar",C,ps,r);const L=C,k=N;let j=uc,G=ps,K=N,V=uc,ie=ps,O;for(let p=BigInt(n-1);p>=ps;p--){const f=L>>p&uc;ie^=f,O=h(ie,j,K),j=O[0],K=O[1],O=h(ie,G,V),G=O[0],V=O[1],ie=f;const u=j+G,b=i(u*u),_=j-G,E=i(_*_),w=b-E,d=K+V,m=K-V,v=i(m*u),A=i(d*_),U=v+A,x=v-A;K=i(U*U),V=i(k*i(x*x)),j=i(b*E),G=i(w*(b+i(l*w)))}O=h(ie,j,K),j=O[0],K=O[1],O=h(ie,G,V),G=O[0],V=O[1];const g=c(G);return i(j*g)}function M(N){return d8(i(N),s)}function I(N){const C=e0("u coordinate",N,s);return o===32&&(C[31]&=127),Ql(C)}function S(N){const C=e0("scalar",N),L=C.length;if(L!==s&&L!==o){let k=""+s+" or "+o;throw new Error("invalid scalar, expected "+k+" bytes, got "+L)}return Ql(a(C))}function D(N,C){const L=I(C),k=S(N),j=y(L,k);if(j===ps)throw new Error("invalid private or public key received");return M(j)}const R=M(e.Gu);function $(N){return D(N,R)}return{scalarMult:D,scalarMultBase:$,getSharedSecret:(N,C)=>D(N,C),getPublicKey:N=>$(N),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:R}}const dc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const m8=BigInt(1),i0=BigInt(2),w8=BigInt(3),_8=BigInt(5);BigInt(8);function x8(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=dc,o=t*t%s*t%s,a=Xr(o,i0,s)*o%s,c=Xr(a,m8,s)*t%s,h=Xr(c,_8,s)*c%s,l=Xr(h,e,s)*h%s,y=Xr(l,r,s)*l%s,M=Xr(y,i,s)*y%s,I=Xr(M,n,s)*M%s,S=Xr(I,n,s)*M%s,D=Xr(S,e,s)*h%s;return{pow_p_5_8:Xr(D,i0,s)*t%s,b2:o}}function E8(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const lc=y8({P:dc,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=dc,{pow_p_5_8:r,b2:i}=x8(t);return r0(Xr(r,w8,e)*i,e)},adjustScalarBytes:E8,randomBytes:js}),n0="base10",rr="base16",hn="base64pad",Hs="base64url",Ws="utf8",s0=0,$i=1,Gs=2,S8=0,o0=1,Js=12,pc=32;function M8(){const t=lc.utils.randomPrivateKey(),e=lc.getPublicKey(t);return{privateKey:cr(t,rr),publicKey:cr(e,rr)}}function gc(){const t=js(pc);return cr(t,rr)}function I8(t,e){const r=lc.getSharedSecret(Cr(t,rr),Cr(e,rr)),i=t8(ca,r,void 0,void 0,pc);return cr(i,rr)}function ua(t){const e=ca(Cr(t,rr));return cr(e,rr)}function Ri(t){const e=ca(Cr(t,Ws));return cr(e,rr)}function a0(t){return Cr(`${t}`,n0)}function Pn(t){return Number(cr(t,n0))}function A8(t){const e=a0(typeof t.type<"u"?t.type:s0);if(Pn(e)===$i&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Cr(t.senderPublicKey,rr):void 0,i=typeof t.iv<"u"?Cr(t.iv,rr):js(Js),n=Cr(t.symKey,rr),s=Hl(n,i).encrypt(Cr(t.message,Ws));return f0({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function D8(t){const e=Cr(t.symKey,rr),{sealed:r,iv:i}=Ys(t),n=Hl(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return cr(n,Ws)}function O8(t,e){const r=a0(Gs),i=js(Js),n=Cr(t,Ws);return f0({type:r,sealed:n,iv:i,encoding:e})}function P8(t,e){const{sealed:r}=Ys({encoded:t,encoding:e});return cr(r,Ws)}function f0(t){const{encoding:e=hn}=t;if(Pn(t.type)===Gs)return cr(Ff([t.type,t.sealed]),e);if(Pn(t.type)===$i){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return cr(Ff([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return cr(Ff([t.type,t.iv,t.sealed]),e)}function Ys(t){const{encoded:e,encoding:r=hn}=t,i=Cr(e,r),n=i.slice(S8,o0),s=o0;if(Pn(n)===$i){const h=s+pc,l=h+Js,y=i.slice(s,h),M=i.slice(h,l),I=i.slice(l);return{type:n,sealed:I,iv:M,senderPublicKey:y}}if(Pn(n)===Gs){const h=i.slice(s),l=js(Js);return{type:n,sealed:h,iv:l}}const o=s+Js,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function $8(t,e){const r=Ys({encoded:t,encoding:e?.encoding});return c0({type:Pn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?cr(r.senderPublicKey,rr):void 0,receiverPublicKey:e?.receiverPublicKey})}function c0(t){const e=t?.type||s0;if(e===$i){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function h0(t){return t.type===$i&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function u0(t){return t.type===Gs}function R8(t){return new Wd.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function N8(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function T8(t){return Buffer.from(N8(t),"base64")}function F8(t,e){const[r,i,n]=t.split("."),s=T8(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,h=ca(c),l=R8(e),y=cr(h,rr);if(!l.verify(y,{r:o,s:a}))throw new Error("Invalid signature");return uf(t).payload}const C8="irn";function da(t){return t?.relay||{protocol:C8}}function Zs(t){const e=_6[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function B8(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function d0(t){if(!t.includes("wc:")){const h=vl(t);h!=null&&h.includes("wc:")&&(t=h)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a={};o.forEach((h,l)=>{a[l]=h});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:L8(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:B8(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function L8(t){return t.startsWith("//")?t.substring(2):t}function q8(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=r+e+n;t[n]&&(i[s]=t[n])}),i}function l0(t){const e=new URLSearchParams,r=q8(t.relay);Object.keys(r).sort().forEach(n=>{e.set(n,r[n])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function la(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function gs(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function U8(t){const e=[];return Object.values(t).forEach(r=>{e.push(...gs(r.accounts))}),e}function z8(t,e){const r=[];return Object.values(t).forEach(i=>{gs(i.accounts).includes(e)&&r.push(...i.methods)}),r}function k8(t,e){const r=[];return Object.values(t).forEach(i=>{gs(i.accounts).includes(e)&&r.push(...i.events)}),r}function j8(t){const e={};return t?.forEach(r=>{const[i,n]=r.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(r),e[i].chains.push(`${i}:${n}`)}),e}function p0(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=j8(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=N6(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const K8={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},V8={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Q(t,e){const{message:r,code:i}=V8[t];return{message:e?`${r} ${e}`:r,code:i}}function pt(t,e){const{message:r,code:i}=K8[t];return{message:e?`${r} ${e}`:r,code:i}}function Xs(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function pa(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function hr(t){return typeof t>"u"}function Mt(t,e){return e&&hr(t)?!0:typeof t=="string"&&!!t.trim().length}function bc(t,e){return e&&hr(t)?!0:typeof t=="number"&&!isNaN(t)}function H8(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return An(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:h}=t.namespaces[o],l=gs(a),y=r[o];(!An(al(o,y),l)||!An(y.methods,c)||!An(y.events,h))&&(s=!1)}),s):!1}function ga(t){return Mt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function W8(t){if(Mt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ga(r)}}return!1}function G8(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(Mt(t,!1)){if(e(t))return!0;const r=vl(t);return e(r)}}catch{}return!1}function J8(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function Y8(t){return t?.topic}function Z8(t,e){let r=null;return Mt(t?.publicKey,!1)||(r=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function g0(t){let e=!0;return Xs(t)?t.length&&(e=t.every(r=>Mt(r,!1))):e=!1,e}function X8(t,e,r){let i=null;return Xs(e)&&e.length?e.forEach(n=>{i||ga(n)||(i=pt("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):ga(t)||(i=pt("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Q8(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=X8(n,al(n,s),`${e} ${r}`);o&&(i=o)}),i}function e5(t,e){let r=null;return Xs(t)?t.forEach(i=>{r||W8(i)||(r=pt("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=pt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function t5(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=e5(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function r5(t,e){let r=null;return g0(t?.methods)?g0(t?.events)||(r=pt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=pt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function b0(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=r5(i,`${e}, namespace`);n&&(r=n)}),r}function i5(t,e,r){let i=null;if(t&&pa(t)){const n=b0(t,e);n&&(i=n);const s=Q8(t,e,r);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function vc(t,e){let r=null;if(t&&pa(t)){const i=b0(t,e);i&&(r=i);const n=t5(t,e);n&&(r=n)}else r=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function v0(t){return Mt(t.protocol,!0)}function n5(t,e){let r=!1;return e&&!t?r=!0:t&&Xs(t)&&t.length&&t.forEach(i=>{r=v0(i)}),r}function s5(t){return typeof t=="number"}function vr(t){return typeof t<"u"&&typeof t!==null}function o5(t){return!(!t||typeof t!="object"||!t.code||!bc(t.code,!1)||!t.message||!Mt(t.message,!1))}function a5(t){return!(hr(t)||!Mt(t.method,!1))}function f5(t){return!(hr(t)||hr(t.result)&&hr(t.error)||!bc(t.id,!1)||!Mt(t.jsonrpc,!1))}function c5(t){return!(hr(t)||!Mt(t.name,!1))}function y0(t,e){return!(!ga(e)||!U8(t).includes(e))}function h5(t,e,r){return Mt(r,!1)?z8(t,e).includes(r):!1}function u5(t,e,r){return Mt(r,!1)?k8(t,e).includes(r):!1}function m0(t,e,r){let i=null;const n=d5(t),s=l5(e),o=Object.keys(n),a=Object.keys(s),c=w0(Object.keys(t)),h=w0(Object.keys(e)),l=c.filter(y=>!h.includes(y));return l.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
25
|
-
Required: ${l.toString()}
|
|
26
|
-
Received: ${Object.keys(e).toString()}`)),An(o,a)||(i=Q("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
14
|
+
***************************************************************************** */var za=function(t,e){return za=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},za(t,e)};function X1(t,e){za(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Ua=function(){return Ua=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Ua.apply(this,arguments)};function Q1(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function eg(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function tg(t,e){return function(r,i){e(r,i,t)}}function rg(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ig(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(h){try{f(i.next(h))}catch(l){o(l)}}function c(h){try{f(i.throw(h))}catch(l){o(l)}}function f(h){h.done?s(h.value):n(h.value).then(a,c)}f((i=i.apply(t,e||[])).next())})}function ng(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(h){return c([f,h])}}function c(f){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=f[0]&2?n.return:f[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,f[1])).done)return s;switch(n=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,n=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(h){f=[6,h],n=0}finally{i=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function sg(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function og(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function ka(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pu(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function ag(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Pu(arguments[e]));return t}function cg(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function is(t){return this instanceof is?(this.v=t,this):new is(t)}function fg(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(g){i[g]&&(n[g]=function(w){return new Promise(function(b,E){s.push([g,w,b,E])>1||a(g,w)})})}function a(g,w){try{c(i[g](w))}catch(b){l(s[0][3],b)}}function c(g){g.value instanceof is?Promise.resolve(g.value.v).then(f,h):l(s[0][2],g)}function f(g){a("next",g)}function h(g){a("throw",g)}function l(g,w){g(w),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ug(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:is(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function hg(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof ka=="function"?ka(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(f){s({value:f,done:a})},o)}}function dg(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function lg(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function pg(t){return t&&t.__esModule?t:{default:t}}function gg(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function bg(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var yg=Object.freeze({__proto__:null,__extends:X1,get __assign(){return Ua},__rest:Q1,__decorate:eg,__param:tg,__metadata:rg,__awaiter:ig,__generator:ng,__createBinding:sg,__exportStar:og,__values:ka,__read:Pu,__spread:ag,__spreadArrays:cg,__await:is,__asyncGenerator:fg,__asyncDelegator:ug,__asyncValues:hg,__makeTemplateObject:dg,__importStar:lg,__importDefault:pg,__classPrivateFieldGet:gg,__classPrivateFieldSet:bg}),go=La(yg),ja={},ns={},Ru;function vg(){if(Ru)return ns;Ru=1,Object.defineProperty(ns,"__esModule",{value:!0}),ns.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ns.delay=t,ns}var Ti={},Ka={},Ni={},Tu;function mg(){return Tu||(Tu=1,Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.ONE_THOUSAND=Ni.ONE_HUNDRED=void 0,Ni.ONE_HUNDRED=100,Ni.ONE_THOUSAND=1e3),Ni}var Va={},Nu;function wg(){return Nu||(Nu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(Va)),Va}var Cu;function Bu(){return Cu||(Cu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(mg(),t),e.__exportStar(wg(),t)}(Ka)),Ka}var Fu;function _g(){if(Fu)return Ti;Fu=1,Object.defineProperty(Ti,"__esModule",{value:!0}),Ti.fromMiliseconds=Ti.toMiliseconds=void 0;const t=Bu();function e(i){return i*t.ONE_THOUSAND}Ti.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Ti.fromMiliseconds=r,Ti}var Lu;function xg(){return Lu||(Lu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(vg(),t),e.__exportStar(_g(),t)}(ja)),ja}var pn={},qu;function Eg(){if(qu)return pn;qu=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return pn.Watch=t,pn.default=t,pn}var Ha={},ss={},zu;function Sg(){if(zu)return ss;zu=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.IWatch=void 0;class t{}return ss.IWatch=t,ss}var Uu;function Ig(){return Uu||(Uu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),go.__exportStar(Sg(),t)}(Ha)),Ha}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(xg(),t),e.__exportStar(Eg(),t),e.__exportStar(Ig(),t),e.__exportStar(Bu(),t)})(V);class Ci{}class Ag extends Ci{constructor(e){super()}}const ku=V.FIVE_SECONDS,gn={pulse:"heartbeat_pulse"};class Wa extends Ag{constructor(e){super(e),this.events=new Ot.exports.EventEmitter,this.interval=ku,this.interval=e?.interval||ku}static async init(e){const r=new Wa(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),V.toMiliseconds(this.interval))}pulse(){this.events.emit(gn.pulse)}}const Dg=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,$g=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Og=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Mg(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Pg(t);return}return e}function Pg(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function bo(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!Og.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Dg.test(t)||$g.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,Mg)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function Rg(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function ft(t,...e){try{return Rg(t(...e))}catch(r){return Promise.reject(r)}}function Tg(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function Ng(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function yo(t){if(Tg(t))return String(t);if(Ng(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return yo(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function ju(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ga="base64:";function Cg(t){if(typeof t=="string")return t;ju();const e=Buffer.from(t).toString("base64");return Ga+e}function Bg(t){return typeof t!="string"||!t.startsWith(Ga)?t:(ju(),Buffer.from(t.slice(Ga.length),"base64"))}function zt(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Fg(...t){return zt(t.join(":"))}function vo(t){return t=zt(t),t?t+":":""}function hA(t){return t}const Lg="memory",qg=()=>{const t=new Map;return{name:Lg,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function zg(t={}){const e={mounts:{"":t.driver||qg()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=f=>{for(const h of e.mountpoints)if(f.startsWith(h))return{base:h,relativeKey:f.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:f,driver:e.mounts[""]}},i=(f,h)=>e.mountpoints.filter(l=>l.startsWith(f)||h&&f.startsWith(l)).map(l=>({relativeBase:f.length>l.length?f.slice(l.length):void 0,mountpoint:l,driver:e.mounts[l]})),n=(f,h)=>{if(e.watching){h=zt(h);for(const l of e.watchListeners)l(f,h)}},s=async()=>{if(!e.watching){e.watching=!0;for(const f in e.mounts)e.unwatch[f]=await Ku(e.mounts[f],n,f)}},o=async()=>{if(e.watching){for(const f in e.unwatch)await e.unwatch[f]();e.unwatch={},e.watching=!1}},a=(f,h,l)=>{const g=new Map,w=b=>{let E=g.get(b.base);return E||(E={driver:b.driver,base:b.base,items:[]},g.set(b.base,E)),E};for(const b of f){const E=typeof b=="string",A=zt(E?b:b.key),$=E?void 0:b.value,M=E||!b.options?h:{...h,...b.options},P=r(A);w(P).items.push({key:A,value:$,relativeKey:P.relativeKey,options:M})}return Promise.all([...g.values()].map(b=>l(b))).then(b=>b.flat())},c={hasItem(f,h={}){f=zt(f);const{relativeKey:l,driver:g}=r(f);return ft(g.hasItem,l,h)},getItem(f,h={}){f=zt(f);const{relativeKey:l,driver:g}=r(f);return ft(g.getItem,l,h).then(w=>bo(w))},getItems(f,h){return a(f,h,l=>l.driver.getItems?ft(l.driver.getItems,l.items.map(g=>({key:g.relativeKey,options:g.options})),h).then(g=>g.map(w=>({key:Fg(l.base,w.key),value:bo(w.value)}))):Promise.all(l.items.map(g=>ft(l.driver.getItem,g.relativeKey,g.options).then(w=>({key:g.key,value:bo(w)})))))},getItemRaw(f,h={}){f=zt(f);const{relativeKey:l,driver:g}=r(f);return g.getItemRaw?ft(g.getItemRaw,l,h):ft(g.getItem,l,h).then(w=>Bg(w))},async setItem(f,h,l={}){if(h===void 0)return c.removeItem(f);f=zt(f);const{relativeKey:g,driver:w}=r(f);w.setItem&&(await ft(w.setItem,g,yo(h),l),w.watch||n("update",f))},async setItems(f,h){await a(f,h,async l=>{if(l.driver.setItems)return ft(l.driver.setItems,l.items.map(g=>({key:g.relativeKey,value:yo(g.value),options:g.options})),h);l.driver.setItem&&await Promise.all(l.items.map(g=>ft(l.driver.setItem,g.relativeKey,yo(g.value),g.options)))})},async setItemRaw(f,h,l={}){if(h===void 0)return c.removeItem(f,l);f=zt(f);const{relativeKey:g,driver:w}=r(f);if(w.setItemRaw)await ft(w.setItemRaw,g,h,l);else if(w.setItem)await ft(w.setItem,g,Cg(h),l);else return;w.watch||n("update",f)},async removeItem(f,h={}){typeof h=="boolean"&&(h={removeMeta:h}),f=zt(f);const{relativeKey:l,driver:g}=r(f);g.removeItem&&(await ft(g.removeItem,l,h),(h.removeMeta||h.removeMata)&&await ft(g.removeItem,l+"$",h),g.watch||n("remove",f))},async getMeta(f,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),f=zt(f);const{relativeKey:l,driver:g}=r(f),w=Object.create(null);if(g.getMeta&&Object.assign(w,await ft(g.getMeta,l,h)),!h.nativeOnly){const b=await ft(g.getItem,l+"$",h).then(E=>bo(E));b&&typeof b=="object"&&(typeof b.atime=="string"&&(b.atime=new Date(b.atime)),typeof b.mtime=="string"&&(b.mtime=new Date(b.mtime)),Object.assign(w,b))}return w},setMeta(f,h,l={}){return this.setItem(f+"$",h,l)},removeMeta(f,h={}){return this.removeItem(f+"$",h)},async getKeys(f,h={}){f=vo(f);const l=i(f,!0);let g=[];const w=[];for(const b of l){const E=await ft(b.driver.getKeys,b.relativeBase,h);for(const A of E){const $=b.mountpoint+zt(A);g.some(M=>$.startsWith(M))||w.push($)}g=[b.mountpoint,...g.filter(A=>!A.startsWith(b.mountpoint))]}return f?w.filter(b=>b.startsWith(f)&&b[b.length-1]!=="$"):w.filter(b=>b[b.length-1]!=="$")},async clear(f,h={}){f=vo(f),await Promise.all(i(f,!1).map(async l=>{if(l.driver.clear)return ft(l.driver.clear,l.relativeBase,h);if(l.driver.removeItem){const g=await l.driver.getKeys(l.relativeBase||"",h);return Promise.all(g.map(w=>l.driver.removeItem(w,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(f=>Vu(f)))},async watch(f){return await s(),e.watchListeners.push(f),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==f),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(f,h){if(f=vo(f),f&&e.mounts[f])throw new Error(`already mounted at ${f}`);return f&&(e.mountpoints.push(f),e.mountpoints.sort((l,g)=>g.length-l.length)),e.mounts[f]=h,e.watching&&Promise.resolve(Ku(h,n,f)).then(l=>{e.unwatch[f]=l}).catch(console.error),c},async unmount(f,h=!0){f=vo(f),!(!f||!e.mounts[f])&&(e.watching&&f in e.unwatch&&(e.unwatch[f](),delete e.unwatch[f]),h&&await Vu(e.mounts[f]),e.mountpoints=e.mountpoints.filter(l=>l!==f),delete e.mounts[f])},getMount(f=""){f=zt(f)+":";const h=r(f);return{driver:h.driver,base:h.base}},getMounts(f="",h={}){return f=zt(f),i(f,h.parents).map(g=>({driver:g.driver,base:g.mountpoint}))},keys:(f,h={})=>c.getKeys(f,h),get:(f,h={})=>c.getItem(f,h),set:(f,h,l={})=>c.setItem(f,h,l),has:(f,h={})=>c.hasItem(f,h),del:(f,h={})=>c.removeItem(f,h),remove:(f,h={})=>c.removeItem(f,h)};return c}function Ku(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Vu(t){typeof t.dispose=="function"&&await ft(t.dispose)}function Bi(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Hu(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=Bi(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let Ya;function os(){return Ya||(Ya=Hu("keyval-store","keyval")),Ya}function Wu(t,e=os()){return e("readonly",r=>Bi(r.get(t)))}function Ug(t,e,r=os()){return r("readwrite",i=>(i.put(e,t),Bi(i.transaction)))}function kg(t,e=os()){return e("readwrite",r=>(r.delete(t),Bi(r.transaction)))}function jg(t=os()){return t("readwrite",e=>(e.clear(),Bi(e.transaction)))}function Kg(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Bi(t.transaction)}function Vg(t=os()){return t("readonly",e=>{if(e.getAllKeys)return Bi(e.getAllKeys());const r=[];return Kg(e,i=>r.push(i.key)).then(()=>r)})}const Hg=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Wg=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function bn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Wg(t)}catch{return t}}function Fi(t){return typeof t=="string"?t:Hg(t)||""}const Gg="idb-keyval";var Yg=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Hu(t.dbName,t.storeName)),{name:Gg,options:t,async hasItem(n){return!(typeof await Wu(r(n),i)>"u")},async getItem(n){return await Wu(r(n),i)??null},setItem(n,s){return Ug(r(n),s,i)},removeItem(n){return kg(r(n),i)},getKeys(){return Vg(i)},clear(){return jg(i)}}};const Jg="WALLET_CONNECT_V2_INDEXED_DB",Zg="keyvaluestorage";class Xg{constructor(){this.indexedDb=zg({driver:Yg({dbName:Jg,storeName:Zg})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,Fi(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},mo={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ja<"u"&&Ja.localStorage?mo.exports=Ja.localStorage:typeof window<"u"&&window.localStorage?mo.exports=window.localStorage:mo.exports=new e})();function Qg(t){var e;return[t[0],bn((e=t[1])!=null?e:"")]}class eb{constructor(){this.localStorage=mo.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Qg)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return bn(r)}async setItem(e,r){this.localStorage.setItem(e,Fi(r))}async removeItem(e){this.localStorage.removeItem(e)}}const tb="wc_storage_version",Gu=1,rb=async(t,e,r)=>{const i=tb,n=await e.getItem(i);if(n&&n>=Gu){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const f=await t.getItem(a);await e.setItem(a,f),o.push(a)}}await e.setItem(i,Gu),r(e),ib(t,o)},ib=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class nb{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new eb;this.storage=e;try{const r=new Xg;rb(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}function sb(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var ob=ab;function ab(t,e,r){var i=r&&r.stringify||sb,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a<s;a++)o[a]=i(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var f="",h=1-n,l=-1,g=t&&t.length||0,w=0;w<g;){if(t.charCodeAt(w)===37&&w+1<g){switch(l=l>-1?l:0,t.charCodeAt(w+1)){case 100:case 102:if(h>=c||e[h]==null)break;l<w&&(f+=t.slice(l,w)),f+=Number(e[h]),l=w+2,w++;break;case 105:if(h>=c||e[h]==null)break;l<w&&(f+=t.slice(l,w)),f+=Math.floor(Number(e[h])),l=w+2,w++;break;case 79:case 111:case 106:if(h>=c||e[h]===void 0)break;l<w&&(f+=t.slice(l,w));var b=typeof e[h];if(b==="string"){f+="'"+e[h]+"'",l=w+2,w++;break}if(b==="function"){f+=e[h].name||"<anonymous>",l=w+2,w++;break}f+=i(e[h]),l=w+2,w++;break;case 115:if(h>=c)break;l<w&&(f+=t.slice(l,w)),f+=String(e[h]),l=w+2,w++;break;case 37:l<w&&(f+=t.slice(l,w)),f+="%",l=w+2,w++,h--;break}++h}++w}return l===-1?t:(l<g&&(f+=t.slice(l)),f)}const Yu=ob;var Hr=Er;const as=yb().console||{},cb={mapHttpRequest:_o,mapHttpResponse:_o,wrapRequestSerializer:Xa,wrapResponseSerializer:Xa,wrapErrorSerializer:Xa,req:_o,res:_o,err:lb};function fb(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Er(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||as;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=fb(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=cs),Object.defineProperty(c,"levelVal",{get:h}),Object.defineProperty(c,"level",{get:l,set:g});const f={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:pb(t)};c.levels=Er.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=cs,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=w,e&&(c._logEvent=Za());function h(){return this.level==="silent"?1/0:this.levels.values[this.level]}function l(){return this._level}function g(b){if(b!=="silent"&&!this.levels.values[b])throw Error("unknown level "+b);this._level=b,yn(f,c,"error","log"),yn(f,c,"fatal","error"),yn(f,c,"warn","error"),yn(f,c,"info","log"),yn(f,c,"debug","log"),yn(f,c,"trace","log")}function w(b,E){if(!b)throw new Error("missing bindings for child Pino");E=E||{},n&&b.serializers&&(E.serializers=b.serializers);const A=E.serializers;if(n&&A){var $=Object.assign({},i,A),M=t.browser.serialize===!0?Object.keys($):n;delete b.serializers,wo([b],M,$,this._stdErrSerialize)}function P(R){this._childLevel=(R._childLevel|0)+1,this.error=vn(R,b,"error"),this.fatal=vn(R,b,"fatal"),this.warn=vn(R,b,"warn"),this.info=vn(R,b,"info"),this.debug=vn(R,b,"debug"),this.trace=vn(R,b,"trace"),$&&(this.serializers=$,this._serialize=M),e&&(this._logEvent=Za([].concat(R._logEvent.bindings,b)))}return P.prototype=this,new P(this)}return c}Er.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Er.stdSerializers=cb,Er.stdTimeFunctions=Object.assign({},{nullTime:Ju,epochTime:Zu,unixTime:gb,isoTime:bb});function yn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?cs:n[r]?n[r]:as[r]||as[i]||cs,ub(t,e,r)}function ub(t,e,r){!t.transmit&&e[r]===cs||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===as?as:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&wo(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,hb(this,r,o,s)):i.apply(a,o),t.transmit){const f=t.transmit.level||e.level,h=Er.levels.values[f],l=Er.levels.values[r];if(l<h)return;db(this,{ts:s,methodLevel:r,methodValue:l,transmitLevel:f,transmitValue:Er.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function hb(t,e,r,i){t._serialize&&wo(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Er.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Yu(n.shift(),n):void 0}else typeof s=="string"&&(s=Yu(n.shift(),n));return s!==void 0&&(o.msg=s),o}function wo(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Er.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function vn(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function db(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;wo(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(f){return c.indexOf(f)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=Za(c)}function Za(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function lb(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function pb(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Ju:Zu}function _o(){return{}}function Xa(t){return t}function cs(){}function Ju(){return!1}function Zu(){return Date.now()}function gb(){return Math.round(Date.now()/1e3)}function bb(){return new Date(Date.now()).toISOString()}function yb(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const vb={level:"info"},fs="custom_context",Qa=1e3*1024;class mb{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class Xu{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new mb(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}}class Qu{constructor(e,r=Qa){this.level=e??"error",this.levelValue=Hr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Xu(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Hr.levels.values.error?console.error(e):r===Hr.levels.values.warn?console.warn(e):r===Hr.levels.values.debug?console.debug(e):r===Hr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Fi({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new Xu(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Fi({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class wb{constructor(e,r=Qa){this.baseChunkLogger=new Qu(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}}class _b{constructor(e,r=Qa){this.baseChunkLogger=new Qu(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var xb=Object.defineProperty,Eb=Object.defineProperties,Sb=Object.getOwnPropertyDescriptors,eh=Object.getOwnPropertySymbols,Ib=Object.prototype.hasOwnProperty,Ab=Object.prototype.propertyIsEnumerable,th=(t,e,r)=>e in t?xb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xo=(t,e)=>{for(var r in e||(e={}))Ib.call(e,r)&&th(t,r,e[r]);if(eh)for(var r of eh(e))Ab.call(e,r)&&th(t,r,e[r]);return t},Eo=(t,e)=>Eb(t,Sb(e));function ec(t){return Eo(xo({},t),{level:t?.level||vb.level})}function Db(t,e=fs){return t[e]||""}function $b(t,e,r=fs){return t[r]=e,t}function Ut(t,e=fs){let r="";return typeof t.bindings>"u"?r=Db(t,e):r=t.bindings().context||"",r}function Ob(t,e,r=fs){const i=Ut(t,r);return i.trim()?`${i}/${e}`:e}function Bt(t,e,r=fs){const i=Ob(t,e,r),n=t.child({context:i});return $b(n,i,r)}function Mb(t){var e,r;const i=new wb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Hr(Eo(xo({},t.opts),{level:"trace",browser:Eo(xo({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function Pb(t){var e;const r=new _b((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Hr(Eo(xo({},t.opts),{level:"trace"})),chunkLoggerController:r}}function Rb(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Mb(t):Pb(t)}var Tb=Object.defineProperty,Nb=(t,e,r)=>e in t?Tb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rh=(t,e,r)=>Nb(t,typeof e!="symbol"?e+"":e,r);class Cb extends Ci{constructor(e){super(),this.opts=e,rh(this,"protocol","wc"),rh(this,"version",2)}}var Bb=Object.defineProperty,Fb=(t,e,r)=>e in t?Bb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Lb=(t,e,r)=>Fb(t,typeof e!="symbol"?e+"":e,r);class qb extends Ci{constructor(e,r){super(),this.core=e,this.logger=r,Lb(this,"records",new Map)}}class zb{constructor(e,r){this.logger=e,this.core=r}}class Ub extends Ci{constructor(e,r){super(),this.relayer=e,this.logger=r}}class kb extends Ci{constructor(e){super()}}class jb{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Kb extends Ci{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Vb extends Ci{constructor(e,r){super(),this.core=e,this.logger=r}}class Hb{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class Wb{constructor(e,r){this.projectId=e,this.logger=r}}class Gb{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}var Yb=Object.defineProperty,Jb=(t,e,r)=>e in t?Yb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ih=(t,e,r)=>Jb(t,typeof e!="symbol"?e+"":e,r);class Zb{constructor(e){this.opts=e,ih(this,"protocol","wc"),ih(this,"version",2)}}class Xb{constructor(e){this.client=e}}function Qb(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function nh(t,...e){if(!Qb(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function sh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ey(t,e){nh(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const mn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tc=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function ty(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function oh(t){return typeof t=="string"&&(t=ty(t)),nh(t),t}class ry{clone(){return this._cloneInto()}}function iy(t){const e=i=>t().update(oh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ah(t=32){if(mn&&typeof mn.getRandomValues=="function")return mn.getRandomValues(new Uint8Array(t));if(mn&&typeof mn.randomBytes=="function")return mn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function ny(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}class sy extends ry{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=tc(this.buffer)}update(e){sh(this);const{view:r,buffer:i,blockLen:n}=this;e=oh(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=tc(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){sh(this),ey(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let l=o;l<n;l++)r[l]=0;ny(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=tc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,h[l],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const So=BigInt(2**32-1),rc=BigInt(32);function ch(t,e=!1){return e?{h:Number(t&So),l:Number(t>>rc&So)}:{h:Number(t>>rc&So)|0,l:Number(t&So)|0}}function oy(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=ch(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const ay=(t,e)=>BigInt(t>>>0)<<rc|BigInt(e>>>0),cy=(t,e,r)=>t>>>r,fy=(t,e,r)=>t<<32-r|e>>>r,uy=(t,e,r)=>t>>>r|e<<32-r,hy=(t,e,r)=>t<<32-r|e>>>r,dy=(t,e,r)=>t<<64-r|e>>>r-32,ly=(t,e,r)=>t>>>r-32|e<<64-r,py=(t,e)=>e,gy=(t,e)=>t,by=(t,e,r)=>t<<r|e>>>32-r,yy=(t,e,r)=>e<<r|t>>>32-r,vy=(t,e,r)=>e<<r-32|t>>>64-r,my=(t,e,r)=>t<<r-32|e>>>64-r;function wy(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const _y=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),xy=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,Ey=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),Sy=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,Iy=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),Ay=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,te={fromBig:ch,split:oy,toBig:ay,shrSH:cy,shrSL:fy,rotrSH:uy,rotrSL:hy,rotrBH:dy,rotrBL:ly,rotr32H:py,rotr32L:gy,rotlSH:by,rotlSL:yy,rotlBH:vy,rotlBL:my,add:wy,add3L:_y,add3H:xy,add4L:Ey,add4H:Sy,add5H:Ay,add5L:Iy},[Dy,$y]=(()=>te.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),fi=new Uint32Array(80),ui=new Uint32Array(80);class Oy extends sy{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:h,Fh:l,Fl:g,Gh:w,Gl:b,Hh:E,Hl:A}=this;return[e,r,i,n,s,o,a,c,f,h,l,g,w,b,E,A]}set(e,r,i,n,s,o,a,c,f,h,l,g,w,b,E,A){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=h|0,this.Fh=l|0,this.Fl=g|0,this.Gh=w|0,this.Gl=b|0,this.Hh=E|0,this.Hl=A|0}process(e,r){for(let P=0;P<16;P++,r+=4)fi[P]=e.getUint32(r),ui[P]=e.getUint32(r+=4);for(let P=16;P<80;P++){const R=fi[P-15]|0,N=ui[P-15]|0,L=te.rotrSH(R,N,1)^te.rotrSH(R,N,8)^te.shrSH(R,N,7),F=te.rotrSL(R,N,1)^te.rotrSL(R,N,8)^te.shrSL(R,N,7),B=fi[P-2]|0,C=ui[P-2]|0,W=te.rotrSH(B,C,19)^te.rotrBH(B,C,61)^te.shrSH(B,C,6),I=te.rotrSL(B,C,19)^te.rotrBL(B,C,61)^te.shrSL(B,C,6),u=te.add4L(F,I,ui[P-7],ui[P-16]),p=te.add4H(u,L,W,fi[P-7],fi[P-16]);fi[P]=p|0,ui[P]=u|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:h,Eh:l,El:g,Fh:w,Fl:b,Gh:E,Gl:A,Hh:$,Hl:M}=this;for(let P=0;P<80;P++){const R=te.rotrSH(l,g,14)^te.rotrSH(l,g,18)^te.rotrBH(l,g,41),N=te.rotrSL(l,g,14)^te.rotrSL(l,g,18)^te.rotrBL(l,g,41),L=l&w^~l&E,F=g&b^~g&A,B=te.add5L(M,N,F,$y[P],ui[P]),C=te.add5H(B,$,R,L,Dy[P],fi[P]),W=B|0,I=te.rotrSH(i,n,28)^te.rotrBH(i,n,34)^te.rotrBH(i,n,39),u=te.rotrSL(i,n,28)^te.rotrBL(i,n,34)^te.rotrBL(i,n,39),p=i&s^i&a^s&a,v=n&o^n&c^o&c;$=E|0,M=A|0,E=w|0,A=b|0,w=l|0,b=g|0,{h:l,l:g}=te.add(f|0,h|0,C|0,W|0),f=a|0,h=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const y=te.add3L(W,u,v);i=te.add3H(y,C,I,p),n=y|0}({h:i,l:n}=te.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=te.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=te.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:h}=te.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:l,l:g}=te.add(this.Eh|0,this.El|0,l|0,g|0),{h:w,l:b}=te.add(this.Fh|0,this.Fl|0,w|0,b|0),{h:E,l:A}=te.add(this.Gh|0,this.Gl|0,E|0,A|0),{h:$,l:M}=te.add(this.Hh|0,this.Hl|0,$|0,M|0),this.set(i,n,s,o,a,c,f,h,l,g,w,b,E,A,$,M)}roundClean(){fi.fill(0),ui.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const My=iy(()=>new Oy);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ic=BigInt(0),fh=BigInt(1),Py=BigInt(2);function nc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function sc(t){if(!nc(t))throw new Error("Uint8Array expected")}function oc(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Ry=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ac(t){sc(t);let e="";for(let r=0;r<t.length;r++)e+=Ry[t[r]];return e}function uh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ic:BigInt("0x"+t)}const Wr={_0:48,_9:57,A:65,F:70,a:97,f:102};function hh(t){if(t>=Wr._0&&t<=Wr._9)return t-Wr._0;if(t>=Wr.A&&t<=Wr.F)return t-(Wr.A-10);if(t>=Wr.a&&t<=Wr.f)return t-(Wr.a-10)}function dh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=hh(t.charCodeAt(s)),a=hh(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Ty(t){return uh(ac(t))}function Io(t){return sc(t),uh(ac(Uint8Array.from(t).reverse()))}function lh(t,e){return dh(t.toString(16).padStart(e*2,"0"))}function cc(t,e){return lh(t,e).reverse()}function Gr(t,e,r){let i;if(typeof e=="string")try{i=dh(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(nc(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function ph(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];sc(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const fc=t=>typeof t=="bigint"&&ic<=t;function Ny(t,e,r){return fc(t)&&fc(e)&&fc(r)&&e<=t&&t<r}function us(t,e,r,i){if(!Ny(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Cy(t){let e;for(e=0;t>ic;t>>=fh,e+=1);return e}const By=t=>(Py<<BigInt(t-1))-fh,Fy={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||nc(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function uc(t,e,r={}){const i=(n,s,o)=>{const a=Fy[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function gh(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const ut=BigInt(0),rt=BigInt(1),Li=BigInt(2),Ly=BigInt(3),hc=BigInt(4),bh=BigInt(5),yh=BigInt(8);function ot(t,e){const r=t%e;return r>=ut?r:e+r}function qy(t,e,r){if(e<ut)throw new Error("invalid exponent, negatives unsupported");if(r<=ut)throw new Error("invalid modulus");if(r===rt)return ut;let i=rt;for(;e>ut;)e&rt&&(i=i*t%r),t=t*t%r,e>>=rt;return i}function Sr(t,e,r){let i=t;for(;e-- >ut;)i*=i,i%=r;return i}function vh(t,e){if(t===ut)throw new Error("invert: expected non-zero number");if(e<=ut)throw new Error("invert: expected positive modulus, got "+e);let r=ot(t,e),i=e,n=ut,s=rt;for(;r!==ut;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==rt)throw new Error("invert: does not exist");return ot(n,e)}function zy(t){const e=(t-rt)/Li;let r,i,n;for(r=t-rt,i=0;r%Li===ut;r/=Li,i++);for(n=Li;n<t&&qy(n,e,t)!==t-rt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+rt)/hc;return function(a,c){const f=a.pow(c,o);if(!a.eql(a.sqr(f),c))throw new Error("Cannot find square root");return f}}const s=(r+rt)/Li;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,f=o.pow(o.mul(o.ONE,n),r),h=o.pow(a,s),l=o.pow(a,r);for(;!o.eql(l,o.ONE);){if(o.eql(l,o.ZERO))return o.ZERO;let g=1;for(let b=o.sqr(l);g<c&&!o.eql(b,o.ONE);g++)b=o.sqr(b);const w=o.pow(f,rt<<BigInt(c-g-1));f=o.sqr(w),h=o.mul(h,w),l=o.mul(l,f),c=g}return h}}function Uy(t){if(t%hc===Ly){const e=(t+rt)/hc;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%yh===bh){const e=(t-bh)/yh;return function(r,i){const n=r.mul(i,Li),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,Li),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return zy(t)}const ky=(t,e)=>(ot(t,e)&rt)===rt,jy=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ky(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=jy.reduce((i,n)=>(i[n]="function",i),e);return uc(t,r)}function Vy(t,e,r){if(r<ut)throw new Error("invalid exponent, negatives unsupported");if(r===ut)return t.ONE;if(r===rt)return e;let i=t.ONE,n=e;for(;r>ut;)r&rt&&(i=t.mul(i,n)),n=t.sqr(n),r>>=rt;return i}function Hy(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function mh(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function wh(t,e,r=!1,i={}){if(t<=ut)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=mh(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:By(n),ZERO:ut,ONE:rt,create:c=>ot(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ut<=c&&c<t},is0:c=>c===ut,isOdd:c=>(c&rt)===rt,neg:c=>ot(-c,t),eql:(c,f)=>c===f,sqr:c=>ot(c*c,t),add:(c,f)=>ot(c+f,t),sub:(c,f)=>ot(c-f,t),mul:(c,f)=>ot(c*f,t),pow:(c,f)=>Vy(a,c,f),div:(c,f)=>ot(c*vh(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>vh(c,t),sqrt:i.sqrt||(c=>(o||(o=Uy(t)),o(a,c))),invertBatch:c=>Hy(a,c),cmov:(c,f,h)=>h?f:c,toBytes:c=>r?cc(c,s):lh(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Io(c):Ty(c)}});return Object.freeze(a)}const _h=BigInt(0),Ao=BigInt(1);function dc(t,e){const r=e.negate();return t?r:e}function xh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function lc(t,e){xh(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function Wy(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function Gy(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const pc=new WeakMap,Eh=new WeakMap;function gc(t){return Eh.get(t)||1}function Yy(t,e){return{constTimeNegate:dc,hasPrecomputes(r){return gc(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>_h;)i&Ao&&(n=n.add(s)),s=s.double(),i>>=Ao;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=lc(i,e),o=[];let a=r,c=a;for(let f=0;f<n;f++){c=a,o.push(c);for(let h=1;h<s;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=lc(r,e);let a=t.ZERO,c=t.BASE;const f=BigInt(2**r-1),h=2**r,l=BigInt(r);for(let g=0;g<s;g++){const w=g*o;let b=Number(n&f);n>>=l,b>o&&(b-=h,n+=Ao);const E=w,A=w+Math.abs(b)-1,$=g%2!==0,M=b<0;b===0?c=c.add(dc($,i[E])):a=a.add(dc(M,i[A]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=lc(r,e),c=BigInt(2**r-1),f=2**r,h=BigInt(r);for(let l=0;l<o;l++){const g=l*a;if(n===_h)break;let w=Number(n&c);if(n>>=h,w>a&&(w-=f,n+=Ao),w===0)continue;let b=i[g+Math.abs(w)-1];w<0&&(b=b.negate()),s=s.add(b)}return s},getPrecomputes(r,i,n){let s=pc.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&pc.set(i,n(s))),s},wNAFCached(r,i,n){const s=gc(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=gc(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){xh(i,e),Eh.set(r,i),pc.delete(r)}}}function Jy(t,e,r,i){if(Wy(r,t),Gy(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=Cy(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),f=Math.floor((e.BITS-1)/o)*o;let h=n;for(let l=f;l>=0;l-=o){c.fill(n);for(let w=0;w<i.length;w++){const b=i[w],E=Number(b>>BigInt(l)&BigInt(a));c[E]=c[E].add(r[w])}let g=n;for(let w=c.length-1,b=n;w>0;w--)b=b.add(c[w]),g=g.add(b);if(h=h.add(g),l!==0)for(let w=0;w<o;w++)h=h.double()}return h}function Zy(t){return Ky(t.Fp),uc(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...mh(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const dr=BigInt(0),kt=BigInt(1),Do=BigInt(2),Xy=BigInt(8),Qy={zip215:!0};function e2(t){const e=Zy(t);return uc(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function t2(t){const e=e2(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Do<<BigInt(a*8)-kt,h=r.create,l=wh(e.n,e.nBitLength),g=e.uvRatio||((y,m)=>{try{return{isValid:!0,value:r.sqrt(y*r.inv(m))}}catch{return{isValid:!1,value:dr}}}),w=e.adjustScalarBytes||(y=>y),b=e.domain||((y,m,S)=>{if(oc("phflag",S),m.length||S)throw new Error("Contexts/pre-hash are not supported");return y});function E(y,m){us("coordinate "+y,m,dr,f)}function A(y){if(!(y instanceof P))throw new Error("ExtendedPoint expected")}const $=gh((y,m)=>{const{ex:S,ey:D,ez:_}=y,d=y.is0();m==null&&(m=d?Xy:r.inv(_));const x=h(S*m),q=h(D*m),z=h(_*m);if(d)return{x:dr,y:kt};if(z!==kt)throw new Error("invZ was invalid");return{x,y:q}}),M=gh(y=>{const{a:m,d:S}=e;if(y.is0())throw new Error("bad point: ZERO");const{ex:D,ey:_,ez:d,et:x}=y,q=h(D*D),z=h(_*_),U=h(d*d),k=h(U*U),G=h(q*m),Z=h(U*h(G+z)),X=h(k+h(S*h(q*z)));if(Z!==X)throw new Error("bad point: equation left != right (1)");const J=h(D*_),Q=h(d*x);if(J!==Q)throw new Error("bad point: equation left != right (2)");return!0});class P{constructor(m,S,D,_){this.ex=m,this.ey=S,this.ez=D,this.et=_,E("x",m),E("y",S),E("z",D),E("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof P)throw new Error("extended point not allowed");const{x:S,y:D}=m||{};return E("x",S),E("y",D),new P(S,D,kt,h(S*D))}static normalizeZ(m){const S=r.invertBatch(m.map(D=>D.ez));return m.map((D,_)=>D.toAffine(S[_])).map(P.fromAffine)}static msm(m,S){return Jy(P,l,m,S)}_setWindowSize(m){L.setWindowSize(this,m)}assertValidity(){M(this)}equals(m){A(m);const{ex:S,ey:D,ez:_}=this,{ex:d,ey:x,ez:q}=m,z=h(S*q),U=h(d*_),k=h(D*q),G=h(x*_);return z===U&&k===G}is0(){return this.equals(P.ZERO)}negate(){return new P(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:m}=e,{ex:S,ey:D,ez:_}=this,d=h(S*S),x=h(D*D),q=h(Do*h(_*_)),z=h(m*d),U=S+D,k=h(h(U*U)-d-x),G=z+x,Z=G-q,X=z-x,J=h(k*Z),Q=h(G*X),Fe=h(k*X),re=h(Z*G);return new P(J,Q,re,Fe)}add(m){A(m);const{a:S,d:D}=e,{ex:_,ey:d,ez:x,et:q}=this,{ex:z,ey:U,ez:k,et:G}=m;if(S===BigInt(-1)){const Ie=h((d-_)*(U+z)),on=h((d+_)*(U-z)),_e=h(on-Ie);if(_e===dr)return this.double();const Ae=h(x*Do*G),an=h(q*Do*k),De=an+Ae,$e=on+Ie,cn=an-Ae,be=h(De*_e),xe=h($e*cn),fn=h(De*cn),ae=h(_e*$e);return new P(be,xe,ae,fn)}const Z=h(_*z),X=h(d*U),J=h(q*D*G),Q=h(x*k),Fe=h((_+d)*(z+U)-Z-X),re=Q-J,oe=Q+J,ct=h(X-S*Z),he=h(Fe*re),Me=h(oe*ct),es=h(Fe*ct),Pe=h(re*oe);return new P(he,Me,Pe,es)}subtract(m){return this.add(m.negate())}wNAF(m){return L.wNAFCached(this,m,P.normalizeZ)}multiply(m){const S=m;us("scalar",S,kt,i);const{p:D,f:_}=this.wNAF(S);return P.normalizeZ([D,_])[0]}multiplyUnsafe(m,S=P.ZERO){const D=m;return us("scalar",D,dr,i),D===dr?N:this.is0()||D===kt?this:L.wNAFCachedUnsafe(this,D,P.normalizeZ,S)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return L.unsafeLadder(this,i).is0()}toAffine(m){return $(this,m)}clearCofactor(){const{h:m}=e;return m===kt?this:this.multiplyUnsafe(m)}static fromHex(m,S=!1){const{d:D,a:_}=e,d=r.BYTES;m=Gr("pointHex",m,d),oc("zip215",S);const x=m.slice(),q=m[d-1];x[d-1]=q&-129;const z=Io(x),U=S?f:r.ORDER;us("pointHex.y",z,dr,U);const k=h(z*z),G=h(k-kt),Z=h(D*k-_);let{isValid:X,value:J}=g(G,Z);if(!X)throw new Error("Point.fromHex: invalid y coordinate");const Q=(J&kt)===kt,Fe=(q&128)!==0;if(!S&&J===dr&&Fe)throw new Error("Point.fromHex: x=0 and x_0=1");return Fe!==Q&&(J=h(-J)),P.fromAffine({x:J,y:z})}static fromPrivateKey(m){return C(m).point}toRawBytes(){const{x:m,y:S}=this.toAffine(),D=cc(S,r.BYTES);return D[D.length-1]|=m&kt?128:0,D}toHex(){return ac(this.toRawBytes())}}P.BASE=new P(e.Gx,e.Gy,kt,h(e.Gx*e.Gy)),P.ZERO=new P(dr,kt,kt,dr);const{BASE:R,ZERO:N}=P,L=Yy(P,a*8);function F(y){return ot(y,i)}function B(y){return F(Io(y))}function C(y){const m=r.BYTES;y=Gr("private key",y,m);const S=Gr("hashed private key",s(y),2*m),D=w(S.slice(0,m)),_=S.slice(m,2*m),d=B(D),x=R.multiply(d),q=x.toRawBytes();return{head:D,prefix:_,scalar:d,point:x,pointBytes:q}}function W(y){return C(y).pointBytes}function I(y=new Uint8Array,...m){const S=ph(...m);return B(s(b(S,Gr("context",y),!!n)))}function u(y,m,S={}){y=Gr("message",y),n&&(y=n(y));const{prefix:D,scalar:_,pointBytes:d}=C(m),x=I(S.context,D,y),q=R.multiply(x).toRawBytes(),z=I(S.context,q,d,y),U=F(x+z*_);us("signature.s",U,dr,i);const k=ph(q,cc(U,r.BYTES));return Gr("result",k,r.BYTES*2)}const p=Qy;function v(y,m,S,D=p){const{context:_,zip215:d}=D,x=r.BYTES;y=Gr("signature",y,2*x),m=Gr("message",m),S=Gr("publicKey",S,x),d!==void 0&&oc("zip215",d),n&&(m=n(m));const q=Io(y.slice(x,2*x));let z,U,k;try{z=P.fromHex(S,d),U=P.fromHex(y.slice(0,x),d),k=R.multiplyUnsafe(q)}catch{return!1}if(!d&&z.isSmallOrder())return!1;const G=I(_,U.toRawBytes(),z.toRawBytes(),m);return U.add(z.multiplyUnsafe(G)).subtract(k).clearCofactor().equals(P.ZERO)}return R._setWindowSize(8),{CURVE:e,getPublicKey:W,sign:u,verify:v,ExtendedPoint:P,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>o(r.BYTES),precompute(y=8,m=P.BASE){return m._setWindowSize(y),m.multiply(BigInt(3)),m}}}}BigInt(0),BigInt(1);const bc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Sh=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const r2=BigInt(1),Ih=BigInt(2);BigInt(3);const i2=BigInt(5),n2=BigInt(8);function s2(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=bc,o=t*t%s*t%s,a=Sr(o,Ih,s)*o%s,c=Sr(a,r2,s)*t%s,f=Sr(c,i2,s)*c%s,h=Sr(f,e,s)*f%s,l=Sr(h,r,s)*h%s,g=Sr(l,i,s)*l%s,w=Sr(g,n,s)*g%s,b=Sr(w,n,s)*g%s,E=Sr(b,e,s)*f%s;return{pow_p_5_8:Sr(E,Ih,s)*t%s,b2:o}}function o2(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function a2(t,e){const r=bc,i=ot(e*e*e,r),n=ot(i*i*e,r),s=s2(t*n).pow_p_5_8;let o=ot(t*i*s,r);const a=ot(e*o*o,r),c=o,f=ot(o*Sh,r),h=a===t,l=a===ot(-t,r),g=a===ot(-t*Sh,r);return h&&(o=c),(l||g)&&(o=f),ky(o,r)&&(o=ot(-o,r)),{isValid:h||l,value:o}}const c2=(()=>wh(bc,void 0,!0))(),f2=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:c2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:n2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:My,randomBytes:ah,adjustScalarBytes:o2,uvRatio:a2}))(),Ah=(()=>t2(f2))(),u2="EdDSA",h2="JWT",$o=".",Oo="base64url",Dh="utf8",$h="utf8",d2=":",l2="did",p2="key",Oh="base58btc",g2="z",b2="K36",y2=32;function yc(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Mh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?yc(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Ph(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Mh(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return yc(r)}function v2(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var E=0,A=0,$=0,M=b.length;$!==M&&b[$]===0;)$++,E++;for(var P=(M-$)*h+1>>>0,R=new Uint8Array(P);$!==M;){for(var N=b[$],L=0,F=P-1;(N!==0||L<A)&&F!==-1;F--,L++)N+=256*R[F]>>>0,R[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");A=L,$++}for(var B=P-A;B!==P&&R[B]===0;)B++;for(var C=c.repeat(E);B<P;++B)C+=t.charAt(R[B]);return C}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var E=0;if(b[E]!==" "){for(var A=0,$=0;b[E]===c;)A++,E++;for(var M=(b.length-E)*f+1>>>0,P=new Uint8Array(M);b[E];){var R=r[b.charCodeAt(E)];if(R===255)return;for(var N=0,L=M-1;(R!==0||N<$)&&L!==-1;L--,N++)R+=a*P[L]>>>0,P[L]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");$=N,E++}if(b[E]!==" "){for(var F=M-$;F!==M&&P[F]===0;)F++;for(var B=new Uint8Array(A+(M-F)),C=A;F!==M;)B[C++]=P[F++];return B}}}function w(b){var E=g(b);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:g,decode:w}}var m2=v2,w2=m2;const Rh=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},_2=t=>new TextEncoder().encode(t),x2=t=>new TextDecoder().decode(t);class E2{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class S2{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Th(this,e)}}class I2{constructor(e){this.decoders=e}or(e){return Th(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Th=(t,e)=>new I2({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class A2{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new E2(e,r,i),this.decoder=new S2(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Mo=({name:t,prefix:e,encode:r,decode:i})=>new A2(t,e,r,i),hs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=w2(r,e);return Mo({prefix:t,name:e,encode:i,decode:s=>Rh(n(s))})},D2=(t,e,r,i)=>{const n={};for(let h=0;h<e.length;++h)n[e[h]]=h;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,f=0;for(let h=0;h<s;++h){const l=n[t[h]];if(l===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,o[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},$2=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},wt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Mo({prefix:e,name:t,encode(n){return $2(n,i,r)},decode(n){return D2(n,i,r,t)}}),O2=Mo({prefix:"\0",name:"identity",encode:t=>x2(t),decode:t=>_2(t)});var M2=Object.freeze({__proto__:null,identity:O2});const P2=wt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var R2=Object.freeze({__proto__:null,base2:P2});const T2=wt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var N2=Object.freeze({__proto__:null,base8:T2});const C2=hs({prefix:"9",name:"base10",alphabet:"0123456789"});var B2=Object.freeze({__proto__:null,base10:C2});const F2=wt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),L2=wt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var q2=Object.freeze({__proto__:null,base16:F2,base16upper:L2});const z2=wt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U2=wt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),k2=wt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j2=wt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),K2=wt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),V2=wt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),H2=wt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),W2=wt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),G2=wt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Y2=Object.freeze({__proto__:null,base32:z2,base32upper:U2,base32pad:k2,base32padupper:j2,base32hex:K2,base32hexupper:V2,base32hexpad:H2,base32hexpadupper:W2,base32z:G2});const J2=hs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Z2=hs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var X2=Object.freeze({__proto__:null,base36:J2,base36upper:Z2});const Q2=hs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ev=hs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tv=Object.freeze({__proto__:null,base58btc:Q2,base58flickr:ev});const rv=wt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),iv=wt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),nv=wt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sv=wt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ov=Object.freeze({__proto__:null,base64:rv,base64pad:iv,base64url:nv,base64urlpad:sv});const Nh=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),av=Nh.reduce((t,e,r)=>(t[r]=e,t),[]),cv=Nh.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function fv(t){return t.reduce((e,r)=>(e+=av[r],e),"")}function uv(t){const e=[];for(const r of t){const i=cv[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const hv=Mo({prefix:"\u{1F680}",name:"base256emoji",encode:fv,decode:uv});var dv=Object.freeze({__proto__:null,base256emoji:hv}),lv=Bh,Ch=128,pv=127,gv=~pv,bv=Math.pow(2,31);function Bh(t,e,r){e=e||[],r=r||0;for(var i=r;t>=bv;)e[r++]=t&255|Ch,t/=128;for(;t&gv;)e[r++]=t&255|Ch,t>>>=7;return e[r]=t|0,Bh.bytes=r-i+1,e}var yv=vc,vv=128,Fh=127;function vc(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw vc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Fh)<<n:(o&Fh)*Math.pow(2,n),n+=7}while(o>=vv);return vc.bytes=s-i,r}var mv=Math.pow(2,7),wv=Math.pow(2,14),_v=Math.pow(2,21),xv=Math.pow(2,28),Ev=Math.pow(2,35),Sv=Math.pow(2,42),Iv=Math.pow(2,49),Av=Math.pow(2,56),Dv=Math.pow(2,63),$v=function(t){return t<mv?1:t<wv?2:t<_v?3:t<xv?4:t<Ev?5:t<Sv?6:t<Iv?7:t<Av?8:t<Dv?9:10},Ov={encode:lv,decode:yv,encodingLength:$v},Lh=Ov;const qh=(t,e,r=0)=>(Lh.encode(t,e,r),e),zh=t=>Lh.encodingLength(t),mc=(t,e)=>{const r=e.byteLength,i=zh(t),n=i+zh(r),s=new Uint8Array(n+r);return qh(t,s,0),qh(r,s,i),s.set(e,n),new Mv(t,r,e,s)};class Mv{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Uh=({name:t,code:e,encode:r})=>new Pv(t,e,r);class Pv{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?mc(this.code,r):r.then(i=>mc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const kh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Rv=Uh({name:"sha2-256",code:18,encode:kh("SHA-256")}),Tv=Uh({name:"sha2-512",code:19,encode:kh("SHA-512")});var Nv=Object.freeze({__proto__:null,sha256:Rv,sha512:Tv});const jh=0,Cv="identity",Kh=Rh;var Bv=Object.freeze({__proto__:null,identity:{code:jh,name:Cv,encode:Kh,digest:t=>mc(jh,Kh(t))}});new TextEncoder,new TextDecoder;const Vh={...M2,...R2,...N2,...B2,...q2,...Y2,...X2,...tv,...ov,...dv};({...Nv,...Bv});function Hh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Wh=Hh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),wc=Hh("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Mh(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Gh={utf8:Wh,"utf-8":Wh,hex:Vh.base16,latin1:wc,ascii:wc,binary:wc,...Vh};function Po(t,e="utf8"){const r=Gh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function wn(t,e="utf8"){const r=Gh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?yc(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Yh(t){return bn(Po(wn(t,Oo),Dh))}function Ro(t){return Po(wn(Fi(t),Dh),Oo)}function Jh(t){const e=wn(b2,Oh),r=g2+Po(Ph([e,t]),Oh);return[l2,p2,r].join(d2)}function Fv(t){return Po(t,Oo)}function Lv(t){return wn(t,Oo)}function qv(t){return wn([Ro(t.header),Ro(t.payload)].join($o),$h)}function zv(t){return[Ro(t.header),Ro(t.payload),Fv(t.signature)].join($o)}function _c(t){const e=t.split($o),r=Yh(e[0]),i=Yh(e[1]),n=Lv(e[2]),s=wn(e.slice(0,2).join($o),$h);return{header:r,payload:i,signature:n,data:s}}function Zh(t=ah(y2)){const e=Ah.getPublicKey(t);return{secretKey:Ph([t,e]),publicKey:e}}async function Uv(t,e,r,i,n=V.fromMiliseconds(Date.now())){const s={alg:u2,typ:h2},o=Jh(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},f=qv({header:s,payload:c}),h=Ah.sign(f,i.secretKey.slice(0,32));return zv({header:s,payload:c,signature:h})}var Xh=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},kv=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),jv=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Kv=function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t}(),Vv=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Hv=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Wv=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Gv=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Qh=3,Yv=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Wv]],ed=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Jv(t){return t?td(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Hv:typeof navigator<"u"?td(navigator.userAgent):Qv()}function Zv(t){return t!==""&&Yv.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function td(t){var e=Zv(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Vv;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Qh&&(n=Xh(Xh([],n,!0),em(Qh-n.length),!0)):n=[];var s=n.join("."),o=Xv(t),a=Gv.exec(t);return a&&a[1]?new Kv(r,s,o,a[1]):new kv(r,s,o)}function Xv(t){for(var e=0,r=ed.length;e<r;e++){var i=ed[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Qv(){var t=typeof process<"u"&&process.version;return t?new jv(process.version.slice(1)):null}function em(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var ye={};Object.defineProperty(ye,"__esModule",{value:!0}),ye.getLocalStorage=ye.getLocalStorageOrThrow=ye.getCrypto=ye.getCryptoOrThrow=rd=ye.getLocation=ye.getLocationOrThrow=xc=ye.getNavigator=ye.getNavigatorOrThrow=ds=ye.getDocument=ye.getDocumentOrThrow=ye.getFromWindowOrThrow=ye.getFromWindow=void 0;function qi(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}ye.getFromWindow=qi;function _n(t){const e=qi(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}ye.getFromWindowOrThrow=_n;function tm(){return _n("document")}ye.getDocumentOrThrow=tm;function rm(){return qi("document")}var ds=ye.getDocument=rm;function im(){return _n("navigator")}ye.getNavigatorOrThrow=im;function nm(){return qi("navigator")}var xc=ye.getNavigator=nm;function sm(){return _n("location")}ye.getLocationOrThrow=sm;function om(){return qi("location")}var rd=ye.getLocation=om;function am(){return _n("crypto")}ye.getCryptoOrThrow=am;function cm(){return qi("crypto")}ye.getCrypto=cm;function fm(){return _n("localStorage")}ye.getLocalStorageOrThrow=fm;function um(){return qi("localStorage")}ye.getLocalStorage=um;var Ec={};Object.defineProperty(Ec,"__esModule",{value:!0});var id=Ec.getWindowMetadata=void 0;const nd=ye;function hm(){let t,e;try{t=nd.getDocumentOrThrow(),e=nd.getLocationOrThrow()}catch{return null}function r(){const l=t.getElementsByTagName("link"),g=[];for(let w=0;w<l.length;w++){const b=l[w],E=b.getAttribute("rel");if(E&&E.toLowerCase().indexOf("icon")>-1){const A=b.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(A.indexOf("/")===0)$+=A;else{const M=e.pathname.split("/");M.pop();const P=M.join("/");$+=P+"/"+A}g.push($)}else if(A.indexOf("//")===0){const $=e.protocol+A;g.push($)}else g.push(A)}}return g}function i(...l){const g=t.getElementsByTagName("meta");for(let w=0;w<g.length;w++){const b=g[w],E=["itemprop","property","name"].map(A=>b.getAttribute(A)).filter(A=>A?l.includes(A):!1);if(E.length&&E){const A=b.getAttribute("content");if(A)return A}}return""}function n(){let l=i("name","og:site_name","og:title","twitter:title");return l||(l=t.title),l}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,f=r();return{description:a,url:c,icons:f,name:o}}id=Ec.getWindowMetadata=hm;function ls(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function sd(t){return ls(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const od="2.23.2";let Sc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${od}`};class zi extends Error{constructor(e,r={}){const i=(()=>r.cause instanceof zi?r.cause.details:r.cause?.message?r.cause.message:r.details)(),n=(()=>r.cause instanceof zi&&r.cause.docsPath||r.docsPath)(),s=Sc.getDocsUrl?.({...r,docsPath:n}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...i?[`Details: ${i}`]:[],...Sc.version?[`Version: ${Sc.version}`]:[]].join(`
|
|
15
|
+
`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=od}walk(e){return ad(this,e)}}function ad(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?ad(t.cause,e):e?null:t}class cd extends zi{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function xn(t,{dir:e,size:r=32}={}){return typeof t=="string"?dm(t,{dir:e,size:r}):lm(t,{dir:e,size:r})}function dm(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new cd({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function lm(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new cd({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let n=0;n<r;n++){const s=e==="right";i[s?n:r-n-1]=t[s?n:t.length-n-1]}return i}class pm extends zi{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class gm extends zi{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function En(t,{size:e}){if(sd(t)>e)throw new gm({givenSize:sd(t),maxSize:e})}function Ic(t,e={}){const{signed:r}=e;e.size&&En(t,{size:e.size});const i=BigInt(t);if(!r)return i;const n=(t.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return i<=s?i:i-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function bm(t,e={}){return Number(Ic(t,e))}const ym=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ac(t,e={}){return typeof t=="number"||typeof t=="bigint"?ud(t,e):typeof t=="string"?wm(t,e):typeof t=="boolean"?vm(t,e):fd(t,e)}function vm(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(En(r,{size:e.size}),xn(r,{size:e.size})):r}function fd(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=ym[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(En(i,{size:e.size}),xn(i,{dir:"right",size:e.size})):i}function ud(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const c=typeof t=="bigint"?"n":"";throw new pm({max:s?`${s}${c}`:void 0,min:`${o}${c}`,signed:r,size:i,value:`${t}${c}`})}const a=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?xn(a,{size:i}):a}const mm=new TextEncoder;function wm(t,e={}){const r=mm.encode(t);return fd(r,e)}const _m=new TextEncoder;function xm(t,e={}){return typeof t=="number"||typeof t=="bigint"?Sm(t,e):typeof t=="boolean"?Em(t,e):ls(t)?dd(t,e):ld(t,e)}function Em(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(En(r,{size:e.size}),xn(r,{size:e.size})):r}const Yr={zero:48,nine:57,A:65,F:70,a:97,f:102};function hd(t){if(t>=Yr.zero&&t<=Yr.nine)return t-Yr.zero;if(t>=Yr.A&&t<=Yr.F)return t-(Yr.A-10);if(t>=Yr.a&&t<=Yr.f)return t-(Yr.a-10)}function dd(t,e={}){let r=t;e.size&&(En(r,{size:e.size}),r=xn(r,{dir:"right",size:e.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);const n=i.length/2,s=new Uint8Array(n);for(let o=0,a=0;o<n;o++){const c=hd(i.charCodeAt(a++)),f=hd(i.charCodeAt(a++));if(c===void 0||f===void 0)throw new zi(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);s[o]=c*16+f}return s}function Sm(t,e){const r=ud(t,e);return dd(r)}function ld(t,e={}){const r=_m.encode(t);return typeof e.size=="number"?(En(r,{size:e.size}),xn(r,{dir:"right",size:e.size})):r}function To(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Im(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ps(t,...e){if(!Im(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Am(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");To(t.outputLen),To(t.blockLen)}function Sn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function pd(t,e){ps(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const No=BigInt(2**32-1),gd=BigInt(32);function Dm(t,e=!1){return e?{h:Number(t&No),l:Number(t>>gd&No)}:{h:Number(t>>gd&No)|0,l:Number(t&No)|0}}function $m(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=Dm(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const Om=(t,e,r)=>t<<r|e>>>32-r,Mm=(t,e,r)=>e<<r|t>>>32-r,Pm=(t,e,r)=>e<<r-32|t>>>64-r,Rm=(t,e,r)=>t<<r-32|e>>>64-r,In=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Tm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Dc(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ir(t,e){return t<<32-e|t>>>e}const bd=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Nm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function yd(t){for(let e=0;e<t.length;e++)t[e]=Nm(t[e])}function Cm(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Co(t){return typeof t=="string"&&(t=Cm(t)),ps(t),t}function Bm(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];ps(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}class $c{clone(){return this._cloneInto()}}function vd(t){const e=i=>t().update(Co(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function md(t=32){if(In&&typeof In.getRandomValues=="function")return In.getRandomValues(new Uint8Array(t));if(In&&typeof In.randomBytes=="function")return In.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const wd=[],_d=[],xd=[],Fm=BigInt(0),gs=BigInt(1),Lm=BigInt(2),qm=BigInt(7),zm=BigInt(256),Um=BigInt(113);for(let t=0,e=gs,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],wd.push(2*(5*i+r)),_d.push((t+1)*(t+2)/2%64);let n=Fm;for(let s=0;s<7;s++)e=(e<<gs^(e>>qm)*Um)%zm,e&Lm&&(n^=gs<<(gs<<BigInt(s))-gs);xd.push(n)}const[km,jm]=$m(xd,!0),Ed=(t,e,r)=>r>32?Pm(t,e,r):Om(t,e,r),Sd=(t,e,r)=>r>32?Rm(t,e,r):Mm(t,e,r);function Km(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,f=r[c],h=r[c+1],l=Ed(f,h,1)^r[a],g=Sd(f,h,1)^r[a+1];for(let w=0;w<50;w+=10)t[o+w]^=l,t[o+w+1]^=g}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=_d[o],c=Ed(n,s,a),f=Sd(n,s,a),h=wd[o];n=t[h],s=t[h+1],t[h]=c,t[h+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=km[i],t[1]^=jm[i]}r.fill(0)}class Oc extends $c{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,To(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Tm(this.state)}keccak(){bd||yd(this.state32),Km(this.state32,this.rounds),bd||yd(this.state32),this.posOut=0,this.pos=0}update(e){Sn(this);const{blockLen:r,state:i}=this;e=Co(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Sn(this,!1),ps(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return To(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(pd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new Oc(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Id=((t,e,r)=>vd(()=>new Oc(e,t,r)))(1,136,256/8);function Ad(t,e){const r=e||"hex",i=Id(ls(t,{strict:!1})?xm(t):t);return r==="bytes"?i:Ac(i)}class Dd extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const Mc=new Dd(8192);function Vm(t,e){if(Mc.has(`${t}.${e}`))return Mc.get(`${t}.${e}`);const r=e?`${e}${t.toLowerCase()}`:t.substring(2).toLowerCase(),i=Ad(ld(r),"bytes"),n=(e?r.substring(`${e}0x`.length):r).split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&n[o]&&(n[o]=n[o].toUpperCase()),(i[o>>1]&15)>=8&&n[o+1]&&(n[o+1]=n[o+1].toUpperCase());const s=`0x${n.join("")}`;return Mc.set(`${t}.${e}`,s),s}function Hm(t){const e=Ad(`0x${t.substring(4)}`).substring(26);return Vm(`0x${e}`)}async function Wm({hash:t,signature:e}){const r=ls(t)?t:Ac(t),{secp256k1:i}=await Promise.resolve().then(function(){return Dw});return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:f,s:h,v:l,yParity:g}=e,w=Number(g??l),b=$d(w);return new i.Signature(Ic(f),Ic(h)).addRecoveryBit(b)}const o=ls(e)?e:Ac(e),a=bm(`0x${o.slice(130)}`),c=$d(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function $d(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function Gm({hash:t,signature:e}){return Hm(await Wm({hash:t,signature:e}))}function Ym(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}function Jm(t,e,r){return t&e^~t&r}function Zm(t,e,r){return t&e^t&r^e&r}class Xm extends $c{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Dc(this.buffer)}update(e){Sn(this);const{view:r,buffer:i,blockLen:n}=this;e=Co(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Dc(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Sn(this),pd(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let l=o;l<n;l++)r[l]=0;Ym(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Dc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,h[l],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const Qm=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]),hi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),di=new Uint32Array(64);class e3 extends Xm{constructor(){super(64,32,8,!1),this.A=hi[0]|0,this.B=hi[1]|0,this.C=hi[2]|0,this.D=hi[3]|0,this.E=hi[4]|0,this.F=hi[5]|0,this.G=hi[6]|0,this.H=hi[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)di[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){const g=di[l-15],w=di[l-2],b=Ir(g,7)^Ir(g,18)^g>>>3,E=Ir(w,17)^Ir(w,19)^w>>>10;di[l]=E+di[l-7]+b+di[l-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:f,H:h}=this;for(let l=0;l<64;l++){const g=Ir(a,6)^Ir(a,11)^Ir(a,25),w=h+g+Jm(a,c,f)+Qm[l]+di[l]|0,E=(Ir(i,2)^Ir(i,13)^Ir(i,22))+Zm(i,n,s)|0;h=f,f=c,c=a,a=o+w|0,o=s,s=n,n=i,i=w+E|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(i,n,s,o,a,c,f,h)}roundClean(){di.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Bo=vd(()=>new e3);new Dd(128);const t3=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Od=new Uint8Array(new Array(16).fill(0).map((t,e)=>e)),r3=Od.map(t=>(9*t+5)%16);let i3=[Od],n3=[r3];for(let t=0;t<4;t++)for(let e of[i3,n3])e.push(e[t].map(r=>t3[r]));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fo=BigInt(0),Lo=BigInt(1),s3=BigInt(2);function Ui(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ar(t){if(!Ui(t))throw new Error("Uint8Array expected")}function An(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const o3=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Dn(t){Ar(t);let e="";for(let r=0;r<t.length;r++)e+=o3[t[r]];return e}function $n(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Pc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Fo:BigInt("0x"+t)}const Jr={_0:48,_9:57,A:65,F:70,a:97,f:102};function Md(t){if(t>=Jr._0&&t<=Jr._9)return t-Jr._0;if(t>=Jr.A&&t<=Jr.F)return t-(Jr.A-10);if(t>=Jr.a&&t<=Jr.f)return t-(Jr.a-10)}function On(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=Md(t.charCodeAt(s)),a=Md(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Dr(t){return Pc(Dn(t))}function Rc(t){return Ar(t),Pc(Dn(Uint8Array.from(t).reverse()))}function li(t,e){return On(t.toString(16).padStart(e*2,"0"))}function Tc(t,e){return li(t,e).reverse()}function a3(t){return On($n(t))}function Mt(t,e,r){let i;if(typeof e=="string")try{i=On(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ui(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function Gt(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Ar(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}function c3(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}function qo(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const Nc=t=>typeof t=="bigint"&&Fo<=t;function Mn(t,e,r){return Nc(t)&&Nc(e)&&Nc(r)&&e<=t&&t<r}function pi(t,e,r,i){if(!Mn(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Pd(t){let e;for(e=0;t>Fo;t>>=Lo,e+=1);return e}function f3(t,e){return t>>BigInt(e)&Lo}function u3(t,e,r){return t|(r?Lo:Fo)<<BigInt(e)}const Cc=t=>(s3<<BigInt(t-1))-Lo,Bc=t=>new Uint8Array(t),Rd=t=>Uint8Array.from(t);function Td(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let i=Bc(t),n=Bc(t),s=0;const o=()=>{i.fill(1),n.fill(0),s=0},a=(...l)=>r(n,i,...l),c=(l=Bc())=>{n=a(Rd([0]),l),i=a(),l.length!==0&&(n=a(Rd([1]),l),i=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const g=[];for(;l<e;){i=a();const w=i.slice();g.push(w),l+=i.length}return Gt(...g)};return(l,g)=>{o(),c(l);let w;for(;!(w=g(f()));)c();return o(),w}}const h3={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ui(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Pn(t,e,r={}){const i=(n,s,o)=>{const a=h3[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const d3=()=>{throw new Error("not implemented")};function Fc(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}var l3=Object.freeze({__proto__:null,isBytes:Ui,abytes:Ar,abool:An,bytesToHex:Dn,numberToHexUnpadded:$n,hexToNumber:Pc,hexToBytes:On,bytesToNumberBE:Dr,bytesToNumberLE:Rc,numberToBytesBE:li,numberToBytesLE:Tc,numberToVarBytesBE:a3,ensureBytes:Mt,concatBytes:Gt,equalBytes:c3,utf8ToBytes:qo,inRange:Mn,aInRange:pi,bitLen:Pd,bitGet:f3,bitSet:u3,bitMask:Cc,createHmacDrbg:Td,validateObject:Pn,notImplemented:d3,memoized:Fc});const p3="0.1.1";function g3(){return p3}class Ft extends Error{constructor(e,r={}){const i=(()=>{if(r.cause instanceof Ft){if(r.cause.details)return r.cause.details;if(r.cause.shortMessage)return r.cause.shortMessage}return r.cause?.message?r.cause.message:r.details})(),n=(()=>r.cause instanceof Ft&&r.cause.docsPath||r.docsPath)(),o=`https://oxlib.sh${n??""}`,a=[e||"An error occurred.",...r.metaMessages?["",...r.metaMessages]:[],...i||n?["",i?`Details: ${i}`:void 0,n?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
16
|
+
`);super(a,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${g3()}`}),this.cause=r.cause,this.details=i,this.docs=o,this.docsPath=n,this.shortMessage=e}walk(e){return Nd(this,e)}}function Nd(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?Nd(t.cause,e):e?null:t}function b3(t,e){if(Fd(t)>e)throw new S3({givenSize:Fd(t),maxSize:e})}const Zr={zero:48,nine:57,A:65,F:70,a:97,f:102};function Cd(t){if(t>=Zr.zero&&t<=Zr.nine)return t-Zr.zero;if(t>=Zr.A&&t<=Zr.F)return t-(Zr.A-10);if(t>=Zr.a&&t<=Zr.f)return t-(Zr.a-10)}function y3(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;if(t.length>i)throw new I3({size:t.length,targetSize:i,type:"Bytes"});const n=new Uint8Array(i);for(let s=0;s<i;s++){const o=r==="right";n[o?s:i-s-1]=t[o?s:t.length-s-1]}return n}function Lc(t,e){if(zc(t)>e)throw new R3({givenSize:zc(t),maxSize:e})}function Bd(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;const n=t.replace("0x","");if(n.length>i*2)throw new T3({size:Math.ceil(n.length/2),targetSize:i,type:"Hex"});return`0x${n[r==="right"?"padEnd":"padStart"](i*2,"0")}`}const v3=new TextEncoder;function m3(t){return t instanceof Uint8Array?t:typeof t=="string"?_3(t):w3(t)}function w3(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function _3(t,e={}){const{size:r}=e;let i=t;r&&(Lc(t,r),i=qc(t,r));let n=i.slice(2);n.length%2&&(n=`0${n}`);const s=n.length/2,o=new Uint8Array(s);for(let a=0,c=0;a<s;a++){const f=Cd(n.charCodeAt(c++)),h=Cd(n.charCodeAt(c++));if(f===void 0||h===void 0)throw new Ft(`Invalid byte sequence ("${n[c-2]}${n[c-1]}" in "${n}").`);o[a]=f*16+h}return o}function x3(t,e={}){const{size:r}=e,i=v3.encode(t);return typeof r=="number"?(b3(i,r),E3(i,r)):i}function E3(t,e){return y3(t,{dir:"right",size:e})}function Fd(t){return t.length}class S3 extends Ft{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class I3 extends Ft{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const A3=new TextEncoder,D3=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ld(...t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function $3(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Lc(r,e.size),zo(r,e.size)):r}function qd(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=D3[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(Lc(i,e.size),qc(i,e.size)):i}function O3(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const f=typeof t=="bigint"?"n":"";throw new P3({max:s?`${s}${f}`:void 0,min:`${o}${f}`,signed:r,size:i,value:`${t}${f}`})}const c=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?zo(c,i):c}function M3(t,e={}){return qd(A3.encode(t),e)}function zo(t,e){return Bd(t,{dir:"left",size:e})}function qc(t,e){return Bd(t,{dir:"right",size:e})}function zc(t){return Math.ceil((t.length-2)/2)}class P3 extends Ft{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number \`${s}\` is not in safe${n?` ${n*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${r}\` to \`${e}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class R3 extends Ft{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class T3 extends Ft{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function N3(t,e={}){const{as:r=typeof t=="string"?"Hex":"Bytes"}=e,i=Id(m3(t));return r==="Bytes"?i:qd(i)}class C3 extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const Uc={checksum:new C3(8192)}.checksum,B3=/^0x[a-fA-F0-9]{40}$/;function zd(t,e={}){const{strict:r=!0}=e;if(!B3.test(t))throw new Ud({address:t,cause:new L3});if(r){if(t.toLowerCase()===t)return;if(F3(t)!==t)throw new Ud({address:t,cause:new q3})}}function F3(t){if(Uc.has(t))return Uc.get(t);zd(t,{strict:!1});const e=t.substring(2).toLowerCase(),r=N3(x3(e),{as:"Bytes"}),i=e.split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const n=`0x${i.join("")}`;return Uc.set(t,n),n}class Ud extends Ft{constructor({address:e,cause:r}){super(`Address "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class L3 extends Ft{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class q3 extends Ft{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const z3=/^(.*)\[([0-9]*)\]$/,U3=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,k3=/^(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)?$/;function kc(t,e){if(t.length!==e.length)throw new K3({expectedLength:t.length,givenLength:e.length});const r=[];for(let i=0;i<t.length;i++){const n=t[i],s=e[i];r.push(kc.encode(n,s))}return Ld(...r)}(function(t){function e(r,i,n=!1){if(r==="address"){const c=i;return zd(c),zo(c.toLowerCase(),n?32:0)}if(r==="string")return M3(i);if(r==="bytes")return i;if(r==="bool")return zo($3(i),n?32:1);const s=r.match(k3);if(s){const[c,f,h="256"]=s,l=Number.parseInt(h)/8;return O3(i,{size:n?32:l,signed:f==="int"})}const o=r.match(U3);if(o){const[c,f]=o;if(Number.parseInt(f)!==(i.length-2)/2)throw new j3({expectedSize:Number.parseInt(f),value:i});return qc(i,n?32:0)}const a=r.match(z3);if(a&&Array.isArray(i)){const[c,f]=a,h=[];for(let l=0;l<i.length;l++)h.push(e(f,i[l],!0));return h.length===0?"0x":Ld(...h)}throw new V3(r)}t.encode=e})(kc||(kc={}));class j3 extends Ft{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${zc(r)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class K3 extends Ft{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${r}`].join(`
|
|
17
|
+
`)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class V3 extends Ft{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class kd extends $c{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Am(e);const i=Co(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Sn(this),this.iHash.update(e),this}digestInto(e){Sn(this),ps(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const jd=(t,e,r)=>new kd(t,e).update(r).digest();jd.create=(t,e)=>new kd(t,e);const ht=BigInt(0),it=BigInt(1),ki=BigInt(2),H3=BigInt(3),jc=BigInt(4),Kd=BigInt(5),Vd=BigInt(8);function dt(t,e){const r=t%e;return r>=ht?r:e+r}function W3(t,e,r){if(e<ht)throw new Error("invalid exponent, negatives unsupported");if(r<=ht)throw new Error("invalid modulus");if(r===it)return ht;let i=it;for(;e>ht;)e&it&&(i=i*t%r),t=t*t%r,e>>=it;return i}function tr(t,e,r){let i=t;for(;e-- >ht;)i*=i,i%=r;return i}function Kc(t,e){if(t===ht)throw new Error("invert: expected non-zero number");if(e<=ht)throw new Error("invert: expected positive modulus, got "+e);let r=dt(t,e),i=e,n=ht,s=it;for(;r!==ht;){const a=i/r,c=i%r,f=n-s*a;i=r,r=c,n=s,s=f}if(i!==it)throw new Error("invert: does not exist");return dt(n,e)}function G3(t){const e=(t-it)/ki;let r,i,n;for(r=t-it,i=0;r%ki===ht;r/=ki,i++);for(n=ki;n<t&&W3(n,e,t)!==t-it;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+it)/jc;return function(c,f){const h=c.pow(f,o);if(!c.eql(c.sqr(h),f))throw new Error("Cannot find square root");return h}}const s=(r+it)/ki;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=i,h=a.pow(a.mul(a.ONE,n),r),l=a.pow(c,s),g=a.pow(c,r);for(;!a.eql(g,a.ONE);){if(a.eql(g,a.ZERO))return a.ZERO;let w=1;for(let E=a.sqr(g);w<f&&!a.eql(E,a.ONE);w++)E=a.sqr(E);const b=a.pow(h,it<<BigInt(f-w-1));h=a.sqr(b),l=a.mul(l,b),g=a.mul(g,h),f=w}return l}}function Y3(t){if(t%jc===H3){const e=(t+it)/jc;return function(i,n){const s=i.pow(n,e);if(!i.eql(i.sqr(s),n))throw new Error("Cannot find square root");return s}}if(t%Vd===Kd){const e=(t-Kd)/Vd;return function(i,n){const s=i.mul(n,ki),o=i.pow(s,e),a=i.mul(n,o),c=i.mul(i.mul(a,ki),o),f=i.mul(a,i.sub(c,i.ONE));if(!i.eql(i.sqr(f),n))throw new Error("Cannot find square root");return f}}return G3(t)}const J3=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hd(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=J3.reduce((i,n)=>(i[n]="function",i),e);return Pn(t,r)}function Z3(t,e,r){if(r<ht)throw new Error("invalid exponent, negatives unsupported");if(r===ht)return t.ONE;if(r===it)return e;let i=t.ONE,n=e;for(;r>ht;)r&it&&(i=t.mul(i,n)),n=t.sqr(n),r>>=it;return i}function X3(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function Wd(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Gd(t,e,r=!1,i={}){if(t<=ht)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=Wd(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:Cc(n),ZERO:ht,ONE:it,create:c=>dt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ht<=c&&c<t},is0:c=>c===ht,isOdd:c=>(c&it)===it,neg:c=>dt(-c,t),eql:(c,f)=>c===f,sqr:c=>dt(c*c,t),add:(c,f)=>dt(c+f,t),sub:(c,f)=>dt(c-f,t),mul:(c,f)=>dt(c*f,t),pow:(c,f)=>Z3(a,c,f),div:(c,f)=>dt(c*Kc(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Kc(c,t),sqrt:i.sqrt||(c=>(o||(o=Y3(t)),o(a,c))),invertBatch:c=>X3(a,c),cmov:(c,f,h)=>h?f:c,toBytes:c=>r?Tc(c,s):li(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Rc(c):Dr(c)}});return Object.freeze(a)}function Yd(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Jd(t){const e=Yd(t);return e+Math.ceil(e/2)}function Q3(t,e,r=!1){const i=t.length,n=Yd(e),s=Jd(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const o=r?Rc(t):Dr(t),a=dt(o,e-it)+it;return r?Tc(a,n):li(a,n)}const Zd=BigInt(0),Uo=BigInt(1);function Vc(t,e){const r=e.negate();return t?r:e}function Xd(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Hc(t,e){Xd(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function ew(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function tw(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const Wc=new WeakMap,Qd=new WeakMap;function Gc(t){return Qd.get(t)||1}function rw(t,e){return{constTimeNegate:Vc,hasPrecomputes(r){return Gc(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Zd;)i&Uo&&(n=n.add(s)),s=s.double(),i>>=Uo;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=Hc(i,e),o=[];let a=r,c=a;for(let f=0;f<n;f++){c=a,o.push(c);for(let h=1;h<s;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=Hc(r,e);let a=t.ZERO,c=t.BASE;const f=BigInt(2**r-1),h=2**r,l=BigInt(r);for(let g=0;g<s;g++){const w=g*o;let b=Number(n&f);n>>=l,b>o&&(b-=h,n+=Uo);const E=w,A=w+Math.abs(b)-1,$=g%2!==0,M=b<0;b===0?c=c.add(Vc($,i[E])):a=a.add(Vc(M,i[A]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=Hc(r,e),c=BigInt(2**r-1),f=2**r,h=BigInt(r);for(let l=0;l<o;l++){const g=l*a;if(n===Zd)break;let w=Number(n&c);if(n>>=h,w>a&&(w-=f,n+=Uo),w===0)continue;let b=i[g+Math.abs(w)-1];w<0&&(b=b.negate()),s=s.add(b)}return s},getPrecomputes(r,i,n){let s=Wc.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&Wc.set(i,n(s))),s},wNAFCached(r,i,n){const s=Gc(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=Gc(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){Xd(i,e),Qd.set(r,i),Wc.delete(r)}}}function iw(t,e,r,i){if(ew(r,t),tw(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=Pd(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),f=Math.floor((e.BITS-1)/o)*o;let h=n;for(let l=f;l>=0;l-=o){c.fill(n);for(let w=0;w<i.length;w++){const b=i[w],E=Number(b>>BigInt(l)&BigInt(a));c[E]=c[E].add(r[w])}let g=n;for(let w=c.length-1,b=n;w>0;w--)b=b.add(c[w]),g=g.add(b);if(h=h.add(g),l!==0)for(let w=0;w<o;w++)h=h.double()}return h}function el(t){return Hd(t.Fp),Pn(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Wd(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function tl(t){t.lowS!==void 0&&An("lowS",t.lowS),t.prehash!==void 0&&An("prehash",t.prehash)}function nw(t){const e=el(t);Pn(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:i,a:n}=e;if(r){if(!i.eql(n,i.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:sw,hexToBytes:ow}=l3;class aw extends Error{constructor(e=""){super(e)}}const Xr={Err:aw,_tlv:{encode:(t,e)=>{const{Err:r}=Xr;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const i=e.length/2,n=$n(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const s=i>127?$n(n.length/2|128):"";return $n(t)+s+n+e},decode(t,e){const{Err:r}=Xr;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[i++]!==t)throw new r("tlv.decode: wrong tlv");const n=e[i++],s=!!(n&128);let o=0;if(!s)o=n;else{const c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const f=e.subarray(i,i+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const h of f)o=o<<8|h;if(i+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(t){const{Err:e}=Xr;if(t<lr)throw new e("integer: negative integers are not allowed");let r=$n(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Xr;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return sw(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=Xr,n=typeof t=="string"?ow(t):t;Ar(n);const{v:s,l:o}=i.decode(48,n);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,s),{v:f,l:h}=i.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){const{_tlv:e,_int:r}=Xr,i=e.encode(2,r.encode(t.r)),n=e.encode(2,r.encode(t.s)),s=i+n;return e.encode(48,s)}},lr=BigInt(0),le=BigInt(1),gi=BigInt(2),ko=BigInt(3),rl=BigInt(4);function cw(t){const e=nw(t),{Fp:r}=e,i=Gd(e.n,e.nBitLength),n=e.toBytes||((E,A,$)=>{const M=A.toAffine();return Gt(Uint8Array.from([4]),r.toBytes(M.x),r.toBytes(M.y))}),s=e.fromBytes||(E=>{const A=E.subarray(1),$=r.fromBytes(A.subarray(0,r.BYTES)),M=r.fromBytes(A.subarray(r.BYTES,2*r.BYTES));return{x:$,y:M}});function o(E){const{a:A,b:$}=e,M=r.sqr(E),P=r.mul(M,E);return r.add(r.add(P,r.mul(E,A)),$)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(E){return Mn(E,le,e.n)}function c(E){const{allowedPrivateKeyLengths:A,nByteLength:$,wrapPrivateKey:M,n:P}=e;if(A&&typeof E!="bigint"){if(Ui(E)&&(E=Dn(E)),typeof E!="string"||!A.includes(E.length))throw new Error("invalid private key");E=E.padStart($*2,"0")}let R;try{R=typeof E=="bigint"?E:Dr(Mt("private key",E,$))}catch{throw new Error("invalid private key, expected hex or "+$+" bytes, got "+typeof E)}return M&&(R=dt(R,P)),pi("private key",R,le,P),R}function f(E){if(!(E instanceof g))throw new Error("ProjectivePoint expected")}const h=Fc((E,A)=>{const{px:$,py:M,pz:P}=E;if(r.eql(P,r.ONE))return{x:$,y:M};const R=E.is0();A==null&&(A=R?r.ONE:r.inv(P));const N=r.mul($,A),L=r.mul(M,A),F=r.mul(P,A);if(R)return{x:r.ZERO,y:r.ZERO};if(!r.eql(F,r.ONE))throw new Error("invZ was invalid");return{x:N,y:L}}),l=Fc(E=>{if(E.is0()){if(e.allowInfinityPoint&&!r.is0(E.py))return;throw new Error("bad point: ZERO")}const{x:A,y:$}=E.toAffine();if(!r.isValid(A)||!r.isValid($))throw new Error("bad point: x or y not FE");const M=r.sqr($),P=o(A);if(!r.eql(M,P))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(A,$,M){if(this.px=A,this.py=$,this.pz=M,A==null||!r.isValid(A))throw new Error("x required");if($==null||!r.isValid($))throw new Error("y required");if(M==null||!r.isValid(M))throw new Error("z required");Object.freeze(this)}static fromAffine(A){const{x:$,y:M}=A||{};if(!A||!r.isValid($)||!r.isValid(M))throw new Error("invalid affine point");if(A instanceof g)throw new Error("projective point not allowed");const P=R=>r.eql(R,r.ZERO);return P($)&&P(M)?g.ZERO:new g($,M,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(A){const $=r.invertBatch(A.map(M=>M.pz));return A.map((M,P)=>M.toAffine($[P])).map(g.fromAffine)}static fromHex(A){const $=g.fromAffine(s(Mt("pointHex",A)));return $.assertValidity(),$}static fromPrivateKey(A){return g.BASE.multiply(c(A))}static msm(A,$){return iw(g,i,A,$)}_setWindowSize(A){b.setWindowSize(this,A)}assertValidity(){l(this)}hasEvenY(){const{y:A}=this.toAffine();if(r.isOdd)return!r.isOdd(A);throw new Error("Field doesn't support isOdd")}equals(A){f(A);const{px:$,py:M,pz:P}=this,{px:R,py:N,pz:L}=A,F=r.eql(r.mul($,L),r.mul(R,P)),B=r.eql(r.mul(M,L),r.mul(N,P));return F&&B}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){const{a:A,b:$}=e,M=r.mul($,ko),{px:P,py:R,pz:N}=this;let L=r.ZERO,F=r.ZERO,B=r.ZERO,C=r.mul(P,P),W=r.mul(R,R),I=r.mul(N,N),u=r.mul(P,R);return u=r.add(u,u),B=r.mul(P,N),B=r.add(B,B),L=r.mul(A,B),F=r.mul(M,I),F=r.add(L,F),L=r.sub(W,F),F=r.add(W,F),F=r.mul(L,F),L=r.mul(u,L),B=r.mul(M,B),I=r.mul(A,I),u=r.sub(C,I),u=r.mul(A,u),u=r.add(u,B),B=r.add(C,C),C=r.add(B,C),C=r.add(C,I),C=r.mul(C,u),F=r.add(F,C),I=r.mul(R,N),I=r.add(I,I),C=r.mul(I,u),L=r.sub(L,C),B=r.mul(I,W),B=r.add(B,B),B=r.add(B,B),new g(L,F,B)}add(A){f(A);const{px:$,py:M,pz:P}=this,{px:R,py:N,pz:L}=A;let F=r.ZERO,B=r.ZERO,C=r.ZERO;const W=e.a,I=r.mul(e.b,ko);let u=r.mul($,R),p=r.mul(M,N),v=r.mul(P,L),y=r.add($,M),m=r.add(R,N);y=r.mul(y,m),m=r.add(u,p),y=r.sub(y,m),m=r.add($,P);let S=r.add(R,L);return m=r.mul(m,S),S=r.add(u,v),m=r.sub(m,S),S=r.add(M,P),F=r.add(N,L),S=r.mul(S,F),F=r.add(p,v),S=r.sub(S,F),C=r.mul(W,m),F=r.mul(I,v),C=r.add(F,C),F=r.sub(p,C),C=r.add(p,C),B=r.mul(F,C),p=r.add(u,u),p=r.add(p,u),v=r.mul(W,v),m=r.mul(I,m),p=r.add(p,v),v=r.sub(u,v),v=r.mul(W,v),m=r.add(m,v),u=r.mul(p,m),B=r.add(B,u),u=r.mul(S,m),F=r.mul(y,F),F=r.sub(F,u),u=r.mul(y,p),C=r.mul(S,C),C=r.add(C,u),new g(F,B,C)}subtract(A){return this.add(A.negate())}is0(){return this.equals(g.ZERO)}wNAF(A){return b.wNAFCached(this,A,g.normalizeZ)}multiplyUnsafe(A){const{endo:$,n:M}=e;pi("scalar",A,lr,M);const P=g.ZERO;if(A===lr)return P;if(this.is0()||A===le)return this;if(!$||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,A,g.normalizeZ);let{k1neg:R,k1:N,k2neg:L,k2:F}=$.splitScalar(A),B=P,C=P,W=this;for(;N>lr||F>lr;)N&le&&(B=B.add(W)),F&le&&(C=C.add(W)),W=W.double(),N>>=le,F>>=le;return R&&(B=B.negate()),L&&(C=C.negate()),C=new g(r.mul(C.px,$.beta),C.py,C.pz),B.add(C)}multiply(A){const{endo:$,n:M}=e;pi("scalar",A,le,M);let P,R;if($){const{k1neg:N,k1:L,k2neg:F,k2:B}=$.splitScalar(A);let{p:C,f:W}=this.wNAF(L),{p:I,f:u}=this.wNAF(B);C=b.constTimeNegate(N,C),I=b.constTimeNegate(F,I),I=new g(r.mul(I.px,$.beta),I.py,I.pz),P=C.add(I),R=W.add(u)}else{const{p:N,f:L}=this.wNAF(A);P=N,R=L}return g.normalizeZ([P,R])[0]}multiplyAndAddUnsafe(A,$,M){const P=g.BASE,R=(L,F)=>F===lr||F===le||!L.equals(P)?L.multiplyUnsafe(F):L.multiply(F),N=R(this,$).add(R(A,M));return N.is0()?void 0:N}toAffine(A){return h(this,A)}isTorsionFree(){const{h:A,isTorsionFree:$}=e;if(A===le)return!0;if($)return $(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:A,clearCofactor:$}=e;return A===le?this:$?$(g,this):this.multiplyUnsafe(e.h)}toRawBytes(A=!0){return An("isCompressed",A),this.assertValidity(),n(g,this,A)}toHex(A=!0){return An("isCompressed",A),Dn(this.toRawBytes(A))}}g.BASE=new g(e.Gx,e.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);const w=e.nBitLength,b=rw(g,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function fw(t){const e=el(t);return Pn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function uw(t){const e=fw(t),{Fp:r,n:i}=e,n=r.BYTES+1,s=2*r.BYTES+1;function o(v){return dt(v,i)}function a(v){return Kc(v,i)}const{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:l}=cw({...e,toBytes(v,y,m){const S=y.toAffine(),D=r.toBytes(S.x),_=Gt;return An("isCompressed",m),m?_(Uint8Array.from([y.hasEvenY()?2:3]),D):_(Uint8Array.from([4]),D,r.toBytes(S.y))},fromBytes(v){const y=v.length,m=v[0],S=v.subarray(1);if(y===n&&(m===2||m===3)){const D=Dr(S);if(!Mn(D,le,r.ORDER))throw new Error("Point is not on curve");const _=h(D);let d;try{d=r.sqrt(_)}catch(z){const U=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+U)}const x=(d&le)===le;return(m&1)===1!==x&&(d=r.neg(d)),{x:D,y:d}}else if(y===s&&m===4){const D=r.fromBytes(S.subarray(0,r.BYTES)),_=r.fromBytes(S.subarray(r.BYTES,2*r.BYTES));return{x:D,y:_}}else{const D=n,_=s;throw new Error("invalid Point, expected length of "+D+", or uncompressed "+_+", got "+y)}}}),g=v=>Dn(li(v,e.nByteLength));function w(v){const y=i>>le;return v>y}function b(v){return w(v)?o(-v):v}const E=(v,y,m)=>Dr(v.slice(y,m));class A{constructor(y,m,S){this.r=y,this.s=m,this.recovery=S,this.assertValidity()}static fromCompact(y){const m=e.nByteLength;return y=Mt("compactSignature",y,m*2),new A(E(y,0,m),E(y,m,2*m))}static fromDER(y){const{r:m,s:S}=Xr.toSig(Mt("DER",y));return new A(m,S)}assertValidity(){pi("r",this.r,le,i),pi("s",this.s,le,i)}addRecoveryBit(y){return new A(this.r,this.s,y)}recoverPublicKey(y){const{r:m,s:S,recovery:D}=this,_=L(Mt("msgHash",y));if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");const d=D===2||D===3?m+e.n:m;if(d>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const x=D&1?"03":"02",q=c.fromHex(x+g(d)),z=a(d),U=o(-_*z),k=o(S*z),G=c.BASE.multiplyAndAddUnsafe(q,U,k);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return On(this.toDERHex())}toDERHex(){return Xr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return On(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const $={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const v=Jd(e.n);return Q3(e.randomBytes(v),e.n)},precompute(v=8,y=c.BASE){return y._setWindowSize(v),y.multiply(BigInt(3)),y}};function M(v,y=!0){return c.fromPrivateKey(v).toRawBytes(y)}function P(v){const y=Ui(v),m=typeof v=="string",S=(y||m)&&v.length;return y?S===n||S===s:m?S===2*n||S===2*s:v instanceof c}function R(v,y,m=!0){if(P(v))throw new Error("first arg must be private key");if(!P(y))throw new Error("second arg must be public key");return c.fromHex(y).multiply(f(v)).toRawBytes(m)}const N=e.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");const y=Dr(v),m=v.length*8-e.nBitLength;return m>0?y>>BigInt(m):y},L=e.bits2int_modN||function(v){return o(N(v))},F=Cc(e.nBitLength);function B(v){return pi("num < 2^"+e.nBitLength,v,lr,F),li(v,e.nByteLength)}function C(v,y,m=W){if(["recovered","canonical"].some(X=>X in m))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:D}=e;let{lowS:_,prehash:d,extraEntropy:x}=m;_==null&&(_=!0),v=Mt("msgHash",v),tl(m),d&&(v=Mt("prehashed msgHash",S(v)));const q=L(v),z=f(y),U=[B(z),B(q)];if(x!=null&&x!==!1){const X=x===!0?D(r.BYTES):x;U.push(Mt("extraEntropy",X))}const k=Gt(...U),G=q;function Z(X){const J=N(X);if(!l(J))return;const Q=a(J),Fe=c.BASE.multiply(J).toAffine(),re=o(Fe.x);if(re===lr)return;const oe=o(Q*o(G+re*z));if(oe===lr)return;let ct=(Fe.x===re?0:2)|Number(Fe.y&le),he=oe;return _&&w(oe)&&(he=b(oe),ct^=1),new A(re,he,ct)}return{seed:k,k2sig:Z}}const W={lowS:e.lowS,prehash:!1},I={lowS:e.lowS,prehash:!1};function u(v,y,m=W){const{seed:S,k2sig:D}=C(v,y,m),_=e;return Td(_.hash.outputLen,_.nByteLength,_.hmac)(S,D)}c.BASE._setWindowSize(8);function p(v,y,m,S=I){const D=v;y=Mt("msgHash",y),m=Mt("publicKey",m);const{lowS:_,prehash:d,format:x}=S;if(tl(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(x!==void 0&&x!=="compact"&&x!=="der")throw new Error("format must be compact or der");const q=typeof D=="string"||Ui(D),z=!q&&!x&&typeof D=="object"&&D!==null&&typeof D.r=="bigint"&&typeof D.s=="bigint";if(!q&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let U,k;try{if(z&&(U=new A(D.r,D.s)),q){try{x!=="compact"&&(U=A.fromDER(D))}catch(ct){if(!(ct instanceof Xr.Err))throw ct}!U&&x!=="der"&&(U=A.fromCompact(D))}k=c.fromHex(m)}catch{return!1}if(!U||_&&U.hasHighS())return!1;d&&(y=e.hash(y));const{r:G,s:Z}=U,X=L(y),J=a(Z),Q=o(X*J),Fe=o(G*J),re=c.BASE.multiplyAndAddUnsafe(k,Q,Fe)?.toAffine();return re?o(re.x)===G:!1}return{CURVE:e,getPublicKey:M,getSharedSecret:R,sign:u,verify:p,ProjectivePoint:c,Signature:A,utils:$}}function hw(t,e){const r=t.ORDER;let i=lr;for(let b=r-le;b%gi===lr;b/=gi)i+=le;const n=i,s=gi<<n-le-le,o=s*gi,a=(r-le)/o,c=(a-le)/gi,f=o-le,h=s,l=t.pow(e,a),g=t.pow(e,(a+le)/gi);let w=(b,E)=>{let A=l,$=t.pow(E,f),M=t.sqr($);M=t.mul(M,E);let P=t.mul(b,M);P=t.pow(P,c),P=t.mul(P,$),$=t.mul(P,E),M=t.mul(P,b);let R=t.mul(M,$);P=t.pow(R,h);let N=t.eql(P,t.ONE);$=t.mul(M,g),P=t.mul(R,A),M=t.cmov($,M,N),R=t.cmov(P,R,N);for(let L=n;L>le;L--){let F=L-gi;F=gi<<F-le;let B=t.pow(R,F);const C=t.eql(B,t.ONE);$=t.mul(M,A),A=t.mul(A,A),B=t.mul(R,A),M=t.cmov($,M,C),R=t.cmov(B,R,C)}return{isValid:N,value:M}};if(t.ORDER%rl===ko){const b=(t.ORDER-ko)/rl,E=t.sqrt(t.neg(e));w=(A,$)=>{let M=t.sqr($);const P=t.mul(A,$);M=t.mul(M,P);let R=t.pow(M,b);R=t.mul(R,P);const N=t.mul(R,E),L=t.mul(t.sqr(R),$),F=t.eql(L,A);let B=t.cmov(N,R,F);return{isValid:F,value:B}}}return w}function dw(t,e){if(Hd(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=hw(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return i=>{let n,s,o,a,c,f,h,l;n=t.sqr(i),n=t.mul(n,e.Z),s=t.sqr(n),s=t.add(s,n),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),h=t.mul(n,o);const{isValid:g,value:w}=r(s,f);l=t.mul(n,i),l=t.mul(l,w),h=t.cmov(h,o,g),l=t.cmov(l,w,g);const b=t.isOdd(i)===t.isOdd(l);return l=t.cmov(t.neg(l),l,b),h=t.div(h,a),{x:h,y:l}}}function lw(t){return{hash:t,hmac:(e,...r)=>jd(t,e,Bm(...r)),randomBytes:md}}function pw(t,e){const r=i=>uw({...t,...lw(i)});return{...r(e),create:r}}const gw=Dr;function bi(t,e){if(bs(t),bs(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let i=e-1;i>=0;i--)r[i]=t&255,t>>>=8;return new Uint8Array(r)}function bw(t,e){const r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t[i]^e[i];return r}function bs(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function yw(t,e,r,i){Ar(t),Ar(e),bs(r),e.length>255&&(e=i(Gt(qo("H2C-OVERSIZE-DST-"),e)));const{outputLen:n,blockLen:s}=i,o=Math.ceil(r/n);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=Gt(e,bi(e.length,1)),c=bi(0,s),f=bi(r,2),h=new Array(o),l=i(Gt(c,t,f,bi(0,1),a));h[0]=i(Gt(l,bi(1,1),a));for(let w=1;w<=o;w++){const b=[bw(l,h[w-1]),bi(w+1,1),a];h[w]=i(Gt(...b))}return Gt(...h).slice(0,r)}function vw(t,e,r,i,n){if(Ar(t),Ar(e),bs(r),e.length>255){const s=Math.ceil(2*i/8);e=n.create({dkLen:s}).update(qo("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return n.create({dkLen:r}).update(t).update(bi(r,2)).update(e).update(bi(e.length,1)).digest()}function il(t,e,r){Pn(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:i,k:n,m:s,hash:o,expand:a,DST:c}=r;Ar(t),bs(e);const f=typeof c=="string"?qo(c):c,h=i.toString(2).length,l=Math.ceil((h+n)/8),g=e*s*l;let w;if(a==="xmd")w=yw(t,f,g,o);else if(a==="xof")w=vw(t,f,g,n,o);else if(a==="_internal_pass")w=t;else throw new Error('expand must be "xmd" or "xof"');const b=new Array(e);for(let E=0;E<e;E++){const A=new Array(s);for(let $=0;$<s;$++){const M=l*($+E*s),P=w.subarray(M,M+l);A[$]=dt(gw(P),i)}b[E]=A}return b}function mw(t,e){const r=e.map(i=>Array.from(i).reverse());return(i,n)=>{const[s,o,a,c]=r.map(f=>f.reduce((h,l)=>t.add(t.mul(h,i),l)));return i=t.div(s,o),n=t.mul(n,t.div(a,c)),{x:i,y:n}}}function ww(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(i,n){const s=il(i,2,{...r,DST:r.DST,...n}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(i,n){const s=il(i,1,{...r,DST:r.encodeDST,...n}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(i){if(!Array.isArray(i))throw new Error("mapToCurve: expected array of bigints");for(const s of i)if(typeof s!="bigint")throw new Error("mapToCurve: expected array of bigints");const n=t.fromAffine(e(i)).clearCofactor();return n.assertValidity(),n}}}const ys=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),jo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),vs=BigInt(1),Ko=BigInt(2),nl=(t,e)=>(t+e/Ko)/e;function sl(t){const e=ys,r=BigInt(3),i=BigInt(6),n=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,h=f*f*t%e,l=tr(h,r,e)*h%e,g=tr(l,r,e)*h%e,w=tr(g,Ko,e)*f%e,b=tr(w,n,e)*w%e,E=tr(b,s,e)*b%e,A=tr(E,a,e)*E%e,$=tr(A,c,e)*A%e,M=tr($,a,e)*E%e,P=tr(M,r,e)*h%e,R=tr(P,o,e)*b%e,N=tr(R,i,e)*f%e,L=tr(N,Ko,e);if(!yi.eql(yi.sqr(L),t))throw new Error("Cannot find square root");return L}const yi=Gd(ys,void 0,void 0,{sqrt:sl}),ms=pw({a:BigInt(0),b:BigInt(7),Fp:yi,n:jo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=jo,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-vs*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=nl(s*t,e),c=nl(-i*t,e);let f=dt(t-a*r-c*n,e),h=dt(-a*i-c*s,e);const l=f>o,g=h>o;if(l&&(f=e-f),g&&(h=e-h),f>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:g,k2:h}}}},Bo),ol=BigInt(0),al={};function Vo(t,...e){let r=al[t];if(r===void 0){const i=Bo(Uint8Array.from(t,n=>n.charCodeAt(0)));r=Gt(i,i),al[t]=r}return Bo(Gt(r,...e))}const Yc=t=>t.toRawBytes(!0).slice(1),Jc=t=>li(t,32),Zc=t=>dt(t,ys),ws=t=>dt(t,jo),Xc=ms.ProjectivePoint,_w=(t,e,r)=>Xc.BASE.multiplyAndAddUnsafe(t,e,r);function Qc(t){let e=ms.utils.normPrivateKeyToScalar(t),r=Xc.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:ws(-e),bytes:Yc(r)}}function cl(t){pi("x",t,vs,ys);const e=Zc(t*t),r=Zc(e*t+BigInt(7));let i=sl(r);i%Ko!==ol&&(i=Zc(-i));const n=new Xc(t,i,vs);return n.assertValidity(),n}const Rn=Dr;function fl(...t){return ws(Rn(Vo("BIP0340/challenge",...t)))}function xw(t){return Qc(t).bytes}function Ew(t,e,r=md(32)){const i=Mt("message",t),{bytes:n,scalar:s}=Qc(e),o=Mt("auxRand",r,32),a=Jc(s^Rn(Vo("BIP0340/aux",o))),c=Vo("BIP0340/nonce",a,n,i),f=ws(Rn(c));if(f===ol)throw new Error("sign failed: k is zero");const{bytes:h,scalar:l}=Qc(f),g=fl(h,n,i),w=new Uint8Array(64);if(w.set(h,0),w.set(Jc(ws(l+g*s)),32),!ul(w,i,n))throw new Error("sign: Invalid signature produced");return w}function ul(t,e,r){const i=Mt("signature",t,64),n=Mt("message",e),s=Mt("publicKey",r,32);try{const o=cl(Rn(s)),a=Rn(i.subarray(0,32));if(!Mn(a,vs,ys))return!1;const c=Rn(i.subarray(32,64));if(!Mn(c,vs,jo))return!1;const f=fl(Jc(a),Yc(o),n),h=_w(o,c,ws(-f));return!(!h||!h.hasEvenY()||h.toAffine().x!==a)}catch{return!1}}const Sw=(()=>({getPublicKey:xw,sign:Ew,verify:ul,utils:{randomPrivateKey:ms.utils.randomPrivateKey,lift_x:cl,pointToBytes:Yc,numberToBytesBE:li,bytesToNumberBE:Dr,taggedHash:Vo,mod:dt}}))(),Iw=(()=>mw(yi,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))))(),Aw=(()=>dw(yi,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:yi.create(BigInt("-11"))}))(),hl=(()=>ww(ms.ProjectivePoint,t=>{const{x:e,y:r}=Aw(yi.create(t[0]));return Iw(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:yi.ORDER,m:1,k:128,expand:"xmd",hash:Bo}))();var Dw=Object.freeze({__proto__:null,secp256k1:ms,schnorr:Sw,hashToCurve:(()=>hl.hashToCurve)(),encodeToCurve:(()=>hl.encodeToCurve)()});function dl(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ef(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=dl(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function $w(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var E=0,A=0,$=0,M=b.length;$!==M&&b[$]===0;)$++,E++;for(var P=(M-$)*h+1>>>0,R=new Uint8Array(P);$!==M;){for(var N=b[$],L=0,F=P-1;(N!==0||L<A)&&F!==-1;F--,L++)N+=256*R[F]>>>0,R[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");A=L,$++}for(var B=P-A;B!==P&&R[B]===0;)B++;for(var C=c.repeat(E);B<P;++B)C+=t.charAt(R[B]);return C}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var E=0;if(b[E]!==" "){for(var A=0,$=0;b[E]===c;)A++,E++;for(var M=(b.length-E)*f+1>>>0,P=new Uint8Array(M);b[E];){var R=r[b.charCodeAt(E)];if(R===255)return;for(var N=0,L=M-1;(R!==0||N<$)&&L!==-1;L--,N++)R+=a*P[L]>>>0,P[L]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");$=N,E++}if(b[E]!==" "){for(var F=M-$;F!==M&&P[F]===0;)F++;for(var B=new Uint8Array(A+(M-F)),C=A;F!==M;)B[C++]=P[F++];return B}}}function w(b){var E=g(b);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:g,decode:w}}var Ow=$w,Mw=Ow;const ll=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Pw=t=>new TextEncoder().encode(t),Rw=t=>new TextDecoder().decode(t);class Tw{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Nw{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return pl(this,e)}}class Cw{constructor(e){this.decoders=e}or(e){return pl(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const pl=(t,e)=>new Cw({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Bw{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Tw(e,r,i),this.decoder=new Nw(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ho=({name:t,prefix:e,encode:r,decode:i})=>new Bw(t,e,r,i),_s=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Mw(r,e);return Ho({prefix:t,name:e,encode:i,decode:s=>ll(n(s))})},Fw=(t,e,r,i)=>{const n={};for(let h=0;h<e.length;++h)n[e[h]]=h;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,f=0;for(let h=0;h<s;++h){const l=n[t[h]];if(l===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,o[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Lw=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},_t=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ho({prefix:e,name:t,encode(n){return Lw(n,i,r)},decode(n){return Fw(n,i,r,t)}}),qw=Ho({prefix:"\0",name:"identity",encode:t=>Rw(t),decode:t=>Pw(t)});var zw=Object.freeze({__proto__:null,identity:qw});const Uw=_t({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kw=Object.freeze({__proto__:null,base2:Uw});const jw=_t({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kw=Object.freeze({__proto__:null,base8:jw});const Vw=_s({prefix:"9",name:"base10",alphabet:"0123456789"});var Hw=Object.freeze({__proto__:null,base10:Vw});const Ww=_t({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gw=_t({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yw=Object.freeze({__proto__:null,base16:Ww,base16upper:Gw});const Jw=_t({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zw=_t({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xw=_t({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qw=_t({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=_t({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=_t({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=_t({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=_t({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=_t({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var s6=Object.freeze({__proto__:null,base32:Jw,base32upper:Zw,base32pad:Xw,base32padupper:Qw,base32hex:e6,base32hexupper:t6,base32hexpad:r6,base32hexpadupper:i6,base32z:n6});const o6=_s({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),a6=_s({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var c6=Object.freeze({__proto__:null,base36:o6,base36upper:a6});const f6=_s({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),u6=_s({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var h6=Object.freeze({__proto__:null,base58btc:f6,base58flickr:u6});const d6=_t({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),l6=_t({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),p6=_t({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),g6=_t({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var b6=Object.freeze({__proto__:null,base64:d6,base64pad:l6,base64url:p6,base64urlpad:g6});const gl=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),y6=gl.reduce((t,e,r)=>(t[r]=e,t),[]),v6=gl.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function m6(t){return t.reduce((e,r)=>(e+=y6[r],e),"")}function w6(t){const e=[];for(const r of t){const i=v6[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const _6=Ho({prefix:"\u{1F680}",name:"base256emoji",encode:m6,decode:w6});var x6=Object.freeze({__proto__:null,base256emoji:_6}),E6=yl,bl=128,S6=127,I6=~S6,A6=Math.pow(2,31);function yl(t,e,r){e=e||[],r=r||0;for(var i=r;t>=A6;)e[r++]=t&255|bl,t/=128;for(;t&I6;)e[r++]=t&255|bl,t>>>=7;return e[r]=t|0,yl.bytes=r-i+1,e}var D6=tf,$6=128,vl=127;function tf(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw tf.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&vl)<<n:(o&vl)*Math.pow(2,n),n+=7}while(o>=$6);return tf.bytes=s-i,r}var O6=Math.pow(2,7),M6=Math.pow(2,14),P6=Math.pow(2,21),R6=Math.pow(2,28),T6=Math.pow(2,35),N6=Math.pow(2,42),C6=Math.pow(2,49),B6=Math.pow(2,56),F6=Math.pow(2,63),L6=function(t){return t<O6?1:t<M6?2:t<P6?3:t<R6?4:t<T6?5:t<N6?6:t<C6?7:t<B6?8:t<F6?9:10},q6={encode:E6,decode:D6,encodingLength:L6},ml=q6;const wl=(t,e,r=0)=>(ml.encode(t,e,r),e),_l=t=>ml.encodingLength(t),rf=(t,e)=>{const r=e.byteLength,i=_l(t),n=i+_l(r),s=new Uint8Array(n+r);return wl(t,s,0),wl(r,s,i),s.set(e,n),new z6(t,r,e,s)};class z6{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const xl=({name:t,code:e,encode:r})=>new U6(t,e,r);class U6{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?rf(this.code,r):r.then(i=>rf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const El=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),k6=xl({name:"sha2-256",code:18,encode:El("SHA-256")}),j6=xl({name:"sha2-512",code:19,encode:El("SHA-512")});var K6=Object.freeze({__proto__:null,sha256:k6,sha512:j6});const Sl=0,V6="identity",Il=ll;var H6=Object.freeze({__proto__:null,identity:{code:Sl,name:V6,encode:Il,digest:t=>rf(Sl,Il(t))}});new TextEncoder,new TextDecoder;const Al={...zw,...kw,...Kw,...Hw,...Yw,...s6,...c6,...h6,...b6,...x6};({...K6,...H6});function Dl(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const $l=Dl("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),nf=Dl("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=dl(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ol={utf8:$l,"utf-8":$l,hex:Al.base16,latin1:nf,ascii:nf,binary:nf,...Al};function rr(t,e="utf8"){const r=Ol[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function Lt(t,e="utf8"){const r=Ol[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Ml={},W6="elliptic",G6="6.6.1",Y6="EC cryptography",J6="lib/elliptic.js",Z6=["lib"],X6={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},Q6={type:"git",url:"git@github.com:indutny/elliptic"},e8=["EC","Elliptic","curve","Cryptography"],t8="Fedor Indutny <fedor@indutny.com>",r8="MIT",i8={url:"https://github.com/indutny/elliptic/issues"},n8="https://github.com/indutny/elliptic",s8={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},o8={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},a8={name:W6,version:G6,description:Y6,main:J6,files:Z6,scripts:X6,repository:Q6,keywords:e8,author:t8,license:r8,bugs:i8,homepage:n8,devDependencies:s8,dependencies:o8},Yt={},$r={exports:{}},c8={},f8=Object.freeze({__proto__:null,default:c8}),Pl=La(f8);(function(t){(function(e,r){function i(I,u){if(!I)throw new Error(u||"Assertion failed")}function n(I,u){I.super_=u;var p=function(){};p.prototype=u.prototype,I.prototype=new p,I.prototype.constructor=I}function s(I,u,p){if(s.isBN(I))return I;this.negative=0,this.words=null,this.length=0,this.red=null,I!==null&&((u==="le"||u==="be")&&(p=u,u=10),this._init(I||0,u||10,p||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Pl.Buffer}catch{}s.isBN=function(u){return u instanceof s?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===s.wordSize&&Array.isArray(u.words)},s.max=function(u,p){return u.cmp(p)>0?u:p},s.min=function(u,p){return u.cmp(p)<0?u:p},s.prototype._init=function(u,p,v){if(typeof u=="number")return this._initNumber(u,p,v);if(typeof u=="object")return this._initArray(u,p,v);p==="hex"&&(p=16),i(p===(p|0)&&p>=2&&p<=36),u=u.toString().replace(/\s+/g,"");var y=0;u[0]==="-"&&(y++,this.negative=1),y<u.length&&(p===16?this._parseHex(u,y,v):(this._parseBase(u,p,y),v==="le"&&this._initArray(this.toArray(),p,v)))},s.prototype._initNumber=function(u,p,v){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(i(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),p,v)},s.prototype._initArray=function(u,p,v){if(i(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var y=0;y<this.length;y++)this.words[y]=0;var m,S,D=0;if(v==="be")for(y=u.length-1,m=0;y>=0;y-=3)S=u[y]|u[y-1]<<8|u[y-2]<<16,this.words[m]|=S<<D&67108863,this.words[m+1]=S>>>26-D&67108863,D+=24,D>=26&&(D-=26,m++);else if(v==="le")for(y=0,m=0;y<u.length;y+=3)S=u[y]|u[y+1]<<8|u[y+2]<<16,this.words[m]|=S<<D&67108863,this.words[m+1]=S>>>26-D&67108863,D+=24,D>=26&&(D-=26,m++);return this.strip()};function a(I,u){var p=I.charCodeAt(u);return p>=65&&p<=70?p-55:p>=97&&p<=102?p-87:p-48&15}function c(I,u,p){var v=a(I,p);return p-1>=u&&(v|=a(I,p-1)<<4),v}s.prototype._parseHex=function(u,p,v){this.length=Math.ceil((u.length-p)/6),this.words=new Array(this.length);for(var y=0;y<this.length;y++)this.words[y]=0;var m=0,S=0,D;if(v==="be")for(y=u.length-1;y>=p;y-=2)D=c(u,p,y)<<m,this.words[S]|=D&67108863,m>=18?(m-=18,S+=1,this.words[S]|=D>>>26):m+=8;else{var _=u.length-p;for(y=_%2===0?p+1:p;y<u.length;y+=2)D=c(u,p,y)<<m,this.words[S]|=D&67108863,m>=18?(m-=18,S+=1,this.words[S]|=D>>>26):m+=8}this.strip()};function f(I,u,p,v){for(var y=0,m=Math.min(I.length,p),S=u;S<m;S++){var D=I.charCodeAt(S)-48;y*=v,D>=49?y+=D-49+10:D>=17?y+=D-17+10:y+=D}return y}s.prototype._parseBase=function(u,p,v){this.words=[0],this.length=1;for(var y=0,m=1;m<=67108863;m*=p)y++;y--,m=m/p|0;for(var S=u.length-v,D=S%y,_=Math.min(S,S-D)+v,d=0,x=v;x<_;x+=y)d=f(u,x,x+y,p),this.imuln(m),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(D!==0){var q=1;for(d=f(u,x,u.length,p),x=0;x<D;x++)q*=p;this.imuln(q),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(u){u.words=new Array(this.length);for(var p=0;p<this.length;p++)u.words[p]=this.words[p];u.length=this.length,u.negative=this.negative,u.red=this.red},s.prototype.clone=function(){var u=new s(null);return this.copy(u),u},s.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var h=["","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"],l=[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],g=[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];s.prototype.toString=function(u,p){u=u||10,p=p|0||1;var v;if(u===16||u==="hex"){v="";for(var y=0,m=0,S=0;S<this.length;S++){var D=this.words[S],_=((D<<y|m)&16777215).toString(16);m=D>>>24-y&16777215,y+=2,y>=26&&(y-=26,S--),m!==0||S!==this.length-1?v=h[6-_.length]+_+v:v=_+v}for(m!==0&&(v=m.toString(16)+v);v.length%p!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(u===(u|0)&&u>=2&&u<=36){var d=l[u],x=g[u];v="";var q=this.clone();for(q.negative=0;!q.isZero();){var z=q.modn(x).toString(u);q=q.idivn(x),q.isZero()?v=z+v:v=h[d-z.length]+z+v}for(this.isZero()&&(v="0"+v);v.length%p!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(u,p){return i(typeof o<"u"),this.toArrayLike(o,u,p)},s.prototype.toArray=function(u,p){return this.toArrayLike(Array,u,p)},s.prototype.toArrayLike=function(u,p,v){var y=this.byteLength(),m=v||Math.max(1,y);i(y<=m,"byte array longer than desired length"),i(m>0,"Requested array length <= 0"),this.strip();var S=p==="le",D=new u(m),_,d,x=this.clone();if(S){for(d=0;!x.isZero();d++)_=x.andln(255),x.iushrn(8),D[d]=_;for(;d<m;d++)D[d]=0}else{for(d=0;d<m-y;d++)D[d]=0;for(d=0;!x.isZero();d++)_=x.andln(255),x.iushrn(8),D[m-d-1]=_}return D},Math.clz32?s.prototype._countBits=function(u){return 32-Math.clz32(u)}:s.prototype._countBits=function(u){var p=u,v=0;return p>=4096&&(v+=13,p>>>=13),p>=64&&(v+=7,p>>>=7),p>=8&&(v+=4,p>>>=4),p>=2&&(v+=2,p>>>=2),v+p},s.prototype._zeroBits=function(u){if(u===0)return 26;var p=u,v=0;return p&8191||(v+=13,p>>>=13),p&127||(v+=7,p>>>=7),p&15||(v+=4,p>>>=4),p&3||(v+=2,p>>>=2),p&1||v++,v},s.prototype.bitLength=function(){var u=this.words[this.length-1],p=this._countBits(u);return(this.length-1)*26+p};function w(I){for(var u=new Array(I.bitLength()),p=0;p<u.length;p++){var v=p/26|0,y=p%26;u[p]=(I.words[v]&1<<y)>>>y}return u}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,p=0;p<this.length;p++){var v=this._zeroBits(this.words[p]);if(u+=v,v!==26)break}return u},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},s.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var p=0;p<u.length;p++)this.words[p]=this.words[p]|u.words[p];return this.strip()},s.prototype.ior=function(u){return i((this.negative|u.negative)===0),this.iuor(u)},s.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},s.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},s.prototype.iuand=function(u){var p;this.length>u.length?p=u:p=this;for(var v=0;v<p.length;v++)this.words[v]=this.words[v]&u.words[v];return this.length=p.length,this.strip()},s.prototype.iand=function(u){return i((this.negative|u.negative)===0),this.iuand(u)},s.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},s.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},s.prototype.iuxor=function(u){var p,v;this.length>u.length?(p=this,v=u):(p=u,v=this);for(var y=0;y<v.length;y++)this.words[y]=p.words[y]^v.words[y];if(this!==p)for(;y<p.length;y++)this.words[y]=p.words[y];return this.length=p.length,this.strip()},s.prototype.ixor=function(u){return i((this.negative|u.negative)===0),this.iuxor(u)},s.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},s.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},s.prototype.inotn=function(u){i(typeof u=="number"&&u>=0);var p=Math.ceil(u/26)|0,v=u%26;this._expand(p),v>0&&p--;for(var y=0;y<p;y++)this.words[y]=~this.words[y]&67108863;return v>0&&(this.words[y]=~this.words[y]&67108863>>26-v),this.strip()},s.prototype.notn=function(u){return this.clone().inotn(u)},s.prototype.setn=function(u,p){i(typeof u=="number"&&u>=0);var v=u/26|0,y=u%26;return this._expand(v+1),p?this.words[v]=this.words[v]|1<<y:this.words[v]=this.words[v]&~(1<<y),this.strip()},s.prototype.iadd=function(u){var p;if(this.negative!==0&&u.negative===0)return this.negative=0,p=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,p=this.isub(u),u.negative=1,p._normSign();var v,y;this.length>u.length?(v=this,y=u):(v=u,y=this);for(var m=0,S=0;S<y.length;S++)p=(v.words[S]|0)+(y.words[S]|0)+m,this.words[S]=p&67108863,m=p>>>26;for(;m!==0&&S<v.length;S++)p=(v.words[S]|0)+m,this.words[S]=p&67108863,m=p>>>26;if(this.length=v.length,m!==0)this.words[this.length]=m,this.length++;else if(v!==this)for(;S<v.length;S++)this.words[S]=v.words[S];return this},s.prototype.add=function(u){var p;return u.negative!==0&&this.negative===0?(u.negative=0,p=this.sub(u),u.negative^=1,p):u.negative===0&&this.negative!==0?(this.negative=0,p=u.sub(this),this.negative=1,p):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},s.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var p=this.iadd(u);return u.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var v=this.cmp(u);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var y,m;v>0?(y=this,m=u):(y=u,m=this);for(var S=0,D=0;D<m.length;D++)p=(y.words[D]|0)-(m.words[D]|0)+S,S=p>>26,this.words[D]=p&67108863;for(;S!==0&&D<y.length;D++)p=(y.words[D]|0)+S,S=p>>26,this.words[D]=p&67108863;if(S===0&&D<y.length&&y!==this)for(;D<y.length;D++)this.words[D]=y.words[D];return this.length=Math.max(this.length,D),y!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(u){return this.clone().isub(u)};function b(I,u,p){p.negative=u.negative^I.negative;var v=I.length+u.length|0;p.length=v,v=v-1|0;var y=I.words[0]|0,m=u.words[0]|0,S=y*m,D=S&67108863,_=S/67108864|0;p.words[0]=D;for(var d=1;d<v;d++){for(var x=_>>>26,q=_&67108863,z=Math.min(d,u.length-1),U=Math.max(0,d-I.length+1);U<=z;U++){var k=d-U|0;y=I.words[k]|0,m=u.words[U]|0,S=y*m+q,x+=S/67108864|0,q=S&67108863}p.words[d]=q|0,_=x|0}return _!==0?p.words[d]=_|0:p.length--,p.strip()}var E=function(u,p,v){var y=u.words,m=p.words,S=v.words,D=0,_,d,x,q=y[0]|0,z=q&8191,U=q>>>13,k=y[1]|0,G=k&8191,Z=k>>>13,X=y[2]|0,J=X&8191,Q=X>>>13,Fe=y[3]|0,re=Fe&8191,oe=Fe>>>13,ct=y[4]|0,he=ct&8191,Me=ct>>>13,es=y[5]|0,Pe=es&8191,Ie=es>>>13,on=y[6]|0,_e=on&8191,Ae=on>>>13,an=y[7]|0,De=an&8191,$e=an>>>13,cn=y[8]|0,be=cn&8191,xe=cn>>>13,fn=y[9]|0,ae=fn&8191,Le=fn>>>13,Gs=m[0]|0,He=Gs&8191,qe=Gs>>>13,un=m[1]|0,ze=un&8191,Ue=un>>>13,$a=m[2]|0,ge=$a&8191,ke=$a>>>13,Oa=m[3]|0,We=Oa&8191,Re=Oa>>>13,Oi=m[4]|0,Te=Oi&8191,Ne=Oi>>>13,ts=m[5]|0,Ee=ts&8191,Ge=ts>>>13,Ma=m[6]|0,Ye=Ma&8191,Je=Ma>>>13,Pa=m[7]|0,je=Pa&8191,Ce=Pa>>>13,Vr=m[8]|0,Ze=Vr&8191,Xe=Vr>>>13,Ra=m[9]|0,Qe=Ra&8191,et=Ra>>>13;v.negative=u.negative^p.negative,v.length=19,_=Math.imul(z,He),d=Math.imul(z,qe),d=d+Math.imul(U,He)|0,x=Math.imul(U,qe);var Qt=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,_=Math.imul(G,He),d=Math.imul(G,qe),d=d+Math.imul(Z,He)|0,x=Math.imul(Z,qe),_=_+Math.imul(z,ze)|0,d=d+Math.imul(z,Ue)|0,d=d+Math.imul(U,ze)|0,x=x+Math.imul(U,Ue)|0;var Ys=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Ys>>>26)|0,Ys&=67108863,_=Math.imul(J,He),d=Math.imul(J,qe),d=d+Math.imul(Q,He)|0,x=Math.imul(Q,qe),_=_+Math.imul(G,ze)|0,d=d+Math.imul(G,Ue)|0,d=d+Math.imul(Z,ze)|0,x=x+Math.imul(Z,Ue)|0,_=_+Math.imul(z,ge)|0,d=d+Math.imul(z,ke)|0,d=d+Math.imul(U,ge)|0,x=x+Math.imul(U,ke)|0;var Js=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Js>>>26)|0,Js&=67108863,_=Math.imul(re,He),d=Math.imul(re,qe),d=d+Math.imul(oe,He)|0,x=Math.imul(oe,qe),_=_+Math.imul(J,ze)|0,d=d+Math.imul(J,Ue)|0,d=d+Math.imul(Q,ze)|0,x=x+Math.imul(Q,Ue)|0,_=_+Math.imul(G,ge)|0,d=d+Math.imul(G,ke)|0,d=d+Math.imul(Z,ge)|0,x=x+Math.imul(Z,ke)|0,_=_+Math.imul(z,We)|0,d=d+Math.imul(z,Re)|0,d=d+Math.imul(U,We)|0,x=x+Math.imul(U,Re)|0;var Zs=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Zs>>>26)|0,Zs&=67108863,_=Math.imul(he,He),d=Math.imul(he,qe),d=d+Math.imul(Me,He)|0,x=Math.imul(Me,qe),_=_+Math.imul(re,ze)|0,d=d+Math.imul(re,Ue)|0,d=d+Math.imul(oe,ze)|0,x=x+Math.imul(oe,Ue)|0,_=_+Math.imul(J,ge)|0,d=d+Math.imul(J,ke)|0,d=d+Math.imul(Q,ge)|0,x=x+Math.imul(Q,ke)|0,_=_+Math.imul(G,We)|0,d=d+Math.imul(G,Re)|0,d=d+Math.imul(Z,We)|0,x=x+Math.imul(Z,Re)|0,_=_+Math.imul(z,Te)|0,d=d+Math.imul(z,Ne)|0,d=d+Math.imul(U,Te)|0,x=x+Math.imul(U,Ne)|0;var Xs=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Xs>>>26)|0,Xs&=67108863,_=Math.imul(Pe,He),d=Math.imul(Pe,qe),d=d+Math.imul(Ie,He)|0,x=Math.imul(Ie,qe),_=_+Math.imul(he,ze)|0,d=d+Math.imul(he,Ue)|0,d=d+Math.imul(Me,ze)|0,x=x+Math.imul(Me,Ue)|0,_=_+Math.imul(re,ge)|0,d=d+Math.imul(re,ke)|0,d=d+Math.imul(oe,ge)|0,x=x+Math.imul(oe,ke)|0,_=_+Math.imul(J,We)|0,d=d+Math.imul(J,Re)|0,d=d+Math.imul(Q,We)|0,x=x+Math.imul(Q,Re)|0,_=_+Math.imul(G,Te)|0,d=d+Math.imul(G,Ne)|0,d=d+Math.imul(Z,Te)|0,x=x+Math.imul(Z,Ne)|0,_=_+Math.imul(z,Ee)|0,d=d+Math.imul(z,Ge)|0,d=d+Math.imul(U,Ee)|0,x=x+Math.imul(U,Ge)|0;var Qs=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Qs>>>26)|0,Qs&=67108863,_=Math.imul(_e,He),d=Math.imul(_e,qe),d=d+Math.imul(Ae,He)|0,x=Math.imul(Ae,qe),_=_+Math.imul(Pe,ze)|0,d=d+Math.imul(Pe,Ue)|0,d=d+Math.imul(Ie,ze)|0,x=x+Math.imul(Ie,Ue)|0,_=_+Math.imul(he,ge)|0,d=d+Math.imul(he,ke)|0,d=d+Math.imul(Me,ge)|0,x=x+Math.imul(Me,ke)|0,_=_+Math.imul(re,We)|0,d=d+Math.imul(re,Re)|0,d=d+Math.imul(oe,We)|0,x=x+Math.imul(oe,Re)|0,_=_+Math.imul(J,Te)|0,d=d+Math.imul(J,Ne)|0,d=d+Math.imul(Q,Te)|0,x=x+Math.imul(Q,Ne)|0,_=_+Math.imul(G,Ee)|0,d=d+Math.imul(G,Ge)|0,d=d+Math.imul(Z,Ee)|0,x=x+Math.imul(Z,Ge)|0,_=_+Math.imul(z,Ye)|0,d=d+Math.imul(z,Je)|0,d=d+Math.imul(U,Ye)|0,x=x+Math.imul(U,Je)|0;var _r=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(_r>>>26)|0,_r&=67108863,_=Math.imul(De,He),d=Math.imul(De,qe),d=d+Math.imul($e,He)|0,x=Math.imul($e,qe),_=_+Math.imul(_e,ze)|0,d=d+Math.imul(_e,Ue)|0,d=d+Math.imul(Ae,ze)|0,x=x+Math.imul(Ae,Ue)|0,_=_+Math.imul(Pe,ge)|0,d=d+Math.imul(Pe,ke)|0,d=d+Math.imul(Ie,ge)|0,x=x+Math.imul(Ie,ke)|0,_=_+Math.imul(he,We)|0,d=d+Math.imul(he,Re)|0,d=d+Math.imul(Me,We)|0,x=x+Math.imul(Me,Re)|0,_=_+Math.imul(re,Te)|0,d=d+Math.imul(re,Ne)|0,d=d+Math.imul(oe,Te)|0,x=x+Math.imul(oe,Ne)|0,_=_+Math.imul(J,Ee)|0,d=d+Math.imul(J,Ge)|0,d=d+Math.imul(Q,Ee)|0,x=x+Math.imul(Q,Ge)|0,_=_+Math.imul(G,Ye)|0,d=d+Math.imul(G,Je)|0,d=d+Math.imul(Z,Ye)|0,x=x+Math.imul(Z,Je)|0,_=_+Math.imul(z,je)|0,d=d+Math.imul(z,Ce)|0,d=d+Math.imul(U,je)|0,x=x+Math.imul(U,Ce)|0;var eo=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(eo>>>26)|0,eo&=67108863,_=Math.imul(be,He),d=Math.imul(be,qe),d=d+Math.imul(xe,He)|0,x=Math.imul(xe,qe),_=_+Math.imul(De,ze)|0,d=d+Math.imul(De,Ue)|0,d=d+Math.imul($e,ze)|0,x=x+Math.imul($e,Ue)|0,_=_+Math.imul(_e,ge)|0,d=d+Math.imul(_e,ke)|0,d=d+Math.imul(Ae,ge)|0,x=x+Math.imul(Ae,ke)|0,_=_+Math.imul(Pe,We)|0,d=d+Math.imul(Pe,Re)|0,d=d+Math.imul(Ie,We)|0,x=x+Math.imul(Ie,Re)|0,_=_+Math.imul(he,Te)|0,d=d+Math.imul(he,Ne)|0,d=d+Math.imul(Me,Te)|0,x=x+Math.imul(Me,Ne)|0,_=_+Math.imul(re,Ee)|0,d=d+Math.imul(re,Ge)|0,d=d+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Ge)|0,_=_+Math.imul(J,Ye)|0,d=d+Math.imul(J,Je)|0,d=d+Math.imul(Q,Ye)|0,x=x+Math.imul(Q,Je)|0,_=_+Math.imul(G,je)|0,d=d+Math.imul(G,Ce)|0,d=d+Math.imul(Z,je)|0,x=x+Math.imul(Z,Ce)|0,_=_+Math.imul(z,Ze)|0,d=d+Math.imul(z,Xe)|0,d=d+Math.imul(U,Ze)|0,x=x+Math.imul(U,Xe)|0;var to=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(to>>>26)|0,to&=67108863,_=Math.imul(ae,He),d=Math.imul(ae,qe),d=d+Math.imul(Le,He)|0,x=Math.imul(Le,qe),_=_+Math.imul(be,ze)|0,d=d+Math.imul(be,Ue)|0,d=d+Math.imul(xe,ze)|0,x=x+Math.imul(xe,Ue)|0,_=_+Math.imul(De,ge)|0,d=d+Math.imul(De,ke)|0,d=d+Math.imul($e,ge)|0,x=x+Math.imul($e,ke)|0,_=_+Math.imul(_e,We)|0,d=d+Math.imul(_e,Re)|0,d=d+Math.imul(Ae,We)|0,x=x+Math.imul(Ae,Re)|0,_=_+Math.imul(Pe,Te)|0,d=d+Math.imul(Pe,Ne)|0,d=d+Math.imul(Ie,Te)|0,x=x+Math.imul(Ie,Ne)|0,_=_+Math.imul(he,Ee)|0,d=d+Math.imul(he,Ge)|0,d=d+Math.imul(Me,Ee)|0,x=x+Math.imul(Me,Ge)|0,_=_+Math.imul(re,Ye)|0,d=d+Math.imul(re,Je)|0,d=d+Math.imul(oe,Ye)|0,x=x+Math.imul(oe,Je)|0,_=_+Math.imul(J,je)|0,d=d+Math.imul(J,Ce)|0,d=d+Math.imul(Q,je)|0,x=x+Math.imul(Q,Ce)|0,_=_+Math.imul(G,Ze)|0,d=d+Math.imul(G,Xe)|0,d=d+Math.imul(Z,Ze)|0,x=x+Math.imul(Z,Xe)|0,_=_+Math.imul(z,Qe)|0,d=d+Math.imul(z,et)|0,d=d+Math.imul(U,Qe)|0,x=x+Math.imul(U,et)|0;var ro=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(ro>>>26)|0,ro&=67108863,_=Math.imul(ae,ze),d=Math.imul(ae,Ue),d=d+Math.imul(Le,ze)|0,x=Math.imul(Le,Ue),_=_+Math.imul(be,ge)|0,d=d+Math.imul(be,ke)|0,d=d+Math.imul(xe,ge)|0,x=x+Math.imul(xe,ke)|0,_=_+Math.imul(De,We)|0,d=d+Math.imul(De,Re)|0,d=d+Math.imul($e,We)|0,x=x+Math.imul($e,Re)|0,_=_+Math.imul(_e,Te)|0,d=d+Math.imul(_e,Ne)|0,d=d+Math.imul(Ae,Te)|0,x=x+Math.imul(Ae,Ne)|0,_=_+Math.imul(Pe,Ee)|0,d=d+Math.imul(Pe,Ge)|0,d=d+Math.imul(Ie,Ee)|0,x=x+Math.imul(Ie,Ge)|0,_=_+Math.imul(he,Ye)|0,d=d+Math.imul(he,Je)|0,d=d+Math.imul(Me,Ye)|0,x=x+Math.imul(Me,Je)|0,_=_+Math.imul(re,je)|0,d=d+Math.imul(re,Ce)|0,d=d+Math.imul(oe,je)|0,x=x+Math.imul(oe,Ce)|0,_=_+Math.imul(J,Ze)|0,d=d+Math.imul(J,Xe)|0,d=d+Math.imul(Q,Ze)|0,x=x+Math.imul(Q,Xe)|0,_=_+Math.imul(G,Qe)|0,d=d+Math.imul(G,et)|0,d=d+Math.imul(Z,Qe)|0,x=x+Math.imul(Z,et)|0;var io=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(io>>>26)|0,io&=67108863,_=Math.imul(ae,ge),d=Math.imul(ae,ke),d=d+Math.imul(Le,ge)|0,x=Math.imul(Le,ke),_=_+Math.imul(be,We)|0,d=d+Math.imul(be,Re)|0,d=d+Math.imul(xe,We)|0,x=x+Math.imul(xe,Re)|0,_=_+Math.imul(De,Te)|0,d=d+Math.imul(De,Ne)|0,d=d+Math.imul($e,Te)|0,x=x+Math.imul($e,Ne)|0,_=_+Math.imul(_e,Ee)|0,d=d+Math.imul(_e,Ge)|0,d=d+Math.imul(Ae,Ee)|0,x=x+Math.imul(Ae,Ge)|0,_=_+Math.imul(Pe,Ye)|0,d=d+Math.imul(Pe,Je)|0,d=d+Math.imul(Ie,Ye)|0,x=x+Math.imul(Ie,Je)|0,_=_+Math.imul(he,je)|0,d=d+Math.imul(he,Ce)|0,d=d+Math.imul(Me,je)|0,x=x+Math.imul(Me,Ce)|0,_=_+Math.imul(re,Ze)|0,d=d+Math.imul(re,Xe)|0,d=d+Math.imul(oe,Ze)|0,x=x+Math.imul(oe,Xe)|0,_=_+Math.imul(J,Qe)|0,d=d+Math.imul(J,et)|0,d=d+Math.imul(Q,Qe)|0,x=x+Math.imul(Q,et)|0;var no=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(no>>>26)|0,no&=67108863,_=Math.imul(ae,We),d=Math.imul(ae,Re),d=d+Math.imul(Le,We)|0,x=Math.imul(Le,Re),_=_+Math.imul(be,Te)|0,d=d+Math.imul(be,Ne)|0,d=d+Math.imul(xe,Te)|0,x=x+Math.imul(xe,Ne)|0,_=_+Math.imul(De,Ee)|0,d=d+Math.imul(De,Ge)|0,d=d+Math.imul($e,Ee)|0,x=x+Math.imul($e,Ge)|0,_=_+Math.imul(_e,Ye)|0,d=d+Math.imul(_e,Je)|0,d=d+Math.imul(Ae,Ye)|0,x=x+Math.imul(Ae,Je)|0,_=_+Math.imul(Pe,je)|0,d=d+Math.imul(Pe,Ce)|0,d=d+Math.imul(Ie,je)|0,x=x+Math.imul(Ie,Ce)|0,_=_+Math.imul(he,Ze)|0,d=d+Math.imul(he,Xe)|0,d=d+Math.imul(Me,Ze)|0,x=x+Math.imul(Me,Xe)|0,_=_+Math.imul(re,Qe)|0,d=d+Math.imul(re,et)|0,d=d+Math.imul(oe,Qe)|0,x=x+Math.imul(oe,et)|0;var Mi=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,_=Math.imul(ae,Te),d=Math.imul(ae,Ne),d=d+Math.imul(Le,Te)|0,x=Math.imul(Le,Ne),_=_+Math.imul(be,Ee)|0,d=d+Math.imul(be,Ge)|0,d=d+Math.imul(xe,Ee)|0,x=x+Math.imul(xe,Ge)|0,_=_+Math.imul(De,Ye)|0,d=d+Math.imul(De,Je)|0,d=d+Math.imul($e,Ye)|0,x=x+Math.imul($e,Je)|0,_=_+Math.imul(_e,je)|0,d=d+Math.imul(_e,Ce)|0,d=d+Math.imul(Ae,je)|0,x=x+Math.imul(Ae,Ce)|0,_=_+Math.imul(Pe,Ze)|0,d=d+Math.imul(Pe,Xe)|0,d=d+Math.imul(Ie,Ze)|0,x=x+Math.imul(Ie,Xe)|0,_=_+Math.imul(he,Qe)|0,d=d+Math.imul(he,et)|0,d=d+Math.imul(Me,Qe)|0,x=x+Math.imul(Me,et)|0;var so=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(so>>>26)|0,so&=67108863,_=Math.imul(ae,Ee),d=Math.imul(ae,Ge),d=d+Math.imul(Le,Ee)|0,x=Math.imul(Le,Ge),_=_+Math.imul(be,Ye)|0,d=d+Math.imul(be,Je)|0,d=d+Math.imul(xe,Ye)|0,x=x+Math.imul(xe,Je)|0,_=_+Math.imul(De,je)|0,d=d+Math.imul(De,Ce)|0,d=d+Math.imul($e,je)|0,x=x+Math.imul($e,Ce)|0,_=_+Math.imul(_e,Ze)|0,d=d+Math.imul(_e,Xe)|0,d=d+Math.imul(Ae,Ze)|0,x=x+Math.imul(Ae,Xe)|0,_=_+Math.imul(Pe,Qe)|0,d=d+Math.imul(Pe,et)|0,d=d+Math.imul(Ie,Qe)|0,x=x+Math.imul(Ie,et)|0;var oo=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(oo>>>26)|0,oo&=67108863,_=Math.imul(ae,Ye),d=Math.imul(ae,Je),d=d+Math.imul(Le,Ye)|0,x=Math.imul(Le,Je),_=_+Math.imul(be,je)|0,d=d+Math.imul(be,Ce)|0,d=d+Math.imul(xe,je)|0,x=x+Math.imul(xe,Ce)|0,_=_+Math.imul(De,Ze)|0,d=d+Math.imul(De,Xe)|0,d=d+Math.imul($e,Ze)|0,x=x+Math.imul($e,Xe)|0,_=_+Math.imul(_e,Qe)|0,d=d+Math.imul(_e,et)|0,d=d+Math.imul(Ae,Qe)|0,x=x+Math.imul(Ae,et)|0;var fr=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(fr>>>26)|0,fr&=67108863,_=Math.imul(ae,je),d=Math.imul(ae,Ce),d=d+Math.imul(Le,je)|0,x=Math.imul(Le,Ce),_=_+Math.imul(be,Ze)|0,d=d+Math.imul(be,Xe)|0,d=d+Math.imul(xe,Ze)|0,x=x+Math.imul(xe,Xe)|0,_=_+Math.imul(De,Qe)|0,d=d+Math.imul(De,et)|0,d=d+Math.imul($e,Qe)|0,x=x+Math.imul($e,et)|0;var ao=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(ao>>>26)|0,ao&=67108863,_=Math.imul(ae,Ze),d=Math.imul(ae,Xe),d=d+Math.imul(Le,Ze)|0,x=Math.imul(Le,Xe),_=_+Math.imul(be,Qe)|0,d=d+Math.imul(be,et)|0,d=d+Math.imul(xe,Qe)|0,x=x+Math.imul(xe,et)|0;var co=(D+_|0)+((d&8191)<<13)|0;D=(x+(d>>>13)|0)+(co>>>26)|0,co&=67108863,_=Math.imul(ae,Qe),d=Math.imul(ae,et),d=d+Math.imul(Le,Qe)|0,x=Math.imul(Le,et);var fo=(D+_|0)+((d&8191)<<13)|0;return D=(x+(d>>>13)|0)+(fo>>>26)|0,fo&=67108863,S[0]=Qt,S[1]=Ys,S[2]=Js,S[3]=Zs,S[4]=Xs,S[5]=Qs,S[6]=_r,S[7]=eo,S[8]=to,S[9]=ro,S[10]=io,S[11]=no,S[12]=Mi,S[13]=so,S[14]=oo,S[15]=fr,S[16]=ao,S[17]=co,S[18]=fo,D!==0&&(S[19]=D,v.length++),v};Math.imul||(E=b);function A(I,u,p){p.negative=u.negative^I.negative,p.length=I.length+u.length;for(var v=0,y=0,m=0;m<p.length-1;m++){var S=y;y=0;for(var D=v&67108863,_=Math.min(m,u.length-1),d=Math.max(0,m-I.length+1);d<=_;d++){var x=m-d,q=I.words[x]|0,z=u.words[d]|0,U=q*z,k=U&67108863;S=S+(U/67108864|0)|0,k=k+D|0,D=k&67108863,S=S+(k>>>26)|0,y+=S>>>26,S&=67108863}p.words[m]=D,v=S,S=y}return v!==0?p.words[m]=v:p.length--,p.strip()}function $(I,u,p){var v=new M;return v.mulp(I,u,p)}s.prototype.mulTo=function(u,p){var v,y=this.length+u.length;return this.length===10&&u.length===10?v=E(this,u,p):y<63?v=b(this,u,p):y<1024?v=A(this,u,p):v=$(this,u,p),v};function M(I,u){this.x=I,this.y=u}M.prototype.makeRBT=function(u){for(var p=new Array(u),v=s.prototype._countBits(u)-1,y=0;y<u;y++)p[y]=this.revBin(y,v,u);return p},M.prototype.revBin=function(u,p,v){if(u===0||u===v-1)return u;for(var y=0,m=0;m<p;m++)y|=(u&1)<<p-m-1,u>>=1;return y},M.prototype.permute=function(u,p,v,y,m,S){for(var D=0;D<S;D++)y[D]=p[u[D]],m[D]=v[u[D]]},M.prototype.transform=function(u,p,v,y,m,S){this.permute(S,u,p,v,y,m);for(var D=1;D<m;D<<=1)for(var _=D<<1,d=Math.cos(2*Math.PI/_),x=Math.sin(2*Math.PI/_),q=0;q<m;q+=_)for(var z=d,U=x,k=0;k<D;k++){var G=v[q+k],Z=y[q+k],X=v[q+k+D],J=y[q+k+D],Q=z*X-U*J;J=z*J+U*X,X=Q,v[q+k]=G+X,y[q+k]=Z+J,v[q+k+D]=G-X,y[q+k+D]=Z-J,k!==_&&(Q=d*z-x*U,U=d*U+x*z,z=Q)}},M.prototype.guessLen13b=function(u,p){var v=Math.max(p,u)|1,y=v&1,m=0;for(v=v/2|0;v;v=v>>>1)m++;return 1<<m+1+y},M.prototype.conjugate=function(u,p,v){if(!(v<=1))for(var y=0;y<v/2;y++){var m=u[y];u[y]=u[v-y-1],u[v-y-1]=m,m=p[y],p[y]=-p[v-y-1],p[v-y-1]=-m}},M.prototype.normalize13b=function(u,p){for(var v=0,y=0;y<p/2;y++){var m=Math.round(u[2*y+1]/p)*8192+Math.round(u[2*y]/p)+v;u[y]=m&67108863,m<67108864?v=0:v=m/67108864|0}return u},M.prototype.convert13b=function(u,p,v,y){for(var m=0,S=0;S<p;S++)m=m+(u[S]|0),v[2*S]=m&8191,m=m>>>13,v[2*S+1]=m&8191,m=m>>>13;for(S=2*p;S<y;++S)v[S]=0;i(m===0),i((m&-8192)===0)},M.prototype.stub=function(u){for(var p=new Array(u),v=0;v<u;v++)p[v]=0;return p},M.prototype.mulp=function(u,p,v){var y=2*this.guessLen13b(u.length,p.length),m=this.makeRBT(y),S=this.stub(y),D=new Array(y),_=new Array(y),d=new Array(y),x=new Array(y),q=new Array(y),z=new Array(y),U=v.words;U.length=y,this.convert13b(u.words,u.length,D,y),this.convert13b(p.words,p.length,x,y),this.transform(D,S,_,d,y,m),this.transform(x,S,q,z,y,m);for(var k=0;k<y;k++){var G=_[k]*q[k]-d[k]*z[k];d[k]=_[k]*z[k]+d[k]*q[k],_[k]=G}return this.conjugate(_,d,y),this.transform(_,d,U,S,y,m),this.conjugate(U,S,y),this.normalize13b(U,y),v.negative=u.negative^p.negative,v.length=u.length+p.length,v.strip()},s.prototype.mul=function(u){var p=new s(null);return p.words=new Array(this.length+u.length),this.mulTo(u,p)},s.prototype.mulf=function(u){var p=new s(null);return p.words=new Array(this.length+u.length),$(this,u,p)},s.prototype.imul=function(u){return this.clone().mulTo(u,this)},s.prototype.imuln=function(u){i(typeof u=="number"),i(u<67108864);for(var p=0,v=0;v<this.length;v++){var y=(this.words[v]|0)*u,m=(y&67108863)+(p&67108863);p>>=26,p+=y/67108864|0,p+=m>>>26,this.words[v]=m&67108863}return p!==0&&(this.words[v]=p,this.length++),this},s.prototype.muln=function(u){return this.clone().imuln(u)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(u){var p=w(u);if(p.length===0)return new s(1);for(var v=this,y=0;y<p.length&&p[y]===0;y++,v=v.sqr());if(++y<p.length)for(var m=v.sqr();y<p.length;y++,m=m.sqr())p[y]!==0&&(v=v.mul(m));return v},s.prototype.iushln=function(u){i(typeof u=="number"&&u>=0);var p=u%26,v=(u-p)/26,y=67108863>>>26-p<<26-p,m;if(p!==0){var S=0;for(m=0;m<this.length;m++){var D=this.words[m]&y,_=(this.words[m]|0)-D<<p;this.words[m]=_|S,S=D>>>26-p}S&&(this.words[m]=S,this.length++)}if(v!==0){for(m=this.length-1;m>=0;m--)this.words[m+v]=this.words[m];for(m=0;m<v;m++)this.words[m]=0;this.length+=v}return this.strip()},s.prototype.ishln=function(u){return i(this.negative===0),this.iushln(u)},s.prototype.iushrn=function(u,p,v){i(typeof u=="number"&&u>=0);var y;p?y=(p-p%26)/26:y=0;var m=u%26,S=Math.min((u-m)/26,this.length),D=67108863^67108863>>>m<<m,_=v;if(y-=S,y=Math.max(0,y),_){for(var d=0;d<S;d++)_.words[d]=this.words[d];_.length=S}if(S!==0)if(this.length>S)for(this.length-=S,d=0;d<this.length;d++)this.words[d]=this.words[d+S];else this.words[0]=0,this.length=1;var x=0;for(d=this.length-1;d>=0&&(x!==0||d>=y);d--){var q=this.words[d]|0;this.words[d]=x<<26-m|q>>>m,x=q&D}return _&&x!==0&&(_.words[_.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(u,p,v){return i(this.negative===0),this.iushrn(u,p,v)},s.prototype.shln=function(u){return this.clone().ishln(u)},s.prototype.ushln=function(u){return this.clone().iushln(u)},s.prototype.shrn=function(u){return this.clone().ishrn(u)},s.prototype.ushrn=function(u){return this.clone().iushrn(u)},s.prototype.testn=function(u){i(typeof u=="number"&&u>=0);var p=u%26,v=(u-p)/26,y=1<<p;if(this.length<=v)return!1;var m=this.words[v];return!!(m&y)},s.prototype.imaskn=function(u){i(typeof u=="number"&&u>=0);var p=u%26,v=(u-p)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(p!==0&&v++,this.length=Math.min(v,this.length),p!==0){var y=67108863^67108863>>>p<<p;this.words[this.length-1]&=y}return this.strip()},s.prototype.maskn=function(u){return this.clone().imaskn(u)},s.prototype.iaddn=function(u){return i(typeof u=="number"),i(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},s.prototype._iaddn=function(u){this.words[0]+=u;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},s.prototype.isubn=function(u){if(i(typeof u=="number"),i(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this.strip()},s.prototype.addn=function(u){return this.clone().iaddn(u)},s.prototype.subn=function(u){return this.clone().isubn(u)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(u,p,v){var y=u.length+v,m;this._expand(y);var S,D=0;for(m=0;m<u.length;m++){S=(this.words[m+v]|0)+D;var _=(u.words[m]|0)*p;S-=_&67108863,D=(S>>26)-(_/67108864|0),this.words[m+v]=S&67108863}for(;m<this.length-v;m++)S=(this.words[m+v]|0)+D,D=S>>26,this.words[m+v]=S&67108863;if(D===0)return this.strip();for(i(D===-1),D=0,m=0;m<this.length;m++)S=-(this.words[m]|0)+D,D=S>>26,this.words[m]=S&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(u,p){var v=this.length-u.length,y=this.clone(),m=u,S=m.words[m.length-1]|0,D=this._countBits(S);v=26-D,v!==0&&(m=m.ushln(v),y.iushln(v),S=m.words[m.length-1]|0);var _=y.length-m.length,d;if(p!=="mod"){d=new s(null),d.length=_+1,d.words=new Array(d.length);for(var x=0;x<d.length;x++)d.words[x]=0}var q=y.clone()._ishlnsubmul(m,1,_);q.negative===0&&(y=q,d&&(d.words[_]=1));for(var z=_-1;z>=0;z--){var U=(y.words[m.length+z]|0)*67108864+(y.words[m.length+z-1]|0);for(U=Math.min(U/S|0,67108863),y._ishlnsubmul(m,U,z);y.negative!==0;)U--,y.negative=0,y._ishlnsubmul(m,1,z),y.isZero()||(y.negative^=1);d&&(d.words[z]=U)}return d&&d.strip(),y.strip(),p!=="div"&&v!==0&&y.iushrn(v),{div:d||null,mod:y}},s.prototype.divmod=function(u,p,v){if(i(!u.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var y,m,S;return this.negative!==0&&u.negative===0?(S=this.neg().divmod(u,p),p!=="mod"&&(y=S.div.neg()),p!=="div"&&(m=S.mod.neg(),v&&m.negative!==0&&m.iadd(u)),{div:y,mod:m}):this.negative===0&&u.negative!==0?(S=this.divmod(u.neg(),p),p!=="mod"&&(y=S.div.neg()),{div:y,mod:S.mod}):this.negative&u.negative?(S=this.neg().divmod(u.neg(),p),p!=="div"&&(m=S.mod.neg(),v&&m.negative!==0&&m.isub(u)),{div:S.div,mod:m}):u.length>this.length||this.cmp(u)<0?{div:new s(0),mod:this}:u.length===1?p==="div"?{div:this.divn(u.words[0]),mod:null}:p==="mod"?{div:null,mod:new s(this.modn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new s(this.modn(u.words[0]))}:this._wordDiv(u,p)},s.prototype.div=function(u){return this.divmod(u,"div",!1).div},s.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},s.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},s.prototype.divRound=function(u){var p=this.divmod(u);if(p.mod.isZero())return p.div;var v=p.div.negative!==0?p.mod.isub(u):p.mod,y=u.ushrn(1),m=u.andln(1),S=v.cmp(y);return S<0||m===1&&S===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},s.prototype.modn=function(u){i(u<=67108863);for(var p=(1<<26)%u,v=0,y=this.length-1;y>=0;y--)v=(p*v+(this.words[y]|0))%u;return v},s.prototype.idivn=function(u){i(u<=67108863);for(var p=0,v=this.length-1;v>=0;v--){var y=(this.words[v]|0)+p*67108864;this.words[v]=y/u|0,p=y%u}return this.strip()},s.prototype.divn=function(u){return this.clone().idivn(u)},s.prototype.egcd=function(u){i(u.negative===0),i(!u.isZero());var p=this,v=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var y=new s(1),m=new s(0),S=new s(0),D=new s(1),_=0;p.isEven()&&v.isEven();)p.iushrn(1),v.iushrn(1),++_;for(var d=v.clone(),x=p.clone();!p.isZero();){for(var q=0,z=1;!(p.words[0]&z)&&q<26;++q,z<<=1);if(q>0)for(p.iushrn(q);q-- >0;)(y.isOdd()||m.isOdd())&&(y.iadd(d),m.isub(x)),y.iushrn(1),m.iushrn(1);for(var U=0,k=1;!(v.words[0]&k)&&U<26;++U,k<<=1);if(U>0)for(v.iushrn(U);U-- >0;)(S.isOdd()||D.isOdd())&&(S.iadd(d),D.isub(x)),S.iushrn(1),D.iushrn(1);p.cmp(v)>=0?(p.isub(v),y.isub(S),m.isub(D)):(v.isub(p),S.isub(y),D.isub(m))}return{a:S,b:D,gcd:v.iushln(_)}},s.prototype._invmp=function(u){i(u.negative===0),i(!u.isZero());var p=this,v=u.clone();p.negative!==0?p=p.umod(u):p=p.clone();for(var y=new s(1),m=new s(0),S=v.clone();p.cmpn(1)>0&&v.cmpn(1)>0;){for(var D=0,_=1;!(p.words[0]&_)&&D<26;++D,_<<=1);if(D>0)for(p.iushrn(D);D-- >0;)y.isOdd()&&y.iadd(S),y.iushrn(1);for(var d=0,x=1;!(v.words[0]&x)&&d<26;++d,x<<=1);if(d>0)for(v.iushrn(d);d-- >0;)m.isOdd()&&m.iadd(S),m.iushrn(1);p.cmp(v)>=0?(p.isub(v),y.isub(m)):(v.isub(p),m.isub(y))}var q;return p.cmpn(1)===0?q=y:q=m,q.cmpn(0)<0&&q.iadd(u),q},s.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var p=this.clone(),v=u.clone();p.negative=0,v.negative=0;for(var y=0;p.isEven()&&v.isEven();y++)p.iushrn(1),v.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;v.isEven();)v.iushrn(1);var m=p.cmp(v);if(m<0){var S=p;p=v,v=S}else if(m===0||v.cmpn(1)===0)break;p.isub(v)}while(!0);return v.iushln(y)},s.prototype.invm=function(u){return this.egcd(u).a.umod(u)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(u){return this.words[0]&u},s.prototype.bincn=function(u){i(typeof u=="number");var p=u%26,v=(u-p)/26,y=1<<p;if(this.length<=v)return this._expand(v+1),this.words[v]|=y,this;for(var m=y,S=v;m!==0&&S<this.length;S++){var D=this.words[S]|0;D+=m,m=D>>>26,D&=67108863,this.words[S]=D}return m!==0&&(this.words[S]=m,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(u){var p=u<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this.strip();var v;if(this.length>1)v=1;else{p&&(u=-u),i(u<=67108863,"Number is too big");var y=this.words[0]|0;v=y===u?0:y<u?-1:1}return this.negative!==0?-v|0:v},s.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var p=this.ucmp(u);return this.negative!==0?-p|0:p},s.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var p=0,v=this.length-1;v>=0;v--){var y=this.words[v]|0,m=u.words[v]|0;if(y!==m){y<m?p=-1:y>m&&(p=1);break}}return p},s.prototype.gtn=function(u){return this.cmpn(u)===1},s.prototype.gt=function(u){return this.cmp(u)===1},s.prototype.gten=function(u){return this.cmpn(u)>=0},s.prototype.gte=function(u){return this.cmp(u)>=0},s.prototype.ltn=function(u){return this.cmpn(u)===-1},s.prototype.lt=function(u){return this.cmp(u)===-1},s.prototype.lten=function(u){return this.cmpn(u)<=0},s.prototype.lte=function(u){return this.cmp(u)<=0},s.prototype.eqn=function(u){return this.cmpn(u)===0},s.prototype.eq=function(u){return this.cmp(u)===0},s.red=function(u){return new C(u)},s.prototype.toRed=function(u){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(u){return this.red=u,this},s.prototype.forceRed=function(u){return i(!this.red,"Already a number in reduction context"),this._forceRed(u)},s.prototype.redAdd=function(u){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},s.prototype.redIAdd=function(u){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},s.prototype.redSub=function(u){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},s.prototype.redISub=function(u){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},s.prototype.redShl=function(u){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},s.prototype.redMul=function(u){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},s.prototype.redIMul=function(u){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(u){return i(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var P={k256:null,p224:null,p192:null,p25519:null};function R(I,u){this.name=I,this.p=new s(u,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var u=new s(null);return u.words=new Array(Math.ceil(this.n/13)),u},R.prototype.ireduce=function(u){var p=u,v;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),v=p.bitLength();while(v>this.n);var y=v<this.n?-1:p.ucmp(this.p);return y===0?(p.words[0]=0,p.length=1):y>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},R.prototype.split=function(u,p){u.iushrn(this.n,0,p)},R.prototype.imulK=function(u){return u.imul(this.k)};function N(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(N,R),N.prototype.split=function(u,p){for(var v=4194303,y=Math.min(u.length,9),m=0;m<y;m++)p.words[m]=u.words[m];if(p.length=y,u.length<=9){u.words[0]=0,u.length=1;return}var S=u.words[9];for(p.words[p.length++]=S&v,m=10;m<u.length;m++){var D=u.words[m]|0;u.words[m-10]=(D&v)<<4|S>>>22,S=D}S>>>=22,u.words[m-10]=S,S===0&&u.length>10?u.length-=10:u.length-=9},N.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var p=0,v=0;v<u.length;v++){var y=u.words[v]|0;p+=y*977,u.words[v]=p&67108863,p=y*64+(p/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function L(){R.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(L,R);function F(){R.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(F,R);function B(){R.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(B,R),B.prototype.imulK=function(u){for(var p=0,v=0;v<u.length;v++){var y=(u.words[v]|0)*19+p,m=y&67108863;y>>>=26,u.words[v]=m,p=y}return p!==0&&(u.words[u.length++]=p),u},s._prime=function(u){if(P[u])return P[u];var p;if(u==="k256")p=new N;else if(u==="p224")p=new L;else if(u==="p192")p=new F;else if(u==="p25519")p=new B;else throw new Error("Unknown prime "+u);return P[u]=p,p};function C(I){if(typeof I=="string"){var u=s._prime(I);this.m=u.p,this.prime=u}else i(I.gtn(1),"modulus must be greater than 1"),this.m=I,this.prime=null}C.prototype._verify1=function(u){i(u.negative===0,"red works only with positives"),i(u.red,"red works only with red numbers")},C.prototype._verify2=function(u,p){i((u.negative|p.negative)===0,"red works only with positives"),i(u.red&&u.red===p.red,"red works only with red numbers")},C.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):u.umod(this.m)._forceRed(this)},C.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},C.prototype.add=function(u,p){this._verify2(u,p);var v=u.add(p);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},C.prototype.iadd=function(u,p){this._verify2(u,p);var v=u.iadd(p);return v.cmp(this.m)>=0&&v.isub(this.m),v},C.prototype.sub=function(u,p){this._verify2(u,p);var v=u.sub(p);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},C.prototype.isub=function(u,p){this._verify2(u,p);var v=u.isub(p);return v.cmpn(0)<0&&v.iadd(this.m),v},C.prototype.shl=function(u,p){return this._verify1(u),this.imod(u.ushln(p))},C.prototype.imul=function(u,p){return this._verify2(u,p),this.imod(u.imul(p))},C.prototype.mul=function(u,p){return this._verify2(u,p),this.imod(u.mul(p))},C.prototype.isqr=function(u){return this.imul(u,u.clone())},C.prototype.sqr=function(u){return this.mul(u,u)},C.prototype.sqrt=function(u){if(u.isZero())return u.clone();var p=this.m.andln(3);if(i(p%2===1),p===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(u,v)}for(var y=this.m.subn(1),m=0;!y.isZero()&&y.andln(1)===0;)m++,y.iushrn(1);i(!y.isZero());var S=new s(1).toRed(this),D=S.redNeg(),_=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,_).cmp(D)!==0;)d.redIAdd(D);for(var x=this.pow(d,y),q=this.pow(u,y.addn(1).iushrn(1)),z=this.pow(u,y),U=m;z.cmp(S)!==0;){for(var k=z,G=0;k.cmp(S)!==0;G++)k=k.redSqr();i(G<U);var Z=this.pow(x,new s(1).iushln(U-G-1));q=q.redMul(Z),x=Z.redSqr(),z=z.redMul(x),U=G}return q},C.prototype.invm=function(u){var p=u._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},C.prototype.pow=function(u,p){if(p.isZero())return new s(1).toRed(this);if(p.cmpn(1)===0)return u.clone();var v=4,y=new Array(1<<v);y[0]=new s(1).toRed(this),y[1]=u;for(var m=2;m<y.length;m++)y[m]=this.mul(y[m-1],u);var S=y[0],D=0,_=0,d=p.bitLength()%26;for(d===0&&(d=26),m=p.length-1;m>=0;m--){for(var x=p.words[m],q=d-1;q>=0;q--){var z=x>>q&1;if(S!==y[0]&&(S=this.sqr(S)),z===0&&D===0){_=0;continue}D<<=1,D|=z,_++,!(_!==v&&(m!==0||q!==0))&&(S=this.mul(S,y[D]),_=0,D=0)}d=26}return S},C.prototype.convertTo=function(u){var p=u.umod(this.m);return p===u?p.clone():p},C.prototype.convertFrom=function(u){var p=u.clone();return p.red=null,p},s.mont=function(u){return new W(u)};function W(I){C.call(this,I),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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)}n(W,C),W.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},W.prototype.convertFrom=function(u){var p=this.imod(u.mul(this.rinv));return p.red=null,p},W.prototype.imul=function(u,p){if(u.isZero()||p.isZero())return u.words[0]=0,u.length=1,u;var v=u.imul(p),y=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(y).iushrn(this.shift),S=m;return m.cmp(this.m)>=0?S=m.isub(this.m):m.cmpn(0)<0&&(S=m.iadd(this.m)),S._forceRed(this)},W.prototype.mul=function(u,p){if(u.isZero()||p.isZero())return new s(0)._forceRed(this);var v=u.mul(p),y=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(y).iushrn(this.shift),S=m;return m.cmp(this.m)>=0?S=m.isub(this.m):m.cmpn(0)<0&&(S=m.iadd(this.m)),S._forceRed(this)},W.prototype.invm=function(u){var p=this.imod(u._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,Ct)})($r);var ji=Rl;function Rl(t,e){if(!t)throw new Error(e||"Assertion failed")}Rl.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var sf={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var c=0;c<s.length;c++)a[c]=s[c]|0;return a}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var c=0;c<s.length;c+=2)a.push(parseInt(s[c]+s[c+1],16))}else for(var c=0;c<s.length;c++){var f=s.charCodeAt(c),h=f>>8,l=f&255;h?a.push(h,l):a.push(l)}return a}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",a=0;a<s.length;a++)o+=i(s[a].toString(16));return o}e.toHex=n,e.encode=function(o,a){return a==="hex"?n(o):o}})(sf),function(t){var e=t,r=$r.exports,i=ji,n=sf;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(h,l,g){var w=new Array(Math.max(h.bitLength(),g)+1),b;for(b=0;b<w.length;b+=1)w[b]=0;var E=1<<l+1,A=h.clone();for(b=0;b<w.length;b++){var $,M=A.andln(E-1);A.isOdd()?(M>(E>>1)-1?$=(E>>1)-M:$=M,A.isubn($)):$=0,w[b]=$,A.iushrn(1)}return w}e.getNAF=s;function o(h,l){var g=[[],[]];h=h.clone(),l=l.clone();for(var w=0,b=0,E;h.cmpn(-w)>0||l.cmpn(-b)>0;){var A=h.andln(3)+w&3,$=l.andln(3)+b&3;A===3&&(A=-1),$===3&&($=-1);var M;A&1?(E=h.andln(7)+w&7,(E===3||E===5)&&$===2?M=-A:M=A):M=0,g[0].push(M);var P;$&1?(E=l.andln(7)+b&7,(E===3||E===5)&&A===2?P=-$:P=$):P=0,g[1].push(P),2*w===M+1&&(w=1-w),2*b===P+1&&(b=1-b),h.iushrn(1),l.iushrn(1)}return g}e.getJSF=o;function a(h,l,g){var w="_"+l;h.prototype[l]=function(){return this[w]!==void 0?this[w]:this[w]=g.call(this)}}e.cachedProperty=a;function c(h){return typeof h=="string"?e.toArray(h,"hex"):h}e.parseBytes=c;function f(h){return new r(h,"hex","le")}e.intFromLE=f}(Yt);var Wo={exports:{}},of;Wo.exports=function(e){return of||(of=new vi(null)),of.generate(e)};function vi(t){this.rand=t}if(Wo.exports.Rand=vi,vi.prototype.generate=function(e){return this._rand(e)},vi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i<r.length;i++)r[i]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?vi.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?vi.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(vi.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var Tl=Pl;if(typeof Tl.randomBytes!="function")throw new Error("Not supported");vi.prototype._rand=function(e){return Tl.randomBytes(e)}}catch{}var af={},Ki=$r.exports,xs=Yt,Go=xs.getNAF,u8=xs.getJSF,Yo=xs.assert;function mi(t,e){this.type=t,this.p=new Ki(e.p,16),this.red=e.prime?Ki.red(e.prime):Ki.mont(this.p),this.zero=new Ki(0).toRed(this.red),this.one=new Ki(1).toRed(this.red),this.two=new Ki(2).toRed(this.red),this.n=e.n&&new Ki(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Jo=mi;mi.prototype.point=function(){throw new Error("Not implemented")},mi.prototype.validate=function(){throw new Error("Not implemented")},mi.prototype._fixedNafMul=function(e,r){Yo(e.precomputed);var i=e._getDoubles(),n=Go(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var f=a+i.step-1;f>=a;f--)c=(c<<1)+n[f];o.push(c)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),g=s;g>0;g--){for(a=0;a<o.length;a++)c=o[a],c===g?l=l.mixedAdd(i.points[a]):c===-g&&(l=l.mixedAdd(i.points[a].neg()));h=h.add(l)}return h.toP()},mi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Go(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var f=0;c>=0&&o[c]===0;c--)f++;if(c>=0&&f++,a=a.dblp(f),c<0)break;var h=o[c];Yo(h!==0),e.type==="affine"?h>0?a=a.mixedAdd(s[h-1>>1]):a=a.mixedAdd(s[-h-1>>1].neg()):h>0?a=a.add(s[h-1>>1]):a=a.add(s[-h-1>>1].neg())}return e.type==="affine"?a.toP():a},mi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,f=0,h,l,g;for(h=0;h<n;h++){g=r[h];var w=g._getNAFPoints(e);o[h]=w.wnd,a[h]=w.points}for(h=n-1;h>=1;h-=2){var b=h-1,E=h;if(o[b]!==1||o[E]!==1){c[b]=Go(i[b],o[b],this._bitLength),c[E]=Go(i[E],o[E],this._bitLength),f=Math.max(c[b].length,f),f=Math.max(c[E].length,f);continue}var A=[r[b],null,null,r[E]];r[b].y.cmp(r[E].y)===0?(A[1]=r[b].add(r[E]),A[2]=r[b].toJ().mixedAdd(r[E].neg())):r[b].y.cmp(r[E].y.redNeg())===0?(A[1]=r[b].toJ().mixedAdd(r[E]),A[2]=r[b].add(r[E].neg())):(A[1]=r[b].toJ().mixedAdd(r[E]),A[2]=r[b].toJ().mixedAdd(r[E].neg()));var $=[-3,-1,-5,-7,0,7,5,1,3],M=u8(i[b],i[E]);for(f=Math.max(M[0].length,f),c[b]=new Array(f),c[E]=new Array(f),l=0;l<f;l++){var P=M[0][l]|0,R=M[1][l]|0;c[b][l]=$[(P+1)*3+(R+1)],c[E][l]=0,a[b]=A}}var N=this.jpoint(null,null,null),L=this._wnafT4;for(h=f;h>=0;h--){for(var F=0;h>=0;){var B=!0;for(l=0;l<n;l++)L[l]=c[l][h]|0,L[l]!==0&&(B=!1);if(!B)break;F++,h--}if(h>=0&&F++,N=N.dblp(F),h<0)break;for(l=0;l<n;l++){var C=L[l];C!==0&&(C>0?g=a[l][C-1>>1]:C<0&&(g=a[l][-C-1>>1].neg()),g.type==="affine"?N=N.mixedAdd(g):N=N.add(g))}}for(h=0;h<n;h++)a[h]=null;return s?N:N.toP()};function ir(t,e){this.curve=t,this.type=e,this.precomputed=null}mi.BasePoint=ir,ir.prototype.eq=function(){throw new Error("Not implemented")},ir.prototype.validate=function(){return this.curve.validate(this)},mi.prototype.decodePoint=function(e,r){e=xs.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Yo(e[e.length-1]%2===0):e[0]===7&&Yo(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},ir.prototype.encodeCompressed=function(e){return this.encode(e,!0)},ir.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},ir.prototype.encode=function(e,r){return xs.encode(this._encode(r),e)},ir.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},ir.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},ir.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},ir.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},ir.prototype._getBeta=function(){return null},ir.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var Tn={exports:{}};typeof Object.create=="function"?Tn.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Tn.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var h8=Yt,Ve=$r.exports,cf=Tn.exports,Nn=Jo,d8=h8.assert;function nr(t){Nn.call(this,"short",t),this.a=new Ve(t.a,16).toRed(this.red),this.b=new Ve(t.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(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}cf(nr,Nn);var l8=nr;nr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new Ve(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new Ve(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],d8(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new Ve(a.a,16),b:new Ve(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},nr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:Ve.mont(e),i=new Ve(2).toRed(r).redInvm(),n=i.redNeg(),s=new Ve(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},nr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new Ve(1),o=new Ve(0),a=new Ve(0),c=new Ve(1),f,h,l,g,w,b,E,A=0,$,M;i.cmpn(0)!==0;){var P=n.div(i);$=n.sub(P.mul(i)),M=a.sub(P.mul(s));var R=c.sub(P.mul(o));if(!l&&$.cmp(r)<0)f=E.neg(),h=s,l=$.neg(),g=M;else if(l&&++A===2)break;E=$,n=i,i=$,a=s,s=M,c=o,o=R}w=$.neg(),b=M;var N=l.sqr().add(g.sqr()),L=w.sqr().add(b.sqr());return L.cmp(N)>=0&&(w=f,b=h),l.negative&&(l=l.neg(),g=g.neg()),w.negative&&(w=w.neg(),b=b.neg()),[{a:l,b:g},{a:w,b}]},nr.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),f=s.mul(i.b),h=o.mul(n.b),l=e.sub(a).sub(c),g=f.add(h).neg();return{k1:l,k2:g}},nr.prototype.pointFromX=function(e,r){e=new Ve(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},nr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},nr.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],f=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),f=f.neg(!0)),n[o*2]=c,n[o*2+1]=f,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var h=this._wnafMulAdd(1,n,s,o*2,i),l=0;l<o*2;l++)n[l]=null,s[l]=null;return h};function lt(t,e,r,i){Nn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Ve(e,16),this.y=new Ve(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}cf(lt,Nn.BasePoint),nr.prototype.point=function(e,r,i){return new lt(this,e,r,i)},nr.prototype.pointFromJSON=function(e,r){return lt.fromJSON(this,e,r)},lt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},lt.prototype.toJSON=function(){return this.precomputed?[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)}}]:[this.x,this.y]},lt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},lt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},lt.prototype.isInfinity=function(){return this.inf},lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},lt.prototype.getX=function(){return this.x.fromRed()},lt.prototype.getY=function(){return this.y.fromRed()},lt.prototype.mul=function(e){return e=new Ve(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},lt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},lt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},lt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},lt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function xt(t,e,r,i){Nn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ve(0)):(this.x=new Ve(e,16),this.y=new Ve(r,16),this.z=new Ve(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}cf(xt,Nn.BasePoint),nr.prototype.jpoint=function(e,r,i){return new xt(this,e,r,i)},xt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},xt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},xt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),f=o.redSub(a);if(c.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=c.redSqr(),l=h.redMul(c),g=n.redMul(h),w=f.redSqr().redIAdd(l).redISub(g).redISub(g),b=f.redMul(g.redISub(w)).redISub(o.redMul(l)),E=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(w,b,E)},xt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f=a.redSqr(),h=f.redMul(a),l=i.redMul(f),g=c.redSqr().redIAdd(h).redISub(l).redISub(l),w=c.redMul(l.redISub(g)).redISub(s.redMul(h)),b=this.z.redMul(a);return this.curve.jpoint(g,w,b)},xt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,f=c.redSqr().redSqr(),h=a.redAdd(a);for(r=0;r<e;r++){var l=o.redSqr(),g=h.redSqr(),w=g.redSqr(),b=l.redAdd(l).redIAdd(l).redIAdd(n.redMul(f)),E=o.redMul(g),A=b.redSqr().redISub(E.redAdd(E)),$=E.redISub(A),M=b.redMul($);M=M.redIAdd(M).redISub(w);var P=h.redMul(c);r+1<e&&(f=f.redMul(w)),o=A,c=P,h=M}return this.curve.jpoint(o,h.redMul(s),c)},xt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},xt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),f=c.redSqr().redISub(a).redISub(a),h=o.redIAdd(o);h=h.redIAdd(h),h=h.redIAdd(h),e=f,r=c.redMul(a.redISub(f)).redISub(h),i=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),g=this.y.redSqr(),w=g.redSqr(),b=this.x.redAdd(g).redSqr().redISub(l).redISub(w);b=b.redIAdd(b);var E=l.redAdd(l).redIAdd(l),A=E.redSqr(),$=w.redIAdd(w);$=$.redIAdd($),$=$.redIAdd($),e=A.redISub(b).redISub(b),r=E.redMul(b.redISub(e)).redISub($),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},xt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),f=c.redSqr().redISub(a).redISub(a);e=f;var h=o.redIAdd(o);h=h.redIAdd(h),h=h.redIAdd(h),r=c.redMul(a.redISub(f)).redISub(h),i=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),g=this.y.redSqr(),w=this.x.redMul(g),b=this.x.redSub(l).redMul(this.x.redAdd(l));b=b.redAdd(b).redIAdd(b);var E=w.redIAdd(w);E=E.redIAdd(E);var A=E.redAdd(E);e=b.redSqr().redISub(A),i=this.y.redAdd(this.z).redSqr().redISub(g).redISub(l);var $=g.redSqr();$=$.redIAdd($),$=$.redIAdd($),$=$.redIAdd($),r=b.redMul(E.redISub(e)).redISub($)}return this.curve.jpoint(e,r,i)},xt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),f=r.redAdd(r);f=f.redIAdd(f);var h=f.redMul(a),l=c.redSqr().redISub(h.redAdd(h)),g=h.redISub(l),w=a.redSqr();w=w.redIAdd(w),w=w.redIAdd(w),w=w.redIAdd(w);var b=c.redMul(g).redISub(w),E=i.redAdd(i).redMul(n);return this.curve.jpoint(l,b,E)},xt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),f=n.redIAdd(n);f=f.redIAdd(f),f=f.redIAdd(f),f=f.redIAdd(f);var h=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(f),l=r.redMul(h);l=l.redIAdd(l),l=l.redIAdd(l);var g=this.x.redMul(c).redISub(l);g=g.redIAdd(g),g=g.redIAdd(g);var w=this.y.redMul(h.redMul(f.redISub(h)).redISub(a.redMul(c)));w=w.redIAdd(w),w=w.redIAdd(w),w=w.redIAdd(w);var b=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(g,w,b)},xt.prototype.mul=function(e,r){return e=new Ve(e,r),this.curve._wnafMul(this,e)},xt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},xt.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},xt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},xt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Cn=$r.exports,Nl=Tn.exports,Zo=Jo,p8=Yt;function Bn(t){Zo.call(this,"mont",t),this.a=new Cn(t.a,16).toRed(this.red),this.b=new Cn(t.b,16).toRed(this.red),this.i4=new Cn(4).toRed(this.red).redInvm(),this.two=new Cn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Nl(Bn,Zo);var g8=Bn;Bn.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),n=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),s=n.redSqrt();return s.redSqr().cmp(n)===0};function pt(t,e,r){Zo.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Cn(e,16),this.z=new Cn(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Nl(pt,Zo.BasePoint),Bn.prototype.decodePoint=function(e,r){return this.point(p8.toArray(e,r),1)},Bn.prototype.point=function(e,r){return new pt(this,e,r)},Bn.prototype.pointFromJSON=function(e){return pt.fromJSON(this,e)},pt.prototype.precompute=function(){},pt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},pt.fromJSON=function(e,r){return new pt(e,r[0],r[1]||e.one)},pt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},pt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},pt.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=r.redSub(n),o=r.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},pt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},pt.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),c=s.redMul(n),f=r.z.redMul(a.redAdd(c).redSqr()),h=r.x.redMul(a.redISub(c).redSqr());return this.curve.point(f,h)},pt.prototype.mul=function(e){for(var r=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},pt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},pt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},pt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},pt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},pt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var b8=Yt,Qr=$r.exports,Cl=Tn.exports,Xo=Jo,y8=b8.assert;function Or(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Xo.call(this,"edwards",t),this.a=new Qr(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Qr(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Qr(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),y8(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}Cl(Or,Xo);var v8=Or;Or.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},Or.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},Or.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},Or.prototype.pointFromX=function(e,r){e=new Qr(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=a.fromRed().isOdd();return(r&&!c||!r&&c)&&(a=a.redNeg()),this.point(e,a)},Or.prototype.pointFromY=function(e,r){e=new Qr(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)},Or.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),n=r.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return n.cmp(s)===0};function ve(t,e,r,i,n){Xo.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Qr(e,16),this.y=new Qr(r,16),this.z=i?new Qr(i,16):this.curve.one,this.t=n&&new Qr(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Cl(ve,Xo.BasePoint),Or.prototype.pointFromJSON=function(e){return ve.fromJSON(this,e)},Or.prototype.point=function(e,r,i,n){return new ve(this,e,r,i,n)},ve.fromJSON=function(e,r){return new ve(e,r[0],r[1],r[2])},ve.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},ve.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ve.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=n.redAdd(r),a=o.redSub(i),c=n.redSub(r),f=s.redMul(a),h=o.redMul(c),l=s.redMul(c),g=a.redMul(o);return this.curve.point(f,h,g,l)},ve.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,c,f;if(this.curve.twisted){a=this.curve._mulA(r);var h=a.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(h.redSub(this.curve.two)),s=h.redMul(a.redSub(i)),o=h.redSqr().redSub(h).redSub(h)):(c=this.z.redSqr(),f=h.redSub(c).redISub(c),n=e.redSub(r).redISub(i).redMul(f),s=h.redMul(a.redSub(i)),o=h.redMul(f))}else a=r.redAdd(i),c=this.curve._mulC(this.z).redSqr(),f=a.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(a)).redMul(f),s=this.curve._mulC(a).redMul(r.redISub(i)),o=a.redMul(f);return this.curve.point(n,s,o)},ve.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ve.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(r),a=s.redSub(n),c=s.redAdd(n),f=i.redAdd(r),h=o.redMul(a),l=c.redMul(f),g=o.redMul(f),w=a.redMul(c);return this.curve.point(h,l,w,g)},ve.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),c=i.redAdd(o),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),h=r.redMul(a).redMul(f),l,g;return this.curve.twisted?(l=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),g=a.redMul(c)):(l=r.redMul(c).redMul(s.redSub(n)),g=this.curve._mulC(a).redMul(c)),this.curve.point(h,l,g)},ve.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ve.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ve.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},ve.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},ve.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},ve.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ve.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ve.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ve.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ve.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},ve.prototype.toP=ve.prototype.normalize,ve.prototype.mixedAdd=ve.prototype.add,function(t){var e=t;e.base=Jo,e.short=l8,e.mont=g8,e.edwards=v8}(af);var Qo={},ea={},ie={},m8=ji,w8=Tn.exports;ie.inherits=w8;function _8(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function x8(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):_8(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}ie.toArray=x8;function E8(t){for(var e="",r=0;r<t.length;r++)e+=Fl(t[r].toString(16));return e}ie.toHex=E8;function Bl(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}ie.htonl=Bl;function S8(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=Bl(n)),r+=Ll(n.toString(16))}return r}ie.toHex32=S8;function Fl(t){return t.length===1?"0"+t:t}ie.zero2=Fl;function Ll(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}ie.zero8=Ll;function I8(t,e,r,i){var n=r-e;m8(n%4===0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;i==="big"?c=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:c=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s}ie.join32=I8;function A8(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}ie.split32=A8;function D8(t,e){return t>>>e|t<<32-e}ie.rotr32=D8;function $8(t,e){return t<<e|t>>>32-e}ie.rotl32=$8;function O8(t,e){return t+e>>>0}ie.sum32=O8;function M8(t,e,r){return t+e+r>>>0}ie.sum32_3=M8;function P8(t,e,r,i){return t+e+r+i>>>0}ie.sum32_4=P8;function R8(t,e,r,i,n){return t+e+r+i+n>>>0}ie.sum32_5=R8;function T8(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o}ie.sum64=T8;function N8(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}ie.sum64_hi=N8;function C8(t,e,r,i){var n=e+i;return n>>>0}ie.sum64_lo=C8;function B8(t,e,r,i,n,s,o,a){var c=0,f=e;f=f+i>>>0,c+=f<e?1:0,f=f+s>>>0,c+=f<s?1:0,f=f+a>>>0,c+=f<a?1:0;var h=t+r+n+o+c;return h>>>0}ie.sum64_4_hi=B8;function F8(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}ie.sum64_4_lo=F8;function L8(t,e,r,i,n,s,o,a,c,f){var h=0,l=e;l=l+i>>>0,h+=l<e?1:0,l=l+s>>>0,h+=l<s?1:0,l=l+a>>>0,h+=l<a?1:0,l=l+f>>>0,h+=l<f?1:0;var g=t+r+n+o+c+h;return g>>>0}ie.sum64_5_hi=L8;function q8(t,e,r,i,n,s,o,a,c,f){var h=e+i+s+a+f;return h>>>0}ie.sum64_5_lo=q8;function z8(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}ie.rotr64_hi=z8;function U8(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ie.rotr64_lo=U8;function k8(t,e,r){return t>>>r}ie.shr64_hi=k8;function j8(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ie.shr64_lo=j8;var Fn={},ql=ie,K8=ji;function ta(){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}Fn.BlockHash=ta,ta.prototype.update=function(e,r){if(e=ql.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=ql.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},ta.prototype.digest=function(e){return this.update(this._pad()),K8(this.pending===null),this._digest(e)},ta.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,i=r-(e+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var Ln={},Mr={},V8=ie,Pr=V8.rotr32;function H8(t,e,r,i){if(t===0)return zl(e,r,i);if(t===1||t===3)return kl(e,r,i);if(t===2)return Ul(e,r,i)}Mr.ft_1=H8;function zl(t,e,r){return t&e^~t&r}Mr.ch32=zl;function Ul(t,e,r){return t&e^t&r^e&r}Mr.maj32=Ul;function kl(t,e,r){return t^e^r}Mr.p32=kl;function W8(t){return Pr(t,2)^Pr(t,13)^Pr(t,22)}Mr.s0_256=W8;function G8(t){return Pr(t,6)^Pr(t,11)^Pr(t,25)}Mr.s1_256=G8;function Y8(t){return Pr(t,7)^Pr(t,18)^t>>>3}Mr.g0_256=Y8;function J8(t){return Pr(t,17)^Pr(t,19)^t>>>10}Mr.g1_256=J8;var qn=ie,Z8=Fn,X8=Mr,ff=qn.rotl32,Es=qn.sum32,Q8=qn.sum32_5,e4=X8.ft_1,jl=Z8.BlockHash,t4=[1518500249,1859775393,2400959708,3395469782];function Rr(){if(!(this instanceof Rr))return new Rr;jl.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}qn.inherits(Rr,jl);var r4=Rr;Rr.blockSize=512,Rr.outSize=160,Rr.hmacStrength=80,Rr.padLength=64,Rr.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=ff(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],f=this.h[4];for(n=0;n<i.length;n++){var h=~~(n/20),l=Q8(ff(s,5),e4(h,o,a,c),f,i[n],t4[h]);f=c,c=a,a=ff(o,30),o=s,s=l}this.h[0]=Es(this.h[0],s),this.h[1]=Es(this.h[1],o),this.h[2]=Es(this.h[2],a),this.h[3]=Es(this.h[3],c),this.h[4]=Es(this.h[4],f)},Rr.prototype._digest=function(e){return e==="hex"?qn.toHex32(this.h,"big"):qn.split32(this.h,"big")};var zn=ie,i4=Fn,Un=Mr,n4=ji,pr=zn.sum32,s4=zn.sum32_4,o4=zn.sum32_5,a4=Un.ch32,c4=Un.maj32,f4=Un.s0_256,u4=Un.s1_256,h4=Un.g0_256,d4=Un.g1_256,Kl=i4.BlockHash,l4=[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 Tr(){if(!(this instanceof Tr))return new Tr;Kl.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=l4,this.W=new Array(64)}zn.inherits(Tr,Kl);var Vl=Tr;Tr.blockSize=512,Tr.outSize=256,Tr.hmacStrength=192,Tr.padLength=64,Tr.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=s4(d4(i[n-2]),i[n-7],h4(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],f=this.h[4],h=this.h[5],l=this.h[6],g=this.h[7];for(n4(this.k.length===i.length),n=0;n<i.length;n++){var w=o4(g,u4(f),a4(f,h,l),this.k[n],i[n]),b=pr(f4(s),c4(s,o,a));g=l,l=h,h=f,f=pr(c,w),c=a,a=o,o=s,s=pr(w,b)}this.h[0]=pr(this.h[0],s),this.h[1]=pr(this.h[1],o),this.h[2]=pr(this.h[2],a),this.h[3]=pr(this.h[3],c),this.h[4]=pr(this.h[4],f),this.h[5]=pr(this.h[5],h),this.h[6]=pr(this.h[6],l),this.h[7]=pr(this.h[7],g)},Tr.prototype._digest=function(e){return e==="hex"?zn.toHex32(this.h,"big"):zn.split32(this.h,"big")};var uf=ie,Hl=Vl;function ei(){if(!(this instanceof ei))return new ei;Hl.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}uf.inherits(ei,Hl);var p4=ei;ei.blockSize=512,ei.outSize=224,ei.hmacStrength=192,ei.padLength=64,ei.prototype._digest=function(e){return e==="hex"?uf.toHex32(this.h.slice(0,7),"big"):uf.split32(this.h.slice(0,7),"big")};var jt=ie,g4=Fn,b4=ji,Nr=jt.rotr64_hi,Cr=jt.rotr64_lo,Wl=jt.shr64_hi,Gl=jt.shr64_lo,wi=jt.sum64,hf=jt.sum64_hi,df=jt.sum64_lo,y4=jt.sum64_4_hi,v4=jt.sum64_4_lo,m4=jt.sum64_5_hi,w4=jt.sum64_5_lo,Yl=g4.BlockHash,_4=[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 gr(){if(!(this instanceof gr))return new gr;Yl.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=_4,this.W=new Array(160)}jt.inherits(gr,Yl);var Jl=gr;gr.blockSize=1024,gr.outSize=512,gr.hmacStrength=192,gr.padLength=128,gr.prototype._prepareBlock=function(e,r){for(var i=this.W,n=0;n<32;n++)i[n]=e[r+n];for(;n<i.length;n+=2){var s=R4(i[n-4],i[n-3]),o=T4(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],f=M4(i[n-30],i[n-29]),h=P4(i[n-30],i[n-29]),l=i[n-32],g=i[n-31];i[n]=y4(s,o,a,c,f,h,l,g),i[n+1]=v4(s,o,a,c,f,h,l,g)}},gr.prototype._update=function(e,r){this._prepareBlock(e,r);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],f=this.h[5],h=this.h[6],l=this.h[7],g=this.h[8],w=this.h[9],b=this.h[10],E=this.h[11],A=this.h[12],$=this.h[13],M=this.h[14],P=this.h[15];b4(this.k.length===i.length);for(var R=0;R<i.length;R+=2){var N=M,L=P,F=$4(g,w),B=O4(g,w),C=x4(g,w,b,E,A),W=E4(g,w,b,E,A,$),I=this.k[R],u=this.k[R+1],p=i[R],v=i[R+1],y=m4(N,L,F,B,C,W,I,u,p,v),m=w4(N,L,F,B,C,W,I,u,p,v);N=A4(n,s),L=D4(n,s),F=S4(n,s,o,a,c),B=I4(n,s,o,a,c,f);var S=hf(N,L,F,B),D=df(N,L,F,B);M=A,P=$,A=b,$=E,b=g,E=w,g=hf(h,l,y,m),w=df(l,l,y,m),h=c,l=f,c=o,f=a,o=n,a=s,n=hf(y,m,S,D),s=df(y,m,S,D)}wi(this.h,0,n,s),wi(this.h,2,o,a),wi(this.h,4,c,f),wi(this.h,6,h,l),wi(this.h,8,g,w),wi(this.h,10,b,E),wi(this.h,12,A,$),wi(this.h,14,M,P)},gr.prototype._digest=function(e){return e==="hex"?jt.toHex32(this.h,"big"):jt.split32(this.h,"big")};function x4(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function E4(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function S4(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function I4(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function A4(t,e){var r=Nr(t,e,28),i=Nr(e,t,2),n=Nr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function D4(t,e){var r=Cr(t,e,28),i=Cr(e,t,2),n=Cr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function $4(t,e){var r=Nr(t,e,14),i=Nr(t,e,18),n=Nr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function O4(t,e){var r=Cr(t,e,14),i=Cr(t,e,18),n=Cr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function M4(t,e){var r=Nr(t,e,1),i=Nr(t,e,8),n=Wl(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function P4(t,e){var r=Cr(t,e,1),i=Cr(t,e,8),n=Gl(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function R4(t,e){var r=Nr(t,e,19),i=Nr(e,t,29),n=Wl(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function T4(t,e){var r=Cr(t,e,19),i=Cr(e,t,29),n=Gl(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var lf=ie,Zl=Jl;function ti(){if(!(this instanceof ti))return new ti;Zl.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}lf.inherits(ti,Zl);var N4=ti;ti.blockSize=1024,ti.outSize=384,ti.hmacStrength=192,ti.padLength=128,ti.prototype._digest=function(e){return e==="hex"?lf.toHex32(this.h.slice(0,12),"big"):lf.split32(this.h.slice(0,12),"big")},Ln.sha1=r4,Ln.sha224=p4,Ln.sha256=Vl,Ln.sha384=N4,Ln.sha512=Jl;var Xl={},Vi=ie,C4=Fn,ra=Vi.rotl32,Ql=Vi.sum32,Ss=Vi.sum32_3,e0=Vi.sum32_4,t0=C4.BlockHash;function Br(){if(!(this instanceof Br))return new Br;t0.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Vi.inherits(Br,t0),Xl.ripemd160=Br,Br.blockSize=512,Br.outSize=160,Br.hmacStrength=192,Br.padLength=64,Br.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=i,f=n,h=s,l=o,g=a,w=0;w<80;w++){var b=Ql(ra(e0(i,r0(w,n,s,o),e[L4[w]+r],B4(w)),z4[w]),a);i=a,a=o,o=ra(s,10),s=n,n=b,b=Ql(ra(e0(c,r0(79-w,f,h,l),e[q4[w]+r],F4(w)),U4[w]),g),c=g,g=l,l=ra(h,10),h=f,f=b}b=Ss(this.h[1],s,l),this.h[1]=Ss(this.h[2],o,g),this.h[2]=Ss(this.h[3],a,c),this.h[3]=Ss(this.h[4],i,f),this.h[4]=Ss(this.h[0],n,h),this.h[0]=b},Br.prototype._digest=function(e){return e==="hex"?Vi.toHex32(this.h,"little"):Vi.split32(this.h,"little")};function r0(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function B4(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function F4(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var L4=[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],q4=[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],z4=[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],U4=[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],k4=ie,j4=ji;function kn(t,e,r){if(!(this instanceof kn))return new kn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(k4.toArray(e,r))}var K4=kn;kn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),j4(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)},kn.prototype.update=function(e,r){return this.inner.update(e,r),this},kn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=ie,e.common=Fn,e.sha=Ln,e.ripemd=Xl,e.hmac=K4,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(ea);var pf,i0;function V4(){return i0||(i0=1,pf={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),pf}(function(t){var e=t,r=ea,i=af,n=Yt,s=n.assert;function o(f){f.type==="short"?this.curve=new i.short(f):f.type==="edwards"?this.curve=new i.edwards(f):this.curve=new i.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(f,h){Object.defineProperty(e,f,{configurable:!0,enumerable:!0,get:function(){var l=new o(h);return Object.defineProperty(e,f,{configurable:!0,enumerable:!0,value:l}),l}})}a("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:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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:r.sha384,gRed:!1,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"]}),a("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:r.sha512,gRed:!1,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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=V4()}catch{c=void 0}a("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:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})})(Qo);var H4=ea,Hi=sf,n0=ji;function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Hi.toArray(t.entropy,t.entropyEnc||"hex"),r=Hi.toArray(t.nonce,t.nonceEnc||"hex"),i=Hi.toArray(t.pers,t.persEnc||"hex");n0(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var W4=_i;_i.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},_i.prototype._hmac=function(){return new H4.hmac(this.hash,this.K)},_i.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},_i.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=Hi.toArray(e,r),i=Hi.toArray(i,n),n0(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},_i.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=Hi.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Hi.encode(o,r)};var G4=$r.exports,Y4=Yt,gf=Y4.assert;function Pt(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var J4=Pt;Pt.fromPublic=function(e,r,i){return r instanceof Pt?r:new Pt(e,{pub:r,pubEnc:i})},Pt.fromPrivate=function(e,r,i){return r instanceof Pt?r:new Pt(e,{priv:r,privEnc:i})},Pt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Pt.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},Pt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Pt.prototype._importPrivate=function(e,r){this.priv=new G4(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Pt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?gf(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&gf(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},Pt.prototype.derive=function(e){return e.validate()||gf(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Pt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Pt.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},Pt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var ia=$r.exports,bf=Yt,Z4=bf.assert;function na(t,e){if(t instanceof na)return t;this._importDER(t,e)||(Z4(t.r&&t.s,"Signature without r or s"),this.r=new ia(t.r,16),this.s=new ia(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var X4=na;function Q4(){this.place=0}function yf(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4||t[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function s0(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}na.prototype._importDER=function(e,r){e=bf.toArray(e,r);var i=new Q4;if(e[i.place++]!==48)return!1;var n=yf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=yf(e,i);if(s===!1||e[i.place]&128)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=yf(e,i);if(a===!1||e.length!==a+i.place||e[i.place]&128)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new ia(o),this.s=new ia(c),this.recoveryParam=null,!0};function vf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}na.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=s0(r),i=s0(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];vf(n,r.length),n=n.concat(r),n.push(2),vf(n,i.length);var s=n.concat(i),o=[48];return vf(o,s.length),o=o.concat(s),bf.encode(o,e)};var br=$r.exports,o0=W4,e5=Yt,mf=Qo,t5=Wo.exports,Wi=e5.assert,wf=J4,sa=X4;function sr(t){if(!(this instanceof sr))return new sr(t);typeof t=="string"&&(Wi(Object.prototype.hasOwnProperty.call(mf,t),"Unknown curve "+t),t=mf[t]),t instanceof mf.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var r5=sr;sr.prototype.keyPair=function(e){return new wf(this,e)},sr.prototype.keyFromPrivate=function(e,r){return wf.fromPrivate(this,e,r)},sr.prototype.keyFromPublic=function(e,r){return wf.fromPublic(this,e,r)},sr.prototype.genKeyPair=function(e){e||(e={});for(var r=new o0({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||t5(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new br(2));;){var s=new br(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},sr.prototype._truncateToN=function(e,r,i){var n;if(br.isBN(e)||typeof e=="number")e=new br(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new br(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new br(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},sr.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!br.isBN(e)){Wi(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),Wi(e.length>>>0===e.length);for(var s=0;s<e.length;s++)Wi((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),Wi(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);Wi(new br(c).eq(e),"Can not sign message");for(var f=new o0({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new br(1)),l=0;;l++){var g=n.k?n.k(l):new br(f.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(h)>=0)){var w=this.g.mul(g);if(!w.isInfinity()){var b=w.getX(),E=b.umod(this.n);if(E.cmpn(0)!==0){var A=g.invm(this.n).mul(E.mul(r.getPrivate()).iadd(e));if(A=A.umod(this.n),A.cmpn(0)!==0){var $=(w.getY().isOdd()?1:0)|(b.cmp(E)!==0?2:0);return n.canonical&&A.cmp(this.nh)>0&&(A=this.n.sub(A),$^=1),new sa({r:E,s:A,recoveryParam:$})}}}}}},sr.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new sa(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),f=c.mul(e).umod(this.n),h=c.mul(o).umod(this.n),l;return this.curve._maxwellTrick?(l=this.g.jmulAdd(f,i.getPublic(),h),l.isInfinity()?!1:l.eqXToP(o)):(l=this.g.mulAdd(f,i.getPublic(),h),l.isInfinity()?!1:l.getX().umod(this.n).cmp(o)===0)},sr.prototype.recoverPubKey=function(t,e,r,i){Wi((3&r)===r,"The recovery param is more than two bits"),e=new sa(e,i);var n=this.n,s=new br(t),o=e.r,a=e.s,c=r&1,f=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");f?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var h=e.r.invm(n),l=n.sub(s).mul(h).umod(n),g=a.mul(h).umod(n);return this.g.mulAdd(l,o,g)},sr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new sa(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Is=Yt,a0=Is.assert,c0=Is.parseBytes,jn=Is.cachedProperty;function gt(t,e){this.eddsa=t,this._secret=c0(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=c0(e.pub)}gt.fromPublic=function(e,r){return r instanceof gt?r:new gt(e,{pub:r})},gt.fromSecret=function(e,r){return r instanceof gt?r:new gt(e,{secret:r})},gt.prototype.secret=function(){return this._secret},jn(gt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),jn(gt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),jn(gt,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,n=r.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),jn(gt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),jn(gt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),jn(gt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),gt.prototype.sign=function(e){return a0(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},gt.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},gt.prototype.getSecret=function(e){return a0(this._secret,"KeyPair is public only"),Is.encode(this.secret(),e)},gt.prototype.getPublic=function(e){return Is.encode(this.pubBytes(),e)};var i5=gt,n5=$r.exports,oa=Yt,f0=oa.assert,aa=oa.cachedProperty,s5=oa.parseBytes;function Gi(t,e){this.eddsa=t,typeof e!="object"&&(e=s5(e)),Array.isArray(e)&&(f0(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),f0(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof n5&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}aa(Gi,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),aa(Gi,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),aa(Gi,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),aa(Gi,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Gi.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Gi.prototype.toHex=function(){return oa.encode(this.toBytes(),"hex").toUpperCase()};var o5=Gi,a5=ea,c5=Qo,Kn=Yt,f5=Kn.assert,u0=Kn.parseBytes,h0=i5,d0=o5;function Kt(t){if(f5(t==="ed25519","only tested with ed25519 so far"),!(this instanceof Kt))return new Kt(t);t=c5[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=a5.sha512}var u5=Kt;Kt.prototype.sign=function(e,r){e=u0(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})},Kt.prototype.verify=function(e,r,i){if(e=u0(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(r.Rencoded(),n.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(n.pub().mul(s));return a.eq(o)},Kt.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return Kn.intFromLE(e.digest()).umod(this.curve.n)},Kt.prototype.keyFromPublic=function(e){return h0.fromPublic(this,e)},Kt.prototype.keyFromSecret=function(e){return h0.fromSecret(this,e)},Kt.prototype.makeSignature=function(e){return e instanceof d0?e:new d0(this,e)},Kt.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},Kt.prototype.decodePoint=function(e){e=Kn.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=Kn.intFromLE(i);return this.curve.pointFromY(s,n)},Kt.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},Kt.prototype.decodeInt=function(e){return Kn.intFromLE(e)},Kt.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=a8.version,e.utils=Yt,e.rand=Wo.exports,e.curve=af,e.curves=Qo,e.ec=r5,e.eddsa=u5}(Ml);const h5={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},d5=":";function ca(t){const[e,r]=t.split(d5);return{namespace:e,reference:r}}function l0(t,e){return t.includes(":")?[t]:e.chains||[]}const l5="ReactNative",Jt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},p5="js";function fa(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function xi(){return!ds()&&!!xc()&&navigator.product===l5}function g5(){return xi()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function b5(){return xi()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function As(){return!fa()&&!!xc()&&!!ds()}function Ds(){return xi()?Jt.reactNative:fa()?Jt.node:As()?Jt.browser:Jt.unknown}function p0(){var t;try{return xi()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function y5(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&r.set(i,n)}return r.toString()}function g0(){return id()||{name:"",description:"",url:"",icons:[""]}}function v5(){if(Ds()===Jt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=Jv();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function m5(){var t;const e=Ds();return e===Jt.browser?[e,((t=rd())==null?void 0:t.host)||"unknown"].join(":"):e}function b0(t,e,r){const i=v5(),n=m5();return[[t,e].join("-"),[p5,r].join("-"),i,n].join("/")}function w5({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const f=r.split("?"),h=b0(t,e,i),l={auth:n,ua:h,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},g=y5(f[1]||"",l);return f[0]+"?"+g}function Yi(t,e){return t.filter(r=>e.includes(r)).length===t.length}function y0(t){return Object.fromEntries(t.entries())}function v0(t){return new Map(Object.entries(t))}function Ji(t=V.FIVE_MINUTES,e){const r=V.toMiliseconds(t||V.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const f=new Error(e);o=Promise.reject(f),c(f)},r),i=a,n=c})}}function Ei(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function m0(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function _5(t){return m0("topic",t)}function x5(t){return m0("id",t)}function w0(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function at(t,e){return V.fromMiliseconds((e||Date.now())+V.toMiliseconds(t))}function Si(t){return Date.now()>=V.toMiliseconds(t)}function ue(t,e){return`${t}${e?`:${e}`:""}`}function E5(t=[],e=[]){return[...new Set([...t,...e])]}async function S5({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r,s=n?.href;if(typeof s!="string")return;const o=I5(s,t,e),a=Ds();if(a===Jt.browser){if(!((i=ds())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}A5(o)}else a===Jt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function I5(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${M5(i,!0)}`}else n=`${n}/wc?${i}`;return n}function A5(t){let e="_self";O5()?e="_top":($5()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function D5(t,e){let r="";try{if(As()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function _0(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function x0(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function _f(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function $5(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function O5(){try{return window.self!==window.top}catch{return!1}}function M5(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function E0(t){return Buffer.from(t,"base64").toString("utf-8")}function P5(t){return new Promise(e=>setTimeout(e,t))}function $s(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function R5(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ua(t,...e){if(!R5(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function xf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");$s(t.outputLen),$s(t.blockLen)}function Vn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function S0(t,e){ua(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ha=BigInt(2**32-1),I0=BigInt(32);function T5(t,e=!1){return e?{h:Number(t&ha),l:Number(t>>I0&ha)}:{h:Number(t>>I0&ha)|0,l:Number(t&ha)|0}}function N5(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=T5(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const C5=(t,e,r)=>t<<r|e>>>32-r,B5=(t,e,r)=>e<<r|t>>>32-r,F5=(t,e,r)=>e<<r-32|t>>>64-r,L5=(t,e,r)=>t<<r-32|e>>>64-r,Hn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function q5(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ef(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Fr(t,e){return t<<32-e|t>>>e}const A0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function z5(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function D0(t){for(let e=0;e<t.length;e++)t[e]=z5(t[e])}function U5(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Wn(t){return typeof t=="string"&&(t=U5(t)),ua(t),t}class Sf{clone(){return this._cloneInto()}}function $0(t){const e=i=>t().update(Wn(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Os(t=32){if(Hn&&typeof Hn.getRandomValues=="function")return Hn.getRandomValues(new Uint8Array(t));if(Hn&&typeof Hn.randomBytes=="function")return Hn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const O0=[],M0=[],P0=[],k5=BigInt(0),Ms=BigInt(1),j5=BigInt(2),K5=BigInt(7),V5=BigInt(256),H5=BigInt(113);for(let t=0,e=Ms,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],O0.push(2*(5*i+r)),M0.push((t+1)*(t+2)/2%64);let n=k5;for(let s=0;s<7;s++)e=(e<<Ms^(e>>K5)*H5)%V5,e&j5&&(n^=Ms<<(Ms<<BigInt(s))-Ms);P0.push(n)}const[W5,G5]=N5(P0,!0),R0=(t,e,r)=>r>32?F5(t,e,r):C5(t,e,r),T0=(t,e,r)=>r>32?L5(t,e,r):B5(t,e,r);function Y5(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,f=r[c],h=r[c+1],l=R0(f,h,1)^r[a],g=T0(f,h,1)^r[a+1];for(let w=0;w<50;w+=10)t[o+w]^=l,t[o+w+1]^=g}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=M0[o],c=R0(n,s,a),f=T0(n,s,a),h=O0[o];n=t[h],s=t[h+1],t[h]=c,t[h+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=W5[i],t[1]^=G5[i]}r.fill(0)}class If extends Sf{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,$s(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=q5(this.state)}keccak(){A0||D0(this.state32),Y5(this.state32,this.rounds),A0||D0(this.state32),this.posOut=0,this.pos=0}update(e){Vn(this);const{blockLen:r,state:i}=this;e=Wn(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Vn(this,!1),ua(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return $s(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(S0(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new If(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const J5=(t,e,r)=>$0(()=>new If(e,t,r)),Z5=J5(1,136,256/8),X5="https://rpc.walletconnect.org/v1";function N0(t){const e=`Ethereum Signed Message:
|
|
18
|
+
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(Z5(r)).toString("hex")}async function Q5(t,e,r,i,n,s){switch(r.t){case"eip191":return await e9(t,e,r.s);case"eip1271":return await t9(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function e9(t,e,r){return(await Gm({hash:N0(e),signature:r})).toLowerCase()===t.toLowerCase()}async function t9(t,e,r,i,n,s){const o=ca(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",f="0000000000000000000000000000000000000000000000000000000000000041",h=r.substring(2),l=N0(e).substring(2),g=a+l+c+f+h,w=await fetch(`${s||X5}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:r9(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:g},"latest"]})}),{result:b}=await w.json();return b?b.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function r9(){return Date.now()+Math.floor(Math.random()*1e3)}var i9=Object.defineProperty,n9=Object.defineProperties,s9=Object.getOwnPropertyDescriptors,C0=Object.getOwnPropertySymbols,o9=Object.prototype.hasOwnProperty,a9=Object.prototype.propertyIsEnumerable,B0=(t,e,r)=>e in t?i9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c9=(t,e)=>{for(var r in e||(e={}))o9.call(e,r)&&B0(t,r,e[r]);if(C0)for(var r of C0(e))a9.call(e,r)&&B0(t,r,e[r]);return t},f9=(t,e)=>n9(t,s9(e));const u9="did:pkh:",Af=t=>t?.split(":"),h9=t=>{const e=t&&Af(t);if(e)return t.includes(u9)?e[3]:e[1]},Df=t=>{const e=t&&Af(t);if(e)return e[2]+":"+e[3]},da=t=>{const e=t&&Af(t);if(e)return e.pop()};async function F0(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=L0(n,n.iss),o=da(n.iss);return await Q5(o,s,i,Df(n.iss),r)}const L0=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=da(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${h9(e)}`,c=`Nonce: ${t.nonce}`,f=`Issued At: ${t.iat}`,h=t.exp?`Expiration Time: ${t.exp}`:void 0,l=t.nbf?`Not Before: ${t.nbf}`:void 0,g=t.requestId?`Request ID: ${t.requestId}`:void 0,w=t.resources?`Resources:${t.resources.map(E=>`
|
|
19
|
+
- ${E}`).join("")}`:void 0,b=la(t.resources);if(b){const E=Ps(b);n=w9(n,E)}return[r,i,"",n,"",s,o,a,c,f,h,l,g,w].filter(E=>E!=null).join(`
|
|
20
|
+
`)};function d9(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function l9(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Zi(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function p9(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:g9(e,r,i)}}}function g9(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function q0(t){return Zi(t),`urn:recap:${d9(t).replace(/=/g,"")}`}function Ps(t){const e=l9(t.replace("urn:recap:",""));return Zi(e),e}function b9(t,e,r){const i=p9(t,e,r);return q0(i)}function y9(t){return t&&t.includes("urn:recap:")}function v9(t,e){const r=Ps(t),i=Ps(e),n=m9(r,i);return q0(n)}function m9(t,e){Zi(t),Zi(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,f;i.att[n]=f9(c9({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((f=e.att[n])==null?void 0:f[a])})})}),i}function w9(t="",e){Zi(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));c.sort((l,g)=>l.action.localeCompare(g.action));const f={};c.forEach(l=>{f[l.ability]||(f[l.ability]=[]),f[l.ability].push(l.action)});const h=Object.keys(f).map(l=>(n++,`(${n}) '${l}': '${f[l].join("', '")}' for '${a}'.`));i.push(h.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function z0(t){var e;const r=Ps(t);Zi(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function U0(t){const e=Ps(t);Zi(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function la(t){if(!t)return;const e=t?.[t.length-1];return y9(e)?e:void 0}function $f(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function k0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Zt(t,...e){if(!k0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function j0(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function _9(t,e){Zt(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function K0(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ii=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),x9=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function E9(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Of(t){if(typeof t=="string")t=E9(t);else if(k0(t))t=Mf(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function S9(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function I9(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const A9=(t,e)=>{function r(i,...n){if(Zt(i),t.nonceLength!==void 0){const f=n[0];if(!f)throw new Error("nonce / iv required");t.varSizeNonce?Zt(f):Zt(f,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&Zt(n[1]);const o=e(i,...n),a=(f,h)=>{if(h!==void 0){if(f!==2)throw new Error("cipher output not supported");Zt(h)}};let c=!1;return{encrypt(f,h){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Zt(f),a(o.encrypt.length,h),o.encrypt(f,h)},decrypt(f,h){if(Zt(f),s&&f.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,h),o.decrypt(f,h)}}}return Object.assign(r,t),r};function V0(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!D9(e))throw new Error("invalid output, must be aligned");return e}function H0(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}function D9(t){return t.byteOffset%4===0}function Mf(t){return Uint8Array.from(t)}function Gn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const W0=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),$9=W0("expand 16-byte k"),O9=W0("expand 32-byte k"),M9=Ii($9),P9=Ii(O9);function ce(t,e){return t<<e|t>>>32-e}function Pf(t){return t.byteOffset%4===0}const pa=64,R9=16,G0=2**32-1,Y0=new Uint32Array;function T9(t,e,r,i,n,s,o,a){const c=n.length,f=new Uint8Array(pa),h=Ii(f),l=Pf(n)&&Pf(s),g=l?Ii(n):Y0,w=l?Ii(s):Y0;for(let b=0;b<c;o++){if(t(e,r,i,h,o,a),o>=G0)throw new Error("arx: counter overflow");const E=Math.min(pa,c-b);if(l&&E===pa){const A=b/4;if(b%4!==0)throw new Error("arx: invalid block position");for(let $=0,M;$<R9;$++)M=A+$,w[M]=g[M]^h[$];b+=pa;continue}for(let A=0,$;A<E;A++)$=b+A,s[$]=n[$]^f[A];b+=E}}function N9(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=S9({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return $f(n),$f(o),K0(s),K0(r),(a,c,f,h,l=0)=>{Zt(a),Zt(c),Zt(f);const g=f.length;if(h===void 0&&(h=new Uint8Array(g)),Zt(h),$f(l),l<0||l>=G0)throw new Error("arx: counter overflow");if(h.length<g)throw new Error(`arx: output (${h.length}) is shorter than data (${g})`);const w=[];let b=a.length,E,A;if(b===32)w.push(E=Mf(a)),A=P9;else if(b===16&&r)E=new Uint8Array(32),E.set(a),E.set(a,16),A=M9,w.push(E);else throw new Error(`arx: invalid 32-byte key, got length=${b}`);Pf(c)||w.push(c=Mf(c));const $=Ii(E);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(A,$,Ii(c.subarray(0,16)),$),c=c.subarray(16)}const M=16-n;if(M!==c.length)throw new Error(`arx: nonce must be ${M} or 16 bytes`);if(M!==12){const R=new Uint8Array(12);R.set(c,s?0:12-c.length),c=R,w.push(c)}const P=Ii(c);return T9(t,A,$,P,f,h,l,o),Gn(...w),h}}const Et=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class C9{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Of(e),Zt(e,32);const r=Et(e,0),i=Et(e,2),n=Et(e,4),s=Et(e,6),o=Et(e,8),a=Et(e,10),c=Et(e,12),f=Et(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let h=0;h<8;h++)this.pad[h]=Et(e,16+2*h)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],f=o[2],h=o[3],l=o[4],g=o[5],w=o[6],b=o[7],E=o[8],A=o[9],$=Et(e,r+0),M=Et(e,r+2),P=Et(e,r+4),R=Et(e,r+6),N=Et(e,r+8),L=Et(e,r+10),F=Et(e,r+12),B=Et(e,r+14);let C=s[0]+($&8191),W=s[1]+(($>>>13|M<<3)&8191),I=s[2]+((M>>>10|P<<6)&8191),u=s[3]+((P>>>7|R<<9)&8191),p=s[4]+((R>>>4|N<<12)&8191),v=s[5]+(N>>>1&8191),y=s[6]+((N>>>14|L<<2)&8191),m=s[7]+((L>>>11|F<<5)&8191),S=s[8]+((F>>>8|B<<8)&8191),D=s[9]+(B>>>5|n),_=0,d=_+C*a+W*(5*A)+I*(5*E)+u*(5*b)+p*(5*w);_=d>>>13,d&=8191,d+=v*(5*g)+y*(5*l)+m*(5*h)+S*(5*f)+D*(5*c),_+=d>>>13,d&=8191;let x=_+C*c+W*a+I*(5*A)+u*(5*E)+p*(5*b);_=x>>>13,x&=8191,x+=v*(5*w)+y*(5*g)+m*(5*l)+S*(5*h)+D*(5*f),_+=x>>>13,x&=8191;let q=_+C*f+W*c+I*a+u*(5*A)+p*(5*E);_=q>>>13,q&=8191,q+=v*(5*b)+y*(5*w)+m*(5*g)+S*(5*l)+D*(5*h),_+=q>>>13,q&=8191;let z=_+C*h+W*f+I*c+u*a+p*(5*A);_=z>>>13,z&=8191,z+=v*(5*E)+y*(5*b)+m*(5*w)+S*(5*g)+D*(5*l),_+=z>>>13,z&=8191;let U=_+C*l+W*h+I*f+u*c+p*a;_=U>>>13,U&=8191,U+=v*(5*A)+y*(5*E)+m*(5*b)+S*(5*w)+D*(5*g),_+=U>>>13,U&=8191;let k=_+C*g+W*l+I*h+u*f+p*c;_=k>>>13,k&=8191,k+=v*a+y*(5*A)+m*(5*E)+S*(5*b)+D*(5*w),_+=k>>>13,k&=8191;let G=_+C*w+W*g+I*l+u*h+p*f;_=G>>>13,G&=8191,G+=v*c+y*a+m*(5*A)+S*(5*E)+D*(5*b),_+=G>>>13,G&=8191;let Z=_+C*b+W*w+I*g+u*l+p*h;_=Z>>>13,Z&=8191,Z+=v*f+y*c+m*a+S*(5*A)+D*(5*E),_+=Z>>>13,Z&=8191;let X=_+C*E+W*b+I*w+u*g+p*l;_=X>>>13,X&=8191,X+=v*h+y*f+m*c+S*a+D*(5*A),_+=X>>>13,X&=8191;let J=_+C*A+W*E+I*b+u*w+p*g;_=J>>>13,J&=8191,J+=v*l+y*h+m*f+S*c+D*a,_+=J>>>13,J&=8191,_=(_<<2)+_|0,_=_+d|0,d=_&8191,_=_>>>13,x+=_,s[0]=d,s[1]=x,s[2]=q,s[3]=z,s[4]=U,s[5]=k,s[6]=G,s[7]=Z,s[8]=X,s[9]=J}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;Gn(i)}update(e){j0(this);const{buffer:r,blockLen:i}=this;e=Of(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){Gn(this.h,this.r,this.buffer,this.pad)}digestInto(e){j0(this),_9(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:n}=this;if(n){for(r[n++]=1;n<16;n++)r[n]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function B9(t){const e=(i,n)=>t(n).update(Of(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const F9=B9(t=>new C9(t));function L9(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],f=t[3],h=e[0],l=e[1],g=e[2],w=e[3],b=e[4],E=e[5],A=e[6],$=e[7],M=n,P=r[0],R=r[1],N=r[2],L=o,F=a,B=c,C=f,W=h,I=l,u=g,p=w,v=b,y=E,m=A,S=$,D=M,_=P,d=R,x=N;for(let z=0;z<s;z+=2)L=L+W|0,D=ce(D^L,16),v=v+D|0,W=ce(W^v,12),L=L+W|0,D=ce(D^L,8),v=v+D|0,W=ce(W^v,7),F=F+I|0,_=ce(_^F,16),y=y+_|0,I=ce(I^y,12),F=F+I|0,_=ce(_^F,8),y=y+_|0,I=ce(I^y,7),B=B+u|0,d=ce(d^B,16),m=m+d|0,u=ce(u^m,12),B=B+u|0,d=ce(d^B,8),m=m+d|0,u=ce(u^m,7),C=C+p|0,x=ce(x^C,16),S=S+x|0,p=ce(p^S,12),C=C+p|0,x=ce(x^C,8),S=S+x|0,p=ce(p^S,7),L=L+I|0,x=ce(x^L,16),m=m+x|0,I=ce(I^m,12),L=L+I|0,x=ce(x^L,8),m=m+x|0,I=ce(I^m,7),F=F+u|0,D=ce(D^F,16),S=S+D|0,u=ce(u^S,12),F=F+u|0,D=ce(D^F,8),S=S+D|0,u=ce(u^S,7),B=B+p|0,_=ce(_^B,16),v=v+_|0,p=ce(p^v,12),B=B+p|0,_=ce(_^B,8),v=v+_|0,p=ce(p^v,7),C=C+W|0,d=ce(d^C,16),y=y+d|0,W=ce(W^y,12),C=C+W|0,d=ce(d^C,8),y=y+d|0,W=ce(W^y,7);let q=0;i[q++]=o+L|0,i[q++]=a+F|0,i[q++]=c+B|0,i[q++]=f+C|0,i[q++]=h+W|0,i[q++]=l+I|0,i[q++]=g+u|0,i[q++]=w+p|0,i[q++]=b+v|0,i[q++]=E+y|0,i[q++]=A+m|0,i[q++]=$+S|0,i[q++]=M+D|0,i[q++]=P+_|0,i[q++]=R+d|0,i[q++]=N+x|0}const q9=N9(L9,{counterRight:!1,counterLength:4,allowShortKeys:!1}),z9=new Uint8Array(16),J0=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(z9.subarray(r))},U9=new Uint8Array(32);function Z0(t,e,r,i,n){const s=t(e,r,U9),o=F9.create(s);n&&J0(o,n),J0(o,i);const a=new Uint8Array(16),c=x9(a);H0(c,0,BigInt(n?n.length:0),!0),H0(c,8,BigInt(i.length),!0),o.update(a);const f=o.digest();return Gn(s,a),f}const k9=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=V0(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=Z0(t,e,r,a,i);return s.set(c,o),Gn(c),s},decrypt(n,s){s=V0(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Z0(t,e,r,o,i);if(!I9(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),Gn(c),s}}),X0=A9({blockSize:64,nonceLength:12,tagLength:16},k9(q9));class Q0 extends Sf{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,xf(e);const i=Wn(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Vn(this),this.iHash.update(e),this}digestInto(e){Vn(this),ua(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Rf=(t,e,r)=>new Q0(t,e).update(r).digest();Rf.create=(t,e)=>new Q0(t,e);function j9(t,e,r){return xf(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Rf(t,Wn(r),Wn(e))}const Tf=new Uint8Array([0]),ep=new Uint8Array;function K9(t,e,r,i=32){if(xf(t),$s(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=ep);const s=new Uint8Array(n*t.outputLen),o=Rf.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let f=0;f<n;f++)Tf[0]=f+1,a.update(f===0?ep:c).update(r).update(Tf).digestInto(c),s.set(c,t.outputLen*f),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Tf.fill(0),s.slice(0,i)}const V9=(t,e,r,i,n)=>K9(t,j9(t,e,r),i,n);function H9(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}function W9(t,e,r){return t&e^~t&r}function G9(t,e,r){return t&e^t&r^e&r}class Y9 extends Sf{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ef(this.buffer)}update(e){Vn(this);const{view:r,buffer:i,blockLen:n}=this;e=Wn(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Ef(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Vn(this),S0(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let l=o;l<n;l++)r[l]=0;H9(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Ef(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,h[l],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const J9=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]),Ai=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Di=new Uint32Array(64);class Z9 extends Y9{constructor(){super(64,32,8,!1),this.A=Ai[0]|0,this.B=Ai[1]|0,this.C=Ai[2]|0,this.D=Ai[3]|0,this.E=Ai[4]|0,this.F=Ai[5]|0,this.G=Ai[6]|0,this.H=Ai[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)Di[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){const g=Di[l-15],w=Di[l-2],b=Fr(g,7)^Fr(g,18)^g>>>3,E=Fr(w,17)^Fr(w,19)^w>>>10;Di[l]=E+Di[l-7]+b+Di[l-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:f,H:h}=this;for(let l=0;l<64;l++){const g=Fr(a,6)^Fr(a,11)^Fr(a,25),w=h+g+W9(a,c,f)+J9[l]+Di[l]|0,b=(Fr(i,2)^Fr(i,13)^Fr(i,22))+G9(i,n,s)|0;h=f,f=c,c=a,a=o+w|0,o=s,s=n,n=i,i=w+b|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(i,n,s,o,a,c,f,h)}roundClean(){Di.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ga=$0(()=>new Z9);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tp=BigInt(0);function Nf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rp(t){if(!Nf(t))throw new Error("Uint8Array expected")}const X9=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Q9(t){rp(t);let e="";for(let r=0;r<t.length;r++)e+=X9[t[r]];return e}function e7(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?tp:BigInt("0x"+t)}const ri={_0:48,_9:57,A:65,F:70,a:97,f:102};function ip(t){if(t>=ri._0&&t<=ri._9)return t-ri._0;if(t>=ri.A&&t<=ri.F)return t-(ri.A-10);if(t>=ri.a&&t<=ri.f)return t-(ri.a-10)}function np(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=ip(t.charCodeAt(s)),a=ip(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function sp(t){return rp(t),e7(Q9(Uint8Array.from(t).reverse()))}function t7(t,e){return np(t.toString(16).padStart(e*2,"0"))}function r7(t,e){return t7(t,e).reverse()}function op(t,e,r){let i;if(typeof e=="string")try{i=np(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Nf(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}const Cf=t=>typeof t=="bigint"&&tp<=t;function i7(t,e,r){return Cf(t)&&Cf(e)&&Cf(r)&&e<=t&&t<r}function ap(t,e,r,i){if(!i7(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const n7={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Nf(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function s7(t,e,r={}){const i=(n,s,o)=>{const a=n7[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const Yn=BigInt(0),ba=BigInt(1);function cp(t,e){const r=t%e;return r>=Yn?r:e+r}function o7(t,e,r){if(e<Yn)throw new Error("invalid exponent, negatives unsupported");if(r<=Yn)throw new Error("invalid modulus");if(r===ba)return Yn;let i=ba;for(;e>Yn;)e&ba&&(i=i*t%r),t=t*t%r,e>>=ba;return i}function yr(t,e,r){let i=t;for(;e-- >Yn;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Jn=BigInt(0),Bf=BigInt(1);function a7(t){return s7(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function c7(t){const e=a7(t),{P:r}=e,i=M=>cp(M,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(M=>M),c=e.powPminus2||(M=>o7(M,r-BigInt(2),r));function f(M,P,R){const N=i(M*(P-R));return P=i(P-N),R=i(R+N),[P,R]}const h=(e.a-BigInt(2))/BigInt(4);function l(M,P){ap("u",M,Jn,r),ap("scalar",P,Jn,r);const R=P,N=M;let L=Bf,F=Jn,B=M,C=Bf,W=Jn,I;for(let p=BigInt(n-1);p>=Jn;p--){const v=R>>p&Bf;W^=v,I=f(W,L,B),L=I[0],B=I[1],I=f(W,F,C),F=I[0],C=I[1],W=v;const y=L+F,m=i(y*y),S=L-F,D=i(S*S),_=m-D,d=B+C,x=B-C,q=i(x*y),z=i(d*S),U=q+z,k=q-z;B=i(U*U),C=i(N*i(k*k)),L=i(m*D),F=i(_*(m+i(h*_)))}I=f(W,L,B),L=I[0],B=I[1],I=f(W,F,C),F=I[0],C=I[1];const u=c(F);return i(L*u)}function g(M){return r7(i(M),s)}function w(M){const P=op("u coordinate",M,s);return o===32&&(P[31]&=127),sp(P)}function b(M){const P=op("scalar",M),R=P.length;if(R!==s&&R!==o){let N=""+s+" or "+o;throw new Error("invalid scalar, expected "+N+" bytes, got "+R)}return sp(a(P))}function E(M,P){const R=w(P),N=b(M),L=l(R,N);if(L===Jn)throw new Error("invalid private or public key received");return g(L)}const A=g(e.Gu);function $(M){return E(M,A)}return{scalarMult:E,scalarMultBase:$,getSharedSecret:(M,P)=>E(M,P),getPublicKey:M=>$(M),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:A}}const Ff=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const f7=BigInt(1),fp=BigInt(2),u7=BigInt(3),h7=BigInt(5);BigInt(8);function d7(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=Ff,o=t*t%s*t%s,a=yr(o,fp,s)*o%s,c=yr(a,f7,s)*t%s,f=yr(c,h7,s)*c%s,h=yr(f,e,s)*f%s,l=yr(h,r,s)*h%s,g=yr(l,i,s)*l%s,w=yr(g,n,s)*g%s,b=yr(w,n,s)*g%s,E=yr(b,e,s)*f%s;return{pow_p_5_8:yr(E,fp,s)*t%s,b2:o}}function l7(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Lf=c7({P:Ff,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Ff,{pow_p_5_8:r,b2:i}=d7(t);return cp(yr(r,u7,e)*i,e)},adjustScalarBytes:l7,randomBytes:Os}),up="base10",Rt="base16",$i="base64pad",Rs="base64url",Ts="utf8",hp=0,ii=1,Ns=2,p7=0,dp=1,Cs=12,qf=32;function g7(){const t=Lf.utils.randomPrivateKey(),e=Lf.getPublicKey(t);return{privateKey:Lt(t,Rt),publicKey:Lt(e,Rt)}}function zf(){const t=Os(qf);return Lt(t,Rt)}function b7(t,e){const r=Lf.getSharedSecret(rr(t,Rt),rr(e,Rt)),i=V9(ga,r,void 0,void 0,qf);return Lt(i,Rt)}function ya(t){const e=ga(rr(t,Rt));return Lt(e,Rt)}function ni(t){const e=ga(rr(t,Ts));return Lt(e,Rt)}function lp(t){return rr(`${t}`,up)}function Xi(t){return Number(Lt(t,up))}function y7(t){const e=lp(typeof t.type<"u"?t.type:hp);if(Xi(e)===ii&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?rr(t.senderPublicKey,Rt):void 0,i=typeof t.iv<"u"?rr(t.iv,Rt):Os(Cs),n=rr(t.symKey,Rt),s=X0(n,i).encrypt(rr(t.message,Ts));return pp({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function v7(t){const e=rr(t.symKey,Rt),{sealed:r,iv:i}=Bs(t),n=X0(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return Lt(n,Ts)}function m7(t,e){const r=lp(Ns),i=Os(Cs),n=rr(t,Ts);return pp({type:r,sealed:n,iv:i,encoding:e})}function w7(t,e){const{sealed:r}=Bs({encoded:t,encoding:e});return Lt(r,Ts)}function pp(t){const{encoding:e=$i}=t;if(Xi(t.type)===Ns)return Lt(ef([t.type,t.sealed]),e);if(Xi(t.type)===ii){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Lt(ef([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Lt(ef([t.type,t.iv,t.sealed]),e)}function Bs(t){const{encoded:e,encoding:r=$i}=t,i=rr(e,r),n=i.slice(p7,dp),s=dp;if(Xi(n)===ii){const f=s+qf,h=f+Cs,l=i.slice(s,f),g=i.slice(f,h),w=i.slice(h);return{type:n,sealed:w,iv:g,senderPublicKey:l}}if(Xi(n)===Ns){const f=i.slice(s),h=Os(Cs);return{type:n,sealed:f,iv:h}}const o=s+Cs,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function _7(t,e){const r=Bs({encoded:t,encoding:e?.encoding});return gp({type:Xi(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Lt(r.senderPublicKey,Rt):void 0,receiverPublicKey:e?.receiverPublicKey})}function gp(t){const e=t?.type||hp;if(e===ii){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function bp(t){return t.type===ii&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function yp(t){return t.type===Ns}function x7(t){return new Ml.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function E7(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function S7(t){return Buffer.from(E7(t),"base64")}function I7(t,e){const[r,i,n]=t.split("."),s=S7(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,f=ga(c),h=x7(e),l=Lt(f,Rt);if(!h.verify(l,{r:o,s:a}))throw new Error("Invalid signature");return _c(t).payload}const A7="irn";function va(t){return t?.relay||{protocol:A7}}function Fs(t){const e=h5[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function D7(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function vp(t){if(!t.includes("wc:")){const f=E0(t);f!=null&&f.includes("wc:")&&(t=f)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a={};o.forEach((f,h)=>{a[h]=f});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:$7(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:D7(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function $7(t){return t.startsWith("//")?t.substring(2):t}function O7(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=n,o=r+e+s;t[s]&&(i[o]=t[s])}),i}function mp(t){const e=new URLSearchParams,r=O7(t.relay);Object.keys(r).sort().forEach(n=>{e.set(n,r[n])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function ma(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Zn(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function M7(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Zn(r.accounts))}),e}function P7(t,e){const r=[];return Object.values(t).forEach(i=>{Zn(i.accounts).includes(e)&&r.push(...i.methods)}),r}function R7(t,e){const r=[];return Object.values(t).forEach(i=>{Zn(i.accounts).includes(e)&&r.push(...i.events)}),r}function T7(t){const e={};return t?.forEach(r=>{var i;const[n,s]=r.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[],methods:[]}),e[n].accounts.push(r),(i=e[n].chains)==null||i.push(`${n}:${s}`)}),e}function wp(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=T7(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=E5(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const N7={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},C7={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function H(t,e){const{message:r,code:i}=C7[t];return{message:e?`${r} ${e}`:r,code:i}}function me(t,e){const{message:r,code:i}=N7[t];return{message:e?`${r} ${e}`:r,code:i}}function Ls(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function wa(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function qt(t){return typeof t>"u"}function nt(t,e){return e&&qt(t)?!0:typeof t=="string"&&!!t.trim().length}function Uf(t,e){return e&&qt(t)?!0:typeof t=="number"&&!isNaN(t)}function B7(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return Yi(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:f}=t.namespaces[o],h=Zn(a),l=r[o];(!Yi(l0(o,l),h)||!Yi(l.methods,c)||!Yi(l.events,f))&&(s=!1)}),s):!1}function _a(t){return nt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function F7(t){if(nt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&_a(r)}}return!1}function L7(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(nt(t,!1)){if(e(t))return!0;const r=E0(t);return e(r)}}catch{}return!1}function q7(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function z7(t){return t?.topic}function U7(t,e){let r=null;return nt(t?.publicKey,!1)||(r=H("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function _p(t){let e=!0;return Ls(t)?t.length&&(e=t.every(r=>nt(r,!1))):e=!1,e}function k7(t,e,r){let i=null;return Ls(e)&&e.length?e.forEach(n=>{i||_a(n)||(i=me("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):_a(t)||(i=me("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function j7(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=k7(n,l0(n,s),`${e} ${r}`);o&&(i=o)}),i}function K7(t,e){let r=null;return Ls(t)?t.forEach(i=>{r||F7(i)||(r=me("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=me("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function V7(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=K7(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function H7(t,e){let r=null;return _p(t?.methods)?_p(t?.events)||(r=me("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=me("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function xp(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=H7(i,`${e}, namespace`);n&&(r=n)}),r}function W7(t,e,r){let i=null;if(t&&wa(t)){const n=xp(t,e);n&&(i=n);const s=j7(t,e,r);s&&(i=s)}else i=H("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function kf(t,e){let r=null;if(t&&wa(t)){const i=xp(t,e);i&&(r=i);const n=V7(t,e);n&&(r=n)}else r=H("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Ep(t){return nt(t.protocol,!0)}function G7(t,e){let r=!1;return e&&!t?r=!0:t&&Ls(t)&&t.length&&t.forEach(i=>{r=Ep(i)}),r}function Y7(t){return typeof t=="number"}function Vt(t){return typeof t<"u"&&typeof t!==null}function J7(t){return!(!t||typeof t!="object"||!t.code||!Uf(t.code,!1)||!t.message||!nt(t.message,!1))}function Z7(t){return!(qt(t)||!nt(t.method,!1))}function X7(t){return!(qt(t)||qt(t.result)&&qt(t.error)||!Uf(t.id,!1)||!nt(t.jsonrpc,!1))}function Q7(t){return!(qt(t)||!nt(t.name,!1))}function Sp(t,e){return!(!_a(e)||!M7(t).includes(e))}function e_(t,e,r){return nt(r,!1)?P7(t,e).includes(r):!1}function t_(t,e,r){return nt(r,!1)?R7(t,e).includes(r):!1}function Ip(t,e,r){let i=null;const n=r_(t),s=i_(e),o=Object.keys(n),a=Object.keys(s),c=Ap(Object.keys(t)),f=Ap(Object.keys(e)),h=c.filter(l=>!f.includes(l));return h.length&&(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
21
|
+
Required: ${h.toString()}
|
|
22
|
+
Received: ${Object.keys(e).toString()}`)),Yi(o,a)||(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
27
23
|
Required: ${o.toString()}
|
|
28
|
-
Approved: ${a.toString()}`)),Object.keys(e).forEach(
|
|
29
|
-
Required: ${
|
|
30
|
-
Approved: ${
|
|
24
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||i)return;const g=Zn(e[l].accounts);g.includes(l)||(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${l}
|
|
25
|
+
Required: ${l}
|
|
26
|
+
Approved: ${g.toString()}`))}),o.forEach(l=>{i||(Yi(n[l].methods,s[l].methods)?Yi(n[l].events,s[l].events)||(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${l}`)):i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${l}`))}),i}function r_(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(n=>{e[n]={methods:t[r].methods,events:t[r].events}})}),e}function Ap(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function i_(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:Zn(t[r].accounts)?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}),e}function n_(t,e){return Uf(t,!1)&&t<=e.max&&t>=e.min}function Dp(){const t=Ds();return new Promise(e=>{switch(t){case Jt.browser:e(s_());break;case Jt.reactNative:e(o_());break;case Jt.node:e(a_());break;default:e(!0)}})}function s_(){return As()&&navigator?.onLine}async function o_(){return xi()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function a_(){return!0}function c_(t){switch(Ds()){case Jt.browser:f_(t);break;case Jt.reactNative:u_(t);break}}function f_(t){!xi()&&As()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function u_(t){xi()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const jf={};class qs{static get(e){return jf[e]}static set(e,r){jf[e]=r}static delete(e){delete jf[e]}}const h_="PARSE_ERROR",d_="INVALID_REQUEST",l_="METHOD_NOT_FOUND",p_="INVALID_PARAMS",$p="INTERNAL_ERROR",Kf="SERVER_ERROR",g_=[-32700,-32600,-32601,-32602,-32603],zs={[h_]:{code:-32700,message:"Parse error"},[d_]:{code:-32600,message:"Invalid Request"},[l_]:{code:-32601,message:"Method not found"},[p_]:{code:-32602,message:"Invalid params"},[$p]:{code:-32603,message:"Internal error"},[Kf]:{code:-32e3,message:"Server error"}},Op=Kf;function b_(t){return g_.includes(t)}function Mp(t){return Object.keys(zs).includes(t)?zs[t]:zs[Op]}function y_(t){const e=Object.values(zs).find(r=>r.code===t);return e||zs[Op]}function v_(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Pp={};/*! *****************************************************************************
|
|
31
27
|
Copyright (c) Microsoft Corporation.
|
|
32
28
|
|
|
33
29
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -40,5 +36,5 @@ ${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(a4(r)).toStr
|
|
|
40
36
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41
37
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42
38
|
PERFORMANCE OF THIS SOFTWARE.
|
|
43
|
-
***************************************************************************** */var wc=function(t,e){return wc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},wc(t,e)};function O5(t,e){wc(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var _c=function(){return _c=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},_c.apply(this,arguments)};function P5(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function $5(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function R5(t,e){return function(r,i){e(r,i,t)}}function N5(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function T5(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{h(i.next(l))}catch(y){o(y)}}function c(l){try{h(i.throw(l))}catch(y){o(y)}}function h(l){l.done?s(l.value):n(l.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function F5(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(l){return c([h,l])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,n=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function C5(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function B5(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function xc(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function I0(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function L5(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(I0(arguments[e]));return t}function q5(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function to(t){return this instanceof to?(this.v=t,this):new to(t)}function U5(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(M){i[M]&&(n[M]=function(I){return new Promise(function(S,D){s.push([M,I,S,D])>1||a(M,I)})})}function a(M,I){try{c(i[M](I))}catch(S){y(s[0][3],S)}}function c(M){M.value instanceof to?Promise.resolve(M.value.v).then(h,l):y(s[0][2],M)}function h(M){a("next",M)}function l(M){a("throw",M)}function y(M,I){M(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function z5(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:to(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function k5(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof xc=="function"?xc(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(h){s({value:h,done:a})},o)}}function j5(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function K5(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function V5(t){return t&&t.__esModule?t:{default:t}}function H5(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function W5(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var G5=Object.freeze({__proto__:null,__extends:O5,get __assign(){return _c},__rest:P5,__decorate:$5,__param:R5,__metadata:N5,__awaiter:T5,__generator:F5,__createBinding:C5,__exportStar:B5,__values:xc,__read:I0,__spread:L5,__spreadArrays:q5,__await:to,__asyncGenerator:U5,__asyncDelegator:z5,__asyncValues:k5,__makeTemplateObject:j5,__importStar:K5,__importDefault:V5,__classPrivateFieldGet:H5,__classPrivateFieldSet:W5}),J5=Aa(G5),Ni={},A0;function Y5(){if(A0)return Ni;A0=1,Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.isBrowserCryptoAvailable=Ni.getSubtleCrypto=Ni.getBrowerCrypto=void 0;function t(){return zt?.crypto||zt?.msCrypto||{}}Ni.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}Ni.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Ni.isBrowserCryptoAvailable=r,Ni}var Ti={},D0;function Z5(){if(D0)return Ti;D0=1,Object.defineProperty(Ti,"__esModule",{value:!0}),Ti.isBrowser=Ti.isNode=Ti.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Ti.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Ti.isNode=e;function r(){return!t()&&!e()}return Ti.isBrowser=r,Ti}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=J5;e.__exportStar(Y5(),t),e.__exportStar(Z5(),t)})(M0);function Fi(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function $n(t=6){return BigInt(Fi(t))}function Rn(t,e,r){return{id:r||Fi(),jsonrpc:"2.0",method:t,params:e}}function Ec(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Sc(t,e,r){return{id:t,jsonrpc:"2.0",error:X5(e,r)}}function X5(t,e){return typeof t>"u"?S0(x0):(typeof t=="string"&&(t=Object.assign(Object.assign({},S0(mc)),{message:t})),typeof e<"u"&&(t.data=e),I5(t.code)&&(t=A5(t.code)),t)}class Q5{}class e9 extends Q5{constructor(){super()}}class t9 extends e9{constructor(e){super()}}const r9="^wss?:";function i9(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function n9(t,e){const r=i9(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function O0(t){return n9(t,r9)}function s9(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function P0(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Mc(t){return P0(t)&&"method"in t}function ba(t){return P0(t)&&(bi(t)||Ur(t))}function bi(t){return"result"in t}function Ur(t){return"error"in t}class o9 extends t9{constructor(e){super(e),this.events=new Qt.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(Rn(e.method,e.params||[],e.id||$n().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Ur(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),ba(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const a9=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),f9=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",$0=t=>t.split("?")[0],R0=10,c9=a9();class h9{constructor(e){if(this.url=e,this.events=new Qt.exports.EventEmitter,this.registering=!1,!O0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(vn(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!O0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=M0.isReactNative()?void 0:{rejectUnauthorized:!s9(e)},s=new c9(e,[],n);f9()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?kn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Sc(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return D5(e,$0(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>R0&&this.events.setMaxListeners(R0)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${$0(this.url)}`));return this.events.emit("register_error",r),r}}var Ic={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",h="[object AsyncFunction]",l="[object Boolean]",y="[object Date]",M="[object Error]",I="[object Function]",S="[object GeneratorFunction]",D="[object Map]",R="[object Number]",$="[object Null]",N="[object Object]",C="[object Promise]",L="[object Proxy]",k="[object RegExp]",j="[object Set]",G="[object String]",K="[object Symbol]",V="[object Undefined]",ie="[object WeakMap]",O="[object ArrayBuffer]",g="[object DataView]",p="[object Float32Array]",f="[object Float64Array]",u="[object Int8Array]",b="[object Int16Array]",_="[object Int32Array]",E="[object Uint8Array]",w="[object Uint8ClampedArray]",d="[object Uint16Array]",m="[object Uint32Array]",v=/[\\^$.*+?()[\]{}|]/g,A=/^\[object .+?Constructor\]$/,U=/^(?:0|[1-9]\d*)$/,x={};x[p]=x[f]=x[u]=x[b]=x[_]=x[E]=x[w]=x[d]=x[m]=!0,x[a]=x[c]=x[O]=x[l]=x[g]=x[y]=x[M]=x[I]=x[D]=x[R]=x[N]=x[k]=x[j]=x[G]=x[ie]=!1;var T=typeof zt=="object"&&zt&&zt.Object===Object&&zt,B=typeof self=="object"&&self&&self.Object===Object&&self,q=T||B||Function("return this")(),z=e&&!e.nodeType&&e,Y=z&&!0&&t&&!t.nodeType&&t,X=Y&&Y.exports===z,W=X&&T.process,se=function(){try{return W&&W.binding&&W.binding("util")}catch{}}(),ee=se&&se.isTypedArray;function te(P,F){for(var H=-1,re=P==null?0:P.length,yt=0,_e=[];++H<re;){var xt=P[H];F(xt,H,P)&&(_e[yt++]=xt)}return _e}function ke(P,F){for(var H=-1,re=F.length,yt=P.length;++H<re;)P[yt+H]=F[H];return P}function je(P,F){for(var H=-1,re=P==null?0:P.length;++H<re;)if(F(P[H],H,P))return!0;return!1}function ue(P,F){for(var H=-1,re=Array(P);++H<P;)re[H]=F(H);return re}function Ne(P){return function(F){return P(F)}}function Te(P,F){return P.has(F)}function fe(P,F){return P?.[F]}function Fe(P){var F=-1,H=Array(P.size);return P.forEach(function(re,yt){H[++F]=[yt,re]}),H}function Ce(P,F){return function(H){return P(F(H))}}function he(P){var F=-1,H=Array(P.size);return P.forEach(function(re){H[++F]=re}),H}var Be=Array.prototype,Le=Function.prototype,ae=Object.prototype,$e=q["__core-js_shared__"],qe=Le.toString,ne=ae.hasOwnProperty,Je=function(){var P=/[^.]+$/.exec($e&&$e.keys&&$e.keys.IE_PROTO||"");return P?"Symbol(src)_1."+P:""}(),Ye=ae.toString,ge=RegExp("^"+qe.call(ne).replace(v,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ze=X?q.Buffer:void 0,Ue=q.Symbol,le=q.Uint8Array,Xe=ae.propertyIsEnumerable,tt=Be.splice,oe=Ue?Ue.toStringTag:void 0,Qe=Object.getOwnPropertySymbols,rt=Ze?Ze.isBuffer:void 0,be=Ce(Object.keys,Object),Ke=ys(q,"DataView"),Re=ys(q,"Map"),de=ys(q,"Promise"),Ve=ys(q,"Set"),He=ys(q,"WeakMap"),ce=ys(Object,"create"),it=Bn(Ke),nt=Bn(Re),ve=Bn(de),st=Bn(Ve),ot=Bn(He),pe=Ue?Ue.prototype:void 0,We=pe?pe.valueOf:void 0;function De(P){var F=-1,H=P==null?0:P.length;for(this.clear();++F<H;){var re=P[F];this.set(re[0],re[1])}}function ye(){this.__data__=ce?ce(null):{},this.size=0}function at(P){var F=this.has(P)&&delete this.__data__[P];return this.size-=F?1:0,F}function ft(P){var F=this.__data__;if(ce){var H=F[P];return H===i?void 0:H}return ne.call(F,P)?F[P]:void 0}function me(P){var F=this.__data__;return ce?F[P]!==void 0:ne.call(F,P)}function ct(P,F){var H=this.__data__;return this.size+=this.has(P)?0:1,H[P]=ce&&F===void 0?i:F,this}De.prototype.clear=ye,De.prototype.delete=at,De.prototype.get=ft,De.prototype.has=me,De.prototype.set=ct;function Ee(P){var F=-1,H=P==null?0:P.length;for(this.clear();++F<H;){var re=P[F];this.set(re[0],re[1])}}function et(){this.__data__=[],this.size=0}function wr(P){var F=this.__data__,H=xa(F,P);if(H<0)return!1;var re=F.length-1;return H==re?F.pop():tt.call(F,H,1),--this.size,!0}function _r(P){var F=this.__data__,H=xa(F,P);return H<0?void 0:F[H][1]}function xr(P){return xa(this.__data__,P)>-1}function Er(P,F){var H=this.__data__,re=xa(H,P);return re<0?(++this.size,H.push([P,F])):H[re][1]=F,this}Ee.prototype.clear=et,Ee.prototype.delete=wr,Ee.prototype.get=_r,Ee.prototype.has=xr,Ee.prototype.set=Er;function At(P){var F=-1,H=P==null?0:P.length;for(this.clear();++F<H;){var re=P[F];this.set(re[0],re[1])}}function Bi(){this.size=0,this.__data__={hash:new De,map:new(Re||Ee),string:new De}}function Li(P){var F=Ea(this,P).delete(P);return this.size-=F?1:0,F}function qi(P){return Ea(this,P).get(P)}function Ui(P){return Ea(this,P).has(P)}function zi(P,F){var H=Ea(this,P),re=H.size;return H.set(P,F),this.size+=H.size==re?0:1,this}At.prototype.clear=Bi,At.prototype.delete=Li,At.prototype.get=qi,At.prototype.has=Ui,At.prototype.set=zi;function jr(P){var F=-1,H=P==null?0:P.length;for(this.__data__=new At;++F<H;)this.add(P[F])}function ki(P){return this.__data__.set(P,i),this}function ji(P){return this.__data__.has(P)}jr.prototype.add=jr.prototype.push=ki,jr.prototype.has=ji;function nr(P){var F=this.__data__=new Ee(P);this.size=F.size}function Ki(){this.__data__=new Ee,this.size=0}function Vi(P){var F=this.__data__,H=F.delete(P);return this.size=F.size,H}function Hi(P){return this.__data__.get(P)}function fo(P){return this.__data__.has(P)}function co(P,F){var H=this.__data__;if(H instanceof Ee){var re=H.__data__;if(!Re||re.length<r-1)return re.push([P,F]),this.size=++H.size,this;H=this.__data__=new At(re)}return H.set(P,F),this.size=H.size,this}nr.prototype.clear=Ki,nr.prototype.delete=Vi,nr.prototype.get=Hi,nr.prototype.has=fo,nr.prototype.set=co;function Qx(P,F){var H=Sa(P),re=!H&&pE(P),yt=!H&&!re&&Gc(P),_e=!H&&!re&&!yt&&Np(P),xt=H||re||yt||_e,Ut=xt?ue(P.length,String):[],Zt=Ut.length;for(var mt in P)(F||ne.call(P,mt))&&!(xt&&(mt=="length"||yt&&(mt=="offset"||mt=="parent")||_e&&(mt=="buffer"||mt=="byteLength"||mt=="byteOffset")||cE(mt,Zt)))&&Ut.push(mt);return Ut}function xa(P,F){for(var H=P.length;H--;)if(Op(P[H][0],F))return H;return-1}function eE(P,F,H){var re=F(P);return Sa(P)?re:ke(re,H(P))}function ho(P){return P==null?P===void 0?V:$:oe&&oe in Object(P)?aE(P):lE(P)}function Mp(P){return uo(P)&&ho(P)==a}function Ip(P,F,H,re,yt){return P===F?!0:P==null||F==null||!uo(P)&&!uo(F)?P!==P&&F!==F:tE(P,F,H,re,Ip,yt)}function tE(P,F,H,re,yt,_e){var xt=Sa(P),Ut=Sa(F),Zt=xt?c:un(P),mt=Ut?c:un(F);Zt=Zt==a?N:Zt,mt=mt==a?N:mt;var $r=Zt==N,ri=mt==N,sr=Zt==mt;if(sr&&Gc(P)){if(!Gc(F))return!1;xt=!0,$r=!1}if(sr&&!$r)return _e||(_e=new nr),xt||Np(P)?Ap(P,F,H,re,yt,_e):sE(P,F,Zt,H,re,yt,_e);if(!(H&n)){var Kr=$r&&ne.call(P,"__wrapped__"),Vr=ri&&ne.call(F,"__wrapped__");if(Kr||Vr){var dn=Kr?P.value():P,Wi=Vr?F.value():F;return _e||(_e=new nr),yt(dn,Wi,H,re,_e)}}return sr?(_e||(_e=new nr),oE(P,F,H,re,yt,_e)):!1}function rE(P){if(!Rp(P)||uE(P))return!1;var F=Pp(P)?ge:A;return F.test(Bn(P))}function iE(P){return uo(P)&&$p(P.length)&&!!x[ho(P)]}function nE(P){if(!dE(P))return be(P);var F=[];for(var H in Object(P))ne.call(P,H)&&H!="constructor"&&F.push(H);return F}function Ap(P,F,H,re,yt,_e){var xt=H&n,Ut=P.length,Zt=F.length;if(Ut!=Zt&&!(xt&&Zt>Ut))return!1;var mt=_e.get(P);if(mt&&_e.get(F))return mt==F;var $r=-1,ri=!0,sr=H&s?new jr:void 0;for(_e.set(P,F),_e.set(F,P);++$r<Ut;){var Kr=P[$r],Vr=F[$r];if(re)var dn=xt?re(Vr,Kr,$r,F,P,_e):re(Kr,Vr,$r,P,F,_e);if(dn!==void 0){if(dn)continue;ri=!1;break}if(sr){if(!je(F,function(Wi,Ln){if(!Te(sr,Ln)&&(Kr===Wi||yt(Kr,Wi,H,re,_e)))return sr.push(Ln)})){ri=!1;break}}else if(!(Kr===Vr||yt(Kr,Vr,H,re,_e))){ri=!1;break}}return _e.delete(P),_e.delete(F),ri}function sE(P,F,H,re,yt,_e,xt){switch(H){case g:if(P.byteLength!=F.byteLength||P.byteOffset!=F.byteOffset)return!1;P=P.buffer,F=F.buffer;case O:return!(P.byteLength!=F.byteLength||!_e(new le(P),new le(F)));case l:case y:case R:return Op(+P,+F);case M:return P.name==F.name&&P.message==F.message;case k:case G:return P==F+"";case D:var Ut=Fe;case j:var Zt=re&n;if(Ut||(Ut=he),P.size!=F.size&&!Zt)return!1;var mt=xt.get(P);if(mt)return mt==F;re|=s,xt.set(P,F);var $r=Ap(Ut(P),Ut(F),re,yt,_e,xt);return xt.delete(P),$r;case K:if(We)return We.call(P)==We.call(F)}return!1}function oE(P,F,H,re,yt,_e){var xt=H&n,Ut=Dp(P),Zt=Ut.length,mt=Dp(F),$r=mt.length;if(Zt!=$r&&!xt)return!1;for(var ri=Zt;ri--;){var sr=Ut[ri];if(!(xt?sr in F:ne.call(F,sr)))return!1}var Kr=_e.get(P);if(Kr&&_e.get(F))return Kr==F;var Vr=!0;_e.set(P,F),_e.set(F,P);for(var dn=xt;++ri<Zt;){sr=Ut[ri];var Wi=P[sr],Ln=F[sr];if(re)var Tp=xt?re(Ln,Wi,sr,F,P,_e):re(Wi,Ln,sr,P,F,_e);if(!(Tp===void 0?Wi===Ln||yt(Wi,Ln,H,re,_e):Tp)){Vr=!1;break}dn||(dn=sr=="constructor")}if(Vr&&!dn){var Ma=P.constructor,Ia=F.constructor;Ma!=Ia&&"constructor"in P&&"constructor"in F&&!(typeof Ma=="function"&&Ma instanceof Ma&&typeof Ia=="function"&&Ia instanceof Ia)&&(Vr=!1)}return _e.delete(P),_e.delete(F),Vr}function Dp(P){return eE(P,vE,fE)}function Ea(P,F){var H=P.__data__;return hE(F)?H[typeof F=="string"?"string":"hash"]:H.map}function ys(P,F){var H=fe(P,F);return rE(H)?H:void 0}function aE(P){var F=ne.call(P,oe),H=P[oe];try{P[oe]=void 0;var re=!0}catch{}var yt=Ye.call(P);return re&&(F?P[oe]=H:delete P[oe]),yt}var fE=Qe?function(P){return P==null?[]:(P=Object(P),te(Qe(P),function(F){return Xe.call(P,F)}))}:yE,un=ho;(Ke&&un(new Ke(new ArrayBuffer(1)))!=g||Re&&un(new Re)!=D||de&&un(de.resolve())!=C||Ve&&un(new Ve)!=j||He&&un(new He)!=ie)&&(un=function(P){var F=ho(P),H=F==N?P.constructor:void 0,re=H?Bn(H):"";if(re)switch(re){case it:return g;case nt:return D;case ve:return C;case st:return j;case ot:return ie}return F});function cE(P,F){return F=F??o,!!F&&(typeof P=="number"||U.test(P))&&P>-1&&P%1==0&&P<F}function hE(P){var F=typeof P;return F=="string"||F=="number"||F=="symbol"||F=="boolean"?P!=="__proto__":P===null}function uE(P){return!!Je&&Je in P}function dE(P){var F=P&&P.constructor,H=typeof F=="function"&&F.prototype||ae;return P===H}function lE(P){return Ye.call(P)}function Bn(P){if(P!=null){try{return qe.call(P)}catch{}try{return P+""}catch{}}return""}function Op(P,F){return P===F||P!==P&&F!==F}var pE=Mp(function(){return arguments}())?Mp:function(P){return uo(P)&&ne.call(P,"callee")&&!Xe.call(P,"callee")},Sa=Array.isArray;function gE(P){return P!=null&&$p(P.length)&&!Pp(P)}var Gc=rt||mE;function bE(P,F){return Ip(P,F)}function Pp(P){if(!Rp(P))return!1;var F=ho(P);return F==I||F==S||F==h||F==L}function $p(P){return typeof P=="number"&&P>-1&&P%1==0&&P<=o}function Rp(P){var F=typeof P;return P!=null&&(F=="object"||F=="function")}function uo(P){return P!=null&&typeof P=="object"}var Np=ee?Ne(ee):iE;function vE(P){return gE(P)?Qx(P):nE(P)}function yE(){return[]}function mE(){return!1}t.exports=bE})(Ic,Ic.exports);var u9=Ic.exports;const N0="wc",T0=2,va="core",vi=`${N0}@2:${va}:`,d9={name:va,logger:"error"},l9={database:":memory:"},p9="crypto",F0="client_ed25519_seed",g9=Z.ONE_DAY,b9="keychain",v9="0.3",y9="messages",m9="0.3",C0=Z.SIX_HOURS,w9="publisher",B0="irn",_9="error",L0="wss://relay.walletconnect.org",x9="relayer",Bt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},E9="_subscription",zr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},S9=.1,Ac="2.18.1",gt={link_mode:"link_mode",relay:"relay"},M9="0.3",I9="WALLETCONNECT_CLIENT_ID",q0="WALLETCONNECT_LINK_MODE_APPS",Pr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},A9="subscription",D9="0.3",O9=Z.FIVE_SECONDS*1e3,P9="pairing",$9="0.3",ro={wc_pairingDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Z.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:0},res:{ttl:Z.ONE_DAY,prompt:!1,tag:0}}},Nn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Qr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},R9="history",N9="0.3",T9="expirer",kr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},F9="0.3",C9="verify-api",B9="https://verify.walletconnect.com",U0="https://verify.walletconnect.org",io=U0,L9=`${io}/v3`,q9=[B9,U0],U9="echo",z9="https://echo.walletconnect.com",yi={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Ci={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ei={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Tn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Fn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},no={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},k9=.1,j9="event-client",K9=86400,V9="https://pulse.walletconnect.org/batch";function H9(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var D=0,R=0,$=0,N=S.length;$!==N&&S[$]===0;)$++,D++;for(var C=(N-$)*l+1>>>0,L=new Uint8Array(C);$!==N;){for(var k=S[$],j=0,G=C-1;(k!==0||j<R)&&G!==-1;G--,j++)k+=256*L[G]>>>0,L[G]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");R=j,$++}for(var K=C-R;K!==C&&L[K]===0;)K++;for(var V=c.repeat(D);K<C;++K)V+=t.charAt(L[K]);return V}function M(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var D=0;if(S[D]!==" "){for(var R=0,$=0;S[D]===c;)R++,D++;for(var N=(S.length-D)*h+1>>>0,C=new Uint8Array(N);S[D];){var L=r[S.charCodeAt(D)];if(L===255)return;for(var k=0,j=N-1;(L!==0||k<$)&&j!==-1;j--,k++)L+=a*C[j]>>>0,C[j]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");$=k,D++}if(S[D]!==" "){for(var G=N-$;G!==N&&C[G]===0;)G++;for(var K=new Uint8Array(R+(N-G)),V=R;G!==N;)K[V++]=C[G++];return K}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:M,decode:I}}var W9=H9,G9=W9;const z0=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},J9=t=>new TextEncoder().encode(t),Y9=t=>new TextDecoder().decode(t);class Z9{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class X9{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return k0(this,e)}}class Q9{constructor(e){this.decoders=e}or(e){return k0(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const k0=(t,e)=>new Q9({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class e7{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Z9(e,r,i),this.decoder=new X9(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ya=({name:t,prefix:e,encode:r,decode:i})=>new e7(t,e,r,i),so=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=G9(r,e);return ya({prefix:t,name:e,encode:i,decode:s=>z0(n(s))})},t7=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let l=0;l<s;++l){const y=n[t[l]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|y,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},r7=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Gt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>ya({prefix:e,name:t,encode(n){return r7(n,i,r)},decode(n){return t7(n,i,r,t)}}),i7=ya({prefix:"\0",name:"identity",encode:t=>Y9(t),decode:t=>J9(t)});var n7=Object.freeze({__proto__:null,identity:i7});const s7=Gt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var o7=Object.freeze({__proto__:null,base2:s7});const a7=Gt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var f7=Object.freeze({__proto__:null,base8:a7});const c7=so({prefix:"9",name:"base10",alphabet:"0123456789"});var h7=Object.freeze({__proto__:null,base10:c7});const u7=Gt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),d7=Gt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var l7=Object.freeze({__proto__:null,base16:u7,base16upper:d7});const p7=Gt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),g7=Gt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),b7=Gt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),v7=Gt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),y7=Gt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),m7=Gt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),w7=Gt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_7=Gt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),x7=Gt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var E7=Object.freeze({__proto__:null,base32:p7,base32upper:g7,base32pad:b7,base32padupper:v7,base32hex:y7,base32hexupper:m7,base32hexpad:w7,base32hexpadupper:_7,base32z:x7});const S7=so({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),M7=so({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var I7=Object.freeze({__proto__:null,base36:S7,base36upper:M7});const A7=so({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),D7=so({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var O7=Object.freeze({__proto__:null,base58btc:A7,base58flickr:D7});const P7=Gt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$7=Gt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),R7=Gt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),N7=Gt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var T7=Object.freeze({__proto__:null,base64:P7,base64pad:$7,base64url:R7,base64urlpad:N7});const j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),F7=j0.reduce((t,e,r)=>(t[r]=e,t),[]),C7=j0.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function B7(t){return t.reduce((e,r)=>(e+=F7[r],e),"")}function L7(t){const e=[];for(const r of t){const i=C7[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const q7=ya({prefix:"\u{1F680}",name:"base256emoji",encode:B7,decode:L7});var U7=Object.freeze({__proto__:null,base256emoji:q7}),z7=V0,K0=128,k7=127,j7=~k7,K7=Math.pow(2,31);function V0(t,e,r){e=e||[],r=r||0;for(var i=r;t>=K7;)e[r++]=t&255|K0,t/=128;for(;t&j7;)e[r++]=t&255|K0,t>>>=7;return e[r]=t|0,V0.bytes=r-i+1,e}var V7=Dc,H7=128,H0=127;function Dc(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Dc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&H0)<<n:(o&H0)*Math.pow(2,n),n+=7}while(o>=H7);return Dc.bytes=s-i,r}var W7=Math.pow(2,7),G7=Math.pow(2,14),J7=Math.pow(2,21),Y7=Math.pow(2,28),Z7=Math.pow(2,35),X7=Math.pow(2,42),Q7=Math.pow(2,49),e_=Math.pow(2,56),t_=Math.pow(2,63),r_=function(t){return t<W7?1:t<G7?2:t<J7?3:t<Y7?4:t<Z7?5:t<X7?6:t<Q7?7:t<e_?8:t<t_?9:10},i_={encode:z7,decode:V7,encodingLength:r_},W0=i_;const G0=(t,e,r=0)=>(W0.encode(t,e,r),e),J0=t=>W0.encodingLength(t),Oc=(t,e)=>{const r=e.byteLength,i=J0(t),n=i+J0(r),s=new Uint8Array(n+r);return G0(t,s,0),G0(r,s,i),s.set(e,n),new n_(t,r,e,s)};class n_{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Y0=({name:t,code:e,encode:r})=>new s_(t,e,r);class s_{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Oc(this.code,r):r.then(i=>Oc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Z0=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),o_=Y0({name:"sha2-256",code:18,encode:Z0("SHA-256")}),a_=Y0({name:"sha2-512",code:19,encode:Z0("SHA-512")});var f_=Object.freeze({__proto__:null,sha256:o_,sha512:a_});const X0=0,c_="identity",Q0=z0;var h_=Object.freeze({__proto__:null,identity:{code:X0,name:c_,encode:Q0,digest:t=>Oc(X0,Q0(t))}});new TextEncoder,new TextDecoder;const ep={...n7,...o7,...f7,...h7,...l7,...E7,...I7,...O7,...T7,...U7};({...f_,...h_});function u_(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function tp(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const rp=tp("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Pc=tp("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=u_(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),d_={utf8:rp,"utf-8":rp,hex:ep.base16,latin1:Pc,ascii:Pc,binary:Pc,...ep};function l_(t,e="utf8"){const r=d_[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var p_=Object.defineProperty,g_=(t,e,r)=>e in t?p_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mi=(t,e,r)=>g_(t,typeof e!="symbol"?e+"":e,r);class b_{constructor(e,r){this.core=e,this.logger=r,mi(this,"keychain",new Map),mi(this,"name",b9),mi(this,"version",v9),mi(this,"initialized",!1),mi(this,"storagePrefix",vi),mi(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),mi(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),mi(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),mi(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),mi(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=or(r,this.name)}get context(){return dr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ul(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?dl(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}var v_=Object.defineProperty,y_=(t,e,r)=>e in t?v_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jt=(t,e,r)=>y_(t,typeof e!="symbol"?e+"":e,r);class m_{constructor(e,r,i){this.core=e,this.logger=r,Jt(this,"name",p9),Jt(this,"keychain"),Jt(this,"randomSessionIdentifier",gc()),Jt(this,"initialized",!1),Jt(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Jt(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),Jt(this,"getClientId",async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Iu(n);return Mu(s.publicKey)}),Jt(this,"generateKeyPair",()=>{this.isInitialized();const n=M8();return this.setPrivateKey(n.publicKey,n.privateKey)}),Jt(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Iu(s),a=this.randomSessionIdentifier;return await Ty(a,n,g9,o)}),Jt(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=I8(a,s);return this.setSymKey(c,o)}),Jt(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||ua(n);return await this.keychain.set(o,n),o}),Jt(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),Jt(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),Jt(this,"encode",async(n,s,o)=>{this.isInitialized();const a=c0(o),c=vn(s);if(u0(a))return O8(c,o?.encoding);if(h0(a)){const M=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(M,I)}const h=this.getSymKey(n),{type:l,senderPublicKey:y}=a;return A8({type:l,symKey:h,message:c,senderPublicKey:y,encoding:o?.encoding})}),Jt(this,"decode",async(n,s,o)=>{this.isInitialized();const a=$8(s,o);if(u0(a)){const c=P8(s,o?.encoding);return kn(c)}if(h0(a)){const c=a.receiverPublicKey,h=a.senderPublicKey;n=await this.generateSharedKey(c,h)}try{const c=this.getSymKey(n),h=D8({symKey:c,encoded:s,encoding:o?.encoding});return kn(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Jt(this,"getPayloadType",(n,s=hn)=>{const o=Ys({encoded:n,encoding:s});return Pn(o.type)}),Jt(this,"getPayloadSenderPublicKey",(n,s=hn)=>{const o=Ys({encoded:n,encoding:s});return o.senderPublicKey?cr(o.senderPublicKey,rr):void 0}),this.core=e,this.logger=or(r,this.name),this.keychain=i||new b_(this.core,this.logger)}get context(){return dr(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(F0)}catch{e=gc(),await this.keychain.set(F0,e)}return l_(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}var w_=Object.defineProperty,__=(t,e,r)=>e in t?w_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wi=(t,e,r)=>__(t,typeof e!="symbol"?e+"":e,r);class x_ extends Ng{constructor(e,r){super(e,r),this.logger=e,this.core=r,wi(this,"messages",new Map),wi(this,"name",y9),wi(this,"version",m9),wi(this,"initialized",!1),wi(this,"storagePrefix",vi),wi(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),wi(this,"set",async(i,n)=>{this.isInitialized();const s=Ri(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s}),wi(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),wi(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=Ri(n);return typeof s[o]<"u"}),wi(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=or(e,this.name),this.core=r}get context(){return dr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ul(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?dl(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}var E_=Object.defineProperty,S_=Object.defineProperties,M_=Object.getOwnPropertyDescriptors,ip=Object.getOwnPropertySymbols,I_=Object.prototype.hasOwnProperty,A_=Object.prototype.propertyIsEnumerable,$c=(t,e,r)=>e in t?E_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ma=(t,e)=>{for(var r in e||(e={}))I_.call(e,r)&&$c(t,r,e[r]);if(ip)for(var r of ip(e))A_.call(e,r)&&$c(t,r,e[r]);return t},Rc=(t,e)=>S_(t,M_(e)),ti=(t,e,r)=>$c(t,typeof e!="symbol"?e+"":e,r);class D_ extends Tg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ti(this,"events",new Qt.exports.EventEmitter),ti(this,"name",w9),ti(this,"queue",new Map),ti(this,"publishTimeout",Z.toMiliseconds(Z.ONE_MINUTE)),ti(this,"initialPublishTimeout",Z.toMiliseconds(Z.ONE_SECOND*15)),ti(this,"needsTransportRestart",!1),ti(this,"publish",async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=s?.ttl||C0,c=da(s),h=s?.prompt||!1,l=s?.tag||0,y=s?.id||$n().toString(),M={topic:i,message:n,opts:{ttl:a,relay:c,prompt:h,tag:l,id:y,attestation:s?.attestation,tvf:s?.tvf}},I=`Failed to publish payload, please try again. id:${y} tag:${l}`;try{const S=new Promise(async D=>{const R=({id:N})=>{M.opts.id===N&&(this.removeRequestFromQueue(N),this.relayer.events.removeListener(Bt.publish,R),D(M))};this.relayer.events.on(Bt.publish,R);const $=sn(new Promise((N,C)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:h,tag:l,id:y,attestation:s?.attestation,tvf:s?.tvf}).then(N).catch(L=>{this.logger.warn(L,L?.message),C(L)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${y} tag:${l}`);try{await $,this.events.removeListener(Bt.publish,R)}catch(N){this.queue.set(y,Rc(ma({},M),{attempt:1})),this.logger.warn(N,N?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}}),await sn(S,this.publishTimeout,I)}catch(S){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(S),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw S}finally{this.queue.delete(y)}}),ti(this,"on",(i,n)=>{this.events.on(i,n)}),ti(this,"once",(i,n)=>{this.events.once(i,n)}),ti(this,"off",(i,n)=>{this.events.off(i,n)}),ti(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=or(r,this.name),this.registerEventListeners()}get context(){return dr(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=C0,prompt:h,tag:l,id:y,attestation:M,tvf:I}=e,S={method:Zs(da().protocol).publish,params:ma({topic:o,message:a,ttl:c,prompt:h,tag:l,attestation:M},I),id:y};hr((r=S.params)==null?void 0:r.prompt)&&((i=S.params)==null||delete i.prompt),hr((n=S.params)==null?void 0:n.tag)&&((s=S.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:S});const D=await this.relayer.request(S);return this.relayer.events.emit(Bt.publish,e),this.logger.debug("Successfully Published Payload"),D}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,Rc(ma({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Rc(ma({},e),{topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(zn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Bt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Bt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var O_=Object.defineProperty,P_=(t,e,r)=>e in t?O_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bs=(t,e,r)=>P_(t,typeof e!="symbol"?e+"":e,r);class $_{constructor(){bs(this,"map",new Map),bs(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),bs(this,"get",e=>this.map.get(e)||[]),bs(this,"exists",(e,r)=>this.get(e).includes(r)),bs(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)}),bs(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var R_=Object.defineProperty,N_=Object.defineProperties,T_=Object.getOwnPropertyDescriptors,np=Object.getOwnPropertySymbols,F_=Object.prototype.hasOwnProperty,C_=Object.prototype.propertyIsEnumerable,Nc=(t,e,r)=>e in t?R_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oo=(t,e)=>{for(var r in e||(e={}))F_.call(e,r)&&Nc(t,r,e[r]);if(np)for(var r of np(e))C_.call(e,r)&&Nc(t,r,e[r]);return t},Tc=(t,e)=>N_(t,T_(e)),ut=(t,e,r)=>Nc(t,typeof e!="symbol"?e+"":e,r);class B_ extends Bg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ut(this,"subscriptions",new Map),ut(this,"topicMap",new $_),ut(this,"events",new Qt.exports.EventEmitter),ut(this,"name",A9),ut(this,"version",D9),ut(this,"pending",new Map),ut(this,"cached",[]),ut(this,"initialized",!1),ut(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),ut(this,"pollingInterval",20),ut(this,"storagePrefix",vi),ut(this,"subscribeTimeout",Z.toMiliseconds(Z.ONE_MINUTE)),ut(this,"initialSubscribeTimeout",Z.toMiliseconds(Z.ONE_SECOND*15)),ut(this,"clientId"),ut(this,"batchSubscribeTopicsLimit",500),ut(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ut(this,"subscribe",async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=da(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}}),ut(this,"unsubscribe",async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),ut(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new Z.Watch;a.start(n);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(h=>h.topic===i))&&(clearInterval(c),a.stop(n),s(!0)),a.elapsed(n)>=O9&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),ut(this,"on",(i,n)=>{this.events.on(i,n)}),ut(this,"once",(i,n)=>{this.events.once(i,n)}),ut(this,"off",(i,n)=>{this.events.off(i,n)}),ut(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),ut(this,"start",async()=>{await this.onConnect()}),ut(this,"stop",async()=>{await this.onDisconnect()}),ut(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ut(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)}),ut(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(zn.pulse,async()=>{await this.checkPending()}),this.events.on(Pr.created,async i=>{const n=Pr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(Pr.deleted,async i=>{const n=Pr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=or(r,this.name),this.clientId=""}get context(){return dr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=da(i);await this.rpcUnsubscribe(e,r,n);const s=pt("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r,i){var n;i?.transportType===gt.relay&&await this.restartToComplete();const s={method:Zs(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(i?.transportType===gt.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(l=>this.logger.warn(l))},Z.toMiliseconds(Z.ONE_SECOND)),a;const c=new Promise(async l=>{const y=M=>{M.topic===e&&(this.events.removeListener(Pr.created,y),l(M.id))};this.events.on(Pr.created,y);try{const M=await sn(new Promise((I,S)=>{this.relayer.request(s).catch(D=>{this.logger.warn(D,D?.message),S(D)}).then(I)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Pr.created,y),l(M)}catch{}}),h=await sn(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!h&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return h?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Bt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Zs(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await sn(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Bt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Zs(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await sn(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Bt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Zs(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,Tc(oo({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,oo({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,oo({},r)),this.topicMap.set(r.topic,e),this.events.emit(Pr.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Pr.deleted,Tc(oo({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Pr.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(Pr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>Tc(oo({},r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await z6(Z.toMiliseconds(Z.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return Ri(e+await this.getClientId())}}var L_=Object.defineProperty,sp=Object.getOwnPropertySymbols,q_=Object.prototype.hasOwnProperty,U_=Object.prototype.propertyIsEnumerable,Fc=(t,e,r)=>e in t?L_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,op=(t,e)=>{for(var r in e||(e={}))q_.call(e,r)&&Fc(t,r,e[r]);if(sp)for(var r of sp(e))U_.call(e,r)&&Fc(t,r,e[r]);return t},Ge=(t,e,r)=>Fc(t,typeof e!="symbol"?e+"":e,r);class z_ extends Fg{constructor(e){super(e),Ge(this,"protocol","wc"),Ge(this,"version",2),Ge(this,"core"),Ge(this,"logger"),Ge(this,"events",new Qt.exports.EventEmitter),Ge(this,"provider"),Ge(this,"messages"),Ge(this,"subscriber"),Ge(this,"publisher"),Ge(this,"name",x9),Ge(this,"transportExplicitlyClosed",!1),Ge(this,"initialized",!1),Ge(this,"connectionAttemptInProgress",!1),Ge(this,"relayUrl"),Ge(this,"projectId"),Ge(this,"packageName"),Ge(this,"bundleId"),Ge(this,"hasExperiencedNetworkDisruption",!1),Ge(this,"pingTimeout"),Ge(this,"heartBeatTimeout",Z.toMiliseconds(Z.THIRTY_SECONDS+Z.FIVE_SECONDS)),Ge(this,"reconnectTimeout"),Ge(this,"connectPromise"),Ge(this,"requestsInFlight",[]),Ge(this,"connectTimeout",Z.toMiliseconds(Z.ONE_SECOND*15)),Ge(this,"request",async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||$n().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=r.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}}),Ge(this,"resetPingTimeout",()=>{if(ia())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}}),Ge(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),Ge(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Bt.connect)}),Ge(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()}),Ge(this,"onProviderErrorHandler",r=>{this.logger.fatal(r,`Fatal socket error: ${r?.message}`),this.events.emit(Bt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Ge(this,"registerProviderListeners",()=>{this.provider.on(zr.payload,this.onPayloadHandler),this.provider.on(zr.connect,this.onConnectHandler),this.provider.on(zr.disconnect,this.onDisconnectHandler),this.provider.on(zr.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?or(e.logger,this.name):xi(ja({level:e.logger||_9})),this.messages=new x_(this.logger,e.core),this.subscriber=new B_(this,this.logger),this.publisher=new D_(this,this.logger),this.relayUrl=e?.relayUrl||L0,this.projectId=e.projectId,M6()?this.packageName=fl():I6()&&(this.bundleId=fl()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return dr(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:gt.relay})}async subscribe(e,r){var i,n,s;this.isInitialized(),(!(r!=null&&r.transportType)||r?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=r?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=r?.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const h=l=>{l.topic===e&&(this.subscriber.off(Pr.created,h),c())};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(Pr.created,h)}),new Promise(async(l,y)=>{a=await this.subscriber.subscribe(e,op({internal:{throwOnFailedPublish:o}},r)).catch(M=>{o&&y(M)})||a,l()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await sn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await _0())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=Pt(Z.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Bt.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(zr.disconnect,s),await sn(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(zr.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(zr.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(zr.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,Z.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(ia())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new o9(new h9(P6({sdkVersion:Ac,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.warn(`Ignoring message for non-subscribed topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Mc(e)){if(!e.method.endsWith(E9))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:gt.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(op({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else ba(e)&&this.events.emit(Bt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Bt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Ec(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(zr.payload,this.onPayloadHandler),this.provider.off(zr.connect,this.onConnectHandler),this.provider.off(zr.disconnect,this.onDisconnectHandler),this.provider.off(zr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await _0();y5(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(Bt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e?.message))},Z.toMiliseconds(S9))))}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var k_=Object.defineProperty,ap=Object.getOwnPropertySymbols,j_=Object.prototype.hasOwnProperty,K_=Object.prototype.propertyIsEnumerable,Cc=(t,e,r)=>e in t?k_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fp=(t,e)=>{for(var r in e||(e={}))j_.call(e,r)&&Cc(t,r,e[r]);if(ap)for(var r of ap(e))K_.call(e,r)&&Cc(t,r,e[r]);return t},yr=(t,e,r)=>Cc(t,typeof e!="symbol"?e+"":e,r);class Cn extends Cg{constructor(e,r,i,n=vi,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,yr(this,"map",new Map),yr(this,"version",M9),yr(this,"cached",[]),yr(this,"initialized",!1),yr(this,"getKey"),yr(this,"storagePrefix",vi),yr(this,"recentlyDeleted",[]),yr(this,"recentlyDeletedLimit",200),yr(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!hr(o)?this.map.set(this.getKey(o),o):J8(o)?this.map.set(o.id,o):Y8(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),yr(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),yr(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),yr(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>u9(a[c],o[c]))):this.values)),yr(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=fp(fp({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),yr(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=or(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return dr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}var V_=Object.defineProperty,H_=(t,e,r)=>e in t?V_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Oe=(t,e,r)=>H_(t,typeof e!="symbol"?e+"":e,r);class W_{constructor(e,r){this.core=e,this.logger=r,Oe(this,"name",P9),Oe(this,"version",$9),Oe(this,"events",new Qt.exports),Oe(this,"pairings"),Oe(this,"initialized",!1),Oe(this,"storagePrefix",vi),Oe(this,"ignoredPayloadTypes",[$i]),Oe(this,"registeredMethods",[]),Oe(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),Oe(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),Oe(this,"create",async i=>{this.isInitialized();const n=gc(),s=await this.core.crypto.setSymKey(n),o=Pt(Z.FIVE_MINUTES),a={protocol:B0},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},h=l0({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Nn.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}}),Oe(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[yi.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:h}=d0(i.uri);n.props.properties.topic=s,n.addTrace(yi.pairing_uri_validation_success),n.addTrace(yi.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),n.addTrace(yi.existing_pairing),l.active)throw n.setError(Ci.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(yi.pairing_not_expired)}const y=c||Pt(Z.FIVE_MINUTES),M={topic:s,relay:a,expiry:y,active:!1,methods:h};this.core.expirer.set(s,y),await this.pairings.set(s,M),n.addTrace(yi.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Nn.create,M),n.addTrace(yi.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(yi.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Ci.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(Ci.subscribe_pairing_topic_failure),I}return n.addTrace(yi.subscribe_pairing_topic_success),M}),Oe(this,"activate",async({topic:i})=>{this.isInitialized();const n=Pt(Z.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),Oe(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Dn();this.events.once(Me("pairing_ping",s),({error:h})=>{h?c(h):a()}),await o()}}),Oe(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),Oe(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),Oe(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),Oe(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",pt("USER_DISCONNECTED")),await this.deletePairing(n))}),Oe(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return l0({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),Oe(this,"sendRequest",async(i,n,s)=>{const o=Rn(n,s),a=await this.core.crypto.encode(i,o),c=ro[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),Oe(this,"sendResult",async(i,n,s)=>{const o=Ec(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),h=ro[c.request.method].res;await this.core.relayer.publish(n,a,h),await this.core.history.resolve(o)}),Oe(this,"sendError",async(i,n,s)=>{const o=Sc(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),h=ro[c.request.method]?ro[c.request.method].res:ro.unregistered_method.res;await this.core.relayer.publish(n,a,h),await this.core.history.resolve(o)}),Oe(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,pt("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),Oe(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>on(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),Oe(this,"onRelayEventRequest",i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}}),Oe(this,"onRelayEventResponse",async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}}),Oe(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Nn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),Oe(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{bi(n)?this.events.emit(Me("pairing_ping",s),{}):Ur(n)&&this.events.emit(Me("pairing_ping",s),{error:n.error})},500)}),Oe(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Nn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),Oe(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=pt("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}}),Oe(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(pt("WC_METHOD_UNSUPPORTED",i))}),Oe(this,"isValidPair",(i,n)=>{var s;if(!vr(i)){const{message:a}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Ci.malformed_pairing_uri),new Error(a)}if(!G8(i.uri)){const{message:a}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Ci.malformed_pairing_uri),new Error(a)}const o=d0(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Ci.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Ci.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&Z.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(Ci.pairing_expired);const{message:a}=Q("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),Oe(this,"isValidPing",async i=>{if(!vr(i)){const{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),Oe(this,"isValidDisconnect",async i=>{if(!vr(i)){const{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),Oe(this,"isValidPairingTopic",async i=>{if(!Mt(i,!1)){const{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(on(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=or(r,this.name),this.pairings=new Cn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return dr(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Bt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===gt.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{Mc(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):ba(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(kr.expired,async e=>{const{topic:r}=pl(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Nn.expire,{topic:r}))})}}var G_=Object.defineProperty,J_=(t,e,r)=>e in t?G_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yt=(t,e,r)=>J_(t,typeof e!="symbol"?e+"":e,r);class Y_ extends Rg{constructor(e,r){super(e,r),this.core=e,this.logger=r,Yt(this,"records",new Map),Yt(this,"events",new Qt.exports.EventEmitter),Yt(this,"name",R9),Yt(this,"version",N9),Yt(this,"cached",[]),Yt(this,"initialized",!1),Yt(this,"storagePrefix",vi),Yt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Yt(this,"set",(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:Pt(Z.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Qr.created,o)}),Yt(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Ur(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Qr.updated,n))}),Yt(this,"get",async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n))),Yt(this,"delete",(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Qr.deleted,s)}}),this.persist()}),Yt(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),Yt(this,"on",(i,n)=>{this.events.on(i,n)}),Yt(this,"once",(i,n)=>{this.events.once(i,n)}),Yt(this,"off",(i,n)=>{this.events.off(i,n)}),Yt(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=or(r,this.name)}get context(){return dr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:Rn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Qr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Qr.created,e=>{const r=Qr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Qr.updated,e=>{const r=Qr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Qr.deleted,e=>{const r=Qr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(zn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{Z.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Qr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Z_=Object.defineProperty,X_=(t,e,r)=>e in t?Z_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ir=(t,e,r)=>X_(t,typeof e!="symbol"?e+"":e,r);class Q_ extends Lg{constructor(e,r){super(e,r),this.core=e,this.logger=r,ir(this,"expirations",new Map),ir(this,"events",new Qt.exports.EventEmitter),ir(this,"name",T9),ir(this,"version",F9),ir(this,"cached",[]),ir(this,"initialized",!1),ir(this,"storagePrefix",vi),ir(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),ir(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),ir(this,"set",(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(kr.created,{target:s,expiration:o})}),ir(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),ir(this,"del",i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(kr.deleted,{target:n,expiration:s})}}),ir(this,"on",(i,n)=>{this.events.on(i,n)}),ir(this,"once",(i,n)=>{this.events.once(i,n)}),ir(this,"off",(i,n)=>{this.events.off(i,n)}),ir(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=or(r,this.name)}get context(){return dr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return $6(e);if(typeof e=="number")return R6(e);const{message:r}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(kr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;Z.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(kr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(zn.pulse,()=>this.checkExpirations()),this.events.on(kr.created,e=>{const r=kr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(kr.expired,e=>{const r=kr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(kr.deleted,e=>{const r=kr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}}var ex=Object.defineProperty,tx=(t,e,r)=>e in t?ex(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,It=(t,e,r)=>tx(t,typeof e!="symbol"?e+"":e,r);class rx extends qg{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,It(this,"name",C9),It(this,"abortController"),It(this,"isDevEnv"),It(this,"verifyUrlV3",L9),It(this,"storagePrefix",vi),It(this,"version",T0),It(this,"publicKey"),It(this,"fetchPromise"),It(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&Z.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),It(this,"register",async n=>{if(!Us()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const h=Ds(),l=this.startAbortTimer(Z.ONE_SECOND*5),y=await new Promise((M,I)=>{const S=()=>{window.removeEventListener("message",R),h.body.removeChild(D),I("attestation aborted")};this.abortController.signal.addEventListener("abort",S);const D=h.createElement("iframe");D.src=c,D.style.display="none",D.addEventListener("error",S,{signal:this.abortController.signal});const R=$=>{if($.data&&typeof $.data=="string")try{const N=JSON.parse($.data);if(N.type==="verify_attestation"){if(uf(N.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(D),this.abortController.signal.removeEventListener("abort",S),window.removeEventListener("message",R),M(N.attestation===null?"":N.attestation)}}catch(N){this.logger.warn(N)}};h.body.appendChild(D),window.addEventListener("message",R,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(h){this.logger.warn(h)}return""}),It(this,"resolve",async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(uf(s).payload.id!==a)return;const h=await this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),It(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(Z.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),It(this,"getVerifyUrl",n=>{let s=n||io;return q9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${io}`),s=io),s}),It(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(Z.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}}),It(this,"persistPublicKey",async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n}),It(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),It(this,"isValidJwtAttestation",async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),It(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),It(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n}),It(this,"validateAttestation",(n,s)=>{const o=F8(n,s.publicKey),a={hasExpired:Z.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=or(r,this.name),this.abortController=new AbortController,this.isDevEnv=Yf(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return dr(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),Z.toMiliseconds(e))}}var ix=Object.defineProperty,nx=(t,e,r)=>e in t?ix(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cp=(t,e,r)=>nx(t,typeof e!="symbol"?e+"":e,r);class sx extends Ug{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,cp(this,"context",U9),cp(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${z9}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})}),this.logger=or(r,this.context)}}var ox=Object.defineProperty,hp=Object.getOwnPropertySymbols,ax=Object.prototype.hasOwnProperty,fx=Object.prototype.propertyIsEnumerable,Bc=(t,e,r)=>e in t?ox(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ao=(t,e)=>{for(var r in e||(e={}))ax.call(e,r)&&Bc(t,r,e[r]);if(hp)for(var r of hp(e))fx.call(e,r)&&Bc(t,r,e[r]);return t},Lt=(t,e,r)=>Bc(t,typeof e!="symbol"?e+"":e,r);class cx extends zg{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,Lt(this,"context",j9),Lt(this,"storagePrefix",vi),Lt(this,"storageVersion",k9),Lt(this,"events",new Map),Lt(this,"shouldPersist",!1),Lt(this,"init",async()=>{if(!Yf())try{const n={eventId:bl(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:hl(this.core.relayer.protocol,this.core.relayer.version,Ac)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),Lt(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,h=bl(),l=this.core.projectId||"",y=Date.now(),M=ao({eventId:h,timestamp:y,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,M),this.shouldPersist=!0),M}),Lt(this,"getEvent",n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return ao(ao({},a),this.setMethods(a.eventId))}),Lt(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),Lt(this,"setEventListeners",()=>{this.core.heartbeat.on(zn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{Z.fromMiliseconds(Date.now())-Z.fromMiliseconds(n.timestamp)>K9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),Lt(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),Lt(this,"addTrace",(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)}),Lt(this,"setError",(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)}),Lt(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Lt(this,"restore",async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,ao(ao({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),Lt(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}}),Lt(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${V9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ac}${s}`,{method:"POST",body:JSON.stringify(n)})}),Lt(this,"getAppDomain",()=>cl().url),this.logger=or(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var hx=Object.defineProperty,up=Object.getOwnPropertySymbols,ux=Object.prototype.hasOwnProperty,dx=Object.prototype.propertyIsEnumerable,Lc=(t,e,r)=>e in t?hx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dp=(t,e)=>{for(var r in e||(e={}))ux.call(e,r)&&Lc(t,r,e[r]);if(up)for(var r of up(e))dx.call(e,r)&&Lc(t,r,e[r]);return t},bt=(t,e,r)=>Lc(t,typeof e!="symbol"?e+"":e,r);class qc extends Dg{constructor(e){var r;super(e),bt(this,"protocol",N0),bt(this,"version",T0),bt(this,"name",va),bt(this,"relayUrl"),bt(this,"projectId"),bt(this,"customStoragePrefix"),bt(this,"events",new Qt.exports.EventEmitter),bt(this,"logger"),bt(this,"heartbeat"),bt(this,"relayer"),bt(this,"crypto"),bt(this,"storage"),bt(this,"history"),bt(this,"expirer"),bt(this,"pairing"),bt(this,"verify"),bt(this,"echoClient"),bt(this,"linkModeSupportedApps"),bt(this,"eventClient"),bt(this,"initialized",!1),bt(this,"logChunkController"),bt(this,"on",(o,a)=>this.events.on(o,a)),bt(this,"once",(o,a)=>this.events.once(o,a)),bt(this,"off",(o,a)=>this.events.off(o,a)),bt(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),bt(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const h={topic:o,message:a,publishedAt:Date.now(),transportType:gt.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||L0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=ja({level:typeof e?.logger=="string"&&e.logger?e.logger:d9.logger,name:va}),{logger:n,chunkLoggerController:s}=Mg({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=or(n,this.name),this.heartbeat=new Ca,this.crypto=new m_(this,this.logger,e?.keychain),this.history=new Y_(this,this.logger),this.expirer=new Q_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Z1(dp(dp({},l9),e?.storageOptions)),this.relayer=new z_({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new W_(this,this.logger),this.verify=new rx(this,this.logger,this.storage),this.echoClient=new sx(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new cx(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new qc(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(I9,i),r}get context(){return dr(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(q0,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(q0)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const Uc=qc,lp="wc",pp=2,gp="client",zc=`${lp}@${pp}:${gp}:`,kc={name:gp,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},bp="WALLETCONNECT_DEEPLINK_CHOICE",lx="proposal",px="Proposal expired",gx="session",vs=Z.SEVEN_DAYS,bx="engine",qt={wc_sessionPropose:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Z.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Z.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Z.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Z.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Z.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Z.FIVE_MINUTES,prompt:!1,tag:1119}}},jc={min:Z.FIVE_MINUTES,max:Z.SEVEN_DAYS},_i={idle:"IDLE",active:"ACTIVE"},vp={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},vx="request",yx=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],mx="wc",wx="auth",_x="authKeys",xx="pairingTopics",Ex="requests",wa=`${mx}@${1.5}:${wx}:`,_a=`${wa}:PUB_KEY`;var Sx=Object.defineProperty,Mx=Object.defineProperties,Ix=Object.getOwnPropertyDescriptors,yp=Object.getOwnPropertySymbols,Ax=Object.prototype.hasOwnProperty,Dx=Object.prototype.propertyIsEnumerable,Kc=(t,e,r)=>e in t?Sx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vt=(t,e)=>{for(var r in e||(e={}))Ax.call(e,r)&&Kc(t,r,e[r]);if(yp)for(var r of yp(e))Dx.call(e,r)&&Kc(t,r,e[r]);return t},mr=(t,e)=>Mx(t,Ix(e)),J=(t,e,r)=>Kc(t,typeof e!="symbol"?e+"":e,r);class Ox extends Vg{constructor(e){super(e),J(this,"name",bx),J(this,"events",new Qt.exports),J(this,"initialized",!1),J(this,"requestQueue",{state:_i.idle,queue:[]}),J(this,"sessionRequestQueue",{state:_i.idle,queue:[]}),J(this,"requestQueueDelay",Z.ONE_SECOND),J(this,"expectedPairingMethodMap",new Map),J(this,"recentlyDeletedMap",new Map),J(this,"recentlyDeletedLimit",200),J(this,"relayMessageCache",[]),J(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(qt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},Z.toMiliseconds(this.requestQueueDelay)))}),J(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=mr(vt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let h=n,l,y=!1;try{if(h){const L=this.client.core.pairing.pairings.get(h);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),y=L.active}}catch(L){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),L}if(!h||!y){const{topic:L,uri:k}=await this.client.core.pairing.create();h=L,l=k}if(!h){const{message:L}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(L)}const M=await this.client.core.crypto.generateKeyPair(),I=qt.wc_sessionPropose.req.ttl||Z.FIVE_MINUTES,S=Pt(I),D=vt({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:B0}],proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:S,pairingTopic:h},a&&{sessionProperties:a}),{reject:R,resolve:$,done:N}=Dn(I,px);this.events.once(Me("session_connect"),async({error:L,session:k})=>{if(L)R(L);else if(k){k.self.publicKey=M;const j=mr(vt({},k),{pairingTopic:D.pairingTopic,requiredNamespaces:D.requiredNamespaces,optionalNamespaces:D.optionalNamespaces,transportType:gt.relay});await this.client.session.set(k.topic,j),await this.setExpiry(k.topic,k.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:k.peer.metadata}),this.cleanupDuplicatePairings(j),$(j)}});const C=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:D,throwOnFailedPublish:!0});return await this.setProposal(C,vt({id:C},D)),{uri:l,approval:N}}),J(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}}),J(this,"approve",async r=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[ei.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(K){throw o.setError(Tn.no_internet_connection),K}try{await this.isValidProposalId(r?.id)}catch(K){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(Tn.proposal_not_found),K}try{await this.isValidApprove(r)}catch(K){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Tn.session_approve_namespace_validation_failure),K}const{id:a,relayProtocol:c,namespaces:h,sessionProperties:l,sessionConfig:y}=r,M=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:I,proposer:S,requiredNamespaces:D,optionalNamespaces:R}=M;let $=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});$||($=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ei.session_approve_started,properties:{topic:I,trace:[ei.session_approve_started,ei.session_namespaces_validation_success]}}));const N=await this.client.core.crypto.generateKeyPair(),C=S.publicKey,L=await this.client.core.crypto.generateSharedKey(N,C),k=vt(vt({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:N,metadata:this.client.metadata},expiry:Pt(vs)},l&&{sessionProperties:l}),y&&{sessionConfig:y}),j=gt.relay;$.addTrace(ei.subscribing_session_topic);try{await this.client.core.relayer.subscribe(L,{transportType:j})}catch(K){throw $.setError(Tn.subscribe_session_topic_failure),K}$.addTrace(ei.subscribe_session_topic_success);const G=mr(vt({},k),{topic:L,requiredNamespaces:D,optionalNamespaces:R,pairingTopic:I,acknowledged:!1,self:k.controller,peer:{publicKey:S.publicKey,metadata:S.metadata},controller:N,transportType:gt.relay});await this.client.session.set(L,G),$.addTrace(ei.store_session);try{$.addTrace(ei.publishing_session_settle),await this.sendRequest({topic:L,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0}).catch(K=>{throw $?.setError(Tn.session_settle_publish_failure),K}),$.addTrace(ei.session_settle_publish_success),$.addTrace(ei.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:c??"irn"},responderPublicKey:N},throwOnFailedPublish:!0}).catch(K=>{throw $?.setError(Tn.session_approve_publish_failure),K}),$.addTrace(ei.session_approve_publish_success)}catch(K){throw this.client.logger.error(K),this.client.session.delete(L,pt("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(L),K}return this.client.core.eventClient.deleteEvent({eventId:$.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:S.metadata}),await this.client.proposal.delete(a,pt("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(L,Pt(vs)),{topic:L,acknowledged:()=>Promise.resolve(this.client.session.get(L))}}),J(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:qt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,pt("USER_DISCONNECTED")))}),J(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=Dn(),c=Fi(),h=$n().toString(),l=this.client.session.get(i).namespaces;return this.events.once(Me("session_update",c),({error:y})=>{y?a(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:h}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:l}),a(y)}),{acknowledged:s}}),J(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,n=Fi(),{done:s,resolve:o,reject:a}=Dn();return this.events.once(Me("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,Pt(vs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),J(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch($){throw this.client.logger.error("request() -> isValidRequest() failed"),$}const{chainId:i,request:n,topic:s,expiry:o=qt.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===gt.relay&&await this.confirmOnlineStateOrThrow();const c=Fi(),h=$n().toString(),{done:l,resolve:y,reject:M}=Dn(o,"Request expired. Please try again.");this.events.once(Me("session_request",c),({error:$,result:N})=>{$?M($):y(N)});const I="wc_sessionRequest",S=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(S)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:s,method:I,params:{request:mr(vt({},n),{expiryTimestamp:Pt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:S}).catch($=>M($)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await l();const D={request:mr(vt({},n),{expiryTimestamp:Pt(o)}),chainId:i},R=this.shouldSetTVF(I,D);return await Promise.all([new Promise(async $=>{await this.sendRequest(vt({clientRpcId:c,relayRpcId:h,topic:s,method:I,params:D,expiry:o,throwOnFailedPublish:!0},R&&{tvf:this.getTVFParams(c,D)})).catch(N=>M(N)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),$()}),new Promise(async $=>{var N;if(!((N=a.sessionConfig)!=null&&N.disableDeepLink)){const C=await B6(this.client.core.storage,bp);await T6({id:c,topic:s,wcDeepLink:C})}$()}),l()]).then($=>$[2])}),J(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n,o=this.client.session.get(i);o.transportType===gt.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);bi(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Ur(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)}),J(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=Fi(),s=$n().toString(),{done:o,resolve:a,reject:c}=Dn();this.events.once(Me("session_ping",n),({error:h})=>{h?c(h):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),J(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=$n().toString(),a=Fi();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),J(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:pt("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),J(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>H8(i,r)))),J(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),J(this,"authenticate",async(r,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(r);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?gt.link_mode:gt.relay;o===gt.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:h,domain:l,nonce:y,type:M,exp:I,nbf:S,methods:D=[],expiry:R}=r,$=[...r.resources||[]],{topic:N,uri:C}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:N,uri:C}});const L=await this.client.core.crypto.generateKeyPair(),k=ua(L);if(await Promise.all([this.client.auth.authKeys.set(_a,{responseTopic:k,publicKey:L}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:N})]),await this.client.core.relayer.subscribe(k,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${N}`),D.length>0){const{namespace:E}=ra(a[0]);let w=I4(E,"request",D);aa($)&&(w=D4(w,$.pop())),$.push(w)}const j=R&&R>qt.wc_sessionAuthenticate.req.ttl?R:qt.wc_sessionAuthenticate.req.ttl,G={authPayload:{type:M??"caip122",chains:a,statement:c,aud:h,domain:l,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:S,resources:$},requester:{publicKey:L,metadata:this.client.metadata},expiryTimestamp:Pt(j)},K={eip155:{chains:a,methods:[...new Set(["personal_sign",...D])],events:["chainChanged","accountsChanged"]}},V={requiredNamespaces:{},optionalNamespaces:K,relays:[{protocol:"irn"}],pairingTopic:N,proposer:{publicKey:L,metadata:this.client.metadata},expiryTimestamp:Pt(qt.wc_sessionPropose.req.ttl)},{done:ie,resolve:O,reject:g}=Dn(j,"Request expired"),p=async({error:E,session:w})=>{if(this.events.off(Me("session_request",u),f),E)g(E);else if(w){w.self.publicKey=L,await this.client.session.set(w.topic,w),await this.setExpiry(w.topic,w.expiry),N&&await this.client.core.pairing.updateMetadata({topic:N,metadata:w.peer.metadata});const d=this.client.session.get(w.topic);await this.deleteProposal(b),O({session:d})}},f=async E=>{var w,d,m;if(await this.deletePendingAuthRequest(u,{message:"fulfilled",code:0}),E.error){const q=pt("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===q.code?void 0:(this.events.off(Me("session_connect"),p),g(E.error.message))}await this.deleteProposal(b),this.events.off(Me("session_connect"),p);const{cacaos:v,responder:A}=E.result,U=[],x=[];for(const q of v){await $l({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),g(pt("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:z}=q,Y=aa(z.resources),X=[rc(z.iss)],W=oa(z.iss);if(Y){const se=Tl(Y),ee=Fl(Y);U.push(...se),X.push(...ee)}for(const se of X)x.push(`${se}:${W}`)}const T=await this.client.core.crypto.generateSharedKey(L,A.publicKey);let B;U.length>0&&(B={topic:T,acknowledged:!0,self:{publicKey:L,metadata:this.client.metadata},peer:A,controller:A.publicKey,expiry:Pt(vs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:N,namespaces:p0([...new Set(U)],[...new Set(x)]),transportType:o},await this.client.core.relayer.subscribe(T,{transportType:o}),await this.client.session.set(T,B),N&&await this.client.core.pairing.updateMetadata({topic:N,metadata:A.metadata}),B=this.client.session.get(T)),(w=this.client.metadata.redirect)!=null&&w.linkMode&&(d=A.metadata.redirect)!=null&&d.linkMode&&(m=A.metadata.redirect)!=null&&m.universal&&i&&(this.client.core.addLinkModeSupportedApp(A.metadata.redirect.universal),this.client.session.update(T,{transportType:gt.link_mode})),O({auths:v,session:B})},u=Fi(),b=Fi();this.events.once(Me("session_connect"),p),this.events.once(Me("session_request",u),f);let _;try{if(s){const E=Rn("wc_sessionAuthenticate",G,u);this.client.core.history.set(N,E);const w=await this.client.core.crypto.encode("",E,{type:Gs,encoding:Hs});_=la(i,N,w)}else await Promise.all([this.sendRequest({topic:N,method:"wc_sessionAuthenticate",params:G,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:u}),this.sendRequest({topic:N,method:"wc_sessionPropose",params:V,expiry:qt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(E){throw this.events.off(Me("session_connect"),p),this.events.off(Me("session_request",u),f),E}return await this.setProposal(b,vt({id:b},V)),await this.setAuthRequest(u,{request:mr(vt({},G),{verifyContext:{}}),pairingTopic:N,transportType:o}),{uri:_??C,response:ie}}),J(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Fn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(R){throw s.setError(no.no_internet_connection),R}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(no.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||gt.relay;a===gt.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=ua(c),y={type:$i,receiverPublicKey:c,senderPublicKey:h},M=[],I=[];for(const R of n){if(!await $l({cacao:R,projectId:this.client.core.projectId})){s.setError(no.invalid_cacao);const k=pt("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:k,encodeOpts:y}),new Error(k.message)}s.addTrace(Fn.cacaos_verified);const{p:$}=R,N=aa($.resources),C=[rc($.iss)],L=oa($.iss);if(N){const k=Tl(N),j=Fl(N);M.push(...k),C.push(...j)}for(const k of C)I.push(`${k}:${L}`)}const S=await this.client.core.crypto.generateSharedKey(h,c);s.addTrace(Fn.create_authenticated_session_topic);let D;if(M?.length>0){D={topic:S,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:Pt(vs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:p0([...new Set(M)],[...new Set(I)]),transportType:a},s.addTrace(Fn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:a})}catch(R){throw s.setError(no.subscribe_authenticated_session_topic_failure),R}s.addTrace(Fn.subscribe_authenticated_session_topic_success),await this.client.session.set(S,D),s.addTrace(Fn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Fn.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(R){throw s.setError(no.authenticated_session_approve_publish_failure),R}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:D}}),J(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===gt.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=ua(o),h={type:$i,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:h,rpcOpts:qt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,pt("USER_DISCONNECTED"))}),J(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return Rl(i,n)}),J(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),J(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),J(this,"deleteSession",async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,pt("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(bp).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,pt("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=_i.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),J(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Tn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,pt("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),J(this,"deletePendingSessionRequest",async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=_i.idle,this.client.events.emit("session_request_expire",{id:r}))}),J(this,"deletePendingAuthRequest",async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])}),J(this,"setExpiry",async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))}),J(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,Pt(qt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),J(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=gt.relay}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})}),J(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||Pt(qt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})}),J(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:h,appLink:l,tvf:y}=r,M=Rn(n,s,c);let I;const S=!!l;try{const $=S?Hs:hn;I=await this.client.core.crypto.encode(i,M,{encoding:$})}catch($){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),$}let D;if(yx.includes(n)){const $=Ri(JSON.stringify(M)),N=Ri(I);D=await this.client.core.verify.register({id:N,decryptedId:$})}const R=qt[n].req;if(R.attestation=D,o&&(R.ttl=o),a&&(R.id=a),this.client.core.history.set(i,M),S){const $=la(l,i,I);await global.Linking.openURL($,this.client.name)}else{const $=qt[n].req;o&&($.ttl=o),a&&($.id=a),$.tvf=mr(vt({},y),{correlationId:M.id}),h?($.internal=mr(vt({},$.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,I,$)):this.client.core.relayer.publish(i,I,$).catch(N=>this.client.logger.error(N))}return M.id}),J(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,h=Ec(i,s);let l;const y=c&&typeof(global==null?void 0:global.Linking)<"u";try{const S=y?Hs:hn;l=await this.client.core.crypto.encode(n,h,mr(vt({},a||{}),{encoding:S}))}catch(S){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),S}let M,I;try{M=await this.client.core.history.get(n,i);const S=M.request;try{this.shouldSetTVF(S.method,S.params)&&(I=this.getTVFParams(i,S.params,s))}catch(D){this.client.logger.warn("sendResult() -> getTVFParams() failed",D)}}catch(S){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),S}if(y){const S=la(c,n,l);await global.Linking.openURL(S,this.client.name)}else{const S=qt[M.request.method].res;S.tvf=mr(vt({},I),{correlationId:i}),o?(S.internal=mr(vt({},S.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,l,S)):this.client.core.relayer.publish(n,l,S).catch(D=>this.client.logger.error(D))}await this.client.core.history.resolve(h)}),J(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,h=Sc(i,s);let l;const y=c&&typeof(global==null?void 0:global.Linking)<"u";try{const I=y?Hs:hn;l=await this.client.core.crypto.encode(n,h,mr(vt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let M;try{M=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){const I=la(c,n,l);await global.Linking.openURL(I,this.client.name)}else{const I=a||qt[M.request.method].res;this.client.core.relayer.publish(n,l,I)}await this.client.core.history.resolve(h)}),J(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;on(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{on(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),J(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),J(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===_i.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=_i.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=_i.idle}),J(this,"processRequest",async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=r,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),J(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n,transportType:s}=r,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),J(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),J(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),J(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const h=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(Ci.proposal_listener_not_found)),this.isValidConnect(vt({},n.params));const l=a.expiryTimestamp||Pt(qt.wc_sessionPropose.req.ttl),y=vt({id:c,pairingTopic:i,expiryTimestamp:l},a);await this.setProposal(c,y);const M=await this.getVerifyContext({attestationId:s,hash:Ri(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});h?.addTrace(yi.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:y,verifyContext:M})}catch(h){await this.sendError({id:c,topic:i,error:h,rpcOpts:qt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}}),J(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(bi(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const l=await this.client.core.crypto.generateSharedKey(c,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:l});const y=await this.client.core.relayer.subscribe(l,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:r})}else if(Ur(i)){await this.client.proposal.delete(s,pt("USER_DISCONNECTED"));const o=Me("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Me("session_connect"),{error:i.error})}}),J(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:h,sessionProperties:l,sessionConfig:y}=i.params,M=mr(vt(vt({topic:r,relay:o,expiry:c,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},l&&{sessionProperties:l}),y&&{sessionConfig:y}),{transportType:gt.relay}),I=Me("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Me("session_connect"),{session:M}),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),J(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;bi(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Me("session_approve",n),{})):Ur(i)&&(await this.client.session.delete(r,pt("USER_DISCONNECTED")),this.events.emit(Me("session_approve",n),{error:i.error}))}),J(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=Qs.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:pt("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(vt({topic:r},n));try{Qs.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw Qs.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),J(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),J(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=Me("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);bi(i)?this.events.emit(Me("session_update",n),{}):Ur(i)&&this.events.emit(Me("session_update",n),{error:i.error})}),J(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Pt(vs)),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),J(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=Me("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);bi(i)?this.events.emit(Me("session_extend",n),{}):Ur(i)&&this.events.emit(Me("session_extend",n),{error:i.error})}),J(this,"onSessionPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),J(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=Me("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{bi(i)?this.events.emit(Me("session_ping",n),{}):Ur(i)&&this.events.emit(Me("session_ping",n),{error:i.error})},500)}),J(this,"onSessionDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Bt.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:pt("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),J(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:h,transportType:l}=r,{id:y,params:M}=a;try{await this.isValidRequest(vt({topic:o},M));const I=this.client.session.get(o),S=await this.getVerifyContext({attestationId:c,hash:Ri(JSON.stringify(Rn("wc_sessionRequest",M,y))),encryptedId:h,metadata:I.peer.metadata,transportType:l}),D={id:y,topic:o,params:M,verifyContext:S};await this.setPendingSessionRequest(D),l===gt.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(D):(this.addSessionRequestToSessionRequestQueue(D),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}}),J(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=Me("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);bi(i)?this.events.emit(Me("session_request",n),{result:i.result}):Ur(i)&&this.events.emit(Me("session_request",n),{error:i.error})}),J(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=Qs.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(vt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Qs.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),J(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),bi(i)?this.events.emit(Me("session_request",n),{result:i.result}):Ur(i)&&this.events.emit(Me("session_request",n),{error:i.error})}),J(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:h,authPayload:l,expiryTimestamp:y}=s.params,M=await this.getVerifyContext({attestationId:o,hash:Ri(JSON.stringify(s)),encryptedId:a,metadata:h.metadata,transportType:c}),I={requester:h,pairingTopic:n,id:s.id,authPayload:l,verifyContext:M,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:c}),c===gt.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:M})}catch(h){this.client.logger.error(h);const l=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),M=this.getAppLinkIfEnabled(s.params.requester.metadata,c),I={type:$i,receiverPublicKey:l,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:I,rpcOpts:qt.wc_sessionAuthenticate.autoReject,appLink:M})}}),J(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),J(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=_i.idle,this.processSessionRequestQueue()},Z.toMiliseconds(this.requestQueueDelay))}),J(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=Me("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Me("session_request",s.request.id),{error:i})})}),J(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===_i.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=_i.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),J(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),J(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:Rn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),J(this,"isValidConnect",async r=>{if(!vr(r)){const{message:c}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(hr(i)||await this.isValidPairingTopic(i),!n5(a,!0)){const{message:c}=Q("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!hr(n)&&pa(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!hr(s)&&pa(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),hr(o)||this.validateSessionProps(o,"sessionProperties")}),J(this,"validateNamespaces",(r,i)=>{const n=i5(r,"connect()",i);if(n)throw new Error(n.message)}),J(this,"isValidApprove",async r=>{if(!vr(r))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=vc(n,"approve()");if(c)throw new Error(c.message);const h=m0(a.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!Mt(s,!0)){const{message:l}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(l)}hr(o)||this.validateSessionProps(o,"sessionProperties")}),J(this,"isValidReject",async r=>{if(!vr(r)){const{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!o5(n)){const{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),J(this,"isValidSessionSettleRequest",r=>{if(!vr(r)){const{message:h}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!v0(i)){const{message:h}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const a=Z8(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=vc(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(on(o)){const{message:h}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(h)}}),J(this,"isValidUpdate",async r=>{if(!vr(r)){const{message:c}=Q("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=vc(n,"update()");if(o)throw new Error(o.message);const a=m0(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),J(this,"isValidExtend",async r=>{if(!vr(r)){const{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),J(this,"isValidRequest",async r=>{if(!vr(r)){const{message:c}=Q("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!y0(a,s)){const{message:c}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!a5(n)){const{message:c}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!h5(a,s,n.method)){const{message:c}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!p5(o,jc)){const{message:c}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${jc.min} and ${jc.max}`);throw new Error(c)}}),J(this,"isValidRespond",async r=>{var i;if(!vr(r)){const{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!f5(s)){const{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),J(this,"isValidPing",async r=>{if(!vr(r)){const{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),J(this,"isValidEmit",async r=>{if(!vr(r)){const{message:a}=Q("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!y0(o,s)){const{message:a}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!c5(n)){const{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!u5(o,s,n.name)){const{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),J(this,"isValidDisconnect",async r=>{if(!vr(r)){const{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),J(this,"isValidAuthenticate",r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Mt(n,!1))throw new Error("uri is required parameter");if(!Mt(s,!1))throw new Error("domain is required parameter");if(!Mt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>ra(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ra(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),J(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||io,validation:"UNKNOWN",origin:o.url||""}};try{if(a===gt.link_mode){const l=this.getAppLinkIfEnabled(o,a);return c.verified.validation=l&&new URL(l).origin===new URL(o.url).origin?"VALID":"INVALID",c}const h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(c.verified.origin=h.origin,c.verified.isScam=h.isScam,c.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),J(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach(n=>{if(!Mt(n,!1)){const{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})}),J(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),J(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}}),J(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),J(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,h,l,y,M;return!r||i!==gt.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((h=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:h.universal)!==""&&((l=r?.redirect)==null?void 0:l.universal)!==void 0&&((y=r?.redirect)==null?void 0:y.universal)!==""&&((M=r?.redirect)==null?void 0:M.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),J(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),J(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=gl(r,"topic")||"",n=decodeURIComponent(gl(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:gt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),J(this,"registerLinkModeListeners",async()=>{var r;if(Yf()||nn()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}),J(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:n}=i;return Object.keys(vp).includes(n.method)}),J(this,"getTVFParams",(r,i,n)=>{var s,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,n);return mr(vt({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(s=i.request.params)==null?void 0:s[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),J(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const n=r?.data||((i=r?.[0])==null?void 0:i.data);if(!n.startsWith("0x"))return!1;const s=n.slice(2);return/^[0-9a-fA-F]*$/.test(s)?s.length%2===0:!1}catch{}return!1}),J(this,"extractTxHashesFromResult",(r,i)=>{try{const n=vp[r];if(typeof i=="string")return[i];const s=i[n.key];if(Xs(s))return s;if(typeof s=="string")return[s]}catch(n){this.client.logger.warn("Error extracting tx hashes from result",n)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Bt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(_a)?this.client.auth.authKeys.get(_a):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===gt.link_mode?Hs:hn});try{Mc(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:Ri(i)})):ba(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(kr.expired,async e=>{const{topic:r,id:i}=pl(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Nn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Nn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Mt(e,!1)){const{message:r}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(on(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!Mt(e,!1)){const{message:r}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(on(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=Q("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Mt(e,!1)){const{message:r}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!s5(e)){const{message:r}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(on(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class Px extends Cn{constructor(e,r){super(e,r,lx,zc),this.core=e,this.logger=r}}class mp extends Cn{constructor(e,r){super(e,r,gx,zc),this.core=e,this.logger=r}}class $x extends Cn{constructor(e,r){super(e,r,vx,zc,i=>i.id),this.core=e,this.logger=r}}class Rx extends Cn{constructor(e,r){super(e,r,_x,wa,()=>_a),this.core=e,this.logger=r}}class Nx extends Cn{constructor(e,r){super(e,r,xx,wa),this.core=e,this.logger=r}}class Tx extends Cn{constructor(e,r){super(e,r,Ex,wa,i=>i.id),this.core=e,this.logger=r}}var Fx=Object.defineProperty,Cx=(t,e,r)=>e in t?Fx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vc=(t,e,r)=>Cx(t,typeof e!="symbol"?e+"":e,r);class Bx{constructor(e,r){this.core=e,this.logger=r,Vc(this,"authKeys"),Vc(this,"pairingTopics"),Vc(this,"requests"),this.authKeys=new Rx(this.core,this.logger),this.pairingTopics=new Nx(this.core,this.logger),this.requests=new Tx(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var Lx=Object.defineProperty,qx=(t,e,r)=>e in t?Lx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pe=(t,e,r)=>qx(t,typeof e!="symbol"?e+"":e,r);class Hc extends Kg{constructor(e){super(e),Pe(this,"protocol",lp),Pe(this,"version",pp),Pe(this,"name",kc.name),Pe(this,"metadata"),Pe(this,"core"),Pe(this,"logger"),Pe(this,"events",new Qt.exports.EventEmitter),Pe(this,"engine"),Pe(this,"session"),Pe(this,"proposal"),Pe(this,"pendingRequest"),Pe(this,"auth"),Pe(this,"signConfig"),Pe(this,"on",(i,n)=>this.events.on(i,n)),Pe(this,"once",(i,n)=>this.events.once(i,n)),Pe(this,"off",(i,n)=>this.events.off(i,n)),Pe(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),Pe(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),Pe(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),Pe(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),Pe(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),Pe(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||kc.name,this.metadata=e?.metadata||cl(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:xi(ja({level:e?.logger||kc.logger}));this.core=e?.core||new Uc(e),this.logger=or(r,this.name),this.session=new mp(this.core,this.logger),this.proposal=new Px(this.core,this.logger),this.pendingRequest=new $x(this.core,this.logger),this.engine=new Ox(this),this.auth=new Bx(this.core,this.logger)}static async init(e){const r=new Hc(e);return await r.initialize(),r}get context(){return dr(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},Z.toMiliseconds(Z.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const Ux=mp,zx=Hc;class kx extends Qt.exports{constructor(){super()}}class wp{constructor(e){this.opts=e}}class _p{constructor(e){this.client=e}}var jx=Object.defineProperty,Kx=Object.defineProperties,Vx=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,Hx=Object.prototype.hasOwnProperty,Wx=Object.prototype.propertyIsEnumerable,Ep=(t,e,r)=>e in t?jx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gx=(t,e)=>{for(var r in e||(e={}))Hx.call(e,r)&&Ep(t,r,e[r]);if(xp)for(var r of xp(e))Wx.call(e,r)&&Ep(t,r,e[r]);return t},Jx=(t,e)=>Kx(t,Vx(e));class Yx extends _p{constructor(e){super(e),this.init=async()=>{this.signClient=await zx.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig}),this.signClient.core.eventClient.init().catch(r=>{this.client.logger.warn(r)})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(Jx(Gx({},r),{id:r.id,namespaces:r.namespaces,sessionProperties:r.sessionProperties,sessionConfig:r.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async r=>await this.signClient.reject(r),this.updateSession=async r=>await this.signClient.update(r),this.extendSession=async r=>await this.signClient.extend(r),this.respondSessionRequest=async r=>await this.signClient.respond(r),this.disconnectSession=async r=>await this.signClient.disconnect(r),this.emitSessionEvent=async r=>await this.signClient.emit(r),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((r,i)=>(r[i.topic]=i,r),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async r=>await this.signClient.approveSessionAuthenticate(r),this.rejectSessionAuthenticate=async r=>await this.signClient.rejectSessionAuthenticate(r),this.formatAuthMessage=r=>this.signClient.formatAuthMessage(r),this.registerDeviceToken=r=>this.client.core.echoClient.registerDeviceToken(r),this.on=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"on"),this.client.events.on(r,i)),this.once=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"once"),this.client.events.once(r,i)),this.off=(r,i)=>(this.setEvent(r,"off"),this.client.events.off(r,i)),this.removeListener=(r,i)=>(this.setEvent(r,"removeListener"),this.client.events.removeListener(r,i)),this.onSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onSessionProposal=r=>{this.client.events.emit("session_proposal",r)},this.onSessionDelete=r=>{this.client.events.emit("session_delete",r)},this.onProposalExpire=r=>{this.client.events.emit("proposal_expire",r)},this.onSessionRequestExpire=r=>{this.client.events.emit("session_request_expire",r)},this.onSessionRequestAuthenticate=r=>{this.client.events.emit("session_authenticate",r)},this.setEvent=(r,i)=>{switch(r){case"session_request":this.signClient.events[i]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[i]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[i]("session_delete",this.onSessionDelete);break;case"proposal_expire":this.signClient.events[i]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[i]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[i]("session_authenticate",this.onSessionRequestAuthenticate);break}},this.signClient={}}}const Zx={decryptMessage:async t=>{const e={core:new Uc({storageOptions:t.storageOptions,storage:t.storage})};await e.core.crypto.init();const r=e.core.crypto.decode(t.topic,t.encryptedMessage);return e.core=null,r},getMetadata:async t=>{const e={core:new Uc({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new Ux(e.core,e.core.logger),await e.sessionStore.init();const r=e.sessionStore.get(t.topic),i=r?.peer.metadata;return e.core=null,e.sessionStore=null,i}},Sp=class extends wp{constructor(t){super(t),this.events=new Qt.exports,this.on=(e,r)=>this.engine.on(e,r),this.once=(e,r)=>this.engine.once(e,r),this.off=(e,r)=>this.engine.off(e,r),this.removeListener=(e,r)=>this.engine.removeListener(e,r),this.pair=async e=>{try{return await this.engine.pair(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(r){throw this.logger.error(r.message),r}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(r){throw this.logger.error(r.message),r}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(r){throw this.logger.error(r.message),r}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(r){throw this.logger.error(r.message),r}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.registerDeviceToken=e=>{try{return this.engine.registerDeviceToken(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(r){throw this.logger.error(r.message),r}},this.metadata=t.metadata,this.name=t.name||Da,this.signConfig=t.signConfig,this.core=t.core,this.logger=this.core.logger,this.engine=new Yx(this)}static async init(t){const e=new Sp(t);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(t){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(t.message),t}}};let Wc=Sp;Wc.notifications=Zx;const Xx=Wc;Xt.CLIENT_CONTEXT=Da,Xt.CLIENT_STORAGE_OPTIONS=jp,Xt.CLIENT_STORAGE_PREFIX=kp,Xt.IWalletKit=wp,Xt.IWalletKitEngine=_p,Xt.IWalletKitEvents=kx,Xt.PROTOCOL=sh,Xt.PROTOCOL_VERSION=zp,Xt.REQUEST_CONTEXT=Kp,Xt.WalletKit=Xx,Xt.default=Wc,Object.defineProperty(Xt,"__esModule",{value:!0})});
|
|
39
|
+
***************************************************************************** */var Vf=function(t,e){return Vf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Vf(t,e)};function m_(t,e){Vf(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Hf=function(){return Hf=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Hf.apply(this,arguments)};function w_(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function __(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function x_(t,e){return function(r,i){e(r,i,t)}}function E_(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function S_(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(h){try{f(i.next(h))}catch(l){o(l)}}function c(h){try{f(i.throw(h))}catch(l){o(l)}}function f(h){h.done?s(h.value):n(h.value).then(a,c)}f((i=i.apply(t,e||[])).next())})}function I_(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(h){return c([f,h])}}function c(f){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=f[0]&2?n.return:f[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,f[1])).done)return s;switch(n=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,n=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(h){f=[6,h],n=0}finally{i=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function A_(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function D_(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Wf(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Rp(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function $_(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Rp(arguments[e]));return t}function O_(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function Us(t){return this instanceof Us?(this.v=t,this):new Us(t)}function M_(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(g){i[g]&&(n[g]=function(w){return new Promise(function(b,E){s.push([g,w,b,E])>1||a(g,w)})})}function a(g,w){try{c(i[g](w))}catch(b){l(s[0][3],b)}}function c(g){g.value instanceof Us?Promise.resolve(g.value.v).then(f,h):l(s[0][2],g)}function f(g){a("next",g)}function h(g){a("throw",g)}function l(g,w){g(w),s.shift(),s.length&&a(s[0][0],s[0][1])}}function P_(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:Us(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function R_(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Wf=="function"?Wf(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(f){s({value:f,done:a})},o)}}function T_(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function N_(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function C_(t){return t&&t.__esModule?t:{default:t}}function B_(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function F_(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var L_=Object.freeze({__proto__:null,__extends:m_,get __assign(){return Hf},__rest:w_,__decorate:__,__param:x_,__metadata:E_,__awaiter:S_,__generator:I_,__createBinding:A_,__exportStar:D_,__values:Wf,__read:Rp,__spread:$_,__spreadArrays:O_,__await:Us,__asyncGenerator:M_,__asyncDelegator:P_,__asyncValues:R_,__makeTemplateObject:T_,__importStar:N_,__importDefault:C_,__classPrivateFieldGet:B_,__classPrivateFieldSet:F_}),q_=La(L_),si={},Tp;function z_(){if(Tp)return si;Tp=1,Object.defineProperty(si,"__esModule",{value:!0}),si.isBrowserCryptoAvailable=si.getSubtleCrypto=si.getBrowerCrypto=void 0;function t(){return Ct?.crypto||Ct?.msCrypto||{}}si.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}si.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return si.isBrowserCryptoAvailable=r,si}var oi={},Np;function U_(){if(Np)return oi;Np=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.isBrowser=oi.isNode=oi.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}oi.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}oi.isNode=e;function r(){return!t()&&!e()}return oi.isBrowser=r,oi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=q_;e.__exportStar(z_(),t),e.__exportStar(U_(),t)})(Pp);function Lr(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function Qi(t=6){return BigInt(Lr(t))}function en(t,e,r){return{id:r||Lr(),jsonrpc:"2.0",method:t,params:e}}function Gf(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Yf(t,e,r){return{id:t,jsonrpc:"2.0",error:k_(e,r)}}function k_(t,e){return typeof t>"u"?Mp($p):(typeof t=="string"&&(t=Object.assign(Object.assign({},Mp(Kf)),{message:t})),typeof e<"u"&&(t.data=e),b_(t.code)&&(t=y_(t.code)),t)}class j_{}class K_ extends j_{constructor(){super()}}class V_ extends K_{constructor(e){super()}}const H_="^wss?:";function W_(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function G_(t,e){const r=W_(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Cp(t){return G_(t,H_)}function Y_(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Bp(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Jf(t){return Bp(t)&&"method"in t}function xa(t){return Bp(t)&&(qr(t)||or(t))}function qr(t){return"result"in t}function or(t){return"error"in t}class J_ extends V_{constructor(e){super(e),this.events=new Ot.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(en(e.method,e.params||[],e.id||Qi().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{or(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),xa(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const Z_=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),X_=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Fp=t=>t.split("?")[0],Lp=10,Q_=Z_();class ex{constructor(e){if(this.url=e,this.events=new Ot.exports.EventEmitter,this.registering=!1,!Cp(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Fi(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!Cp(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=Pp.isReactNative()?void 0:{rejectUnauthorized:!Y_(e)},s=new Q_(e,[],n);X_()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?bn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Yf(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return v_(e,Fp(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Lp&&this.events.setMaxListeners(Lp)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Fp(this.url)}`));return this.events.emit("register_error",r),r}}var Zf={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",f="[object AsyncFunction]",h="[object Boolean]",l="[object Date]",g="[object Error]",w="[object Function]",b="[object GeneratorFunction]",E="[object Map]",A="[object Number]",$="[object Null]",M="[object Object]",P="[object Promise]",R="[object Proxy]",N="[object RegExp]",L="[object Set]",F="[object String]",B="[object Symbol]",C="[object Undefined]",W="[object WeakMap]",I="[object ArrayBuffer]",u="[object DataView]",p="[object Float32Array]",v="[object Float64Array]",y="[object Int8Array]",m="[object Int16Array]",S="[object Int32Array]",D="[object Uint8Array]",_="[object Uint8ClampedArray]",d="[object Uint16Array]",x="[object Uint32Array]",q=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,U=/^(?:0|[1-9]\d*)$/,k={};k[p]=k[v]=k[y]=k[m]=k[S]=k[D]=k[_]=k[d]=k[x]=!0,k[a]=k[c]=k[I]=k[h]=k[u]=k[l]=k[g]=k[w]=k[E]=k[A]=k[M]=k[N]=k[L]=k[F]=k[W]=!1;var G=typeof Ct=="object"&&Ct&&Ct.Object===Object&&Ct,Z=typeof self=="object"&&self&&self.Object===Object&&self,X=G||Z||Function("return this")(),J=e&&!e.nodeType&&e,Q=J&&!0&&t&&!t.nodeType&&t,Fe=Q&&Q.exports===J,re=Fe&&G.process,oe=function(){try{return re&&re.binding&&re.binding("util")}catch{}}(),ct=oe&&oe.isTypedArray;function he(O,T){for(var j=-1,Y=O==null?0:O.length,Oe=0,ee=[];++j<Y;){var tt=O[j];T(tt,j,O)&&(ee[Oe++]=tt)}return ee}function Me(O,T){for(var j=-1,Y=T.length,Oe=O.length;++j<Y;)O[Oe+j]=T[j];return O}function es(O,T){for(var j=-1,Y=O==null?0:O.length;++j<Y;)if(T(O[j],j,O))return!0;return!1}function Pe(O,T){for(var j=-1,Y=Array(O);++j<O;)Y[j]=T(j);return Y}function Ie(O){return function(T){return O(T)}}function on(O,T){return O.has(T)}function _e(O,T){return O?.[T]}function Ae(O){var T=-1,j=Array(O.size);return O.forEach(function(Y,Oe){j[++T]=[Oe,Y]}),j}function an(O,T){return function(j){return O(T(j))}}function De(O){var T=-1,j=Array(O.size);return O.forEach(function(Y){j[++T]=Y}),j}var $e=Array.prototype,cn=Function.prototype,be=Object.prototype,xe=X["__core-js_shared__"],fn=cn.toString,ae=be.hasOwnProperty,Le=function(){var O=/[^.]+$/.exec(xe&&xe.keys&&xe.keys.IE_PROTO||"");return O?"Symbol(src)_1."+O:""}(),Gs=be.toString,He=RegExp("^"+fn.call(ae).replace(q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qe=Fe?X.Buffer:void 0,un=X.Symbol,ze=X.Uint8Array,Ue=be.propertyIsEnumerable,$a=$e.splice,ge=un?un.toStringTag:void 0,ke=Object.getOwnPropertySymbols,Oa=qe?qe.isBuffer:void 0,We=an(Object.keys,Object),Re=rs(X,"DataView"),Oi=rs(X,"Map"),Te=rs(X,"Promise"),Ne=rs(X,"Set"),ts=rs(X,"WeakMap"),Ee=rs(Object,"create"),Ge=hn(Re),Ma=hn(Oi),Ye=hn(Te),Je=hn(Ne),Pa=hn(ts),je=un?un.prototype:void 0,Ce=je?je.valueOf:void 0;function Vr(O){var T=-1,j=O==null?0:O.length;for(this.clear();++T<j;){var Y=O[T];this.set(Y[0],Y[1])}}function Ze(){this.__data__=Ee?Ee(null):{},this.size=0}function Xe(O){var T=this.has(O)&&delete this.__data__[O];return this.size-=T?1:0,T}function Ra(O){var T=this.__data__;if(Ee){var j=T[O];return j===i?void 0:j}return ae.call(T,O)?T[O]:void 0}function Qe(O){var T=this.__data__;return Ee?T[O]!==void 0:ae.call(T,O)}function et(O,T){var j=this.__data__;return this.size+=this.has(O)?0:1,j[O]=Ee&&T===void 0?i:T,this}Vr.prototype.clear=Ze,Vr.prototype.delete=Xe,Vr.prototype.get=Ra,Vr.prototype.has=Qe,Vr.prototype.set=et;function Qt(O){var T=-1,j=O==null?0:O.length;for(this.clear();++T<j;){var Y=O[T];this.set(Y[0],Y[1])}}function Ys(){this.__data__=[],this.size=0}function Js(O){var T=this.__data__,j=Ta(T,O);if(j<0)return!1;var Y=T.length-1;return j==Y?T.pop():$a.call(T,j,1),--this.size,!0}function Zs(O){var T=this.__data__,j=Ta(T,O);return j<0?void 0:T[j][1]}function Xs(O){return Ta(this.__data__,O)>-1}function Qs(O,T){var j=this.__data__,Y=Ta(j,O);return Y<0?(++this.size,j.push([O,T])):j[Y][1]=T,this}Qt.prototype.clear=Ys,Qt.prototype.delete=Js,Qt.prototype.get=Zs,Qt.prototype.has=Xs,Qt.prototype.set=Qs;function _r(O){var T=-1,j=O==null?0:O.length;for(this.clear();++T<j;){var Y=O[T];this.set(Y[0],Y[1])}}function eo(){this.size=0,this.__data__={hash:new Vr,map:new(Oi||Qt),string:new Vr}}function to(O){var T=Na(this,O).delete(O);return this.size-=T?1:0,T}function ro(O){return Na(this,O).get(O)}function io(O){return Na(this,O).has(O)}function no(O,T){var j=Na(this,O),Y=j.size;return j.set(O,T),this.size+=j.size==Y?0:1,this}_r.prototype.clear=eo,_r.prototype.delete=to,_r.prototype.get=ro,_r.prototype.has=io,_r.prototype.set=no;function Mi(O){var T=-1,j=O==null?0:O.length;for(this.__data__=new _r;++T<j;)this.add(O[T])}function so(O){return this.__data__.set(O,i),this}function oo(O){return this.__data__.has(O)}Mi.prototype.add=Mi.prototype.push=so,Mi.prototype.has=oo;function fr(O){var T=this.__data__=new Qt(O);this.size=T.size}function ao(){this.__data__=new Qt,this.size=0}function co(O){var T=this.__data__,j=T.delete(O);return this.size=T.size,j}function fo(O){return this.__data__.get(O)}function kI(O){return this.__data__.has(O)}function jI(O,T){var j=this.__data__;if(j instanceof Qt){var Y=j.__data__;if(!Oi||Y.length<r-1)return Y.push([O,T]),this.size=++j.size,this;j=this.__data__=new _r(Y)}return j.set(O,T),this.size=j.size,this}fr.prototype.clear=ao,fr.prototype.delete=co,fr.prototype.get=fo,fr.prototype.has=kI,fr.prototype.set=jI;function KI(O,T){var j=Ca(O),Y=!j&&sA(O),Oe=!j&&!Y&&mu(O),ee=!j&&!Y&&!Oe&&z1(O),tt=j||Y||Oe||ee,mt=tt?Pe(O.length,String):[],Dt=mt.length;for(var Ke in O)(T||ae.call(O,Ke))&&!(tt&&(Ke=="length"||Oe&&(Ke=="offset"||Ke=="parent")||ee&&(Ke=="buffer"||Ke=="byteLength"||Ke=="byteOffset")||eA(Ke,Dt)))&&mt.push(Ke);return mt}function Ta(O,T){for(var j=O.length;j--;)if(B1(O[j][0],T))return j;return-1}function VI(O,T,j){var Y=T(O);return Ca(O)?Y:Me(Y,j(O))}function uo(O){return O==null?O===void 0?C:$:ge&&ge in Object(O)?XI(O):nA(O)}function R1(O){return ho(O)&&uo(O)==a}function T1(O,T,j,Y,Oe){return O===T?!0:O==null||T==null||!ho(O)&&!ho(T)?O!==O&&T!==T:HI(O,T,j,Y,T1,Oe)}function HI(O,T,j,Y,Oe,ee){var tt=Ca(O),mt=Ca(T),Dt=tt?c:Pi(O),Ke=mt?c:Pi(T);Dt=Dt==a?M:Dt,Ke=Ke==a?M:Ke;var er=Dt==M,xr=Ke==M,Nt=Dt==Ke;if(Nt&&mu(O)){if(!mu(T))return!1;tt=!0,er=!1}if(Nt&&!er)return ee||(ee=new fr),tt||z1(O)?N1(O,T,j,Y,Oe,ee):JI(O,T,Dt,j,Y,Oe,ee);if(!(j&n)){var ur=er&&ae.call(O,"__wrapped__"),hr=xr&&ae.call(T,"__wrapped__");if(ur||hr){var Ri=ur?O.value():O,ci=hr?T.value():T;return ee||(ee=new fr),Oe(Ri,ci,j,Y,ee)}}return Nt?(ee||(ee=new fr),ZI(O,T,j,Y,Oe,ee)):!1}function WI(O){if(!q1(O)||rA(O))return!1;var T=F1(O)?He:z;return T.test(hn(O))}function GI(O){return ho(O)&&L1(O.length)&&!!k[uo(O)]}function YI(O){if(!iA(O))return We(O);var T=[];for(var j in Object(O))ae.call(O,j)&&j!="constructor"&&T.push(j);return T}function N1(O,T,j,Y,Oe,ee){var tt=j&n,mt=O.length,Dt=T.length;if(mt!=Dt&&!(tt&&Dt>mt))return!1;var Ke=ee.get(O);if(Ke&&ee.get(T))return Ke==T;var er=-1,xr=!0,Nt=j&s?new Mi:void 0;for(ee.set(O,T),ee.set(T,O);++er<mt;){var ur=O[er],hr=T[er];if(Y)var Ri=tt?Y(hr,ur,er,T,O,ee):Y(ur,hr,er,O,T,ee);if(Ri!==void 0){if(Ri)continue;xr=!1;break}if(Nt){if(!es(T,function(ci,dn){if(!on(Nt,dn)&&(ur===ci||Oe(ur,ci,j,Y,ee)))return Nt.push(dn)})){xr=!1;break}}else if(!(ur===hr||Oe(ur,hr,j,Y,ee))){xr=!1;break}}return ee.delete(O),ee.delete(T),xr}function JI(O,T,j,Y,Oe,ee,tt){switch(j){case u:if(O.byteLength!=T.byteLength||O.byteOffset!=T.byteOffset)return!1;O=O.buffer,T=T.buffer;case I:return!(O.byteLength!=T.byteLength||!ee(new ze(O),new ze(T)));case h:case l:case A:return B1(+O,+T);case g:return O.name==T.name&&O.message==T.message;case N:case F:return O==T+"";case E:var mt=Ae;case L:var Dt=Y&n;if(mt||(mt=De),O.size!=T.size&&!Dt)return!1;var Ke=tt.get(O);if(Ke)return Ke==T;Y|=s,tt.set(O,T);var er=N1(mt(O),mt(T),Y,Oe,ee,tt);return tt.delete(O),er;case B:if(Ce)return Ce.call(O)==Ce.call(T)}return!1}function ZI(O,T,j,Y,Oe,ee){var tt=j&n,mt=C1(O),Dt=mt.length,Ke=C1(T),er=Ke.length;if(Dt!=er&&!tt)return!1;for(var xr=Dt;xr--;){var Nt=mt[xr];if(!(tt?Nt in T:ae.call(T,Nt)))return!1}var ur=ee.get(O);if(ur&&ee.get(T))return ur==T;var hr=!0;ee.set(O,T),ee.set(T,O);for(var Ri=tt;++xr<Dt;){Nt=mt[xr];var ci=O[Nt],dn=T[Nt];if(Y)var U1=tt?Y(dn,ci,Nt,T,O,ee):Y(ci,dn,Nt,O,T,ee);if(!(U1===void 0?ci===dn||Oe(ci,dn,j,Y,ee):U1)){hr=!1;break}Ri||(Ri=Nt=="constructor")}if(hr&&!Ri){var Ba=O.constructor,Fa=T.constructor;Ba!=Fa&&"constructor"in O&&"constructor"in T&&!(typeof Ba=="function"&&Ba instanceof Ba&&typeof Fa=="function"&&Fa instanceof Fa)&&(hr=!1)}return ee.delete(O),ee.delete(T),hr}function C1(O){return VI(O,cA,QI)}function Na(O,T){var j=O.__data__;return tA(T)?j[typeof T=="string"?"string":"hash"]:j.map}function rs(O,T){var j=_e(O,T);return WI(j)?j:void 0}function XI(O){var T=ae.call(O,ge),j=O[ge];try{O[ge]=void 0;var Y=!0}catch{}var Oe=Gs.call(O);return Y&&(T?O[ge]=j:delete O[ge]),Oe}var QI=ke?function(O){return O==null?[]:(O=Object(O),he(ke(O),function(T){return Ue.call(O,T)}))}:fA,Pi=uo;(Re&&Pi(new Re(new ArrayBuffer(1)))!=u||Oi&&Pi(new Oi)!=E||Te&&Pi(Te.resolve())!=P||Ne&&Pi(new Ne)!=L||ts&&Pi(new ts)!=W)&&(Pi=function(O){var T=uo(O),j=T==M?O.constructor:void 0,Y=j?hn(j):"";if(Y)switch(Y){case Ge:return u;case Ma:return E;case Ye:return P;case Je:return L;case Pa:return W}return T});function eA(O,T){return T=T??o,!!T&&(typeof O=="number"||U.test(O))&&O>-1&&O%1==0&&O<T}function tA(O){var T=typeof O;return T=="string"||T=="number"||T=="symbol"||T=="boolean"?O!=="__proto__":O===null}function rA(O){return!!Le&&Le in O}function iA(O){var T=O&&O.constructor,j=typeof T=="function"&&T.prototype||be;return O===j}function nA(O){return Gs.call(O)}function hn(O){if(O!=null){try{return fn.call(O)}catch{}try{return O+""}catch{}}return""}function B1(O,T){return O===T||O!==O&&T!==T}var sA=R1(function(){return arguments}())?R1:function(O){return ho(O)&&ae.call(O,"callee")&&!Ue.call(O,"callee")},Ca=Array.isArray;function oA(O){return O!=null&&L1(O.length)&&!F1(O)}var mu=Oa||uA;function aA(O,T){return T1(O,T)}function F1(O){if(!q1(O))return!1;var T=uo(O);return T==w||T==b||T==f||T==R}function L1(O){return typeof O=="number"&&O>-1&&O%1==0&&O<=o}function q1(O){var T=typeof O;return O!=null&&(T=="object"||T=="function")}function ho(O){return O!=null&&typeof O=="object"}var z1=ct?Ie(ct):GI;function cA(O){return oA(O)?KI(O):YI(O)}function fA(){return[]}function uA(){return!1}t.exports=aA})(Zf,Zf.exports);var tx=Zf.exports;const qp="wc",zp=2,Ea="core",zr=`${qp}@2:${Ea}:`,rx={name:Ea,logger:"error"},ix={database:":memory:"},nx="crypto",Up="client_ed25519_seed",sx=V.ONE_DAY,ox="keychain",ax="0.3",cx="messages",fx="0.3",kp=V.SIX_HOURS,ux="publisher",jp="irn",hx="error",Kp="wss://relay.walletconnect.org",dx="relayer",bt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lx="_subscription",ar={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},px=.1,Xf="2.19.0-rc-1",Se={link_mode:"link_mode",relay:"relay"},gx="0.3",bx="WALLETCONNECT_CLIENT_ID",Vp="WALLETCONNECT_LINK_MODE_APPS",Xt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},yx="subscription",vx="0.3",mx=V.FIVE_SECONDS*1e3,wx="pairing",_x="0.3",ks={wc_pairingDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:V.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:V.ONE_DAY,prompt:!1,tag:0},res:{ttl:V.ONE_DAY,prompt:!1,tag:0}}},tn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},xx="history",Ex="0.3",Sx="expirer",cr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Ix="0.3",Ax="verify-api",Dx="https://verify.walletconnect.com",Hp="https://verify.walletconnect.org",js=Hp,$x=`${js}/v3`,Ox=[Dx,Hp],Mx="echo",Px="https://echo.walletconnect.com",Ur={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ai={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},mr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},rn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},nn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ks={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},Rx=.1,Tx="event-client",Nx=86400,Cx="https://pulse.walletconnect.org/batch";function Bx(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var E=0,A=0,$=0,M=b.length;$!==M&&b[$]===0;)$++,E++;for(var P=(M-$)*h+1>>>0,R=new Uint8Array(P);$!==M;){for(var N=b[$],L=0,F=P-1;(N!==0||L<A)&&F!==-1;F--,L++)N+=256*R[F]>>>0,R[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");A=L,$++}for(var B=P-A;B!==P&&R[B]===0;)B++;for(var C=c.repeat(E);B<P;++B)C+=t.charAt(R[B]);return C}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var E=0;if(b[E]!==" "){for(var A=0,$=0;b[E]===c;)A++,E++;for(var M=(b.length-E)*f+1>>>0,P=new Uint8Array(M);b[E];){var R=r[b.charCodeAt(E)];if(R===255)return;for(var N=0,L=M-1;(R!==0||N<$)&&L!==-1;L--,N++)R+=a*P[L]>>>0,P[L]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");$=N,E++}if(b[E]!==" "){for(var F=M-$;F!==M&&P[F]===0;)F++;for(var B=new Uint8Array(A+(M-F)),C=A;F!==M;)B[C++]=P[F++];return B}}}function w(b){var E=g(b);if(E)return E;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:g,decode:w}}var Fx=Bx,Lx=Fx;const Wp=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},qx=t=>new TextEncoder().encode(t),zx=t=>new TextDecoder().decode(t);class Ux{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class kx{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Gp(this,e)}}class jx{constructor(e){this.decoders=e}or(e){return Gp(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Gp=(t,e)=>new jx({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Kx{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Ux(e,r,i),this.decoder=new kx(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Sa=({name:t,prefix:e,encode:r,decode:i})=>new Kx(t,e,r,i),Vs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Lx(r,e);return Sa({prefix:t,name:e,encode:i,decode:s=>Wp(n(s))})},Vx=(t,e,r,i)=>{const n={};for(let h=0;h<e.length;++h)n[e[h]]=h;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,f=0;for(let h=0;h<s;++h){const l=n[t[h]];if(l===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,o[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Hx=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},St=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Sa({prefix:e,name:t,encode(n){return Hx(n,i,r)},decode(n){return Vx(n,i,r,t)}}),Wx=Sa({prefix:"\0",name:"identity",encode:t=>zx(t),decode:t=>qx(t)});var Gx=Object.freeze({__proto__:null,identity:Wx});const Yx=St({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Jx=Object.freeze({__proto__:null,base2:Yx});const Zx=St({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xx=Object.freeze({__proto__:null,base8:Zx});const Qx=Vs({prefix:"9",name:"base10",alphabet:"0123456789"});var eE=Object.freeze({__proto__:null,base10:Qx});const tE=St({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),rE=St({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var iE=Object.freeze({__proto__:null,base16:tE,base16upper:rE});const nE=St({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),sE=St({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),oE=St({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),aE=St({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cE=St({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),fE=St({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),uE=St({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hE=St({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dE=St({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var lE=Object.freeze({__proto__:null,base32:nE,base32upper:sE,base32pad:oE,base32padupper:aE,base32hex:cE,base32hexupper:fE,base32hexpad:uE,base32hexpadupper:hE,base32z:dE});const pE=Vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gE=Vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var bE=Object.freeze({__proto__:null,base36:pE,base36upper:gE});const yE=Vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vE=Vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mE=Object.freeze({__proto__:null,base58btc:yE,base58flickr:vE});const wE=St({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),_E=St({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xE=St({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),EE=St({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var SE=Object.freeze({__proto__:null,base64:wE,base64pad:_E,base64url:xE,base64urlpad:EE});const Yp=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),IE=Yp.reduce((t,e,r)=>(t[r]=e,t),[]),AE=Yp.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function DE(t){return t.reduce((e,r)=>(e+=IE[r],e),"")}function $E(t){const e=[];for(const r of t){const i=AE[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const OE=Sa({prefix:"\u{1F680}",name:"base256emoji",encode:DE,decode:$E});var ME=Object.freeze({__proto__:null,base256emoji:OE}),PE=Zp,Jp=128,RE=127,TE=~RE,NE=Math.pow(2,31);function Zp(t,e,r){e=e||[],r=r||0;for(var i=r;t>=NE;)e[r++]=t&255|Jp,t/=128;for(;t&TE;)e[r++]=t&255|Jp,t>>>=7;return e[r]=t|0,Zp.bytes=r-i+1,e}var CE=Qf,BE=128,Xp=127;function Qf(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Qf.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Xp)<<n:(o&Xp)*Math.pow(2,n),n+=7}while(o>=BE);return Qf.bytes=s-i,r}var FE=Math.pow(2,7),LE=Math.pow(2,14),qE=Math.pow(2,21),zE=Math.pow(2,28),UE=Math.pow(2,35),kE=Math.pow(2,42),jE=Math.pow(2,49),KE=Math.pow(2,56),VE=Math.pow(2,63),HE=function(t){return t<FE?1:t<LE?2:t<qE?3:t<zE?4:t<UE?5:t<kE?6:t<jE?7:t<KE?8:t<VE?9:10},WE={encode:PE,decode:CE,encodingLength:HE},Qp=WE;const e1=(t,e,r=0)=>(Qp.encode(t,e,r),e),t1=t=>Qp.encodingLength(t),eu=(t,e)=>{const r=e.byteLength,i=t1(t),n=i+t1(r),s=new Uint8Array(n+r);return e1(t,s,0),e1(r,s,i),s.set(e,n),new GE(t,r,e,s)};class GE{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const r1=({name:t,code:e,encode:r})=>new YE(t,e,r);class YE{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?eu(this.code,r):r.then(i=>eu(this.code,i))}else throw Error("Unknown type, must be binary type")}}const i1=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),JE=r1({name:"sha2-256",code:18,encode:i1("SHA-256")}),ZE=r1({name:"sha2-512",code:19,encode:i1("SHA-512")});var XE=Object.freeze({__proto__:null,sha256:JE,sha512:ZE});const n1=0,QE="identity",s1=Wp;var eS=Object.freeze({__proto__:null,identity:{code:n1,name:QE,encode:s1,digest:t=>eu(n1,s1(t))}});new TextEncoder,new TextDecoder;const o1={...Gx,...Jx,...Xx,...eE,...iE,...lE,...bE,...mE,...SE,...ME};({...XE,...eS});function tS(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function a1(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const c1=a1("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),tu=a1("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=tS(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),rS={utf8:c1,"utf-8":c1,hex:o1.base16,latin1:tu,ascii:tu,binary:tu,...o1};function iS(t,e="utf8"){const r=rS[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var nS=Object.defineProperty,sS=(t,e,r)=>e in t?nS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kr=(t,e,r)=>sS(t,typeof e!="symbol"?e+"":e,r);class oS{constructor(e,r){this.core=e,this.logger=r,kr(this,"keychain",new Map),kr(this,"name",ox),kr(this,"version",ax),kr(this,"initialized",!1),kr(this,"storagePrefix",zr),kr(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),kr(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),kr(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),kr(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=H("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),kr(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=Bt(r,this.name)}get context(){return Ut(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,y0(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?v0(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var aS=Object.defineProperty,cS=(t,e,r)=>e in t?aS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,It=(t,e,r)=>cS(t,typeof e!="symbol"?e+"":e,r);class fS{constructor(e,r,i){this.core=e,this.logger=r,It(this,"name",nx),It(this,"keychain"),It(this,"randomSessionIdentifier",zf()),It(this,"initialized",!1),It(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),It(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),It(this,"getClientId",async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Zh(n);return Jh(s.publicKey)}),It(this,"generateKeyPair",()=>{this.isInitialized();const n=g7();return this.setPrivateKey(n.publicKey,n.privateKey)}),It(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Zh(s),a=this.randomSessionIdentifier;return await Uv(a,n,sx,o)}),It(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=b7(a,s);return this.setSymKey(c,o)}),It(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||ya(n);return await this.keychain.set(o,n),o}),It(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),It(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),It(this,"encode",async(n,s,o)=>{this.isInitialized();const a=gp(o),c=Fi(s);if(yp(a))return m7(c,o?.encoding);if(bp(a)){const g=a.senderPublicKey,w=a.receiverPublicKey;n=await this.generateSharedKey(g,w)}const f=this.getSymKey(n),{type:h,senderPublicKey:l}=a;return y7({type:h,symKey:f,message:c,senderPublicKey:l,encoding:o?.encoding})}),It(this,"decode",async(n,s,o)=>{this.isInitialized();const a=_7(s,o);if(yp(a)){const c=w7(s,o?.encoding);return bn(c)}if(bp(a)){const c=a.receiverPublicKey,f=a.senderPublicKey;n=await this.generateSharedKey(c,f)}try{const c=this.getSymKey(n),f=v7({symKey:c,encoded:s,encoding:o?.encoding});return bn(f)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),It(this,"getPayloadType",(n,s=$i)=>{const o=Bs({encoded:n,encoding:s});return Xi(o.type)}),It(this,"getPayloadSenderPublicKey",(n,s=$i)=>{const o=Bs({encoded:n,encoding:s});return o.senderPublicKey?Lt(o.senderPublicKey,Rt):void 0}),this.core=e,this.logger=Bt(r,this.name),this.keychain=i||new oS(this.core,this.logger)}get context(){return Ut(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Up)}catch{e=zf(),await this.keychain.set(Up,e)}return iS(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var uS=Object.defineProperty,hS=(t,e,r)=>e in t?uS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jr=(t,e,r)=>hS(t,typeof e!="symbol"?e+"":e,r);class dS extends zb{constructor(e,r){super(e,r),this.logger=e,this.core=r,jr(this,"messages",new Map),jr(this,"name",cx),jr(this,"version",fx),jr(this,"initialized",!1),jr(this,"storagePrefix",zr),jr(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),jr(this,"set",async(i,n)=>{this.isInitialized();const s=ni(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s}),jr(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),jr(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=ni(n);return typeof s[o]<"u"}),jr(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=Bt(e,this.name),this.core=r}get context(){return Ut(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,y0(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?v0(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var lS=Object.defineProperty,pS=Object.defineProperties,gS=Object.getOwnPropertyDescriptors,f1=Object.getOwnPropertySymbols,bS=Object.prototype.hasOwnProperty,yS=Object.prototype.propertyIsEnumerable,ru=(t,e,r)=>e in t?lS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ia=(t,e)=>{for(var r in e||(e={}))bS.call(e,r)&&ru(t,r,e[r]);if(f1)for(var r of f1(e))yS.call(e,r)&&ru(t,r,e[r]);return t},iu=(t,e)=>pS(t,gS(e)),wr=(t,e,r)=>ru(t,typeof e!="symbol"?e+"":e,r);class vS extends Ub{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,wr(this,"events",new Ot.exports.EventEmitter),wr(this,"name",ux),wr(this,"queue",new Map),wr(this,"publishTimeout",V.toMiliseconds(V.ONE_MINUTE)),wr(this,"initialPublishTimeout",V.toMiliseconds(V.ONE_SECOND*15)),wr(this,"needsTransportRestart",!1),wr(this,"publish",async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=s?.ttl||kp,c=va(s),f=s?.prompt||!1,h=s?.tag||0,l=s?.id||Qi().toString(),g={topic:i,message:n,opts:{ttl:a,relay:c,prompt:f,tag:h,id:l,attestation:s?.attestation,tvf:s?.tvf}},w=`Failed to publish payload, please try again. id:${l} tag:${h}`;try{const b=new Promise(async E=>{const A=({id:M})=>{g.opts.id===M&&(this.removeRequestFromQueue(M),this.relayer.events.removeListener(bt.publish,A),E(g))};this.relayer.events.on(bt.publish,A);const $=Ei(new Promise((M,P)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:f,tag:h,id:l,attestation:s?.attestation,tvf:s?.tvf}).then(M).catch(R=>{this.logger.warn(R,R?.message),P(R)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${l} tag:${h}`);try{await $,this.events.removeListener(bt.publish,A)}catch(M){this.queue.set(l,iu(Ia({},g),{attempt:1})),this.logger.warn(M,M?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:l,topic:i,message:n,opts:s}}),await Ei(b,this.publishTimeout,w)}catch(b){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(b),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw b}finally{this.queue.delete(l)}}),wr(this,"on",(i,n)=>{this.events.on(i,n)}),wr(this,"once",(i,n)=>{this.events.once(i,n)}),wr(this,"off",(i,n)=>{this.events.off(i,n)}),wr(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=Bt(r,this.name),this.registerEventListeners()}get context(){return Ut(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=kp,prompt:f,tag:h,id:l,attestation:g,tvf:w}=e,b={method:Fs(va().protocol).publish,params:Ia({topic:o,message:a,ttl:c,prompt:f,tag:h,attestation:g},w),id:l};qt((r=b.params)==null?void 0:r.prompt)&&((i=b.params)==null||delete i.prompt),qt((n=b.params)==null?void 0:n.tag)&&((s=b.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:b});const E=await this.relayer.request(b);return this.relayer.events.emit(bt.publish,e),this.logger.debug("Successfully Published Payload"),E}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,iu(Ia({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(iu(Ia({},e),{topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(gn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(bt.connection_stalled);return}this.checkQueue()}),this.relayer.on(bt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var mS=Object.defineProperty,wS=(t,e,r)=>e in t?mS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xn=(t,e,r)=>wS(t,typeof e!="symbol"?e+"":e,r);class _S{constructor(){Xn(this,"map",new Map),Xn(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),Xn(this,"get",e=>this.map.get(e)||[]),Xn(this,"exists",(e,r)=>this.get(e).includes(r)),Xn(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)}),Xn(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var xS=Object.defineProperty,ES=Object.defineProperties,SS=Object.getOwnPropertyDescriptors,u1=Object.getOwnPropertySymbols,IS=Object.prototype.hasOwnProperty,AS=Object.prototype.propertyIsEnumerable,nu=(t,e,r)=>e in t?xS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hs=(t,e)=>{for(var r in e||(e={}))IS.call(e,r)&&nu(t,r,e[r]);if(u1)for(var r of u1(e))AS.call(e,r)&&nu(t,r,e[r]);return t},su=(t,e)=>ES(t,SS(e)),pe=(t,e,r)=>nu(t,typeof e!="symbol"?e+"":e,r);class DS extends Kb{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,pe(this,"subscriptions",new Map),pe(this,"topicMap",new _S),pe(this,"events",new Ot.exports.EventEmitter),pe(this,"name",yx),pe(this,"version",vx),pe(this,"pending",new Map),pe(this,"cached",[]),pe(this,"initialized",!1),pe(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),pe(this,"pollingInterval",20),pe(this,"storagePrefix",zr),pe(this,"subscribeTimeout",V.toMiliseconds(V.ONE_MINUTE)),pe(this,"initialSubscribeTimeout",V.toMiliseconds(V.ONE_SECOND*15)),pe(this,"clientId"),pe(this,"batchSubscribeTopicsLimit",500),pe(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),pe(this,"subscribe",async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=va(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}}),pe(this,"unsubscribe",async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),pe(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new V.Watch;a.start(n);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(f=>f.topic===i))&&(clearInterval(c),a.stop(n),s(!0)),a.elapsed(n)>=mx&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),pe(this,"on",(i,n)=>{this.events.on(i,n)}),pe(this,"once",(i,n)=>{this.events.once(i,n)}),pe(this,"off",(i,n)=>{this.events.off(i,n)}),pe(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),pe(this,"start",async()=>{await this.onConnect()}),pe(this,"stop",async()=>{await this.onDisconnect()}),pe(this,"restart",async()=>{await this.restore(),await this.onRestart()}),pe(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)}),pe(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(gn.pulse,async()=>{await this.checkPending()}),this.events.on(Xt.created,async i=>{const n=Xt.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(Xt.deleted,async i=>{const n=Xt.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=Bt(r,this.name),this.clientId=""}get context(){return Ut(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=va(i);await this.restartToComplete({topic:e,id:r,relay:n}),await this.rpcUnsubscribe(e,r,n);const s=me("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r,i){var n;(!i||i?.transportType===Se.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const s={method:Fs(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(i?.transportType===Se.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(h=>this.logger.warn(h))},V.toMiliseconds(V.ONE_SECOND)),a;const c=new Promise(async h=>{const l=g=>{g.topic===e&&(this.events.removeListener(Xt.created,l),h(g.id))};this.events.on(Xt.created,l);try{const g=await Ei(new Promise((w,b)=>{this.relayer.request(s).catch(E=>{this.logger.warn(E,E?.message),b(E)}).then(w)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Xt.created,l),h(g)}catch{}}),f=await Ei(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!f&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return f?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(bt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Fs(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Ei(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(bt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Fs(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Ei(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(bt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Fs(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,su(Hs({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Hs({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,Hs({},r)),this.topicMap.set(r.topic,e),this.events.emit(Xt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Xt.deleted,su(Hs({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Xt.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(Xt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>su(Hs({},r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await P5(V.toMiliseconds(V.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return ni(e+await this.getClientId())}}var $S=Object.defineProperty,h1=Object.getOwnPropertySymbols,OS=Object.prototype.hasOwnProperty,MS=Object.prototype.propertyIsEnumerable,ou=(t,e,r)=>e in t?$S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d1=(t,e)=>{for(var r in e||(e={}))OS.call(e,r)&&ou(t,r,e[r]);if(h1)for(var r of h1(e))MS.call(e,r)&&ou(t,r,e[r]);return t},fe=(t,e,r)=>ou(t,typeof e!="symbol"?e+"":e,r);class PS extends kb{constructor(e){super(e),fe(this,"protocol","wc"),fe(this,"version",2),fe(this,"core"),fe(this,"logger"),fe(this,"events",new Ot.exports.EventEmitter),fe(this,"provider"),fe(this,"messages"),fe(this,"subscriber"),fe(this,"publisher"),fe(this,"name",dx),fe(this,"transportExplicitlyClosed",!1),fe(this,"initialized",!1),fe(this,"connectionAttemptInProgress",!1),fe(this,"relayUrl"),fe(this,"projectId"),fe(this,"packageName"),fe(this,"bundleId"),fe(this,"hasExperiencedNetworkDisruption",!1),fe(this,"pingTimeout"),fe(this,"heartBeatTimeout",V.toMiliseconds(V.THIRTY_SECONDS+V.FIVE_SECONDS)),fe(this,"reconnectTimeout"),fe(this,"connectPromise"),fe(this,"reconnectInProgress",!1),fe(this,"requestsInFlight",[]),fe(this,"connectTimeout",V.toMiliseconds(V.ONE_SECOND*15)),fe(this,"request",async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||Qi().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=r.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}}),fe(this,"resetPingTimeout",()=>{if(fa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}}),fe(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),fe(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(bt.connect)}),fe(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()}),fe(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(bt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),fe(this,"registerProviderListeners",()=>{this.provider.on(ar.payload,this.onPayloadHandler),this.provider.on(ar.connect,this.onConnectHandler),this.provider.on(ar.disconnect,this.onDisconnectHandler),this.provider.on(ar.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Bt(e.logger,this.name):Hr(ec({level:e.logger||hx})),this.messages=new dS(this.logger,e.core),this.subscriber=new DS(this,this.logger),this.publisher=new vS(this,this.logger),this.relayUrl=e?.relayUrl||Kp,this.projectId=e.projectId,g5()?this.packageName=p0():b5()&&(this.bundleId=p0()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return Ut(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:Se.relay})}async subscribe(e,r){var i,n,s;this.isInitialized(),(!(r!=null&&r.transportType)||r?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=r?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=r?.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const f=h=>{h.topic===e&&(this.subscriber.off(Xt.created,f),c())};return await Promise.all([new Promise(h=>{c=h,this.subscriber.on(Xt.created,f)}),new Promise(async(h,l)=>{a=await this.subscriber.subscribe(e,d1({internal:{throwOnFailedPublish:o}},r)).catch(g=>{o&&l(g)})||a,h()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ei(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Dp())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=at(V.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(bt.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(ar.disconnect,s),await Ei(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(ar.disconnect,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(ar.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(ar.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,V.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(fa())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new J_(new ex(w5({sdkVersion:Xf,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.warn(`Ignoring message for non-subscribed topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Jf(e)){if(!e.method.endsWith(lx))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:Se.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(d1({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else xa(e)&&this.events.emit(bt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(bt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Gf(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(ar.payload,this.onPayloadHandler),this.provider.off(ar.connect,this.onConnectHandler),this.provider.off(ar.disconnect,this.onDisconnectHandler),this.provider.off(ar.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Dp();c_(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(bt.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},V.toMiliseconds(px)))))}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}var RS=Object.defineProperty,l1=Object.getOwnPropertySymbols,TS=Object.prototype.hasOwnProperty,NS=Object.prototype.propertyIsEnumerable,au=(t,e,r)=>e in t?RS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,p1=(t,e)=>{for(var r in e||(e={}))TS.call(e,r)&&au(t,r,e[r]);if(l1)for(var r of l1(e))NS.call(e,r)&&au(t,r,e[r]);return t},Ht=(t,e,r)=>au(t,typeof e!="symbol"?e+"":e,r);class sn extends jb{constructor(e,r,i,n=zr,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,Ht(this,"map",new Map),Ht(this,"version",gx),Ht(this,"cached",[]),Ht(this,"initialized",!1),Ht(this,"getKey"),Ht(this,"storagePrefix",zr),Ht(this,"recentlyDeleted",[]),Ht(this,"recentlyDeletedLimit",200),Ht(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!qt(o)?this.map.set(this.getKey(o),o):q7(o)?this.map.set(o.id,o):z7(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Ht(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),Ht(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Ht(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>tx(a[c],o[c]))):this.values)),Ht(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=p1(p1({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),Ht(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=Bt(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Ut(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=H("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var CS=Object.defineProperty,BS=(t,e,r)=>e in t?CS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ne=(t,e,r)=>BS(t,typeof e!="symbol"?e+"":e,r);class FS{constructor(e,r){this.core=e,this.logger=r,ne(this,"name",wx),ne(this,"version",_x),ne(this,"events",new Ot.exports),ne(this,"pairings"),ne(this,"initialized",!1),ne(this,"storagePrefix",zr),ne(this,"ignoredPayloadTypes",[ii]),ne(this,"registeredMethods",[]),ne(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ne(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),ne(this,"create",async i=>{this.isInitialized();const n=zf(),s=await this.core.crypto.setSymKey(n),o=at(V.FIVE_MINUTES),a={protocol:jp},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},f=mp({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(tn.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:f}}),ne(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Ur.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:f}=vp(i.uri);n.props.properties.topic=s,n.addTrace(Ur.pairing_uri_validation_success),n.addTrace(Ur.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(s)){if(h=this.pairings.get(s),n.addTrace(Ur.existing_pairing),h.active)throw n.setError(ai.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Ur.pairing_not_expired)}const l=c||at(V.FIVE_MINUTES),g={topic:s,relay:a,expiry:l,active:!1,methods:f};this.core.expirer.set(s,l),await this.pairings.set(s,g),n.addTrace(Ur.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(tn.create,g),n.addTrace(Ur.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Ur.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ai.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(w){throw n.setError(ai.subscribe_pairing_topic_failure),w}return n.addTrace(Ur.subscribe_pairing_topic_success),g}),ne(this,"activate",async({topic:i})=>{this.isInitialized();const n=at(V.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),ne(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Ji();this.events.once(ue("pairing_ping",s),({error:f})=>{f?c(f):a()}),await o()}}),ne(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),ne(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),ne(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ne(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",me("USER_DISCONNECTED")),await this.deletePairing(n))}),ne(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return mp({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),ne(this,"sendRequest",async(i,n,s)=>{const o=en(n,s),a=await this.core.crypto.encode(i,o),c=ks[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),ne(this,"sendResult",async(i,n,s)=>{const o=Gf(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,f=ks[c].res;await this.core.relayer.publish(n,a,f),await this.core.history.resolve(o)}),ne(this,"sendError",async(i,n,s)=>{const o=Yf(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,f=ks[c]?ks[c].res:ks.unregistered_method.res;await this.core.relayer.publish(n,a,f),await this.core.history.resolve(o)}),ne(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,me("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),ne(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>Si(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),ne(this,"onRelayEventRequest",i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}}),ne(this,"onRelayEventResponse",async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}}),ne(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(tn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),ne(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{qr(n)?this.events.emit(ue("pairing_ping",s),{}):or(n)&&this.events.emit(ue("pairing_ping",s),{error:n.error})},500)}),ne(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(tn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),ne(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=me("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}}),ne(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(me("WC_METHOD_UNSUPPORTED",i))}),ne(this,"isValidPair",(i,n)=>{var s;if(!Vt(i)){const{message:a}=H("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ai.malformed_pairing_uri),new Error(a)}if(!L7(i.uri)){const{message:a}=H("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ai.malformed_pairing_uri),new Error(a)}const o=vp(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=H("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ai.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=H("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ai.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&V.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(ai.pairing_expired);const{message:a}=H("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ne(this,"isValidPing",async i=>{if(!Vt(i)){const{message:s}=H("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),ne(this,"isValidDisconnect",async i=>{if(!Vt(i)){const{message:s}=H("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),ne(this,"isValidPairingTopic",async i=>{if(!nt(i,!1)){const{message:n}=H("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=H("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Si(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=H("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=Bt(r,this.name),this.pairings=new sn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ut(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(bt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===Se.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{Jf(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):xa(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(cr.expired,async e=>{const{topic:r}=w0(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(tn.expire,{topic:r}))})}}var LS=Object.defineProperty,qS=(t,e,r)=>e in t?LS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,At=(t,e,r)=>qS(t,typeof e!="symbol"?e+"":e,r);class zS extends qb{constructor(e,r){super(e,r),this.core=e,this.logger=r,At(this,"records",new Map),At(this,"events",new Ot.exports.EventEmitter),At(this,"name",xx),At(this,"version",Ex),At(this,"cached",[]),At(this,"initialized",!1),At(this,"storagePrefix",zr),At(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),At(this,"set",(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:at(V.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(vr.created,o)}),At(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=or(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(vr.updated,n))}),At(this,"get",async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n))),At(this,"delete",(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(vr.deleted,s)}}),this.persist()}),At(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),At(this,"on",(i,n)=>{this.events.on(i,n)}),At(this,"once",(i,n)=>{this.events.once(i,n)}),At(this,"off",(i,n)=>{this.events.off(i,n)}),At(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Bt(r,this.name)}get context(){return Ut(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:en(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(vr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(vr.created,e=>{const r=vr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(vr.updated,e=>{const r=vr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(vr.deleted,e=>{const r=vr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(gn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{V.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(vr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var US=Object.defineProperty,kS=(t,e,r)=>e in t?US(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tt=(t,e,r)=>kS(t,typeof e!="symbol"?e+"":e,r);class jS extends Vb{constructor(e,r){super(e,r),this.core=e,this.logger=r,Tt(this,"expirations",new Map),Tt(this,"events",new Ot.exports.EventEmitter),Tt(this,"name",Sx),Tt(this,"version",Ix),Tt(this,"cached",[]),Tt(this,"initialized",!1),Tt(this,"storagePrefix",zr),Tt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Tt(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),Tt(this,"set",(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(cr.created,{target:s,expiration:o})}),Tt(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),Tt(this,"del",i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(cr.deleted,{target:n,expiration:s})}}),Tt(this,"on",(i,n)=>{this.events.on(i,n)}),Tt(this,"once",(i,n)=>{this.events.once(i,n)}),Tt(this,"off",(i,n)=>{this.events.off(i,n)}),Tt(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Bt(r,this.name)}get context(){return Ut(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return _5(e);if(typeof e=="number")return x5(e);const{message:r}=H("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(cr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;V.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(cr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(gn.pulse,()=>this.checkExpirations()),this.events.on(cr.created,e=>{const r=cr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(cr.expired,e=>{const r=cr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(cr.deleted,e=>{const r=cr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var KS=Object.defineProperty,VS=(t,e,r)=>e in t?KS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,st=(t,e,r)=>VS(t,typeof e!="symbol"?e+"":e,r);class HS extends Hb{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,st(this,"name",Ax),st(this,"abortController"),st(this,"isDevEnv"),st(this,"verifyUrlV3",$x),st(this,"storagePrefix",zr),st(this,"version",zp),st(this,"publicKey"),st(this,"fetchPromise"),st(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&V.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),st(this,"register",async n=>{if(!As()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const f=ds(),h=this.startAbortTimer(V.ONE_SECOND*5),l=await new Promise((g,w)=>{const b=()=>{window.removeEventListener("message",A),f.body.removeChild(E),w("attestation aborted")};this.abortController.signal.addEventListener("abort",b);const E=f.createElement("iframe");E.src=c,E.style.display="none",E.addEventListener("error",b,{signal:this.abortController.signal});const A=$=>{if($.data&&typeof $.data=="string")try{const M=JSON.parse($.data);if(M.type==="verify_attestation"){if(_c(M.attestation).payload.id!==o)return;clearInterval(h),f.body.removeChild(E),this.abortController.signal.removeEventListener("abort",b),window.removeEventListener("message",A),g(M.attestation===null?"":M.attestation)}}catch(M){this.logger.warn(M)}};f.body.appendChild(E),window.addEventListener("message",A,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",l),l}catch(f){this.logger.warn(f)}return""}),st(this,"resolve",async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(_c(s).payload.id!==a)return;const f=await this.isValidJwtAttestation(s);if(f){if(!f.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return f}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),st(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(V.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),st(this,"getVerifyUrl",n=>{let s=n||js;return Ox.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${js}`),s=js),s}),st(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(V.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}}),st(this,"persistPublicKey",async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n}),st(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),st(this,"isValidJwtAttestation",async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),st(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),st(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n}),st(this,"validateAttestation",(n,s)=>{const o=I7(n,s.publicKey),a={hasExpired:V.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=Bt(r,this.name),this.abortController=new AbortController,this.isDevEnv=_f(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Ut(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),V.toMiliseconds(e))}}var WS=Object.defineProperty,GS=(t,e,r)=>e in t?WS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g1=(t,e,r)=>GS(t,typeof e!="symbol"?e+"":e,r);class YS extends Wb{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,g1(this,"context",Mx),g1(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${Px}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})}),this.logger=Bt(r,this.context)}}var JS=Object.defineProperty,b1=Object.getOwnPropertySymbols,ZS=Object.prototype.hasOwnProperty,XS=Object.prototype.propertyIsEnumerable,cu=(t,e,r)=>e in t?JS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ws=(t,e)=>{for(var r in e||(e={}))ZS.call(e,r)&&cu(t,r,e[r]);if(b1)for(var r of b1(e))XS.call(e,r)&&cu(t,r,e[r]);return t},yt=(t,e,r)=>cu(t,typeof e!="symbol"?e+"":e,r);class QS extends Gb{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,yt(this,"context",Tx),yt(this,"storagePrefix",zr),yt(this,"storageVersion",Rx),yt(this,"events",new Map),yt(this,"shouldPersist",!1),yt(this,"init",async()=>{if(!_f())try{const n={eventId:x0(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:b0(this.core.relayer.protocol,this.core.relayer.version,Xf)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),yt(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,f=x0(),h=this.core.projectId||"",l=Date.now(),g=Ws({eventId:f,timestamp:l,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:h,domain:this.getAppDomain()},this.setMethods(f));return this.telemetryEnabled&&(this.events.set(f,g),this.shouldPersist=!0),g}),yt(this,"getEvent",n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Ws(Ws({},a),this.setMethods(a.eventId))}),yt(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),yt(this,"setEventListeners",()=>{this.core.heartbeat.on(gn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{V.fromMiliseconds(Date.now())-V.fromMiliseconds(n.timestamp)>Nx&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),yt(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),yt(this,"addTrace",(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)}),yt(this,"setError",(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)}),yt(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),yt(this,"restore",async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Ws(Ws({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),yt(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}}),yt(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${Cx}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Xf}${s}`,{method:"POST",body:JSON.stringify(n)})}),yt(this,"getAppDomain",()=>g0().url),this.logger=Bt(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var eI=Object.defineProperty,y1=Object.getOwnPropertySymbols,tI=Object.prototype.hasOwnProperty,rI=Object.prototype.propertyIsEnumerable,fu=(t,e,r)=>e in t?eI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v1=(t,e)=>{for(var r in e||(e={}))tI.call(e,r)&&fu(t,r,e[r]);if(y1)for(var r of y1(e))rI.call(e,r)&&fu(t,r,e[r]);return t},we=(t,e,r)=>fu(t,typeof e!="symbol"?e+"":e,r);class uu extends Cb{constructor(e){var r;super(e),we(this,"protocol",qp),we(this,"version",zp),we(this,"name",Ea),we(this,"relayUrl"),we(this,"projectId"),we(this,"customStoragePrefix"),we(this,"events",new Ot.exports.EventEmitter),we(this,"logger"),we(this,"heartbeat"),we(this,"relayer"),we(this,"crypto"),we(this,"storage"),we(this,"history"),we(this,"expirer"),we(this,"pairing"),we(this,"verify"),we(this,"echoClient"),we(this,"linkModeSupportedApps"),we(this,"eventClient"),we(this,"initialized",!1),we(this,"logChunkController"),we(this,"on",(o,a)=>this.events.on(o,a)),we(this,"once",(o,a)=>this.events.once(o,a)),we(this,"off",(o,a)=>this.events.off(o,a)),we(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),we(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const f={topic:o,message:a,publishedAt:Date.now(),transportType:Se.link_mode};this.relayer.onLinkMessageEvent(f,{sessionExists:c})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Kp,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=ec({level:typeof e?.logger=="string"&&e.logger?e.logger:rx.logger,name:Ea}),{logger:n,chunkLoggerController:s}=Rb({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Bt(n,this.name),this.heartbeat=new Wa,this.crypto=new fS(this,this.logger,e?.keychain),this.history=new zS(this,this.logger),this.expirer=new jS(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new nb(v1(v1({},ix),e?.storageOptions)),this.relayer=new PS({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new FS(this,this.logger),this.verify=new HS(this,this.logger,this.storage),this.echoClient=new YS(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new QS(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new uu(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(bx,i),r}get context(){return Ut(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Vp,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Vp)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const hu=uu,m1="wc",w1=2,_1="client",du=`${m1}@${w1}:${_1}:`,lu={name:_1,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},x1="WALLETCONNECT_DEEPLINK_CHOICE",iI="proposal",E1="Proposal expired",nI="session",Qn=V.SEVEN_DAYS,sI="engine",vt={wc_sessionPropose:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1104},res:{ttl:V.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1106},res:{ttl:V.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1112},res:{ttl:V.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1114},res:{ttl:V.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:V.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:V.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1119}}},pu={min:V.FIVE_MINUTES,max:V.SEVEN_DAYS},Kr={idle:"IDLE",active:"ACTIVE"},S1={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},oI="request",aI=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],cI="wc",fI="auth",uI="authKeys",hI="pairingTopics",dI="requests",Aa=`${cI}@${1.5}:${fI}:`,Da=`${Aa}:PUB_KEY`;var lI=Object.defineProperty,pI=Object.defineProperties,gI=Object.getOwnPropertyDescriptors,I1=Object.getOwnPropertySymbols,bI=Object.prototype.hasOwnProperty,yI=Object.prototype.propertyIsEnumerable,gu=(t,e,r)=>e in t?lI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Be=(t,e)=>{for(var r in e||(e={}))bI.call(e,r)&&gu(t,r,e[r]);if(I1)for(var r of I1(e))yI.call(e,r)&&gu(t,r,e[r]);return t},Wt=(t,e)=>pI(t,gI(e)),K=(t,e,r)=>gu(t,typeof e!="symbol"?e+"":e,r);class vI extends Xb{constructor(e){super(e),K(this,"name",sI),K(this,"events",new Ot.exports),K(this,"initialized",!1),K(this,"requestQueue",{state:Kr.idle,queue:[]}),K(this,"sessionRequestQueue",{state:Kr.idle,queue:[]}),K(this,"requestQueueDelay",V.ONE_SECOND),K(this,"expectedPairingMethodMap",new Map),K(this,"recentlyDeletedMap",new Map),K(this,"recentlyDeletedLimit",200),K(this,"relayMessageCache",[]),K(this,"pendingSessions",new Map),K(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(vt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay)))}),K(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Wt(Be({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let f=n,h,l=!1;try{if(f){const N=this.client.core.pairing.pairings.get(f);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),l=N.active}}catch(N){throw this.client.logger.error(`connect() -> pairing.get(${f}) failed`),N}if(!f||!l){const{topic:N,uri:L}=await this.client.core.pairing.create();f=N,h=L}if(!f){const{message:N}=H("NO_MATCHING_KEY",`connect() pairing topic: ${f}`);throw new Error(N)}const g=await this.client.core.crypto.generateKeyPair(),w=vt.wc_sessionPropose.req.ttl||V.FIVE_MINUTES,b=at(w),E=Wt(Be({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:jp}],proposer:{publicKey:g,metadata:this.client.metadata},expiryTimestamp:b,pairingTopic:f},a&&{sessionProperties:a}),{id:Lr()}),A=ue("session_connect",E.id),{reject:$,resolve:M,done:P}=Ji(w,E1),R=({id:N})=>{N===E.id&&(this.client.events.off("proposal_expire",R),this.pendingSessions.delete(E.id),this.events.emit(A,{error:{message:E1,code:0}}))};return this.client.events.on("proposal_expire",R),this.events.once(A,({error:N,session:L})=>{this.client.events.off("proposal_expire",R),N?$(N):L&&M(L)}),await this.sendRequest({topic:f,method:"wc_sessionPropose",params:E,throwOnFailedPublish:!0,clientRpcId:E.id}),await this.setProposal(E.id,E),{uri:h,approval:P}}),K(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}}),K(this,"approve",async r=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[mr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(B){throw o.setError(rn.no_internet_connection),B}try{await this.isValidProposalId(r?.id)}catch(B){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(rn.proposal_not_found),B}try{await this.isValidApprove(r)}catch(B){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(rn.session_approve_namespace_validation_failure),B}const{id:a,relayProtocol:c,namespaces:f,sessionProperties:h,sessionConfig:l}=r,g=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:w,proposer:b,requiredNamespaces:E,optionalNamespaces:A}=g;let $=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:w});$||($=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:mr.session_approve_started,properties:{topic:w,trace:[mr.session_approve_started,mr.session_namespaces_validation_success]}}));const M=await this.client.core.crypto.generateKeyPair(),P=b.publicKey,R=await this.client.core.crypto.generateSharedKey(M,P),N=Be(Be({relay:{protocol:c??"irn"},namespaces:f,controller:{publicKey:M,metadata:this.client.metadata},expiry:at(Qn)},h&&{sessionProperties:h}),l&&{sessionConfig:l}),L=Se.relay;$.addTrace(mr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(R,{transportType:L})}catch(B){throw $.setError(rn.subscribe_session_topic_failure),B}$.addTrace(mr.subscribe_session_topic_success);const F=Wt(Be({},N),{topic:R,requiredNamespaces:E,optionalNamespaces:A,pairingTopic:w,acknowledged:!1,self:N.controller,peer:{publicKey:b.publicKey,metadata:b.metadata},controller:M,transportType:Se.relay});await this.client.session.set(R,F),$.addTrace(mr.store_session);try{$.addTrace(mr.publishing_session_settle),await this.sendRequest({topic:R,method:"wc_sessionSettle",params:N,throwOnFailedPublish:!0}).catch(B=>{throw $?.setError(rn.session_settle_publish_failure),B}),$.addTrace(mr.session_settle_publish_success),$.addTrace(mr.publishing_session_approve),await this.sendResult({id:a,topic:w,result:{relay:{protocol:c??"irn"},responderPublicKey:M},throwOnFailedPublish:!0}).catch(B=>{throw $?.setError(rn.session_approve_publish_failure),B}),$.addTrace(mr.session_approve_publish_success)}catch(B){throw this.client.logger.error(B),this.client.session.delete(R,me("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(R),B}return this.client.core.eventClient.deleteEvent({eventId:$.eventId}),await this.client.core.pairing.updateMetadata({topic:w,metadata:b.metadata}),await this.client.proposal.delete(a,me("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:w}),await this.setExpiry(R,at(Qn)),{topic:R,acknowledged:()=>Promise.resolve(this.client.session.get(R))}}),K(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:vt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,me("USER_DISCONNECTED")))}),K(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(l){throw this.client.logger.error("update() -> isValidUpdate() failed"),l}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=Ji(),c=Lr(),f=Qi().toString(),h=this.client.session.get(i).namespaces;return this.events.once(ue("session_update",c),({error:l})=>{l?a(l):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:f}).catch(l=>{this.client.logger.error(l),this.client.session.update(i,{namespaces:h}),a(l)}),{acknowledged:s}}),K(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,n=Lr(),{done:s,resolve:o,reject:a}=Ji();return this.events.once(ue("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,at(Qn)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),K(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch($){throw this.client.logger.error("request() -> isValidRequest() failed"),$}const{chainId:i,request:n,topic:s,expiry:o=vt.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===Se.relay&&await this.confirmOnlineStateOrThrow();const c=Lr(),f=Qi().toString(),{done:h,resolve:l,reject:g}=Ji(o,"Request expired. Please try again.");this.events.once(ue("session_request",c),({error:$,result:M})=>{$?g($):l(M)});const w="wc_sessionRequest",b=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(b)return await this.sendRequest({clientRpcId:c,relayRpcId:f,topic:s,method:w,params:{request:Wt(Be({},n),{expiryTimestamp:at(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:b}).catch($=>g($)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await h();const E={request:Wt(Be({},n),{expiryTimestamp:at(o)}),chainId:i},A=this.shouldSetTVF(w,E);return await Promise.all([new Promise(async $=>{await this.sendRequest(Be({clientRpcId:c,relayRpcId:f,topic:s,method:w,params:E,expiry:o,throwOnFailedPublish:!0},A&&{tvf:this.getTVFParams(c,E)})).catch(M=>g(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),$()}),new Promise(async $=>{var M;if(!((M=a.sessionConfig)!=null&&M.disableDeepLink)){const P=await D5(this.client.core.storage,x1);await S5({id:c,topic:s,wcDeepLink:P})}$()}),h()]).then($=>$[2])}),K(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n,o=this.client.session.get(i);o.transportType===Se.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);qr(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):or(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)}),K(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=Lr(),s=Qi().toString(),{done:o,resolve:a,reject:c}=Ji();this.events.once(ue("session_ping",n),({error:f})=>{f?c(f):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),K(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=Qi().toString(),a=Lr();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),K(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:me("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=H("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),K(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>B7(i,r)))),K(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),K(this,"authenticate",async(r,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(r);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?Se.link_mode:Se.relay;o===Se.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:f,domain:h,nonce:l,type:g,exp:w,nbf:b,methods:E=[],expiry:A}=r,$=[...r.resources||[]],{topic:M,uri:P}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:M,uri:P}});const R=await this.client.core.crypto.generateKeyPair(),N=ya(R);if(await Promise.all([this.client.auth.authKeys.set(Da,{responseTopic:N,publicKey:R}),this.client.auth.pairingTopics.set(N,{topic:N,pairingTopic:M})]),await this.client.core.relayer.subscribe(N,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${M}`),E.length>0){const{namespace:_}=ca(a[0]);let d=b9(_,"request",E);la($)&&(d=v9(d,$.pop())),$.push(d)}const L=A&&A>vt.wc_sessionAuthenticate.req.ttl?A:vt.wc_sessionAuthenticate.req.ttl,F={authPayload:{type:g??"caip122",chains:a,statement:c,aud:f,domain:h,version:"1",nonce:l,iat:new Date().toISOString(),exp:w,nbf:b,resources:$},requester:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:at(L)},B={eip155:{chains:a,methods:[...new Set(["personal_sign",...E])],events:["chainChanged","accountsChanged"]}},C={requiredNamespaces:{},optionalNamespaces:B,relays:[{protocol:"irn"}],pairingTopic:M,proposer:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:at(vt.wc_sessionPropose.req.ttl),id:Lr()},{done:W,resolve:I,reject:u}=Ji(L,"Request expired"),p=Lr(),v=ue("session_connect",C.id),y=ue("session_request",p),m=async({error:_,session:d})=>{this.events.off(y,S),_?u(_):d&&I({session:d})},S=async _=>{var d,x,q;if(await this.deletePendingAuthRequest(p,{message:"fulfilled",code:0}),_.error){const J=me("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return _.error.code===J.code?void 0:(this.events.off(v,m),u(_.error.message))}await this.deleteProposal(C.id),this.events.off(v,m);const{cacaos:z,responder:U}=_.result,k=[],G=[];for(const J of z){await F0({cacao:J,projectId:this.client.core.projectId})||(this.client.logger.error(J,"Signature verification failed"),u(me("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Q}=J,Fe=la(Q.resources),re=[Df(Q.iss)],oe=da(Q.iss);if(Fe){const ct=z0(Fe),he=U0(Fe);k.push(...ct),re.push(...he)}for(const ct of re)G.push(`${ct}:${oe}`)}const Z=await this.client.core.crypto.generateSharedKey(R,U.publicKey);let X;k.length>0&&(X={topic:Z,acknowledged:!0,self:{publicKey:R,metadata:this.client.metadata},peer:U,controller:U.publicKey,expiry:at(Qn),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:M,namespaces:wp([...new Set(k)],[...new Set(G)]),transportType:o},await this.client.core.relayer.subscribe(Z,{transportType:o}),await this.client.session.set(Z,X),M&&await this.client.core.pairing.updateMetadata({topic:M,metadata:U.metadata}),X=this.client.session.get(Z)),(d=this.client.metadata.redirect)!=null&&d.linkMode&&(x=U.metadata.redirect)!=null&&x.linkMode&&(q=U.metadata.redirect)!=null&&q.universal&&i&&(this.client.core.addLinkModeSupportedApp(U.metadata.redirect.universal),this.client.session.update(Z,{transportType:Se.link_mode})),I({auths:z,session:X})};this.events.once(v,m),this.events.once(y,S);let D;try{if(s){const _=en("wc_sessionAuthenticate",F,p);this.client.core.history.set(M,_);const d=await this.client.core.crypto.encode("",_,{type:Ns,encoding:Rs});D=ma(i,M,d)}else await Promise.all([this.sendRequest({topic:M,method:"wc_sessionAuthenticate",params:F,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:p}),this.sendRequest({topic:M,method:"wc_sessionPropose",params:C,expiry:vt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:C.id})])}catch(_){throw this.events.off(v,m),this.events.off(y,S),_}return await this.setProposal(C.id,C),await this.setAuthRequest(p,{request:Wt(Be({},F),{verifyContext:{}}),pairingTopic:M,transportType:o}),{uri:D??P,response:W}}),K(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[nn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(A){throw s.setError(Ks.no_internet_connection),A}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ks.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||Se.relay;a===Se.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),h=ya(c),l={type:ii,receiverPublicKey:c,senderPublicKey:f},g=[],w=[];for(const A of n){if(!await F0({cacao:A,projectId:this.client.core.projectId})){s.setError(Ks.invalid_cacao);const N=me("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:h,error:N,encodeOpts:l}),new Error(N.message)}s.addTrace(nn.cacaos_verified);const{p:$}=A,M=la($.resources),P=[Df($.iss)],R=da($.iss);if(M){const N=z0(M),L=U0(M);g.push(...N),P.push(...L)}for(const N of P)w.push(`${N}:${R}`)}const b=await this.client.core.crypto.generateSharedKey(f,c);s.addTrace(nn.create_authenticated_session_topic);let E;if(g?.length>0){E={topic:b,acknowledged:!0,self:{publicKey:f,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:at(Qn),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:wp([...new Set(g)],[...new Set(w)]),transportType:a},s.addTrace(nn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(b,{transportType:a})}catch(A){throw s.setError(Ks.subscribe_authenticated_session_topic_failure),A}s.addTrace(nn.subscribe_authenticated_session_topic_success),await this.client.session.set(b,E),s.addTrace(nn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(nn.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:i,result:{cacaos:n,responder:{publicKey:f,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(A){throw s.setError(Ks.authenticated_session_approve_publish_failure),A}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:E}}),K(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===Se.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=ya(o),f={type:ii,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:f,rpcOpts:vt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,me("USER_DISCONNECTED"))}),K(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return L0(i,n)}),K(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),K(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),K(this,"deleteSession",async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,me("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(x1).catch(f=>this.client.logger.warn(f)),this.getPendingSessionRequests().forEach(f=>{f.topic===n&&this.deletePendingSessionRequest(f.id,me("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Kr.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),K(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(rn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,me("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),K(this,"deletePendingSessionRequest",async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=Kr.idle,this.client.events.emit("session_request_expire",{id:r}))}),K(this,"deletePendingAuthRequest",async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])}),K(this,"setExpiry",async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))}),K(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,at(vt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),K(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=Se.relay}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})}),K(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||at(vt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})}),K(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:f,appLink:h,tvf:l}=r,g=en(n,s,c);let w;const b=!!h;try{const $=b?Rs:$i;w=await this.client.core.crypto.encode(i,g,{encoding:$})}catch($){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),$}let E;if(aI.includes(n)){const $=ni(JSON.stringify(g)),M=ni(w);E=await this.client.core.verify.register({id:M,decryptedId:$})}const A=vt[n].req;if(A.attestation=E,o&&(A.ttl=o),a&&(A.id=a),this.client.core.history.set(i,g),b){const $=ma(h,i,w);await global.Linking.openURL($,this.client.name)}else{const $=vt[n].req;o&&($.ttl=o),a&&($.id=a),$.tvf=Wt(Be({},l),{correlationId:g.id}),f?($.internal=Wt(Be({},$.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,w,$)):this.client.core.relayer.publish(i,w,$).catch(M=>this.client.logger.error(M))}return g.id}),K(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,f=Gf(i,s);let h;const l=c&&typeof(global==null?void 0:global.Linking)<"u";try{const b=l?Rs:$i;h=await this.client.core.crypto.encode(n,f,Wt(Be({},a||{}),{encoding:b}))}catch(b){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),b}let g,w;try{g=await this.client.core.history.get(n,i);const b=g.request;try{this.shouldSetTVF(b.method,b.params)&&(w=this.getTVFParams(i,b.params,s))}catch(E){this.client.logger.warn("sendResult() -> getTVFParams() failed",E)}}catch(b){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),b}if(l){const b=ma(c,n,h);await global.Linking.openURL(b,this.client.name)}else{const b=g.request.method,E=vt[b].res;E.tvf=Wt(Be({},w),{correlationId:i}),o?(E.internal=Wt(Be({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,h,E)):this.client.core.relayer.publish(n,h,E).catch(A=>this.client.logger.error(A))}await this.client.core.history.resolve(f)}),K(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,f=Yf(i,s);let h;const l=c&&typeof(global==null?void 0:global.Linking)<"u";try{const w=l?Rs:$i;h=await this.client.core.crypto.encode(n,f,Wt(Be({},o||{}),{encoding:w}))}catch(w){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),w}let g;try{g=await this.client.core.history.get(n,i)}catch(w){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),w}if(l){const w=ma(c,n,h);await global.Linking.openURL(w,this.client.name)}else{const w=g.request.method,b=a||vt[w].res;this.client.core.relayer.publish(n,h,b)}await this.client.core.history.resolve(f)}),K(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Si(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Si(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),K(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),K(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Kr.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Kr.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Kr.idle}),K(this,"processRequest",async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=r,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),K(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n,transportType:s}=r,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),K(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=H("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),K(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),K(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const f=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),f?.setError(ai.proposal_listener_not_found)),this.isValidConnect(Be({},n.params));const h=a.expiryTimestamp||at(vt.wc_sessionPropose.req.ttl),l=Be({id:c,pairingTopic:i,expiryTimestamp:h},a);await this.setProposal(c,l);const g=await this.getVerifyContext({attestationId:s,hash:ni(JSON.stringify(n)),encryptedId:o,metadata:l.proposer.metadata});f?.addTrace(Ur.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:g})}catch(f){await this.sendError({id:c,topic:i,error:f,rpcOpts:vt.wc_sessionPropose.autoReject}),this.client.logger.error(f)}}),K(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(qr(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const f=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:f});const h=await this.client.core.crypto.generateSharedKey(c,f);this.pendingSessions.set(s,{sessionTopic:h,pairingTopic:r,proposalId:s,publicKey:c});const l=await this.client.core.relayer.subscribe(h,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else if(or(i)){await this.client.proposal.delete(s,me("USER_DISCONNECTED"));const o=ue("session_connect",s);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),K(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:f,sessionProperties:h,sessionConfig:l}=i.params,g=[...this.pendingSessions.values()].find(E=>E.sessionTopic===r);if(!g)return this.client.logger.error(`Pending session not found for topic ${r}`);const w=this.client.proposal.get(g.proposalId),b=Wt(Be(Be({topic:r,relay:o,expiry:c,namespaces:f,acknowledged:!0,pairingTopic:g.pairingTopic,requiredNamespaces:w.requiredNamespaces,optionalNamespaces:w.optionalNamespaces,controller:a.publicKey,self:{publicKey:g.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},h&&{sessionProperties:h}),l&&{sessionConfig:l}),{transportType:Se.relay});await this.client.session.set(b.topic,b),await this.setExpiry(b.topic,b.expiry),await this.client.core.pairing.updateMetadata({topic:g.pairingTopic,metadata:b.peer.metadata}),this.client.events.emit("session_connect",{session:b}),this.events.emit(ue("session_connect",g.proposalId),{session:b}),this.pendingSessions.delete(g.proposalId),this.deleteProposal(g.proposalId,!1),this.cleanupDuplicatePairings(b),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),K(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;qr(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ue("session_approve",n),{})):or(i)&&(await this.client.session.delete(r,me("USER_DISCONNECTED")),this.events.emit(ue("session_approve",n),{error:i.error}))}),K(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=qs.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:me("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Be({topic:r},n));try{qs.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw qs.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),K(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),K(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=ue("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);qr(i)?this.events.emit(ue("session_update",n),{}):or(i)&&this.events.emit(ue("session_update",n),{error:i.error})}),K(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,at(Qn)),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),K(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=ue("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);qr(i)?this.events.emit(ue("session_extend",n),{}):or(i)&&this.events.emit(ue("session_extend",n),{error:i.error})}),K(this,"onSessionPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),K(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=ue("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{qr(i)?this.events.emit(ue("session_ping",n),{}):or(i)&&this.events.emit(ue("session_ping",n),{error:i.error})},500)}),K(this,"onSessionDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(bt.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:me("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),K(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:f,transportType:h}=r,{id:l,params:g}=a;try{await this.isValidRequest(Be({topic:o},g));const w=this.client.session.get(o),b=await this.getVerifyContext({attestationId:c,hash:ni(JSON.stringify(en("wc_sessionRequest",g,l))),encryptedId:f,metadata:w.peer.metadata,transportType:h}),E={id:l,topic:o,params:g,verifyContext:b};await this.setPendingSessionRequest(E),h===Se.link_mode&&(i=w.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=w.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(E):(this.addSessionRequestToSessionRequestQueue(E),this.processSessionRequestQueue())}catch(w){await this.sendError({id:l,topic:o,error:w}),this.client.logger.error(w)}}),K(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=ue("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);qr(i)?this.events.emit(ue("session_request",n),{result:i.result}):or(i)&&this.events.emit(ue("session_request",n),{error:i.error})}),K(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=qs.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(Be({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),qs.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),K(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),qr(i)?this.events.emit(ue("session_request",n),{result:i.result}):or(i)&&this.events.emit(ue("session_request",n),{error:i.error})}),K(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:f,authPayload:h,expiryTimestamp:l}=s.params,g=await this.getVerifyContext({attestationId:o,hash:ni(JSON.stringify(s)),encryptedId:a,metadata:f.metadata,transportType:c}),w={requester:f,pairingTopic:n,id:s.id,authPayload:h,verifyContext:g,expiryTimestamp:l};await this.setAuthRequest(s.id,{request:w,pairingTopic:n,transportType:c}),c===Se.link_mode&&(i=f.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(f.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:g})}catch(f){this.client.logger.error(f);const h=s.params.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),g=this.getAppLinkIfEnabled(s.params.requester.metadata,c),w={type:ii,receiverPublicKey:h,senderPublicKey:l};await this.sendError({id:s.id,topic:n,error:f,encodeOpts:w,rpcOpts:vt.wc_sessionAuthenticate.autoReject,appLink:g})}}),K(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),K(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Kr.idle,this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay))}),K(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=ue("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(ue("session_request",s.request.id),{error:i})})}),K(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Kr.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Kr.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),K(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),K(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:en("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),K(this,"isValidConnect",async r=>{if(!Vt(r)){const{message:c}=H("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(qt(i)||await this.isValidPairingTopic(i),!G7(a,!0)){const{message:c}=H("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!qt(n)&&wa(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!qt(s)&&wa(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),qt(o)||this.validateSessionProps(o,"sessionProperties")}),K(this,"validateNamespaces",(r,i)=>{const n=W7(r,"connect()",i);if(n)throw new Error(n.message)}),K(this,"isValidApprove",async r=>{if(!Vt(r))throw new Error(H("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=kf(n,"approve()");if(c)throw new Error(c.message);const f=Ip(a.requiredNamespaces,n,"approve()");if(f)throw new Error(f.message);if(!nt(s,!0)){const{message:h}=H("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}qt(o)||this.validateSessionProps(o,"sessionProperties")}),K(this,"isValidReject",async r=>{if(!Vt(r)){const{message:s}=H("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!J7(n)){const{message:s}=H("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),K(this,"isValidSessionSettleRequest",r=>{if(!Vt(r)){const{message:f}=H("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(f)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Ep(i)){const{message:f}=H("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const a=U7(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=kf(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Si(o)){const{message:f}=H("EXPIRED","onSessionSettleRequest()");throw new Error(f)}}),K(this,"isValidUpdate",async r=>{if(!Vt(r)){const{message:c}=H("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=kf(n,"update()");if(o)throw new Error(o.message);const a=Ip(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),K(this,"isValidExtend",async r=>{if(!Vt(r)){const{message:n}=H("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),K(this,"isValidRequest",async r=>{if(!Vt(r)){const{message:c}=H("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Sp(a,s)){const{message:c}=H("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!Z7(n)){const{message:c}=H("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!e_(a,s,n.method)){const{message:c}=H("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!n_(o,pu)){const{message:c}=H("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${pu.min} and ${pu.max}`);throw new Error(c)}}),K(this,"isValidRespond",async r=>{var i;if(!Vt(r)){const{message:o}=H("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!X7(s)){const{message:o}=H("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),K(this,"isValidPing",async r=>{if(!Vt(r)){const{message:n}=H("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),K(this,"isValidEmit",async r=>{if(!Vt(r)){const{message:a}=H("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Sp(o,s)){const{message:a}=H("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Q7(n)){const{message:a}=H("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!t_(o,s,n.name)){const{message:a}=H("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),K(this,"isValidDisconnect",async r=>{if(!Vt(r)){const{message:n}=H("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),K(this,"isValidAuthenticate",r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!nt(n,!1))throw new Error("uri is required parameter");if(!nt(s,!1))throw new Error("domain is required parameter");if(!nt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>ca(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ca(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),K(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||js,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Se.link_mode){const h=this.getAppLinkIfEnabled(o,a);return c.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",c}const f=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});f&&(c.verified.origin=f.origin,c.verified.isScam=f.isScam,c.verified.validation=f.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(f){this.client.logger.warn(f)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),K(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach(n=>{if(!nt(n,!1)){const{message:s}=H("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})}),K(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),K(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}}),K(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=H("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),K(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,f,h,l,g;return!r||i!==Se.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((f=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:f.universal)!==""&&((h=r?.redirect)==null?void 0:h.universal)!==void 0&&((l=r?.redirect)==null?void 0:l.universal)!==""&&((g=r?.redirect)==null?void 0:g.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),K(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),K(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=_0(r,"topic")||"",n=decodeURIComponent(_0(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:Se.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),K(this,"registerLinkModeListeners",async()=>{var r;if(_f()||xi()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}),K(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:n}=i;return Object.keys(S1).includes(n.method)}),K(this,"getTVFParams",(r,i,n)=>{var s,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,n);return Wt(Be({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(s=i.request.params)==null?void 0:s[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),K(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const n=r?.data||((i=r?.[0])==null?void 0:i.data);if(!n.startsWith("0x"))return!1;const s=n.slice(2);return/^[0-9a-fA-F]*$/.test(s)?s.length%2===0:!1}catch{}return!1}),K(this,"extractTxHashesFromResult",(r,i)=>{try{const n=S1[r];if(typeof i=="string")return[i];const s=i[n.key];if(Ls(s))return s;if(typeof s=="string")return[s]}catch(n){this.client.logger.warn("Error extracting tx hashes from result",n)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(bt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Da)?this.client.auth.authKeys.get(Da):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===Se.link_mode?Rs:$i});try{Jf(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:ni(i)})):xa(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(cr.expired,async e=>{const{topic:r,id:i}=w0(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,H("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,H("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(tn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(tn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!nt(e,!1)){const{message:r}=H("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=H("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Si(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=H("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!nt(e,!1)){const{message:r}=H("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=H("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Si(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=H("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=H("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(nt(e,!1)){const{message:r}=H("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=H("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!Y7(e)){const{message:r}=H("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=H("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Si(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=H("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class mI extends sn{constructor(e,r){super(e,r,iI,du),this.core=e,this.logger=r}}class A1 extends sn{constructor(e,r){super(e,r,nI,du),this.core=e,this.logger=r}}class wI extends sn{constructor(e,r){super(e,r,oI,du,i=>i.id),this.core=e,this.logger=r}}class _I extends sn{constructor(e,r){super(e,r,uI,Aa,()=>Da),this.core=e,this.logger=r}}class xI extends sn{constructor(e,r){super(e,r,hI,Aa),this.core=e,this.logger=r}}class EI extends sn{constructor(e,r){super(e,r,dI,Aa,i=>i.id),this.core=e,this.logger=r}}var SI=Object.defineProperty,II=(t,e,r)=>e in t?SI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bu=(t,e,r)=>II(t,typeof e!="symbol"?e+"":e,r);class AI{constructor(e,r){this.core=e,this.logger=r,bu(this,"authKeys"),bu(this,"pairingTopics"),bu(this,"requests"),this.authKeys=new _I(this.core,this.logger),this.pairingTopics=new xI(this.core,this.logger),this.requests=new EI(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var DI=Object.defineProperty,$I=(t,e,r)=>e in t?DI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,se=(t,e,r)=>$I(t,typeof e!="symbol"?e+"":e,r);class yu extends Zb{constructor(e){super(e),se(this,"protocol",m1),se(this,"version",w1),se(this,"name",lu.name),se(this,"metadata"),se(this,"core"),se(this,"logger"),se(this,"events",new Ot.exports.EventEmitter),se(this,"engine"),se(this,"session"),se(this,"proposal"),se(this,"pendingRequest"),se(this,"auth"),se(this,"signConfig"),se(this,"on",(i,n)=>this.events.on(i,n)),se(this,"once",(i,n)=>this.events.once(i,n)),se(this,"off",(i,n)=>this.events.off(i,n)),se(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),se(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),se(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),se(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),se(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||lu.name,this.metadata=e?.metadata||g0(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Hr(ec({level:e?.logger||lu.logger}));this.core=e?.core||new hu(e),this.logger=Bt(r,this.name),this.session=new A1(this.core,this.logger),this.proposal=new mI(this.core,this.logger),this.pendingRequest=new wI(this.core,this.logger),this.engine=new vI(this),this.auth=new AI(this.core,this.logger)}static async init(e){const r=new yu(e);return await r.initialize(),r}get context(){return Ut(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},V.toMiliseconds(V.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const OI=A1,MI=yu;class PI extends Ot.exports{constructor(){super()}}class D1{constructor(e){this.opts=e}}class $1{constructor(e){this.client=e}}var RI=Object.defineProperty,TI=Object.defineProperties,NI=Object.getOwnPropertyDescriptors,O1=Object.getOwnPropertySymbols,CI=Object.prototype.hasOwnProperty,BI=Object.prototype.propertyIsEnumerable,M1=(t,e,r)=>e in t?RI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,FI=(t,e)=>{for(var r in e||(e={}))CI.call(e,r)&&M1(t,r,e[r]);if(O1)for(var r of O1(e))BI.call(e,r)&&M1(t,r,e[r]);return t},LI=(t,e)=>TI(t,NI(e));class qI extends $1{constructor(e){super(e),this.init=async()=>{this.signClient=await MI.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig}),this.signClient.core.eventClient.init().catch(r=>{this.client.logger.warn(r)})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(LI(FI({},r),{id:r.id,namespaces:r.namespaces,sessionProperties:r.sessionProperties,sessionConfig:r.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async r=>await this.signClient.reject(r),this.updateSession=async r=>await this.signClient.update(r),this.extendSession=async r=>await this.signClient.extend(r),this.respondSessionRequest=async r=>await this.signClient.respond(r),this.disconnectSession=async r=>await this.signClient.disconnect(r),this.emitSessionEvent=async r=>await this.signClient.emit(r),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((r,i)=>(r[i.topic]=i,r),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async r=>await this.signClient.approveSessionAuthenticate(r),this.rejectSessionAuthenticate=async r=>await this.signClient.rejectSessionAuthenticate(r),this.formatAuthMessage=r=>this.signClient.formatAuthMessage(r),this.registerDeviceToken=r=>this.client.core.echoClient.registerDeviceToken(r),this.on=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"on"),this.client.events.on(r,i)),this.once=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"once"),this.client.events.once(r,i)),this.off=(r,i)=>(this.setEvent(r,"off"),this.client.events.off(r,i)),this.removeListener=(r,i)=>(this.setEvent(r,"removeListener"),this.client.events.removeListener(r,i)),this.onSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onSessionProposal=r=>{this.client.events.emit("session_proposal",r)},this.onSessionDelete=r=>{this.client.events.emit("session_delete",r)},this.onProposalExpire=r=>{this.client.events.emit("proposal_expire",r)},this.onSessionRequestExpire=r=>{this.client.events.emit("session_request_expire",r)},this.onSessionRequestAuthenticate=r=>{this.client.events.emit("session_authenticate",r)},this.setEvent=(r,i)=>{switch(r){case"session_request":this.signClient.events[i]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[i]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[i]("session_delete",this.onSessionDelete);break;case"proposal_expire":this.signClient.events[i]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[i]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[i]("session_authenticate",this.onSessionRequestAuthenticate);break}},this.signClient={}}}const zI={decryptMessage:async t=>{const e={core:new hu({storageOptions:t.storageOptions,storage:t.storage})};await e.core.crypto.init();const r=e.core.crypto.decode(t.topic,t.encryptedMessage);return e.core=null,r},getMetadata:async t=>{const e={core:new hu({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new OI(e.core,e.core.logger),await e.sessionStore.init();const r=e.sessionStore.get(t.topic),i=r?.peer.metadata;return e.core=null,e.sessionStore=null,i}},P1=class extends D1{constructor(t){super(t),this.events=new Ot.exports,this.on=(e,r)=>this.engine.on(e,r),this.once=(e,r)=>this.engine.once(e,r),this.off=(e,r)=>this.engine.off(e,r),this.removeListener=(e,r)=>this.engine.removeListener(e,r),this.pair=async e=>{try{return await this.engine.pair(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(r){throw this.logger.error(r.message),r}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(r){throw this.logger.error(r.message),r}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(r){throw this.logger.error(r.message),r}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(r){throw this.logger.error(r.message),r}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.registerDeviceToken=e=>{try{return this.engine.registerDeviceToken(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(r){throw this.logger.error(r.message),r}},this.metadata=t.metadata,this.name=t.name||qa,this.signConfig=t.signConfig,this.core=t.core,this.logger=this.core.logger,this.engine=new qI(this)}static async init(t){const e=new P1(t);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(t){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(t.message),t}}};let vu=P1;vu.notifications=zI;const UI=vu;$t.CLIENT_CONTEXT=qa,$t.CLIENT_STORAGE_OPTIONS=J1,$t.CLIENT_STORAGE_PREFIX=Y1,$t.IWalletKit=D1,$t.IWalletKitEngine=$1,$t.IWalletKitEvents=PI,$t.PROTOCOL=Mu,$t.PROTOCOL_VERSION=G1,$t.REQUEST_CONTEXT=Z1,$t.WalletKit=UI,$t.default=vu,Object.defineProperty($t,"__esModule",{value:!0})});
|
|
44
40
|
//# sourceMappingURL=index.umd.js.map
|