@reown/walletkit 1.1.1-rc-0 → 1.1.2-canary-nbl-1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.umd.js +12 -12
- 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(kt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports):typeof define=="function"&&define.amd?define(["exports"],Nt):(kt=typeof globalThis<"u"?globalThis:kt||self,Nt(kt["@reown/walletkit"]={}))})(this,function(kt){"use strict";var Nt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ua(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 jt={exports:{}},Sn=typeof Reflect=="object"?Reflect:null,Mc=Sn&&typeof Sn.apply=="function"?Sn.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Ys;Sn&&typeof Sn.ownKeys=="function"?Ys=Sn.ownKeys:Object.getOwnPropertySymbols?Ys=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ys=function(e){return Object.getOwnPropertyNames(e)};function Mp(t){console&&console.warn&&console.warn(t)}var Ic=Number.isNaN||function(e){return e!==e};function ot(){ot.init.call(this)}jt.exports=ot,jt.exports.once=Op,ot.EventEmitter=ot,ot.prototype._events=void 0,ot.prototype._eventsCount=0,ot.prototype._maxListeners=void 0;var Ac=10;function Xs(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ot,"defaultMaxListeners",{enumerable:!0,get:function(){return Ac},set:function(t){if(typeof t!="number"||t<0||Ic(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ac=t}}),ot.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},ot.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ic(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 Dc(t){return t._maxListeners===void 0?ot.defaultMaxListeners:t._maxListeners}ot.prototype.getMaxListeners=function(){return Dc(this)},ot.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")Mc(c,this,r);else for(var h=c.length,l=Nc(c,h),i=0;i<h;++i)Mc(l[i],this,r);return!0};function Oc(t,e,r,i){var n,s,o;if(Xs(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=Dc(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,Mp(a)}return t}ot.prototype.addListener=function(e,r){return Oc(this,e,r,!1)},ot.prototype.on=ot.prototype.addListener,ot.prototype.prependListener=function(e,r){return Oc(this,e,r,!0)};function Ip(){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 Pc(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Ip.bind(i);return n.listener=r,i.wrapFn=n,n}ot.prototype.once=function(e,r){return Xs(r),this.on(e,Pc(this,e,r)),this},ot.prototype.prependOnceListener=function(e,r){return Xs(r),this.prependListener(e,Pc(this,e,r)),this},ot.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Xs(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():Ap(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},ot.prototype.off=ot.prototype.removeListener,ot.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 Rc(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?Dp(n):Nc(n,n.length)}ot.prototype.listeners=function(e){return Rc(this,e,!0)},ot.prototype.rawListeners=function(e){return Rc(this,e,!1)},ot.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):$c.call(t,e)},ot.prototype.listenerCount=$c;function $c(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}ot.prototype.eventNames=function(){return this._eventsCount>0?Ys(this._events):[]};function Nc(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Ap(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Dp(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Op(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))}Fc(t,e,s,{once:!0}),e!=="error"&&Pp(t,n,{once:!0})})}function Pp(t,e,r){typeof t.on=="function"&&Fc(t,"error",e,r)}function Fc(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 Tc="wc",Rp=2,da="WalletKit",$p=`${Tc}@2:${da}:`,Np={database:":memory:"},Fp="request";var Y={};/*! *****************************************************************************
|
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,23 @@
|
|
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 La=function(r,e){return La=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},La(r,e)};function Cd(r,e){La(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var qa=function(){return qa=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},qa.apply(this,arguments)};function Td(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function Fd(r,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Bd(r,e){return function(t,i){e(t,i,r)}}function Ld(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function qd(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(g){try{h(i.next(g))}catch(m){o(m)}}function u(g){try{h(i.throw(g))}catch(m){o(m)}}function h(g){g.done?s(g.value):n(g.value).then(f,u)}h((i=i.apply(r,e||[])).next())})}function Ud(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(g){return u([h,g])}}function u(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)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 t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(g){h=[6,g],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function $d(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function zd(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function Ua(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qf(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function kd(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(qf(arguments[e]));return r}function Kd(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,f=s.length;o<f;o++,n++)i[n]=s[o];return i}function Tn(r){return this instanceof Tn?(this.v=r,this):new Tn(r)}function jd(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(I){i[I]&&(n[I]=function(M){return new Promise(function(D,N){s.push([I,M,D,N])>1||f(I,M)})})}function f(I,M){try{u(i[I](M))}catch(D){m(s[0][3],D)}}function u(I){I.value instanceof Tn?Promise.resolve(I.value.v).then(h,g):m(s[0][2],I)}function h(I){f("next",I)}function g(I){f("throw",I)}function m(I,M){I(M),s.shift(),s.length&&f(s[0][0],s[0][1])}}function Hd(r){var e,t;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]=r[n]?function(o){return(t=!t)?{value:Tn(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Vd(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Ua=="function"?Ua(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(h){s({value:h,done:f})},o)}}function Gd(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wd(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jd(r){return r&&r.__esModule?r:{default:r}}function Yd(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Qd(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var Xd=Object.freeze({__proto__:null,__extends:Cd,get __assign(){return qa},__rest:Td,__decorate:Fd,__param:Bd,__metadata:Ld,__awaiter:qd,__generator:Ud,__createBinding:$d,__exportStar:zd,__values:Ua,__read:qf,__spread:kd,__spreadArrays:Kd,__await:Tn,__asyncGenerator:jd,__asyncDelegator:Hd,__asyncValues:Vd,__makeTemplateObject:Gd,__importStar:Wd,__importDefault:Jd,__classPrivateFieldGet:Yd,__classPrivateFieldSet:Qd}),Ms=Fa(Xd),$a={},Fn={},Uf;function Zd(){if(Uf)return Fn;Uf=1,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.delay=void 0;function r(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}return Fn.delay=r,Fn}var Ti={},za={},Fi={},$f;function el(){return $f||($f=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.ONE_THOUSAND=Fi.ONE_HUNDRED=void 0,Fi.ONE_HUNDRED=100,Fi.ONE_THOUSAND=1e3),Fi}var ka={},zf;function tl(){return zf||(zf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(ka)),ka}var kf;function Kf(){return kf||(kf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Ms;e.__exportStar(el(),r),e.__exportStar(tl(),r)}(za)),za}var jf;function rl(){if(jf)return Ti;jf=1,Object.defineProperty(Ti,"__esModule",{value:!0}),Ti.fromMiliseconds=Ti.toMiliseconds=void 0;const r=Kf();function e(i){return i*r.ONE_THOUSAND}Ti.toMiliseconds=e;function t(i){return Math.floor(i/r.ONE_THOUSAND)}return Ti.fromMiliseconds=t,Ti}var Hf;function il(){return Hf||(Hf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Ms;e.__exportStar(Zd(),r),e.__exportStar(rl(),r)}($a)),$a}var an={},Vf;function nl(){if(Vf)return an;Vf=1,Object.defineProperty(an,"__esModule",{value:!0}),an.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const i=this.get(t);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${t}`);const n=Date.now()-i.started;this.timestamps.set(t,{started:i.started,elapsed:n})}get(t){const i=this.timestamps.get(t);if(typeof i>"u")throw new Error(`No timestamp found for label: ${t}`);return i}elapsed(t){const i=this.get(t);return i.elapsed||Date.now()-i.started}}return an.Watch=r,an.default=r,an}var Ka={},Bn={},Gf;function sl(){if(Gf)return Bn;Gf=1,Object.defineProperty(Bn,"__esModule",{value:!0}),Bn.IWatch=void 0;class r{}return Bn.IWatch=r,Bn}var Wf;function al(){return Wf||(Wf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Ms.__exportStar(sl(),r)}(Ka)),Ka}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Ms;e.__exportStar(il(),r),e.__exportStar(nl(),r),e.__exportStar(al(),r),e.__exportStar(Kf(),r)})(ae);class Bi{}class ol extends Bi{constructor(e){super()}}const Jf=ae.FIVE_SECONDS,on={pulse:"heartbeat_pulse"};class ja extends ol{constructor(e){super(e),this.events=new qt.exports.EventEmitter,this.interval=Jf,this.interval=e?.interval||Jf}static async init(e){const t=new ja(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),ae.toMiliseconds(this.interval))}pulse(){this.events.emit(on.pulse)}}const fl=/"(?:_|\\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*:/,cl=/"(?: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*:/,hl=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function ul(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){dl(r);return}return e}function dl(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Is(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.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(!hl.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(fl.test(r)||cl.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,ul)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function ll(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function _t(r,...e){try{return ll(r(...e))}catch(t){return Promise.reject(t)}}function pl(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function gl(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function Ds(r){if(pl(r))return String(r);if(gl(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return Ds(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Yf(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ha="base64:";function bl(r){if(typeof r=="string")return r;Yf();const e=Buffer.from(r).toString("base64");return Ha+e}function vl(r){return typeof r!="string"||!r.startsWith(Ha)?r:(Yf(),Buffer.from(r.slice(Ha.length),"base64"))}function Yt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function ml(...r){return Yt(r.join(":"))}function Os(r){return r=Yt(r),r?r+":":""}function a4(r){return r}const yl="memory",wl=()=>{const r=new Map;return{name:yl,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function _l(r={}){const e={mounts:{"":r.driver||wl()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=h=>{for(const g of e.mountpoints)if(h.startsWith(g))return{base:g,relativeKey:h.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,g)=>e.mountpoints.filter(m=>m.startsWith(h)||g&&h.startsWith(m)).map(m=>({relativeBase:h.length>m.length?h.slice(m.length):void 0,mountpoint:m,driver:e.mounts[m]})),n=(h,g)=>{if(e.watching){g=Yt(g);for(const m of e.watchListeners)m(h,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await Qf(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}},f=(h,g,m)=>{const I=new Map,M=D=>{let N=I.get(D.base);return N||(N={driver:D.driver,base:D.base,items:[]},I.set(D.base,N)),N};for(const D of h){const N=typeof D=="string",k=Yt(N?D:D.key),K=N?void 0:D.value,B=N||!D.options?g:{...g,...D.options},j=t(k);M(j).items.push({key:k,value:K,relativeKey:j.relativeKey,options:B})}return Promise.all([...I.values()].map(D=>m(D))).then(D=>D.flat())},u={hasItem(h,g={}){h=Yt(h);const{relativeKey:m,driver:I}=t(h);return _t(I.hasItem,m,g)},getItem(h,g={}){h=Yt(h);const{relativeKey:m,driver:I}=t(h);return _t(I.getItem,m,g).then(M=>Is(M))},getItems(h,g){return f(h,g,m=>m.driver.getItems?_t(m.driver.getItems,m.items.map(I=>({key:I.relativeKey,options:I.options})),g).then(I=>I.map(M=>({key:ml(m.base,M.key),value:Is(M.value)}))):Promise.all(m.items.map(I=>_t(m.driver.getItem,I.relativeKey,I.options).then(M=>({key:I.key,value:Is(M)})))))},getItemRaw(h,g={}){h=Yt(h);const{relativeKey:m,driver:I}=t(h);return I.getItemRaw?_t(I.getItemRaw,m,g):_t(I.getItem,m,g).then(M=>vl(M))},async setItem(h,g,m={}){if(g===void 0)return u.removeItem(h);h=Yt(h);const{relativeKey:I,driver:M}=t(h);M.setItem&&(await _t(M.setItem,I,Ds(g),m),M.watch||n("update",h))},async setItems(h,g){await f(h,g,async m=>{if(m.driver.setItems)return _t(m.driver.setItems,m.items.map(I=>({key:I.relativeKey,value:Ds(I.value),options:I.options})),g);m.driver.setItem&&await Promise.all(m.items.map(I=>_t(m.driver.setItem,I.relativeKey,Ds(I.value),I.options)))})},async setItemRaw(h,g,m={}){if(g===void 0)return u.removeItem(h,m);h=Yt(h);const{relativeKey:I,driver:M}=t(h);if(M.setItemRaw)await _t(M.setItemRaw,I,g,m);else if(M.setItem)await _t(M.setItem,I,bl(g),m);else return;M.watch||n("update",h)},async removeItem(h,g={}){typeof g=="boolean"&&(g={removeMeta:g}),h=Yt(h);const{relativeKey:m,driver:I}=t(h);I.removeItem&&(await _t(I.removeItem,m,g),(g.removeMeta||g.removeMata)&&await _t(I.removeItem,m+"$",g),I.watch||n("remove",h))},async getMeta(h,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),h=Yt(h);const{relativeKey:m,driver:I}=t(h),M=Object.create(null);if(I.getMeta&&Object.assign(M,await _t(I.getMeta,m,g)),!g.nativeOnly){const D=await _t(I.getItem,m+"$",g).then(N=>Is(N));D&&typeof D=="object"&&(typeof D.atime=="string"&&(D.atime=new Date(D.atime)),typeof D.mtime=="string"&&(D.mtime=new Date(D.mtime)),Object.assign(M,D))}return M},setMeta(h,g,m={}){return this.setItem(h+"$",g,m)},removeMeta(h,g={}){return this.removeItem(h+"$",g)},async getKeys(h,g={}){h=Os(h);const m=i(h,!0);let I=[];const M=[];for(const D of m){const N=await _t(D.driver.getKeys,D.relativeBase,g);for(const k of N){const K=D.mountpoint+Yt(k);I.some(B=>K.startsWith(B))||M.push(K)}I=[D.mountpoint,...I.filter(k=>!k.startsWith(D.mountpoint))]}return h?M.filter(D=>D.startsWith(h)&&D[D.length-1]!=="$"):M.filter(D=>D[D.length-1]!=="$")},async clear(h,g={}){h=Os(h),await Promise.all(i(h,!1).map(async m=>{if(m.driver.clear)return _t(m.driver.clear,m.relativeBase,g);if(m.driver.removeItem){const I=await m.driver.getKeys(m.relativeBase||"",g);return Promise.all(I.map(M=>m.driver.removeItem(M,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>Xf(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,g){if(h=Os(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((m,I)=>I.length-m.length)),e.mounts[h]=g,e.watching&&Promise.resolve(Qf(g,n,h)).then(m=>{e.unwatch[h]=m}).catch(console.error),u},async unmount(h,g=!0){h=Os(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),g&&await Xf(e.mounts[h]),e.mountpoints=e.mountpoints.filter(m=>m!==h),delete e.mounts[h])},getMount(h=""){h=Yt(h)+":";const g=t(h);return{driver:g.driver,base:g.base}},getMounts(h="",g={}){return h=Yt(h),i(h,g.parents).map(I=>({driver:I.driver,base:I.mountpoint}))},keys:(h,g={})=>u.getKeys(h,g),get:(h,g={})=>u.getItem(h,g),set:(h,g,m={})=>u.setItem(h,g,m),has:(h,g={})=>u.hasItem(h,g),del:(h,g={})=>u.removeItem(h,g),remove:(h,g={})=>u.removeItem(h,g)};return u}function Qf(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function Xf(r){typeof r.dispose=="function"&&await _t(r.dispose)}function Li(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function Zf(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=Li(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let Va;function Ln(){return Va||(Va=Zf("keyval-store","keyval")),Va}function ec(r,e=Ln()){return e("readonly",t=>Li(t.get(r)))}function xl(r,e,t=Ln()){return t("readwrite",i=>(i.put(e,r),Li(i.transaction)))}function Al(r,e=Ln()){return e("readwrite",t=>(t.delete(r),Li(t.transaction)))}function El(r=Ln()){return r("readwrite",e=>(e.clear(),Li(e.transaction)))}function Sl(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Li(r.transaction)}function Ml(r=Ln()){return r("readonly",e=>{if(e.getAllKeys)return Li(e.getAllKeys());const t=[];return Sl(e,i=>t.push(i.key)).then(()=>t)})}const Il=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),Dl=r=>{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,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function fn(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return Dl(r)}catch{return r}}function qi(r){return typeof r=="string"?r:Il(r)||""}const Ol="idb-keyval";var Pl=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=Zf(r.dbName,r.storeName)),{name:Ol,options:r,async hasItem(n){return!(typeof await ec(t(n),i)>"u")},async getItem(n){return await ec(t(n),i)??null},setItem(n,s){return xl(t(n),s,i)},removeItem(n){return Al(t(n),i)},getKeys(){return Ml(i)},clear(){return El(i)}}};const Rl="WALLET_CONNECT_V2_INDEXED_DB",Nl="keyvaluestorage";class Cl{constructor(){this.indexedDb=_l({driver:Pl({dbName:Rl,storeName:Nl})})}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 t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,qi(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Ga=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ps={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ga<"u"&&Ga.localStorage?Ps.exports=Ga.localStorage:typeof window<"u"&&window.localStorage?Ps.exports=window.localStorage:Ps.exports=new e})();function Tl(r){var e;return[r[0],fn((e=r[1])!=null?e:"")]}class Fl{constructor(){this.localStorage=Ps.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Tl)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return fn(t)}async setItem(e,t){this.localStorage.setItem(e,qi(t))}async removeItem(e){this.localStorage.removeItem(e)}}const Bl="wc_storage_version",tc=1,Ll=async(r,e,t)=>{const i=Bl,n=await e.getItem(i);if(n&&n>=tc){t(e);return}const s=await r.getKeys();if(!s.length){t(e);return}const o=[];for(;s.length;){const f=s.shift();if(!f)continue;const u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){const h=await r.getItem(f);await e.setItem(f,h),o.push(f)}}await e.setItem(i,tc),t(e),ql(r,o)},ql=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};class Ul{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new Fl;this.storage=e;try{const t=new Cl;Ll(e,t,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,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}function $l(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var zl=kl;function kl(r,e,t){var i=t&&t.stringify||$l,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f<s;f++)o[f]=i(e[f]);return o.join(" ")}if(typeof r!="string")return r;var u=e.length;if(u===0)return r;for(var h="",g=1-n,m=-1,I=r&&r.length||0,M=0;M<I;){if(r.charCodeAt(M)===37&&M+1<I){switch(m=m>-1?m:0,r.charCodeAt(M+1)){case 100:case 102:if(g>=u||e[g]==null)break;m<M&&(h+=r.slice(m,M)),h+=Number(e[g]),m=M+2,M++;break;case 105:if(g>=u||e[g]==null)break;m<M&&(h+=r.slice(m,M)),h+=Math.floor(Number(e[g])),m=M+2,M++;break;case 79:case 111:case 106:if(g>=u||e[g]===void 0)break;m<M&&(h+=r.slice(m,M));var D=typeof e[g];if(D==="string"){h+="'"+e[g]+"'",m=M+2,M++;break}if(D==="function"){h+=e[g].name||"<anonymous>",m=M+2,M++;break}h+=i(e[g]),m=M+2,M++;break;case 115:if(g>=u)break;m<M&&(h+=r.slice(m,M)),h+=String(e[g]),m=M+2,M++;break;case 37:m<M&&(h+=r.slice(m,M)),h+="%",m=M+2,M++,g--;break}++g}++M}return m===-1?r:(m<I&&(h+=r.slice(m)),h)}const rc=zl;var Xr=Tr;const qn=Xl().console||{},Kl={mapHttpRequest:Ns,mapHttpResponse:Ns,wrapRequestSerializer:Ja,wrapResponseSerializer:Ja,wrapErrorSerializer:Ja,req:Ns,res:Ns,err:Wl};function jl(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Tr(r){r=r||{},r.browser=r.browser||{};const e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const t=r.browser.write||qn;r.browser.write&&(r.browser.asObject=!0);const i=r.serializers||{},n=jl(r.browser.serialize,i);let s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");const f=r.level||"info",u=Object.create(t);u.log||(u.log=Un),Object.defineProperty(u,"levelVal",{get:g}),Object.defineProperty(u,"level",{get:m,set:I});const h={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:Jl(r)};u.levels=Tr.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=Un,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=M,e&&(u._logEvent=Wa());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function m(){return this._level}function I(D){if(D!=="silent"&&!this.levels.values[D])throw Error("unknown level "+D);this._level=D,cn(h,u,"error","log"),cn(h,u,"fatal","error"),cn(h,u,"warn","error"),cn(h,u,"info","log"),cn(h,u,"debug","log"),cn(h,u,"trace","log")}function M(D,N){if(!D)throw new Error("missing bindings for child Pino");N=N||{},n&&D.serializers&&(N.serializers=D.serializers);const k=N.serializers;if(n&&k){var K=Object.assign({},i,k),B=r.browser.serialize===!0?Object.keys(K):n;delete D.serializers,Rs([D],B,K,this._stdErrSerialize)}function j(F){this._childLevel=(F._childLevel|0)+1,this.error=hn(F,D,"error"),this.fatal=hn(F,D,"fatal"),this.warn=hn(F,D,"warn"),this.info=hn(F,D,"info"),this.debug=hn(F,D,"debug"),this.trace=hn(F,D,"trace"),K&&(this.serializers=K,this._serialize=B),e&&(this._logEvent=Wa([].concat(F._logEvent.bindings,D)))}return j.prototype=this,new j(this)}return u}Tr.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"}},Tr.stdSerializers=Kl,Tr.stdTimeFunctions=Object.assign({},{nullTime:ic,epochTime:nc,unixTime:Yl,isoTime:Ql});function cn(r,e,t,i){const n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?Un:n[t]?n[t]:qn[t]||qn[i]||Un,Hl(r,e,t)}function Hl(r,e,t){!r.transmit&&e[t]===Un||(e[t]=function(i){return function(){const s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===qn?qn:this;for(var u=0;u<o.length;u++)o[u]=arguments[u];if(r.serialize&&!r.asObject&&Rs(o,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?i.call(f,Vl(this,t,o,s)):i.apply(f,o),r.transmit){const h=r.transmit.level||e.level,g=Tr.levels.values[h],m=Tr.levels.values[t];if(m<g)return;Gl(this,{ts:s,methodLevel:t,methodValue:m,transmitLevel:h,transmitValue:Tr.levels.values[r.transmit.level||e.level],send:r.transmit.send,val:e.levelVal},o)}}}(e[t]))}function Vl(r,e,t,i){r._serialize&&Rs(t,r._serialize,r.serializers,r._stdErrSerialize);const n=t.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Tr.levels.values[e];let f=(r._childLevel|0)+1;if(f<1&&(f=1),s!==null&&typeof s=="object"){for(;f--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?rc(n.shift(),n):void 0}else typeof s=="string"&&(s=rc(n.shift(),n));return s!==void 0&&(o.msg=s),o}function Rs(r,e,t,i){for(const n in r)if(i&&r[n]instanceof Error)r[n]=Tr.stdSerializers.err(r[n]);else if(typeof r[n]=="object"&&!Array.isArray(r[n]))for(const s in r[n])e&&e.indexOf(s)>-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function hn(r,e,t){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 r[t].apply(this,i)}}function Gl(r,e,t){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,f=e.val,u=r._logEvent.bindings;Rs(t,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=n,r._logEvent.messages=t.filter(function(h){return u.indexOf(h)===-1}),r._logEvent.level.label=s,r._logEvent.level.value=o,i(s,r._logEvent,f),r._logEvent=Wa(u)}function Wa(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function Wl(r){const e={type:r.constructor.name,msg:r.message,stack:r.stack};for(const t in r)e[t]===void 0&&(e[t]=r[t]);return e}function Jl(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?ic:nc}function Ns(){return{}}function Ja(r){return r}function Un(){}function ic(){return!1}function nc(){return Date.now()}function Yl(){return Math.round(Date.now()/1e3)}function Ql(){return new Date(Date.now()).toISOString()}function Xl(){function r(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 r(self)||r(window)||r(this)||{}}}const Zl={level:"info"},$n="custom_context",Ya=1e3*1024;class ep{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 sc{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new ep(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.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 t=this.head;for(;t!==null;)e.push(t.value),t=t.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 t=e.value;return e=e.next,{done:!1,value:t}}}}}class ac{constructor(e,t=Ya){this.level=e??"error",this.levelValue=Xr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new sc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Xr.levels.values.error?console.error(e):t===Xr.levels.values.warn?console.warn(e):t===Xr.levels.values.debug?console.debug(e):t===Xr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(qi({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new sc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(qi({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class tp{constructor(e,t=Ya){this.baseChunkLogger=new ac(e,t)}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 t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}}class rp{constructor(e,t=Ya){this.baseChunkLogger=new ac(e,t)}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 ip=Object.defineProperty,np=Object.defineProperties,sp=Object.getOwnPropertyDescriptors,oc=Object.getOwnPropertySymbols,ap=Object.prototype.hasOwnProperty,op=Object.prototype.propertyIsEnumerable,fc=(r,e,t)=>e in r?ip(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cs=(r,e)=>{for(var t in e||(e={}))ap.call(e,t)&&fc(r,t,e[t]);if(oc)for(var t of oc(e))op.call(e,t)&&fc(r,t,e[t]);return r},Ts=(r,e)=>np(r,sp(e));function Qa(r){return Ts(Cs({},r),{level:r?.level||Zl.level})}function fp(r,e=$n){return r[e]||""}function cp(r,e,t=$n){return r[t]=e,r}function Qt(r,e=$n){let t="";return typeof r.bindings>"u"?t=fp(r,e):t=r.bindings().context||"",t}function hp(r,e,t=$n){const i=Qt(r,t);return i.trim()?`${i}/${e}`:e}function jt(r,e,t=$n){const i=hp(r,e,t),n=r.child({context:i});return cp(n,i,t)}function up(r){var e,t;const i=new tp((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Xr(Ts(Cs({},r.opts),{level:"trace",browser:Ts(Cs({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function dp(r){var e;const t=new rp((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Xr(Ts(Cs({},r.opts),{level:"trace"})),chunkLoggerController:t}}function lp(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?up(r):dp(r)}class pp extends Bi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class gp extends Bi{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class bp{constructor(e,t){this.logger=e,this.core=t}}class vp extends Bi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class mp extends Bi{constructor(e){super()}}class yp{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}}class wp extends Bi{constructor(e,t){super(),this.relayer=e,this.logger=t}}class _p extends Bi{constructor(e,t){super(),this.core=e,this.logger=t}}class xp{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}class Ap{constructor(e,t){this.projectId=e,this.logger=t}}class Ep{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}class Sp{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Mp{constructor(e){this.client=e}}var Xa={},_i={},Fs={},Bs={};Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.BrowserRandomSource=void 0;const cc=65536;class Ip{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let i=0;i<t.length;i+=cc)this._crypto.getRandomValues(t.subarray(i,i+Math.min(t.length-i,cc)));return t}}Bs.BrowserRandomSource=Ip;function Dp(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ls={},ar={};Object.defineProperty(ar,"__esModule",{value:!0});function Op(r){for(var e=0;e<r.length;e++)r[e]=0;return r}ar.wipe=Op;var Pp={},Rp=Object.freeze({__proto__:null,default:Pp}),qs=Fa(Rp);Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.NodeRandomSource=void 0;const Np=ar;class Cp{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Dp<"u"){const e=qs;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=t[n];return(0,Np.wipe)(t),i}}Ls.NodeRandomSource=Cp,Object.defineProperty(Fs,"__esModule",{value:!0}),Fs.SystemRandomSource=void 0;const Tp=Bs,Fp=Ls;class Bp{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Tp.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Fp.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}Fs.SystemRandomSource=Bp;var He={},hc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function e(f,u){var h=f>>>16&65535,g=f&65535,m=u>>>16&65535,I=u&65535;return g*I+(h*I+g*m<<16>>>0)|0}r.mul=Math.imul||e;function t(f,u){return f+u|0}r.add=t;function i(f,u){return f-u|0}r.sub=i;function n(f,u){return f<<u|f>>>32-u}r.rotl=n;function s(f,u){return f<<32-u|f>>>u}r.rotr=s;function o(f){return typeof f=="number"&&isFinite(f)&&Math.floor(f)===f}r.isInteger=Number.isInteger||o,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(f){return r.isInteger(f)&&f>=-r.MAX_SAFE_INTEGER&&f<=r.MAX_SAFE_INTEGER}})(hc),Object.defineProperty(He,"__esModule",{value:!0});var uc=hc;function Lp(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}He.readInt16BE=Lp;function qp(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}He.readUint16BE=qp;function Up(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}He.readInt16LE=Up;function $p(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}He.readUint16LE=$p;function dc(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}He.writeUint16BE=dc,He.writeInt16BE=dc;function lc(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}He.writeUint16LE=lc,He.writeInt16LE=lc;function Za(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}He.readInt32BE=Za;function eo(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}He.readUint32BE=eo;function to(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}He.readInt32LE=to;function ro(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}He.readUint32LE=ro;function Us(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}He.writeUint32BE=Us,He.writeInt32BE=Us;function $s(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}He.writeUint32LE=$s,He.writeInt32LE=$s;function zp(r,e){e===void 0&&(e=0);var t=Za(r,e),i=Za(r,e+4);return t*4294967296+i-(i>>31)*4294967296}He.readInt64BE=zp;function kp(r,e){e===void 0&&(e=0);var t=eo(r,e),i=eo(r,e+4);return t*4294967296+i}He.readUint64BE=kp;function Kp(r,e){e===void 0&&(e=0);var t=to(r,e),i=to(r,e+4);return i*4294967296+t-(t>>31)*4294967296}He.readInt64LE=Kp;function jp(r,e){e===void 0&&(e=0);var t=ro(r,e),i=ro(r,e+4);return i*4294967296+t}He.readUint64LE=jp;function pc(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Us(r/4294967296>>>0,e,t),Us(r>>>0,e,t+4),e}He.writeUint64BE=pc,He.writeInt64BE=pc;function gc(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),$s(r>>>0,e,t),$s(r/4294967296>>>0,e,t+4),e}He.writeUint64LE=gc,He.writeInt64LE=gc;function Hp(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}He.readUintBE=Hp;function Vp(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s<t+r/8;s++)i+=e[s]*n,n*=256;return i}He.readUintLE=Vp;function Gp(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!uc.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=r/8+i-1;s>=i;s--)t[s]=e/n&255,n*=256;return t}He.writeUintBE=Gp;function Wp(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!uc.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+r/8;s++)t[s]=e/n&255,n*=256;return t}He.writeUintLE=Wp;function Jp(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e)}He.readFloat32BE=Jp;function Yp(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e,!0)}He.readFloat32LE=Yp;function Qp(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e)}He.readFloat64BE=Qp;function Xp(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e,!0)}He.readFloat64LE=Xp;function Zp(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r),e}He.writeFloat32BE=Zp;function e1(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r,!0),e}He.writeFloat32LE=e1;function t1(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r),e}He.writeFloat64BE=t1;function r1(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r,!0),e}He.writeFloat64LE=r1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const e=Fs,t=He,i=ar;r.defaultRandomSource=new e.SystemRandomSource;function n(h,g=r.defaultRandomSource){return g.randomBytes(h)}r.randomBytes=n;function s(h=r.defaultRandomSource){const g=n(4,h),m=(0,t.readUint32LE)(g);return(0,i.wipe)(g),m}r.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function f(h,g=o,m=r.defaultRandomSource){if(g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");let I="";const M=g.length,D=256-256%M;for(;h>0;){const N=n(Math.ceil(h*256/D),m);for(let k=0;k<N.length&&h>0;k++){const K=N[k];K<D&&(I+=g.charAt(K%M),h--)}(0,i.wipe)(N)}return I}r.randomString=f;function u(h,g=o,m=r.defaultRandomSource){const I=Math.ceil(h/(Math.log(g.length)/Math.LN2));return f(I,g,m)}r.randomStringForEntropy=u}(_i);var bc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=He,t=ar;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._tempHi),t.wipe(this._tempLo),this.reset()},f.prototype.update=function(u,h){if(h===void 0&&(h=u.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&h>0;)this._buffer[this._bufferLength++]=u[g++],h--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,u,g,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=u[g++],h--;return this},f.prototype.finish=function(u){if(!this._finished){var h=this._bytesHashed,g=this._bufferLength,m=h/536870912|0,I=h<<3,M=h%128<112?128:256;this._buffer[g]=128;for(var D=g+1;D<M-8;D++)this._buffer[D]=0;e.writeUint32BE(m,this._buffer,M-8),e.writeUint32BE(I,this._buffer,M-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,M),this._finished=!0}for(var D=0;D<this.digestLength/8;D++)e.writeUint32BE(this._stateHi[D],u,D*8),e.writeUint32BE(this._stateLo[D],u,D*8+4);return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(u){return this._stateHi.set(u.stateHi),this._stateLo.set(u.stateLo),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(u){t.wipe(u.stateHi),t.wipe(u.stateLo),u.buffer&&t.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},f}();r.SHA512=i;var n=new Int32Array([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 s(f,u,h,g,m,I,M){for(var D=h[0],N=h[1],k=h[2],K=h[3],B=h[4],j=h[5],F=h[6],U=h[7],z=g[0],_=g[1],P=g[2],J=g[3],Q=g[4],R=g[5],p=g[6],l=g[7],a,c,b,A,E,x,d,w;M>=128;){for(var v=0;v<16;v++){var O=8*v+I;f[v]=e.readUint32BE(m,O),u[v]=e.readUint32BE(m,O+4)}for(var v=0;v<80;v++){var W=D,S=N,H=k,C=K,q=B,T=j,y=F,L=U,G=z,Y=_,X=P,ee=J,we=Q,Se=R,he=p,Re=l;if(a=U,c=l,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=(B>>>14|Q<<32-14)^(B>>>18|Q<<32-18)^(Q>>>41-32|B<<32-(41-32)),c=(Q>>>14|B<<32-14)^(Q>>>18|B<<32-18)^(B>>>41-32|Q<<32-(41-32)),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=B&j^~B&F,c=Q&R^~Q&p,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=n[v*2],c=n[v*2+1],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=f[v%16],c=u[v%16],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,b=d&65535|w<<16,A=E&65535|x<<16,a=b,c=A,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=(D>>>28|z<<32-28)^(z>>>34-32|D<<32-(34-32))^(z>>>39-32|D<<32-(39-32)),c=(z>>>28|D<<32-28)^(D>>>34-32|z<<32-(34-32))^(D>>>39-32|z<<32-(39-32)),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=D&N^D&k^N&k,c=z&_^z&P^_&P,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,L=d&65535|w<<16,Re=E&65535|x<<16,a=C,c=ee,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=b,c=A,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,C=d&65535|w<<16,ee=E&65535|x<<16,N=W,k=S,K=H,B=C,j=q,F=T,U=y,D=L,_=G,P=Y,J=X,Q=ee,R=we,p=Se,l=he,z=Re,v%16===15)for(var O=0;O<16;O++)a=f[O],c=u[O],E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=f[(O+9)%16],c=u[(O+9)%16],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,b=f[(O+1)%16],A=u[(O+1)%16],a=(b>>>1|A<<32-1)^(b>>>8|A<<32-8)^b>>>7,c=(A>>>1|b<<32-1)^(A>>>8|b<<32-8)^(A>>>7|b<<32-7),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,b=f[(O+14)%16],A=u[(O+14)%16],a=(b>>>19|A<<32-19)^(A>>>61-32|b<<32-(61-32))^b>>>6,c=(A>>>19|b<<32-19)^(b>>>61-32|A<<32-(61-32))^(A>>>6|b<<32-6),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,f[O]=d&65535|w<<16,u[O]=E&65535|x<<16}a=D,c=z,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[0],c=g[0],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[0]=D=d&65535|w<<16,g[0]=z=E&65535|x<<16,a=N,c=_,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[1],c=g[1],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[1]=N=d&65535|w<<16,g[1]=_=E&65535|x<<16,a=k,c=P,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[2],c=g[2],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[2]=k=d&65535|w<<16,g[2]=P=E&65535|x<<16,a=K,c=J,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[3],c=g[3],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[3]=K=d&65535|w<<16,g[3]=J=E&65535|x<<16,a=B,c=Q,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[4],c=g[4],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[4]=B=d&65535|w<<16,g[4]=Q=E&65535|x<<16,a=j,c=R,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[5],c=g[5],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[5]=j=d&65535|w<<16,g[5]=R=E&65535|x<<16,a=F,c=p,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[6],c=g[6],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[6]=F=d&65535|w<<16,g[6]=p=E&65535|x<<16,a=U,c=l,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[7],c=g[7],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[7]=U=d&65535|w<<16,g[7]=l=E&65535|x<<16,I+=128,M-=128}return I}function o(f){var u=new i;u.update(f);var h=u.digest();return u.clean(),h}r.hash=o})(bc),function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=_i,t=bc,i=ar;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function n(C){const q=new Float64Array(16);if(C)for(let T=0;T<C.length;T++)q[T]=C[T];return q}const s=new Uint8Array(32);s[0]=9;const o=n(),f=n([1]),u=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),I=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function M(C,q){for(let T=0;T<16;T++)C[T]=q[T]|0}function D(C){let q=1;for(let T=0;T<16;T++){let y=C[T]+q+65535;q=Math.floor(y/65536),C[T]=y-q*65536}C[0]+=q-1+37*(q-1)}function N(C,q,T){const y=~(T-1);for(let L=0;L<16;L++){const G=y&(C[L]^q[L]);C[L]^=G,q[L]^=G}}function k(C,q){const T=n(),y=n();for(let L=0;L<16;L++)y[L]=q[L];D(y),D(y),D(y);for(let L=0;L<2;L++){T[0]=y[0]-65517;for(let Y=1;Y<15;Y++)T[Y]=y[Y]-65535-(T[Y-1]>>16&1),T[Y-1]&=65535;T[15]=y[15]-32767-(T[14]>>16&1);const G=T[15]>>16&1;T[14]&=65535,N(y,T,1-G)}for(let L=0;L<16;L++)C[2*L]=y[L]&255,C[2*L+1]=y[L]>>8}function K(C,q){let T=0;for(let y=0;y<32;y++)T|=C[y]^q[y];return(1&T-1>>>8)-1}function B(C,q){const T=new Uint8Array(32),y=new Uint8Array(32);return k(T,C),k(y,q),K(T,y)}function j(C){const q=new Uint8Array(32);return k(q,C),q[0]&1}function F(C,q){for(let T=0;T<16;T++)C[T]=q[2*T]+(q[2*T+1]<<8);C[15]&=32767}function U(C,q,T){for(let y=0;y<16;y++)C[y]=q[y]+T[y]}function z(C,q,T){for(let y=0;y<16;y++)C[y]=q[y]-T[y]}function _(C,q,T){let y,L,G=0,Y=0,X=0,ee=0,we=0,Se=0,he=0,Re=0,xe=0,se=0,ve=0,le=0,ie=0,ue=0,fe=0,te=0,pe=0,_e=0,re=0,Ae=0,Ee=0,oe=0,De=0,Me=0,Oe=0,We=0,Qe=0,Ie=0,et=0,tt=0,Ne=0,Te=T[0],Ce=T[1],de=T[2],Fe=T[3],Be=T[4],ce=T[5],Ue=T[6],$e=T[7],me=T[8],ze=T[9],ke=T[10],ge=T[11],Le=T[12],Pe=T[13],ye=T[14],Ke=T[15];y=q[0],G+=y*Te,Y+=y*Ce,X+=y*de,ee+=y*Fe,we+=y*Be,Se+=y*ce,he+=y*Ue,Re+=y*$e,xe+=y*me,se+=y*ze,ve+=y*ke,le+=y*ge,ie+=y*Le,ue+=y*Pe,fe+=y*ye,te+=y*Ke,y=q[1],Y+=y*Te,X+=y*Ce,ee+=y*de,we+=y*Fe,Se+=y*Be,he+=y*ce,Re+=y*Ue,xe+=y*$e,se+=y*me,ve+=y*ze,le+=y*ke,ie+=y*ge,ue+=y*Le,fe+=y*Pe,te+=y*ye,pe+=y*Ke,y=q[2],X+=y*Te,ee+=y*Ce,we+=y*de,Se+=y*Fe,he+=y*Be,Re+=y*ce,xe+=y*Ue,se+=y*$e,ve+=y*me,le+=y*ze,ie+=y*ke,ue+=y*ge,fe+=y*Le,te+=y*Pe,pe+=y*ye,_e+=y*Ke,y=q[3],ee+=y*Te,we+=y*Ce,Se+=y*de,he+=y*Fe,Re+=y*Be,xe+=y*ce,se+=y*Ue,ve+=y*$e,le+=y*me,ie+=y*ze,ue+=y*ke,fe+=y*ge,te+=y*Le,pe+=y*Pe,_e+=y*ye,re+=y*Ke,y=q[4],we+=y*Te,Se+=y*Ce,he+=y*de,Re+=y*Fe,xe+=y*Be,se+=y*ce,ve+=y*Ue,le+=y*$e,ie+=y*me,ue+=y*ze,fe+=y*ke,te+=y*ge,pe+=y*Le,_e+=y*Pe,re+=y*ye,Ae+=y*Ke,y=q[5],Se+=y*Te,he+=y*Ce,Re+=y*de,xe+=y*Fe,se+=y*Be,ve+=y*ce,le+=y*Ue,ie+=y*$e,ue+=y*me,fe+=y*ze,te+=y*ke,pe+=y*ge,_e+=y*Le,re+=y*Pe,Ae+=y*ye,Ee+=y*Ke,y=q[6],he+=y*Te,Re+=y*Ce,xe+=y*de,se+=y*Fe,ve+=y*Be,le+=y*ce,ie+=y*Ue,ue+=y*$e,fe+=y*me,te+=y*ze,pe+=y*ke,_e+=y*ge,re+=y*Le,Ae+=y*Pe,Ee+=y*ye,oe+=y*Ke,y=q[7],Re+=y*Te,xe+=y*Ce,se+=y*de,ve+=y*Fe,le+=y*Be,ie+=y*ce,ue+=y*Ue,fe+=y*$e,te+=y*me,pe+=y*ze,_e+=y*ke,re+=y*ge,Ae+=y*Le,Ee+=y*Pe,oe+=y*ye,De+=y*Ke,y=q[8],xe+=y*Te,se+=y*Ce,ve+=y*de,le+=y*Fe,ie+=y*Be,ue+=y*ce,fe+=y*Ue,te+=y*$e,pe+=y*me,_e+=y*ze,re+=y*ke,Ae+=y*ge,Ee+=y*Le,oe+=y*Pe,De+=y*ye,Me+=y*Ke,y=q[9],se+=y*Te,ve+=y*Ce,le+=y*de,ie+=y*Fe,ue+=y*Be,fe+=y*ce,te+=y*Ue,pe+=y*$e,_e+=y*me,re+=y*ze,Ae+=y*ke,Ee+=y*ge,oe+=y*Le,De+=y*Pe,Me+=y*ye,Oe+=y*Ke,y=q[10],ve+=y*Te,le+=y*Ce,ie+=y*de,ue+=y*Fe,fe+=y*Be,te+=y*ce,pe+=y*Ue,_e+=y*$e,re+=y*me,Ae+=y*ze,Ee+=y*ke,oe+=y*ge,De+=y*Le,Me+=y*Pe,Oe+=y*ye,We+=y*Ke,y=q[11],le+=y*Te,ie+=y*Ce,ue+=y*de,fe+=y*Fe,te+=y*Be,pe+=y*ce,_e+=y*Ue,re+=y*$e,Ae+=y*me,Ee+=y*ze,oe+=y*ke,De+=y*ge,Me+=y*Le,Oe+=y*Pe,We+=y*ye,Qe+=y*Ke,y=q[12],ie+=y*Te,ue+=y*Ce,fe+=y*de,te+=y*Fe,pe+=y*Be,_e+=y*ce,re+=y*Ue,Ae+=y*$e,Ee+=y*me,oe+=y*ze,De+=y*ke,Me+=y*ge,Oe+=y*Le,We+=y*Pe,Qe+=y*ye,Ie+=y*Ke,y=q[13],ue+=y*Te,fe+=y*Ce,te+=y*de,pe+=y*Fe,_e+=y*Be,re+=y*ce,Ae+=y*Ue,Ee+=y*$e,oe+=y*me,De+=y*ze,Me+=y*ke,Oe+=y*ge,We+=y*Le,Qe+=y*Pe,Ie+=y*ye,et+=y*Ke,y=q[14],fe+=y*Te,te+=y*Ce,pe+=y*de,_e+=y*Fe,re+=y*Be,Ae+=y*ce,Ee+=y*Ue,oe+=y*$e,De+=y*me,Me+=y*ze,Oe+=y*ke,We+=y*ge,Qe+=y*Le,Ie+=y*Pe,et+=y*ye,tt+=y*Ke,y=q[15],te+=y*Te,pe+=y*Ce,_e+=y*de,re+=y*Fe,Ae+=y*Be,Ee+=y*ce,oe+=y*Ue,De+=y*$e,Me+=y*me,Oe+=y*ze,We+=y*ke,Qe+=y*ge,Ie+=y*Le,et+=y*Pe,tt+=y*ye,Ne+=y*Ke,G+=38*pe,Y+=38*_e,X+=38*re,ee+=38*Ae,we+=38*Ee,Se+=38*oe,he+=38*De,Re+=38*Me,xe+=38*Oe,se+=38*We,ve+=38*Qe,le+=38*Ie,ie+=38*et,ue+=38*tt,fe+=38*Ne,L=1,y=G+L+65535,L=Math.floor(y/65536),G=y-L*65536,y=Y+L+65535,L=Math.floor(y/65536),Y=y-L*65536,y=X+L+65535,L=Math.floor(y/65536),X=y-L*65536,y=ee+L+65535,L=Math.floor(y/65536),ee=y-L*65536,y=we+L+65535,L=Math.floor(y/65536),we=y-L*65536,y=Se+L+65535,L=Math.floor(y/65536),Se=y-L*65536,y=he+L+65535,L=Math.floor(y/65536),he=y-L*65536,y=Re+L+65535,L=Math.floor(y/65536),Re=y-L*65536,y=xe+L+65535,L=Math.floor(y/65536),xe=y-L*65536,y=se+L+65535,L=Math.floor(y/65536),se=y-L*65536,y=ve+L+65535,L=Math.floor(y/65536),ve=y-L*65536,y=le+L+65535,L=Math.floor(y/65536),le=y-L*65536,y=ie+L+65535,L=Math.floor(y/65536),ie=y-L*65536,y=ue+L+65535,L=Math.floor(y/65536),ue=y-L*65536,y=fe+L+65535,L=Math.floor(y/65536),fe=y-L*65536,y=te+L+65535,L=Math.floor(y/65536),te=y-L*65536,G+=L-1+37*(L-1),L=1,y=G+L+65535,L=Math.floor(y/65536),G=y-L*65536,y=Y+L+65535,L=Math.floor(y/65536),Y=y-L*65536,y=X+L+65535,L=Math.floor(y/65536),X=y-L*65536,y=ee+L+65535,L=Math.floor(y/65536),ee=y-L*65536,y=we+L+65535,L=Math.floor(y/65536),we=y-L*65536,y=Se+L+65535,L=Math.floor(y/65536),Se=y-L*65536,y=he+L+65535,L=Math.floor(y/65536),he=y-L*65536,y=Re+L+65535,L=Math.floor(y/65536),Re=y-L*65536,y=xe+L+65535,L=Math.floor(y/65536),xe=y-L*65536,y=se+L+65535,L=Math.floor(y/65536),se=y-L*65536,y=ve+L+65535,L=Math.floor(y/65536),ve=y-L*65536,y=le+L+65535,L=Math.floor(y/65536),le=y-L*65536,y=ie+L+65535,L=Math.floor(y/65536),ie=y-L*65536,y=ue+L+65535,L=Math.floor(y/65536),ue=y-L*65536,y=fe+L+65535,L=Math.floor(y/65536),fe=y-L*65536,y=te+L+65535,L=Math.floor(y/65536),te=y-L*65536,G+=L-1+37*(L-1),C[0]=G,C[1]=Y,C[2]=X,C[3]=ee,C[4]=we,C[5]=Se,C[6]=he,C[7]=Re,C[8]=xe,C[9]=se,C[10]=ve,C[11]=le,C[12]=ie,C[13]=ue,C[14]=fe,C[15]=te}function P(C,q){_(C,q,q)}function J(C,q){const T=n();let y;for(y=0;y<16;y++)T[y]=q[y];for(y=253;y>=0;y--)P(T,T),y!==2&&y!==4&&_(T,T,q);for(y=0;y<16;y++)C[y]=T[y]}function Q(C,q){const T=n();let y;for(y=0;y<16;y++)T[y]=q[y];for(y=250;y>=0;y--)P(T,T),y!==1&&_(T,T,q);for(y=0;y<16;y++)C[y]=T[y]}function R(C,q){const T=n(),y=n(),L=n(),G=n(),Y=n(),X=n(),ee=n(),we=n(),Se=n();z(T,C[1],C[0]),z(Se,q[1],q[0]),_(T,T,Se),U(y,C[0],C[1]),U(Se,q[0],q[1]),_(y,y,Se),_(L,C[3],q[3]),_(L,L,h),_(G,C[2],q[2]),U(G,G,G),z(Y,y,T),z(X,G,L),U(ee,G,L),U(we,y,T),_(C[0],Y,X),_(C[1],we,ee),_(C[2],ee,X),_(C[3],Y,we)}function p(C,q,T){for(let y=0;y<4;y++)N(C[y],q[y],T)}function l(C,q){const T=n(),y=n(),L=n();J(L,q[2]),_(T,q[0],L),_(y,q[1],L),k(C,y),C[31]^=j(T)<<7}function a(C,q,T){M(C[0],o),M(C[1],f),M(C[2],f),M(C[3],o);for(let y=255;y>=0;--y){const L=T[y/8|0]>>(y&7)&1;p(C,q,L),R(q,C),R(C,C),p(C,q,L)}}function c(C,q){const T=[n(),n(),n(),n()];M(T[0],g),M(T[1],m),M(T[2],f),_(T[3],g,m),a(C,T,q)}function b(C){if(C.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const q=(0,t.hash)(C);q[0]&=248,q[31]&=127,q[31]|=64;const T=new Uint8Array(32),y=[n(),n(),n(),n()];c(y,q),l(T,y);const L=new Uint8Array(64);return L.set(C),L.set(T,32),{publicKey:T,secretKey:L}}r.generateKeyPairFromSeed=b;function A(C){const q=(0,e.randomBytes)(32,C),T=b(q);return(0,i.wipe)(q),T}r.generateKeyPair=A;function E(C){if(C.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(C.subarray(32))}r.extractPublicKeyFromSecretKey=E;const x=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function d(C,q){let T,y,L,G;for(y=63;y>=32;--y){for(T=0,L=y-32,G=y-12;L<G;++L)q[L]+=T-16*q[y]*x[L-(y-32)],T=Math.floor((q[L]+128)/256),q[L]-=T*256;q[L]+=T,q[y]=0}for(T=0,L=0;L<32;L++)q[L]+=T-(q[31]>>4)*x[L],T=q[L]>>8,q[L]&=255;for(L=0;L<32;L++)q[L]-=T*x[L];for(y=0;y<32;y++)q[y+1]+=q[y]>>8,C[y]=q[y]&255}function w(C){const q=new Float64Array(64);for(let T=0;T<64;T++)q[T]=C[T];for(let T=0;T<64;T++)C[T]=0;d(C,q)}function v(C,q){const T=new Float64Array(64),y=[n(),n(),n(),n()],L=(0,t.hash)(C.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const G=new Uint8Array(64);G.set(L.subarray(32),32);const Y=new t.SHA512;Y.update(G.subarray(32)),Y.update(q);const X=Y.digest();Y.clean(),w(X),c(y,X),l(G,y),Y.reset(),Y.update(G.subarray(0,32)),Y.update(C.subarray(32)),Y.update(q);const ee=Y.digest();w(ee);for(let we=0;we<32;we++)T[we]=X[we];for(let we=0;we<32;we++)for(let Se=0;Se<32;Se++)T[we+Se]+=ee[we]*L[Se];return d(G.subarray(32),T),G}r.sign=v;function O(C,q){const T=n(),y=n(),L=n(),G=n(),Y=n(),X=n(),ee=n();return M(C[2],f),F(C[1],q),P(L,C[1]),_(G,L,u),z(L,L,C[2]),U(G,C[2],G),P(Y,G),P(X,Y),_(ee,X,Y),_(T,ee,L),_(T,T,G),Q(T,T),_(T,T,L),_(T,T,G),_(T,T,G),_(C[0],T,G),P(y,C[0]),_(y,y,G),B(y,L)&&_(C[0],C[0],I),P(y,C[0]),_(y,y,G),B(y,L)?-1:(j(C[0])===q[31]>>7&&z(C[0],o,C[0]),_(C[3],C[0],C[1]),0)}function W(C,q,T){const y=new Uint8Array(32),L=[n(),n(),n(),n()],G=[n(),n(),n(),n()];if(T.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(O(G,C))return!1;const Y=new t.SHA512;Y.update(T.subarray(0,32)),Y.update(C),Y.update(q);const X=Y.digest();return w(X),a(L,G,X),c(G,T.subarray(32)),R(L,G),l(y,L),!K(T,y)}r.verify=W;function S(C){let q=[n(),n(),n(),n()];if(O(q,C))throw new Error("Ed25519: invalid public key");let T=n(),y=n(),L=q[1];U(T,f,L),z(y,f,L),J(y,y),_(T,T,y);let G=new Uint8Array(32);return k(G,T),G}r.convertPublicKeyToX25519=S;function H(C){const q=(0,t.hash)(C.subarray(0,32));q[0]&=248,q[31]&=127,q[31]|=64;const T=new Uint8Array(q.subarray(0,32));return(0,i.wipe)(q),T}r.convertSecretKeyToX25519=H}(Xa);const i1="EdDSA",n1="JWT",zs=".",ks="base64url",vc="utf8",mc="utf8",s1=":",a1="did",o1="key",yc="base58btc",f1="z",c1="K36",h1=32;function wc(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Ks(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));const t=wc(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t}function u1(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var f=r.length,u=r.charAt(0),h=Math.log(f)/Math.log(256),g=Math.log(256)/Math.log(f);function m(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var N=0,k=0,K=0,B=D.length;K!==B&&D[K]===0;)K++,N++;for(var j=(B-K)*g+1>>>0,F=new Uint8Array(j);K!==B;){for(var U=D[K],z=0,_=j-1;(U!==0||z<k)&&_!==-1;_--,z++)U+=256*F[_]>>>0,F[_]=U%f>>>0,U=U/f>>>0;if(U!==0)throw new Error("Non-zero carry");k=z,K++}for(var P=j-k;P!==j&&F[P]===0;)P++;for(var J=u.repeat(N);P<j;++P)J+=r.charAt(F[P]);return J}function I(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var N=0;if(D[N]!==" "){for(var k=0,K=0;D[N]===u;)k++,N++;for(var B=(D.length-N)*h+1>>>0,j=new Uint8Array(B);D[N];){var F=t[D.charCodeAt(N)];if(F===255)return;for(var U=0,z=B-1;(F!==0||U<K)&&z!==-1;z--,U++)F+=f*j[z]>>>0,j[z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");K=U,N++}if(D[N]!==" "){for(var _=B-K;_!==B&&j[_]===0;)_++;for(var P=new Uint8Array(k+(B-_)),J=k;_!==B;)P[J++]=j[_++];return P}}}function M(D){var N=I(D);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:I,decode:M}}var d1=u1,l1=d1;const _c=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},p1=r=>new TextEncoder().encode(r),g1=r=>new TextDecoder().decode(r);class b1{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class v1{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 xc(this,e)}}class m1{constructor(e){this.decoders=e}or(e){return xc(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 xc=(r,e)=>new m1({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class y1{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new b1(e,t,i),this.decoder=new v1(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const js=({name:r,prefix:e,encode:t,decode:i})=>new y1(r,e,t,i),zn=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=l1(t,e);return js({prefix:r,name:e,encode:i,decode:s=>_c(n(s))})},w1=(r,e,t,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let f=0,u=0,h=0;for(let g=0;g<s;++g){const m=n[r[g]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<t|m,f+=t,f>=8&&(f-=8,o[h++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},_1=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,f=0;for(let u=0;u<r.length;++u)for(f=f<<8|r[u],o+=8;o>t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<<t-o]),i)for(;s.length*t&7;)s+="=";return s},Rt=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>js({prefix:e,name:r,encode(n){return _1(n,i,t)},decode(n){return w1(n,i,t,r)}}),x1=js({prefix:"\0",name:"identity",encode:r=>g1(r),decode:r=>p1(r)});var A1=Object.freeze({__proto__:null,identity:x1});const E1=Rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var S1=Object.freeze({__proto__:null,base2:E1});const M1=Rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var I1=Object.freeze({__proto__:null,base8:M1});const D1=zn({prefix:"9",name:"base10",alphabet:"0123456789"});var O1=Object.freeze({__proto__:null,base10:D1});const P1=Rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),R1=Rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var N1=Object.freeze({__proto__:null,base16:P1,base16upper:R1});const C1=Rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),T1=Rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),F1=Rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),B1=Rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),L1=Rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),q1=Rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),U1=Rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$1=Rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),z1=Rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var k1=Object.freeze({__proto__:null,base32:C1,base32upper:T1,base32pad:F1,base32padupper:B1,base32hex:L1,base32hexupper:q1,base32hexpad:U1,base32hexpadupper:$1,base32z:z1});const K1=zn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),j1=zn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var H1=Object.freeze({__proto__:null,base36:K1,base36upper:j1});const V1=zn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),G1=zn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var W1=Object.freeze({__proto__:null,base58btc:V1,base58flickr:G1});const J1=Rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Y1=Rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Q1=Rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),X1=Rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Z1=Object.freeze({__proto__:null,base64:J1,base64pad:Y1,base64url:Q1,base64urlpad:X1});const Ac=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}"),eg=Ac.reduce((r,e,t)=>(r[t]=e,r),[]),tg=Ac.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function rg(r){return r.reduce((e,t)=>(e+=eg[t],e),"")}function ig(r){const e=[];for(const t of r){const i=tg[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const ng=js({prefix:"\u{1F680}",name:"base256emoji",encode:rg,decode:ig});var sg=Object.freeze({__proto__:null,base256emoji:ng}),ag=Sc,Ec=128,og=127,fg=~og,cg=Math.pow(2,31);function Sc(r,e,t){e=e||[],t=t||0;for(var i=t;r>=cg;)e[t++]=r&255|Ec,r/=128;for(;r&fg;)e[t++]=r&255|Ec,r>>>=7;return e[t]=r|0,Sc.bytes=t-i+1,e}var hg=io,ug=128,Mc=127;function io(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw io.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Mc)<<n:(o&Mc)*Math.pow(2,n),n+=7}while(o>=ug);return io.bytes=s-i,t}var dg=Math.pow(2,7),lg=Math.pow(2,14),pg=Math.pow(2,21),gg=Math.pow(2,28),bg=Math.pow(2,35),vg=Math.pow(2,42),mg=Math.pow(2,49),yg=Math.pow(2,56),wg=Math.pow(2,63),_g=function(r){return r<dg?1:r<lg?2:r<pg?3:r<gg?4:r<bg?5:r<vg?6:r<mg?7:r<yg?8:r<wg?9:10},xg={encode:ag,decode:hg,encodingLength:_g},Ic=xg;const Dc=(r,e,t=0)=>(Ic.encode(r,e,t),e),Oc=r=>Ic.encodingLength(r),no=(r,e)=>{const t=e.byteLength,i=Oc(r),n=i+Oc(t),s=new Uint8Array(n+t);return Dc(r,s,0),Dc(t,s,i),s.set(e,n),new Ag(r,t,e,s)};class Ag{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const Pc=({name:r,code:e,encode:t})=>new Eg(r,e,t);class Eg{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?no(this.code,t):t.then(i=>no(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Rc=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Sg=Pc({name:"sha2-256",code:18,encode:Rc("SHA-256")}),Mg=Pc({name:"sha2-512",code:19,encode:Rc("SHA-512")});var Ig=Object.freeze({__proto__:null,sha256:Sg,sha512:Mg});const Nc=0,Dg="identity",Cc=_c;var Og=Object.freeze({__proto__:null,identity:{code:Nc,name:Dg,encode:Cc,digest:r=>no(Nc,Cc(r))}});new TextEncoder,new TextDecoder;const Tc={...A1,...S1,...I1,...O1,...N1,...k1,...H1,...W1,...Z1,...sg};({...Ig,...Og});function Fc(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Bc=Fc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),so=Fc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=wc(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Lc={utf8:Bc,"utf-8":Bc,hex:Tc.base16,latin1:so,ascii:so,binary:so,...Tc};function xt(r,e="utf8"){const t=Lc[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function At(r,e="utf8"){const t=Lc[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}function qc(r){return fn(xt(At(r,ks),vc))}function Hs(r){return xt(At(qi(r),vc),ks)}function Uc(r){const e=At(c1,yc),t=f1+xt(Ks([e,r]),yc);return[a1,o1,t].join(s1)}function Pg(r){return xt(r,ks)}function Rg(r){return At(r,ks)}function Ng(r){return At([Hs(r.header),Hs(r.payload)].join(zs),mc)}function Cg(r){return[Hs(r.header),Hs(r.payload),Pg(r.signature)].join(zs)}function ao(r){const e=r.split(zs),t=qc(e[0]),i=qc(e[1]),n=Rg(e[2]),s=At(e.slice(0,2).join(zs),mc);return{header:t,payload:i,signature:n,data:s}}function $c(r=_i.randomBytes(h1)){return Xa.generateKeyPairFromSeed(r)}async function Tg(r,e,t,i,n=ae.fromMiliseconds(Date.now())){const s={alg:i1,typ:n1},o=Uc(i.publicKey),f=n+t,u={iss:o,sub:r,aud:e,iat:n,exp:f},h=Ng({header:s,payload:u}),g=Xa.sign(i.secretKey,h);return Cg({header:s,payload:u,signature:g})}var zc=function(r,e,t){if(t||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 r.concat(s||Array.prototype.slice.call(e))},Fg=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),Bg=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return r}(),Lg=function(){function r(e,t,i,n){this.name=e,this.version=t,this.os=i,this.bot=n,this.type="bot-device"}return r}(),qg=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),Ug=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),$g=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,zg=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,kc=3,kg=[["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",$g]],Kc=[["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 Kg(r){return r?jc(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Ug:typeof navigator<"u"?jc(navigator.userAgent):Vg()}function jg(r){return r!==""&&kg.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function jc(r){var e=jg(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new qg;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<kc&&(n=zc(zc([],n,!0),Gg(kc-n.length),!0)):n=[];var s=n.join("."),o=Hg(r),f=zg.exec(r);return f&&f[1]?new Lg(t,s,o,f[1]):new Fg(t,s,o)}function Hg(r){for(var e=0,t=Kc.length;e<t;e++){var i=Kc[e],n=i[0],s=i[1],o=s.exec(r);if(o)return n}return null}function Vg(){var r=typeof process<"u"&&process.version;return r?new Bg(process.version.slice(1)):null}function Gg(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.getLocalStorage=at.getLocalStorageOrThrow=at.getCrypto=at.getCryptoOrThrow=Hc=at.getLocation=at.getLocationOrThrow=oo=at.getNavigator=at.getNavigatorOrThrow=kn=at.getDocument=at.getDocumentOrThrow=at.getFromWindowOrThrow=at.getFromWindow=void 0;function Ui(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}at.getFromWindow=Ui;function un(r){const e=Ui(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}at.getFromWindowOrThrow=un;function Wg(){return un("document")}at.getDocumentOrThrow=Wg;function Jg(){return Ui("document")}var kn=at.getDocument=Jg;function Yg(){return un("navigator")}at.getNavigatorOrThrow=Yg;function Qg(){return Ui("navigator")}var oo=at.getNavigator=Qg;function Xg(){return un("location")}at.getLocationOrThrow=Xg;function Zg(){return Ui("location")}var Hc=at.getLocation=Zg;function eb(){return un("crypto")}at.getCryptoOrThrow=eb;function tb(){return Ui("crypto")}at.getCrypto=tb;function rb(){return un("localStorage")}at.getLocalStorageOrThrow=rb;function ib(){return Ui("localStorage")}at.getLocalStorage=ib;var fo={};Object.defineProperty(fo,"__esModule",{value:!0});var Vc=fo.getWindowMetadata=void 0;const Gc=at;function nb(){let r,e;try{r=Gc.getDocumentOrThrow(),e=Gc.getLocationOrThrow()}catch{return null}function t(){const m=r.getElementsByTagName("link"),I=[];for(let M=0;M<m.length;M++){const D=m[M],N=D.getAttribute("rel");if(N&&N.toLowerCase().indexOf("icon")>-1){const k=D.getAttribute("href");if(k)if(k.toLowerCase().indexOf("https:")===-1&&k.toLowerCase().indexOf("http:")===-1&&k.indexOf("//")!==0){let K=e.protocol+"//"+e.host;if(k.indexOf("/")===0)K+=k;else{const B=e.pathname.split("/");B.pop();const j=B.join("/");K+=j+"/"+k}I.push(K)}else if(k.indexOf("//")===0){const K=e.protocol+k;I.push(K)}else I.push(k)}}return I}function i(...m){const I=r.getElementsByTagName("meta");for(let M=0;M<I.length;M++){const D=I[M],N=["itemprop","property","name"].map(k=>D.getAttribute(k)).filter(k=>k?m.includes(k):!1);if(N.length&&N){const k=D.getAttribute("content");if(k)return k}}return""}function n(){let m=i("name","og:site_name","og:title","twitter:title");return m||(m=r.title),m}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),f=s(),u=e.origin,h=t();return{description:f,url:u,icons:h,name:o}}Vc=fo.getWindowMetadata=nb;var Kn={},sb=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Wc="%[a-f0-9]{2}",Jc=new RegExp("("+Wc+")|([^%]+?)","gi"),Yc=new RegExp("("+Wc+")+","gi");function co(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],co(t),co(i))}function ab(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(Jc)||[],t=1;t<e.length;t++)r=co(e,t).join(""),e=r.match(Jc)||[];return r}}function ob(r){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},t=Yc.exec(r);t;){try{e[t[0]]=decodeURIComponent(t[0])}catch{var i=ab(t[0]);i!==t[0]&&(e[t[0]]=i)}t=Yc.exec(r)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];r=r.replace(new RegExp(o,"g"),e[o])}return r}var fb=function(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return r=r.replace(/\+/g," "),decodeURIComponent(r)}catch{return ob(r)}},cb=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},hb=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],f=r[o];(n?e.indexOf(o)!==-1:e(o,f,r))&&(t[o]=f)}return t};(function(r){const e=sb,t=fb,i=cb,n=hb,s=B=>B==null,o=Symbol("encodeFragmentIdentifier");function f(B){switch(B.arrayFormat){case"index":return j=>(F,U)=>{const z=F.length;return U===void 0||B.skipNull&&U===null||B.skipEmptyString&&U===""?F:U===null?[...F,[g(j,B),"[",z,"]"].join("")]:[...F,[g(j,B),"[",g(z,B),"]=",g(U,B)].join("")]};case"bracket":return j=>(F,U)=>U===void 0||B.skipNull&&U===null||B.skipEmptyString&&U===""?F:U===null?[...F,[g(j,B),"[]"].join("")]:[...F,[g(j,B),"[]=",g(U,B)].join("")];case"colon-list-separator":return j=>(F,U)=>U===void 0||B.skipNull&&U===null||B.skipEmptyString&&U===""?F:U===null?[...F,[g(j,B),":list="].join("")]:[...F,[g(j,B),":list=",g(U,B)].join("")];case"comma":case"separator":case"bracket-separator":{const j=B.arrayFormat==="bracket-separator"?"[]=":"=";return F=>(U,z)=>z===void 0||B.skipNull&&z===null||B.skipEmptyString&&z===""?U:(z=z===null?"":z,U.length===0?[[g(F,B),j,g(z,B)].join("")]:[[U,g(z,B)].join(B.arrayFormatSeparator)])}default:return j=>(F,U)=>U===void 0||B.skipNull&&U===null||B.skipEmptyString&&U===""?F:U===null?[...F,g(j,B)]:[...F,[g(j,B),"=",g(U,B)].join("")]}}function u(B){let j;switch(B.arrayFormat){case"index":return(F,U,z)=>{if(j=/\[(\d*)\]$/.exec(F),F=F.replace(/\[\d*\]$/,""),!j){z[F]=U;return}z[F]===void 0&&(z[F]={}),z[F][j[1]]=U};case"bracket":return(F,U,z)=>{if(j=/(\[\])$/.exec(F),F=F.replace(/\[\]$/,""),!j){z[F]=U;return}if(z[F]===void 0){z[F]=[U];return}z[F]=[].concat(z[F],U)};case"colon-list-separator":return(F,U,z)=>{if(j=/(:list)$/.exec(F),F=F.replace(/:list$/,""),!j){z[F]=U;return}if(z[F]===void 0){z[F]=[U];return}z[F]=[].concat(z[F],U)};case"comma":case"separator":return(F,U,z)=>{const _=typeof U=="string"&&U.includes(B.arrayFormatSeparator),P=typeof U=="string"&&!_&&m(U,B).includes(B.arrayFormatSeparator);U=P?m(U,B):U;const J=_||P?U.split(B.arrayFormatSeparator).map(Q=>m(Q,B)):U===null?U:m(U,B);z[F]=J};case"bracket-separator":return(F,U,z)=>{const _=/(\[\])$/.test(F);if(F=F.replace(/\[\]$/,""),!_){z[F]=U&&m(U,B);return}const P=U===null?[]:U.split(B.arrayFormatSeparator).map(J=>m(J,B));if(z[F]===void 0){z[F]=P;return}z[F]=[].concat(z[F],P)};default:return(F,U,z)=>{if(z[F]===void 0){z[F]=U;return}z[F]=[].concat(z[F],U)}}}function h(B){if(typeof B!="string"||B.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(B,j){return j.encode?j.strict?e(B):encodeURIComponent(B):B}function m(B,j){return j.decode?t(B):B}function I(B){return Array.isArray(B)?B.sort():typeof B=="object"?I(Object.keys(B)).sort((j,F)=>Number(j)-Number(F)).map(j=>B[j]):B}function M(B){const j=B.indexOf("#");return j!==-1&&(B=B.slice(0,j)),B}function D(B){let j="";const F=B.indexOf("#");return F!==-1&&(j=B.slice(F)),j}function N(B){B=M(B);const j=B.indexOf("?");return j===-1?"":B.slice(j+1)}function k(B,j){return j.parseNumbers&&!Number.isNaN(Number(B))&&typeof B=="string"&&B.trim()!==""?B=Number(B):j.parseBooleans&&B!==null&&(B.toLowerCase()==="true"||B.toLowerCase()==="false")&&(B=B.toLowerCase()==="true"),B}function K(B,j){j=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},j),h(j.arrayFormatSeparator);const F=u(j),U=Object.create(null);if(typeof B!="string"||(B=B.trim().replace(/^[?#&]/,""),!B))return U;for(const z of B.split("&")){if(z==="")continue;let[_,P]=i(j.decode?z.replace(/\+/g," "):z,"=");P=P===void 0?null:["comma","separator","bracket-separator"].includes(j.arrayFormat)?P:m(P,j),F(m(_,j),P,U)}for(const z of Object.keys(U)){const _=U[z];if(typeof _=="object"&&_!==null)for(const P of Object.keys(_))_[P]=k(_[P],j);else U[z]=k(_,j)}return j.sort===!1?U:(j.sort===!0?Object.keys(U).sort():Object.keys(U).sort(j.sort)).reduce((z,_)=>{const P=U[_];return P&&typeof P=="object"&&!Array.isArray(P)?z[_]=I(P):z[_]=P,z},Object.create(null))}r.extract=N,r.parse=K,r.stringify=(B,j)=>{if(!B)return"";j=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},j),h(j.arrayFormatSeparator);const F=P=>j.skipNull&&s(B[P])||j.skipEmptyString&&B[P]==="",U=f(j),z={};for(const P of Object.keys(B))F(P)||(z[P]=B[P]);const _=Object.keys(z);return j.sort!==!1&&_.sort(j.sort),_.map(P=>{const J=B[P];return J===void 0?"":J===null?g(P,j):Array.isArray(J)?J.length===0&&j.arrayFormat==="bracket-separator"?g(P,j)+"[]":J.reduce(U(P),[]).join("&"):g(P,j)+"="+g(J,j)}).filter(P=>P.length>0).join("&")},r.parseUrl=(B,j)=>{j=Object.assign({decode:!0},j);const[F,U]=i(B,"#");return Object.assign({url:F.split("?")[0]||"",query:K(N(B),j)},j&&j.parseFragmentIdentifier&&U?{fragmentIdentifier:m(U,j)}:{})},r.stringifyUrl=(B,j)=>{j=Object.assign({encode:!0,strict:!0,[o]:!0},j);const F=M(B.url).split("?")[0]||"",U=r.extract(B.url),z=r.parse(U,{sort:!1}),_=Object.assign(z,B.query);let P=r.stringify(_,j);P&&(P=`?${P}`);let J=D(B.url);return B.fragmentIdentifier&&(J=`#${j[o]?g(B.fragmentIdentifier,j):B.fragmentIdentifier}`),`${F}${P}${J}`},r.pick=(B,j,F)=>{F=Object.assign({parseFragmentIdentifier:!0,[o]:!1},F);const{url:U,query:z,fragmentIdentifier:_}=r.parseUrl(B,F);return r.stringifyUrl({url:U,query:n(z,j),fragmentIdentifier:_},F)},r.exclude=(B,j,F)=>{const U=Array.isArray(j)?z=>!j.includes(z):(z,_)=>!j(z,_);return r.pick(B,U,F)}})(Kn);var Qc={exports:{}};/**
|
14
|
+
***************************************************************************** */var la=function(t,e){return la=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])},la(t,e)};function Tp(t,e){la(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 Cp(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 Bp(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 Lp(t,e){return function(r,i){e(r,i,t)}}function qp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Up(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(v){o(v)}}function c(l){try{h(i.throw(l))}catch(v){o(v)}}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 kp(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function jp(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function ga(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 Cc(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 Kp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Cc(arguments[e]));return t}function Vp(){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 Hp(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){v(s[0][3],S)}}function c(M){M.value instanceof is?Promise.resolve(M.value.v).then(h,l):v(s[0][2],M)}function h(M){a("next",M)}function l(M){a("throw",M)}function v(M,I){M(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Wp(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 Gp(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 ga=="function"?ga(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 Jp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Yp(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 Xp(t){return t&&t.__esModule?t:{default:t}}function Zp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function Qp(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 e1=Object.freeze({__proto__:null,__extends:Tp,get __assign(){return pa},__rest:Cp,__decorate:Bp,__param:Lp,__metadata:qp,__awaiter:Up,__generator:zp,__createBinding:kp,__exportStar:jp,__values:ga,__read:Cc,__spread:Kp,__spreadArrays:Vp,__await:is,__asyncGenerator:Hp,__asyncDelegator:Wp,__asyncValues:Gp,__makeTemplateObject:Jp,__importStar:Yp,__importDefault:Xp,__classPrivateFieldGet:Zp,__classPrivateFieldSet:Qp}),Zs=ua(e1),ba={},ns={},Bc;function t1(){if(Bc)return ns;Bc=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 Xi={},va={},Zi={},Lc;function r1(){return Lc||(Lc=1,Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.ONE_THOUSAND=Zi.ONE_HUNDRED=void 0,Zi.ONE_HUNDRED=100,Zi.ONE_THOUSAND=1e3),Zi}var ya={},qc;function i1(){return qc||(qc=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}(ya)),ya}var Uc;function zc(){return Uc||(Uc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Zs;e.__exportStar(r1(),t),e.__exportStar(i1(),t)}(va)),va}var kc;function n1(){if(kc)return Xi;kc=1,Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.fromMiliseconds=Xi.toMiliseconds=void 0;const t=zc();function e(i){return i*t.ONE_THOUSAND}Xi.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Xi.fromMiliseconds=r,Xi}var jc;function s1(){return jc||(jc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Zs;e.__exportStar(t1(),t),e.__exportStar(n1(),t)}(ba)),ba}var Mn={},Kc;function o1(){if(Kc)return Mn;Kc=1,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.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 Mn.Watch=t,Mn.default=t,Mn}var ma={},ss={},Vc;function a1(){if(Vc)return ss;Vc=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.IWatch=void 0;class t{}return ss.IWatch=t,ss}var Hc;function f1(){return Hc||(Hc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Zs.__exportStar(a1(),t)}(ma)),ma}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Zs;e.__exportStar(s1(),t),e.__exportStar(o1(),t),e.__exportStar(f1(),t),e.__exportStar(zc(),t)})(Y);class Qi{}class c1 extends Qi{constructor(e){super()}}const Wc=Y.FIVE_SECONDS,In={pulse:"heartbeat_pulse"};class wa extends c1{constructor(e){super(e),this.events=new jt.exports.EventEmitter,this.interval=Wc,this.interval=e?.interval||Wc}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(),Y.toMiliseconds(this.interval))}pulse(){this.events.emit(In.pulse)}}const h1=/"(?:_|\\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*:/,u1=/"(?: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*:/,d1=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function l1(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){p1(t);return}return e}function p1(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Qs(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(!d1.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(h1.test(t)||u1.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,l1)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function g1(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function St(t,...e){try{return g1(t(...e))}catch(r){return Promise.reject(r)}}function b1(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function v1(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function eo(t){if(b1(t))return String(t);if(v1(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return eo(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Gc(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const _a="base64:";function y1(t){if(typeof t=="string")return t;Gc();const e=Buffer.from(t).toString("base64");return _a+e}function m1(t){return typeof t!="string"||!t.startsWith(_a)?t:(Gc(),Buffer.from(t.slice(_a.length),"base64"))}function er(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function w1(...t){return er(t.join(":"))}function to(t){return t=er(t),t?t+":":""}function Gx(t){return t}const _1="memory",x1=()=>{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 E1(t={}){const e={mounts:{"":t.driver||x1()},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(v=>v.startsWith(h)||l&&h.startsWith(v)).map(v=>({relativeBase:h.length>v.length?h.slice(v.length):void 0,mountpoint:v,driver:e.mounts[v]})),n=(h,l)=>{if(e.watching){l=er(l);for(const v of e.watchListeners)v(h,l)}},s=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await Jc(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,v)=>{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",F=er(D?S:S.key),T=D?void 0:S.value,O=D||!S.options?l:{...l,...S.options},$=r(F);I($).items.push({key:F,value:T,relativeKey:$.relativeKey,options:O})}return Promise.all([...M.values()].map(S=>v(S))).then(S=>S.flat())},c={hasItem(h,l={}){h=er(h);const{relativeKey:v,driver:M}=r(h);return St(M.hasItem,v,l)},getItem(h,l={}){h=er(h);const{relativeKey:v,driver:M}=r(h);return St(M.getItem,v,l).then(I=>Qs(I))},getItems(h,l){return a(h,l,v=>v.driver.getItems?St(v.driver.getItems,v.items.map(M=>({key:M.relativeKey,options:M.options})),l).then(M=>M.map(I=>({key:w1(v.base,I.key),value:Qs(I.value)}))):Promise.all(v.items.map(M=>St(v.driver.getItem,M.relativeKey,M.options).then(I=>({key:M.key,value:Qs(I)})))))},getItemRaw(h,l={}){h=er(h);const{relativeKey:v,driver:M}=r(h);return M.getItemRaw?St(M.getItemRaw,v,l):St(M.getItem,v,l).then(I=>m1(I))},async setItem(h,l,v={}){if(l===void 0)return c.removeItem(h);h=er(h);const{relativeKey:M,driver:I}=r(h);I.setItem&&(await St(I.setItem,M,eo(l),v),I.watch||n("update",h))},async setItems(h,l){await a(h,l,async v=>{if(v.driver.setItems)return St(v.driver.setItems,v.items.map(M=>({key:M.relativeKey,value:eo(M.value),options:M.options})),l);v.driver.setItem&&await Promise.all(v.items.map(M=>St(v.driver.setItem,M.relativeKey,eo(M.value),M.options)))})},async setItemRaw(h,l,v={}){if(l===void 0)return c.removeItem(h,v);h=er(h);const{relativeKey:M,driver:I}=r(h);if(I.setItemRaw)await St(I.setItemRaw,M,l,v);else if(I.setItem)await St(I.setItem,M,y1(l),v);else return;I.watch||n("update",h)},async removeItem(h,l={}){typeof l=="boolean"&&(l={removeMeta:l}),h=er(h);const{relativeKey:v,driver:M}=r(h);M.removeItem&&(await St(M.removeItem,v,l),(l.removeMeta||l.removeMata)&&await St(M.removeItem,v+"$",l),M.watch||n("remove",h))},async getMeta(h,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),h=er(h);const{relativeKey:v,driver:M}=r(h),I=Object.create(null);if(M.getMeta&&Object.assign(I,await St(M.getMeta,v,l)),!l.nativeOnly){const S=await St(M.getItem,v+"$",l).then(D=>Qs(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,v={}){return this.setItem(h+"$",l,v)},removeMeta(h,l={}){return this.removeItem(h+"$",l)},async getKeys(h,l={}){h=to(h);const v=i(h,!0);let M=[];const I=[];for(const S of v){const D=await St(S.driver.getKeys,S.relativeBase,l);for(const F of D){const T=S.mountpoint+er(F);M.some(O=>T.startsWith(O))||I.push(T)}M=[S.mountpoint,...M.filter(F=>!F.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=to(h),await Promise.all(i(h,!1).map(async v=>{if(v.driver.clear)return St(v.driver.clear,v.relativeBase,l);if(v.driver.removeItem){const M=await v.driver.getKeys(v.relativeBase||"",l);return Promise.all(M.map(I=>v.driver.removeItem(I,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>Yc(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=to(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((v,M)=>M.length-v.length)),e.mounts[h]=l,e.watching&&Promise.resolve(Jc(l,n,h)).then(v=>{e.unwatch[h]=v}).catch(console.error),c},async unmount(h,l=!0){h=to(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),l&&await Yc(e.mounts[h]),e.mountpoints=e.mountpoints.filter(v=>v!==h),delete e.mounts[h])},getMount(h=""){h=er(h)+":";const l=r(h);return{driver:l.driver,base:l.base}},getMounts(h="",l={}){return h=er(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,v={})=>c.setItem(h,l,v),has:(h,l={})=>c.hasItem(h,l),del:(h,l={})=>c.removeItem(h,l),remove:(h,l={})=>c.removeItem(h,l)};return c}function Jc(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Yc(t){typeof t.dispose=="function"&&await St(t.dispose)}function en(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Xc(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=en(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let xa;function os(){return xa||(xa=Xc("keyval-store","keyval")),xa}function Zc(t,e=os()){return e("readonly",r=>en(r.get(t)))}function S1(t,e,r=os()){return r("readwrite",i=>(i.put(e,t),en(i.transaction)))}function M1(t,e=os()){return e("readwrite",r=>(r.delete(t),en(r.transaction)))}function I1(t=os()){return t("readwrite",e=>(e.clear(),en(e.transaction)))}function A1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},en(t.transaction)}function D1(t=os()){return t("readonly",e=>{if(e.getAllKeys)return en(e.getAllKeys());const r=[];return A1(e,i=>r.push(i.key)).then(()=>r)})}const O1=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),P1=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 An(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return P1(t)}catch{return t}}function tn(t){return typeof t=="string"?t:O1(t)||""}const R1="idb-keyval";var $1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Xc(t.dbName,t.storeName)),{name:R1,options:t,async hasItem(n){return!(typeof await Zc(r(n),i)>"u")},async getItem(n){return await Zc(r(n),i)??null},setItem(n,s){return S1(r(n),s,i)},removeItem(n){return M1(r(n),i)},getKeys(){return D1(i)},clear(){return I1(i)}}};const N1="WALLET_CONNECT_V2_INDEXED_DB",F1="keyvaluestorage";class T1{constructor(){this.indexedDb=E1({driver:$1({dbName:N1,storeName:F1})})}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,tn(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Ea=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ro={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 Ea<"u"&&Ea.localStorage?ro.exports=Ea.localStorage:typeof window<"u"&&window.localStorage?ro.exports=window.localStorage:ro.exports=new e})();function C1(t){var e;return[t[0],An((e=t[1])!=null?e:"")]}class B1{constructor(){this.localStorage=ro.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(C1)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return An(r)}async setItem(e,r){this.localStorage.setItem(e,tn(r))}async removeItem(e){this.localStorage.removeItem(e)}}const L1="wc_storage_version",Qc=1,q1=async(t,e,r)=>{const i=L1,n=await e.getItem(i);if(n&&n>=Qc){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,Qc),r(e),U1(t,o)},U1=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 B1;this.storage=e;try{const r=new T1;q1(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 k1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var j1=K1;function K1(t,e,r){var i=r&&r.stringify||k1,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,v=-1,M=t&&t.length||0,I=0;I<M;){if(t.charCodeAt(I)===37&&I+1<M){switch(v=v>-1?v:0,t.charCodeAt(I+1)){case 100:case 102:if(l>=c||e[l]==null)break;v<I&&(h+=t.slice(v,I)),h+=Number(e[l]),v=I+2,I++;break;case 105:if(l>=c||e[l]==null)break;v<I&&(h+=t.slice(v,I)),h+=Math.floor(Number(e[l])),v=I+2,I++;break;case 79:case 111:case 106:if(l>=c||e[l]===void 0)break;v<I&&(h+=t.slice(v,I));var S=typeof e[l];if(S==="string"){h+="'"+e[l]+"'",v=I+2,I++;break}if(S==="function"){h+=e[l].name||"<anonymous>",v=I+2,I++;break}h+=i(e[l]),v=I+2,I++;break;case 115:if(l>=c)break;v<I&&(h+=t.slice(v,I)),h+=String(e[l]),v=I+2,I++;break;case 37:v<I&&(h+=t.slice(v,I)),h+="%",v=I+2,I++,l--;break}++l}++I}return v===-1?t:(v<M&&(h+=t.slice(v)),h)}const eh=j1;var ai=Kr;const as=eg().console||{},V1={mapHttpRequest:no,mapHttpResponse:no,wrapRequestSerializer:Ma,wrapResponseSerializer:Ma,wrapErrorSerializer:Ma,req:no,res:no,err:Y1};function H1(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Kr(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=H1(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=fs),Object.defineProperty(c,"levelVal",{get:l}),Object.defineProperty(c,"level",{get:v,set:M});const h={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:X1(t)};c.levels=Kr.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=fs,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=I,e&&(c._logEvent=Sa());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function v(){return this._level}function M(S){if(S!=="silent"&&!this.levels.values[S])throw Error("unknown level "+S);this._level=S,Dn(h,c,"error","log"),Dn(h,c,"fatal","error"),Dn(h,c,"warn","error"),Dn(h,c,"info","log"),Dn(h,c,"debug","log"),Dn(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 F=D.serializers;if(n&&F){var T=Object.assign({},i,F),O=t.browser.serialize===!0?Object.keys(T):n;delete S.serializers,io([S],O,T,this._stdErrSerialize)}function $(N){this._childLevel=(N._childLevel|0)+1,this.error=On(N,S,"error"),this.fatal=On(N,S,"fatal"),this.warn=On(N,S,"warn"),this.info=On(N,S,"info"),this.debug=On(N,S,"debug"),this.trace=On(N,S,"trace"),T&&(this.serializers=T,this._serialize=O),e&&(this._logEvent=Sa([].concat(N._logEvent.bindings,S)))}return $.prototype=this,new $(this)}return c}Kr.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"}},Kr.stdSerializers=V1,Kr.stdTimeFunctions=Object.assign({},{nullTime:th,epochTime:rh,unixTime:Z1,isoTime:Q1});function Dn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?fs:n[r]?n[r]:as[r]||as[i]||fs,W1(t,e,r)}function W1(t,e,r){!t.transmit&&e[r]===fs||(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&&io(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,G1(this,r,o,s)):i.apply(a,o),t.transmit){const h=t.transmit.level||e.level,l=Kr.levels.values[h],v=Kr.levels.values[r];if(v<l)return;J1(this,{ts:s,methodLevel:r,methodValue:v,transmitLevel:h,transmitValue:Kr.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function G1(t,e,r,i){t._serialize&&io(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Kr.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?eh(n.shift(),n):void 0}else typeof s=="string"&&(s=eh(n.shift(),n));return s!==void 0&&(o.msg=s),o}function io(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Kr.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 On(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 J1(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;io(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=Sa(c)}function Sa(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Y1(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 X1(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?th:rh}function no(){return{}}function Ma(t){return t}function fs(){}function th(){return!1}function rh(){return Date.now()}function Z1(){return Math.round(Date.now()/1e3)}function Q1(){return new Date(Date.now()).toISOString()}function eg(){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 tg={level:"info"},cs="custom_context",Ia=1e3*1024;class rg{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 ih{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new rg(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 nh{constructor(e,r=Ia){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new ih(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===ai.levels.values.error?console.error(e):r===ai.levels.values.warn?console.warn(e):r===ai.levels.values.debug?console.debug(e):r===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(tn({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 ih(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(tn({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class ig{constructor(e,r=Ia){this.baseChunkLogger=new nh(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 ng{constructor(e,r=Ia){this.baseChunkLogger=new nh(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 sg=Object.defineProperty,og=Object.defineProperties,ag=Object.getOwnPropertyDescriptors,sh=Object.getOwnPropertySymbols,fg=Object.prototype.hasOwnProperty,cg=Object.prototype.propertyIsEnumerable,oh=(t,e,r)=>e in t?sg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,so=(t,e)=>{for(var r in e||(e={}))fg.call(e,r)&&oh(t,r,e[r]);if(sh)for(var r of sh(e))cg.call(e,r)&&oh(t,r,e[r]);return t},oo=(t,e)=>og(t,ag(e));function Aa(t){return oo(so({},t),{level:t?.level||tg.level})}function hg(t,e=cs){return t[e]||""}function ug(t,e,r=cs){return t[r]=e,t}function tr(t,e=cs){let r="";return typeof t.bindings>"u"?r=hg(t,e):r=t.bindings().context||"",r}function dg(t,e,r=cs){const i=tr(t,r);return i.trim()?`${i}/${e}`:e}function Jt(t,e,r=cs){const i=dg(t,e,r),n=t.child({context:i});return ug(n,i,r)}function lg(t){var e,r;const i=new ig((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:ai(oo(so({},t.opts),{level:"trace",browser:oo(so({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function pg(t){var e;const r=new ng((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:ai(oo(so({},t.opts),{level:"trace"})),chunkLoggerController:r}}function gg(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?lg(t):pg(t)}class bg extends Qi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class vg extends Qi{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class yg{constructor(e,r){this.logger=e,this.core=r}}class mg extends Qi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class wg extends Qi{constructor(e){super()}}class _g{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class xg extends Qi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Eg extends Qi{constructor(e,r){super(),this.core=e,this.logger=r}}class Sg{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class Mg{constructor(e,r){this.projectId=e,this.logger=r}}class Ig{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}class Ag{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Dg{constructor(e){this.client=e}}function Og(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ah(t,...e){if(!Og(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 fh(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 Pg(t,e){ah(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Pn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Da=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Rg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ch(t){return typeof t=="string"&&(t=Rg(t)),ah(t),t}class $g{clone(){return this._cloneInto()}}function Ng(t){const e=i=>t().update(ch(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function hh(t=32){if(Pn&&typeof Pn.getRandomValues=="function")return Pn.getRandomValues(new Uint8Array(t));if(Pn&&typeof Pn.randomBytes=="function")return Pn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Fg(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 Tg extends $g{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=Da(this.buffer)}update(e){fh(this);const{view:r,buffer:i,blockLen:n}=this;e=ch(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=Da(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){fh(this),Pg(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 v=o;v<n;v++)r[v]=0;Fg(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Da(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 v=0;v<h;v++)a.setUint32(4*v,l[v],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 ao=BigInt(2**32-1),Oa=BigInt(32);function uh(t,e=!1){return e?{h:Number(t&ao),l:Number(t>>Oa&ao)}:{h:Number(t>>Oa&ao)|0,l:Number(t&ao)|0}}function Cg(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}=uh(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const Bg=(t,e)=>BigInt(t>>>0)<<Oa|BigInt(e>>>0),Lg=(t,e,r)=>t>>>r,qg=(t,e,r)=>t<<32-r|e>>>r,Ug=(t,e,r)=>t>>>r|e<<32-r,zg=(t,e,r)=>t<<32-r|e>>>r,kg=(t,e,r)=>t<<64-r|e>>>r-32,jg=(t,e,r)=>t>>>r-32|e<<64-r,Kg=(t,e)=>e,Vg=(t,e)=>t,Hg=(t,e,r)=>t<<r|e>>>32-r,Wg=(t,e,r)=>e<<r|t>>>32-r,Gg=(t,e,r)=>e<<r-32|t>>>64-r,Jg=(t,e,r)=>t<<r-32|e>>>64-r;function Yg(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const Xg=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Zg=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,Qg=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),eb=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,tb=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),rb=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,_e={fromBig:uh,split:Cg,toBig:Bg,shrSH:Lg,shrSL:qg,rotrSH:Ug,rotrSL:zg,rotrBH:kg,rotrBL:jg,rotr32H:Kg,rotr32L:Vg,rotlSH:Hg,rotlSL:Wg,rotlBH:Gg,rotlBL:Jg,add:Yg,add3L:Xg,add3H:Zg,add4L:Qg,add4H:eb,add5H:rb,add5L:tb},[ib,nb]=(()=>_e.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))))(),Ni=new Uint32Array(80),Fi=new Uint32Array(80);class sb extends Tg{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:v,Fl:M,Gh:I,Gl:S,Hh:D,Hl:F}=this;return[e,r,i,n,s,o,a,c,h,l,v,M,I,S,D,F]}set(e,r,i,n,s,o,a,c,h,l,v,M,I,S,D,F){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=v|0,this.Fl=M|0,this.Gh=I|0,this.Gl=S|0,this.Hh=D|0,this.Hl=F|0}process(e,r){for(let $=0;$<16;$++,r+=4)Ni[$]=e.getUint32(r),Fi[$]=e.getUint32(r+=4);for(let $=16;$<80;$++){const N=Ni[$-15]|0,C=Fi[$-15]|0,L=_e.rotrSH(N,C,1)^_e.rotrSH(N,C,8)^_e.shrSH(N,C,7),V=_e.rotrSL(N,C,1)^_e.rotrSL(N,C,8)^_e.shrSL(N,C,7),z=Ni[$-2]|0,H=Fi[$-2]|0,re=_e.rotrSH(z,H,19)^_e.rotrBH(z,H,61)^_e.shrSH(z,H,6),P=_e.rotrSL(z,H,19)^_e.rotrBL(z,H,61)^_e.shrSL(z,H,6),g=_e.add4L(V,P,Fi[$-7],Fi[$-16]),p=_e.add4H(g,L,re,Ni[$-7],Ni[$-16]);Ni[$]=p|0,Fi[$]=g|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:h,Dl:l,Eh:v,El:M,Fh:I,Fl:S,Gh:D,Gl:F,Hh:T,Hl:O}=this;for(let $=0;$<80;$++){const N=_e.rotrSH(v,M,14)^_e.rotrSH(v,M,18)^_e.rotrBH(v,M,41),C=_e.rotrSL(v,M,14)^_e.rotrSL(v,M,18)^_e.rotrBL(v,M,41),L=v&I^~v&D,V=M&S^~M&F,z=_e.add5L(O,C,V,nb[$],Fi[$]),H=_e.add5H(z,T,N,L,ib[$],Ni[$]),re=z|0,P=_e.rotrSH(i,n,28)^_e.rotrBH(i,n,34)^_e.rotrBH(i,n,39),g=_e.rotrSL(i,n,28)^_e.rotrBL(i,n,34)^_e.rotrBL(i,n,39),p=i&s^i&a^s&a,f=n&o^n&c^o&c;T=D|0,O=F|0,D=I|0,F=S|0,I=v|0,S=M|0,{h:v,l:M}=_e.add(h|0,l|0,H|0,re|0),h=a|0,l=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const u=_e.add3L(re,g,f);i=_e.add3H(u,H,P,p),n=u|0}({h:i,l:n}=_e.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=_e.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=_e.add(this.Ch|0,this.Cl|0,a|0,c|0),{h,l}=_e.add(this.Dh|0,this.Dl|0,h|0,l|0),{h:v,l:M}=_e.add(this.Eh|0,this.El|0,v|0,M|0),{h:I,l:S}=_e.add(this.Fh|0,this.Fl|0,I|0,S|0),{h:D,l:F}=_e.add(this.Gh|0,this.Gl|0,D|0,F|0),{h:T,l:O}=_e.add(this.Hh|0,this.Hl|0,T|0,O|0),this.set(i,n,s,o,a,c,h,l,v,M,I,S,D,F,T,O)}roundClean(){Ni.fill(0),Fi.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 ob=Ng(()=>new sb);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pa=BigInt(0),dh=BigInt(1),ab=BigInt(2);function Ra(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function $a(t){if(!Ra(t))throw new Error("Uint8Array expected")}function Na(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const fb=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Fa(t){$a(t);let e="";for(let r=0;r<t.length;r++)e+=fb[t[r]];return e}function lh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Pa:BigInt("0x"+t)}const fi={_0:48,_9:57,A:65,F:70,a:97,f:102};function ph(t){if(t>=fi._0&&t<=fi._9)return t-fi._0;if(t>=fi.A&&t<=fi.F)return t-(fi.A-10);if(t>=fi.a&&t<=fi.f)return t-(fi.a-10)}function gh(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=ph(t.charCodeAt(s)),a=ph(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 cb(t){return lh(Fa(t))}function fo(t){return $a(t),lh(Fa(Uint8Array.from(t).reverse()))}function bh(t,e){return gh(t.toString(16).padStart(e*2,"0"))}function Ta(t,e){return bh(t,e).reverse()}function ci(t,e,r){let i;if(typeof e=="string")try{i=gh(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ra(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 vh(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];$a(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 Ca=t=>typeof t=="bigint"&&Pa<=t;function hb(t,e,r){return Ca(t)&&Ca(e)&&Ca(r)&&e<=t&&t<r}function hs(t,e,r,i){if(!hb(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function ub(t){let e;for(e=0;t>Pa;t>>=dh,e+=1);return e}const db=t=>(ab<<BigInt(t-1))-dh,lb={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"||Ra(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 Ba(t,e,r={}){const i=(n,s,o)=>{const a=lb[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 yh(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 Mt=BigInt(0),vt=BigInt(1),rn=BigInt(2),pb=BigInt(3),La=BigInt(4),mh=BigInt(5),wh=BigInt(8);function _t(t,e){const r=t%e;return r>=Mt?r:e+r}function gb(t,e,r){if(e<Mt)throw new Error("invalid exponent, negatives unsupported");if(r<=Mt)throw new Error("invalid modulus");if(r===vt)return Mt;let i=vt;for(;e>Mt;)e&vt&&(i=i*t%r),t=t*t%r,e>>=vt;return i}function Vr(t,e,r){let i=t;for(;e-- >Mt;)i*=i,i%=r;return i}function _h(t,e){if(t===Mt)throw new Error("invert: expected non-zero number");if(e<=Mt)throw new Error("invert: expected positive modulus, got "+e);let r=_t(t,e),i=e,n=Mt,s=vt;for(;r!==Mt;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==vt)throw new Error("invert: does not exist");return _t(n,e)}function bb(t){const e=(t-vt)/rn;let r,i,n;for(r=t-vt,i=0;r%rn===Mt;r/=rn,i++);for(n=rn;n<t&&gb(n,e,t)!==t-vt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+vt)/La;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+vt)/rn;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),v=o.pow(a,r);for(;!o.eql(v,o.ONE);){if(o.eql(v,o.ZERO))return o.ZERO;let M=1;for(let S=o.sqr(v);M<c&&!o.eql(S,o.ONE);M++)S=o.sqr(S);const I=o.pow(h,vt<<BigInt(c-M-1));h=o.sqr(I),l=o.mul(l,I),v=o.mul(v,h),c=M}return l}}function vb(t){if(t%La===pb){const e=(t+vt)/La;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%wh===mh){const e=(t-mh)/wh;return function(r,i){const n=r.mul(i,rn),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,rn),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 bb(t)}const yb=(t,e)=>(_t(t,e)&vt)===vt,mb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wb(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=mb.reduce((i,n)=>(i[n]="function",i),e);return Ba(t,r)}function _b(t,e,r){if(r<Mt)throw new Error("invalid exponent, negatives unsupported");if(r===Mt)return t.ONE;if(r===vt)return e;let i=t.ONE,n=e;for(;r>Mt;)r&vt&&(i=t.mul(i,n)),n=t.sqr(n),r>>=vt;return i}function xb(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 xh(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Eh(t,e,r=!1,i={}){if(t<=Mt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=xh(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:db(n),ZERO:Mt,ONE:vt,create:c=>_t(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Mt<=c&&c<t},is0:c=>c===Mt,isOdd:c=>(c&vt)===vt,neg:c=>_t(-c,t),eql:(c,h)=>c===h,sqr:c=>_t(c*c,t),add:(c,h)=>_t(c+h,t),sub:(c,h)=>_t(c-h,t),mul:(c,h)=>_t(c*h,t),pow:(c,h)=>_b(a,c,h),div:(c,h)=>_t(c*_h(h,t),t),sqrN:c=>c*c,addN:(c,h)=>c+h,subN:(c,h)=>c-h,mulN:(c,h)=>c*h,inv:c=>_h(c,t),sqrt:i.sqrt||(c=>(o||(o=vb(t)),o(a,c))),invertBatch:c=>xb(a,c),cmov:(c,h,l)=>l?h:c,toBytes:c=>r?Ta(c,s):bh(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?fo(c):cb(c)}});return Object.freeze(a)}const Sh=BigInt(0),co=BigInt(1);function qa(t,e){const r=e.negate();return t?r:e}function Mh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ua(t,e){Mh(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function Eb(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 Sb(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 za=new WeakMap,Ih=new WeakMap;function ka(t){return Ih.get(t)||1}function Mb(t,e){return{constTimeNegate:qa,hasPrecomputes(r){return ka(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Sh;)i&co&&(n=n.add(s)),s=s.double(),i>>=co;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=Ua(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}=Ua(r,e);let a=t.ZERO,c=t.BASE;const h=BigInt(2**r-1),l=2**r,v=BigInt(r);for(let M=0;M<s;M++){const I=M*o;let S=Number(n&h);n>>=v,S>o&&(S-=l,n+=co);const D=I,F=I+Math.abs(S)-1,T=M%2!==0,O=S<0;S===0?c=c.add(qa(T,i[D])):a=a.add(qa(O,i[F]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=Ua(r,e),c=BigInt(2**r-1),h=2**r,l=BigInt(r);for(let v=0;v<o;v++){const M=v*a;if(n===Sh)break;let I=Number(n&c);if(n>>=l,I>a&&(I-=h,n+=co),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=za.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&za.set(i,n(s))),s},wNAFCached(r,i,n){const s=ka(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=ka(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){Mh(i,e),Ih.set(r,i),za.delete(r)}}}function Ib(t,e,r,i){if(Eb(r,t),Sb(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=ub(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 v=h;v>=0;v-=o){c.fill(n);for(let I=0;I<i.length;I++){const S=i[I],D=Number(S>>BigInt(v)&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),v!==0)for(let I=0;I<o;I++)l=l.double()}return l}function Ab(t){return wb(t.Fp),Ba(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xh(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Nr=BigInt(0),rr=BigInt(1),ho=BigInt(2),Db=BigInt(8),Ob={zip215:!0};function Pb(t){const e=Ab(t);return Ba(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Rb(t){const e=Pb(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,h=ho<<BigInt(a*8)-rr,l=r.create,v=Eh(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:Nr}}}),I=e.adjustScalarBytes||(u=>u),S=e.domain||((u,b,_)=>{if(Na("phflag",_),b.length||_)throw new Error("Contexts/pre-hash are not supported");return u});function D(u,b){hs("coordinate "+u,b,Nr,h)}function F(u){if(!(u instanceof $))throw new Error("ExtendedPoint expected")}const T=yh((u,b)=>{const{ex:_,ey:E,ez:w}=u,d=u.is0();b==null&&(b=d?Db:r.inv(w));const m=l(_*b),y=l(E*b),A=l(w*b);if(d)return{x:Nr,y:rr};if(A!==rr)throw new Error("invZ was invalid");return{x:m,y}}),O=yh(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,y=l(E*E),A=l(w*w),j=l(d*d),x=l(j*j),B=l(y*b),U=l(j*l(B+A)),k=l(x+l(_*l(y*A)));if(U!==k)throw new Error("bad point: equation left != right (1)");const K=l(E*w),J=l(d*m);if(K!==J)throw new Error("bad point: equation left != right (2)");return!0});class ${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 $)throw new Error("extended point not allowed");const{x:_,y:E}=b||{};return D("x",_),D("y",E),new $(_,E,rr,l(_*E))}static normalizeZ(b){const _=r.invertBatch(b.map(E=>E.ez));return b.map((E,w)=>E.toAffine(_[w])).map($.fromAffine)}static msm(b,_){return Ib($,v,b,_)}_setWindowSize(b){L.setWindowSize(this,b)}assertValidity(){O(this)}equals(b){F(b);const{ex:_,ey:E,ez:w}=this,{ex:d,ey:m,ez:y}=b,A=l(_*y),j=l(d*w),x=l(E*y),B=l(m*w);return A===j&&x===B}is0(){return this.equals($.ZERO)}negate(){return new $(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),y=l(ho*l(w*w)),A=l(b*d),j=_+E,x=l(l(j*j)-d-m),B=A+m,U=B-y,k=A-m,K=l(x*U),J=l(B*k),X=l(x*k),G=l(U*B);return new $(K,J,G,X)}add(b){F(b);const{a:_,d:E}=e,{ex:w,ey:d,ez:m,et:y}=this,{ex:A,ey:j,ez:x,et:B}=b;if(_===BigInt(-1)){const Pe=l((d-w)*(j+A)),Re=l((d+w)*(j-A)),ae=l(Re-Pe);if(ae===Nr)return this.double();const $e=l(m*ho*B),Ne=l(y*ho*x),ce=Ne+$e,Fe=Re+Pe,Te=Ne-$e,oe=l(ce*ae),De=l(Fe*Te),Ce=l(ce*Te),ie=l(ae*Fe);return new $(oe,De,ie,Ce)}const U=l(w*A),k=l(d*j),K=l(y*E*B),J=l(m*x),X=l((w+d)*(A+j)-U-k),G=J-K,ne=J+K,Q=l(k-_*U),ee=l(X*G),qe=l(ne*Q),Ue=l(X*Q),he=l(G*ne);return new $(ee,qe,he,Ue)}subtract(b){return this.add(b.negate())}wNAF(b){return L.wNAFCached(this,b,$.normalizeZ)}multiply(b){const _=b;hs("scalar",_,rr,i);const{p:E,f:w}=this.wNAF(_);return $.normalizeZ([E,w])[0]}multiplyUnsafe(b,_=$.ZERO){const E=b;return hs("scalar",E,Nr,i),E===Nr?C:this.is0()||E===rr?this:L.wNAFCachedUnsafe(this,E,$.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return L.unsafeLadder(this,i).is0()}toAffine(b){return T(this,b)}clearCofactor(){const{h:b}=e;return b===rr?this:this.multiplyUnsafe(b)}static fromHex(b,_=!1){const{d:E,a:w}=e,d=r.BYTES;b=ci("pointHex",b,d),Na("zip215",_);const m=b.slice(),y=b[d-1];m[d-1]=y&-129;const A=fo(m),j=_?h:r.ORDER;hs("pointHex.y",A,Nr,j);const x=l(A*A),B=l(x-rr),U=l(E*x-w);let{isValid:k,value:K}=M(B,U);if(!k)throw new Error("Point.fromHex: invalid y coordinate");const J=(K&rr)===rr,X=(y&128)!==0;if(!_&&K===Nr&&X)throw new Error("Point.fromHex: x=0 and x_0=1");return X!==J&&(K=l(-K)),$.fromAffine({x:K,y:A})}static fromPrivateKey(b){return H(b).point}toRawBytes(){const{x:b,y:_}=this.toAffine(),E=Ta(_,r.BYTES);return E[E.length-1]|=b&rr?128:0,E}toHex(){return Fa(this.toRawBytes())}}$.BASE=new $(e.Gx,e.Gy,rr,l(e.Gx*e.Gy)),$.ZERO=new $(Nr,rr,rr,Nr);const{BASE:N,ZERO:C}=$,L=Mb($,a*8);function V(u){return _t(u,i)}function z(u){return V(fo(u))}function H(u){const b=r.BYTES;u=ci("private key",u,b);const _=ci("hashed private key",s(u),2*b),E=I(_.slice(0,b)),w=_.slice(b,2*b),d=z(E),m=N.multiply(d),y=m.toRawBytes();return{head:E,prefix:w,scalar:d,point:m,pointBytes:y}}function re(u){return H(u).pointBytes}function P(u=new Uint8Array,...b){const _=vh(...b);return z(s(S(_,ci("context",u),!!n)))}function g(u,b,_={}){u=ci("message",u),n&&(u=n(u));const{prefix:E,scalar:w,pointBytes:d}=H(b),m=P(_.context,E,u),y=N.multiply(m).toRawBytes(),A=P(_.context,y,d,u),j=V(m+A*w);hs("signature.s",j,Nr,i);const x=vh(y,Ta(j,r.BYTES));return ci("result",x,r.BYTES*2)}const p=Ob;function f(u,b,_,E=p){const{context:w,zip215:d}=E,m=r.BYTES;u=ci("signature",u,2*m),b=ci("message",b),_=ci("publicKey",_,m),d!==void 0&&Na("zip215",d),n&&(b=n(b));const y=fo(u.slice(m,2*m));let A,j,x;try{A=$.fromHex(_,d),j=$.fromHex(u.slice(0,m),d),x=N.multiplyUnsafe(y)}catch{return!1}if(!d&&A.isSmallOrder())return!1;const B=P(w,j.toRawBytes(),A.toRawBytes(),b);return j.add(A.multiplyUnsafe(B)).subtract(x).clearCofactor().equals($.ZERO)}return N._setWindowSize(8),{CURVE:e,getPublicKey:re,sign:g,verify:f,ExtendedPoint:$,utils:{getExtendedPublicKey:H,randomPrivateKey:()=>o(r.BYTES),precompute(u=8,b=$.BASE){return b._setWindowSize(u),b.multiply(BigInt(3)),b}}}}BigInt(0),BigInt(1);const ja=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ah=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const $b=BigInt(1),Dh=BigInt(2);BigInt(3);const Nb=BigInt(5),Fb=BigInt(8);function Tb(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=ja,o=t*t%s*t%s,a=Vr(o,Dh,s)*o%s,c=Vr(a,$b,s)*t%s,h=Vr(c,Nb,s)*c%s,l=Vr(h,e,s)*h%s,v=Vr(l,r,s)*l%s,M=Vr(v,i,s)*v%s,I=Vr(M,n,s)*M%s,S=Vr(I,n,s)*M%s,D=Vr(S,e,s)*h%s;return{pow_p_5_8:Vr(D,Dh,s)*t%s,b2:o}}function Cb(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Bb(t,e){const r=ja,i=_t(e*e*e,r),n=_t(i*i*e,r),s=Tb(t*n).pow_p_5_8;let o=_t(t*i*s,r);const a=_t(e*o*o,r),c=o,h=_t(o*Ah,r),l=a===t,v=a===_t(-t,r),M=a===_t(-t*Ah,r);return l&&(o=c),(v||M)&&(o=h),yb(o,r)&&(o=_t(-o,r)),{isValid:l||v,value:o}}const Lb=(()=>Eh(ja,void 0,!0))(),qb=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Lb,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Fb,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ob,randomBytes:hh,adjustScalarBytes:Cb,uvRatio:Bb}))(),Oh=(()=>Rb(qb))(),Ub="EdDSA",zb="JWT",uo=".",lo="base64url",Ph="utf8",Rh="utf8",kb=":",jb="did",Kb="key",$h="base58btc",Vb="z",Hb="K36",Wb=32;function Ka(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Nh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Ka(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Fh(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Nh(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return Ka(r)}function Gb(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 v(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,F=0,T=0,O=S.length;T!==O&&S[T]===0;)T++,D++;for(var $=(O-T)*l+1>>>0,N=new Uint8Array($);T!==O;){for(var C=S[T],L=0,V=$-1;(C!==0||L<F)&&V!==-1;V--,L++)C+=256*N[V]>>>0,N[V]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");F=L,T++}for(var z=$-F;z!==$&&N[z]===0;)z++;for(var H=c.repeat(D);z<$;++z)H+=t.charAt(N[z]);return H}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 F=0,T=0;S[D]===c;)F++,D++;for(var O=(S.length-D)*h+1>>>0,$=new Uint8Array(O);S[D];){var N=r[S.charCodeAt(D)];if(N===255)return;for(var C=0,L=O-1;(N!==0||C<T)&&L!==-1;L--,C++)N+=a*$[L]>>>0,$[L]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");T=C,D++}if(S[D]!==" "){for(var V=O-T;V!==O&&$[V]===0;)V++;for(var z=new Uint8Array(F+(O-V)),H=F;V!==O;)z[H++]=$[V++];return z}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:M,decode:I}}var Jb=Gb,Yb=Jb;const Th=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")},Xb=t=>new TextEncoder().encode(t),Zb=t=>new TextDecoder().decode(t);class Qb{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 ev{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 Ch(this,e)}}class tv{constructor(e){this.decoders=e}or(e){return Ch(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 Ch=(t,e)=>new tv({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class rv{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Qb(e,r,i),this.decoder=new ev(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 rv(t,e,r,i),us=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Yb(r,e);return po({prefix:t,name:e,encode:i,decode:s=>Th(n(s))})},iv=(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 v=n[t[l]];if(v===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|v,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},nv=(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},Ft=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>po({prefix:e,name:t,encode(n){return nv(n,i,r)},decode(n){return iv(n,i,r,t)}}),sv=po({prefix:"\0",name:"identity",encode:t=>Zb(t),decode:t=>Xb(t)});var ov=Object.freeze({__proto__:null,identity:sv});const av=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var fv=Object.freeze({__proto__:null,base2:av});const cv=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var hv=Object.freeze({__proto__:null,base8:cv});const uv=us({prefix:"9",name:"base10",alphabet:"0123456789"});var dv=Object.freeze({__proto__:null,base10:uv});const lv=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pv=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gv=Object.freeze({__proto__:null,base16:lv,base16upper:pv});const bv=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vv=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yv=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mv=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wv=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_v=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xv=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ev=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Sv=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mv=Object.freeze({__proto__:null,base32:bv,base32upper:vv,base32pad:yv,base32padupper:mv,base32hex:wv,base32hexupper:_v,base32hexpad:xv,base32hexpadupper:Ev,base32z:Sv});const Iv=us({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Av=us({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Dv=Object.freeze({__proto__:null,base36:Iv,base36upper:Av});const Ov=us({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Pv=us({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rv=Object.freeze({__proto__:null,base58btc:Ov,base58flickr:Pv});const $v=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nv=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fv=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Tv=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Cv=Object.freeze({__proto__:null,base64:$v,base64pad:Nv,base64url:Fv,base64urlpad:Tv});const Bh=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}"),Bv=Bh.reduce((t,e,r)=>(t[r]=e,t),[]),Lv=Bh.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function qv(t){return t.reduce((e,r)=>(e+=Bv[r],e),"")}function Uv(t){const e=[];for(const r of t){const i=Lv[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const zv=po({prefix:"\u{1F680}",name:"base256emoji",encode:qv,decode:Uv});var kv=Object.freeze({__proto__:null,base256emoji:zv}),jv=qh,Lh=128,Kv=127,Vv=~Kv,Hv=Math.pow(2,31);function qh(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Hv;)e[r++]=t&255|Lh,t/=128;for(;t&Vv;)e[r++]=t&255|Lh,t>>>=7;return e[r]=t|0,qh.bytes=r-i+1,e}var Wv=Va,Gv=128,Uh=127;function Va(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Va.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Uh)<<n:(o&Uh)*Math.pow(2,n),n+=7}while(o>=Gv);return Va.bytes=s-i,r}var Jv=Math.pow(2,7),Yv=Math.pow(2,14),Xv=Math.pow(2,21),Zv=Math.pow(2,28),Qv=Math.pow(2,35),ey=Math.pow(2,42),ty=Math.pow(2,49),ry=Math.pow(2,56),iy=Math.pow(2,63),ny=function(t){return t<Jv?1:t<Yv?2:t<Xv?3:t<Zv?4:t<Qv?5:t<ey?6:t<ty?7:t<ry?8:t<iy?9:10},sy={encode:jv,decode:Wv,encodingLength:ny},zh=sy;const kh=(t,e,r=0)=>(zh.encode(t,e,r),e),jh=t=>zh.encodingLength(t),Ha=(t,e)=>{const r=e.byteLength,i=jh(t),n=i+jh(r),s=new Uint8Array(n+r);return kh(t,s,0),kh(r,s,i),s.set(e,n),new oy(t,r,e,s)};class oy{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Kh=({name:t,code:e,encode:r})=>new ay(t,e,r);class ay{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?Ha(this.code,r):r.then(i=>Ha(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Vh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),fy=Kh({name:"sha2-256",code:18,encode:Vh("SHA-256")}),cy=Kh({name:"sha2-512",code:19,encode:Vh("SHA-512")});var hy=Object.freeze({__proto__:null,sha256:fy,sha512:cy});const Hh=0,uy="identity",Wh=Th;var dy=Object.freeze({__proto__:null,identity:{code:Hh,name:uy,encode:Wh,digest:t=>Ha(Hh,Wh(t))}});new TextEncoder,new TextDecoder;const Gh={...ov,...fv,...hv,...dv,...gv,...Mv,...Dv,...Rv,...Cv,...kv};({...hy,...dy});function Jh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Yh=Jh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Wa=Jh("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=Nh(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Xh={utf8:Yh,"utf-8":Yh,hex:Gh.base16,latin1:Wa,ascii:Wa,binary:Wa,...Gh};function go(t,e="utf8"){const r=Xh[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 Rn(t,e="utf8"){const r=Xh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ka(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Zh(t){return An(go(Rn(t,lo),Ph))}function bo(t){return go(Rn(tn(t),Ph),lo)}function Qh(t){const e=Rn(Hb,$h),r=Vb+go(Fh([e,t]),$h);return[jb,Kb,r].join(kb)}function ly(t){return go(t,lo)}function py(t){return Rn(t,lo)}function gy(t){return Rn([bo(t.header),bo(t.payload)].join(uo),Rh)}function by(t){return[bo(t.header),bo(t.payload),ly(t.signature)].join(uo)}function Ga(t){const e=t.split(uo),r=Zh(e[0]),i=Zh(e[1]),n=py(e[2]),s=Rn(e.slice(0,2).join(uo),Rh);return{header:r,payload:i,signature:n,data:s}}function eu(t=hh(Wb)){const e=Oh.getPublicKey(t);return{secretKey:Fh([t,e]),publicKey:e}}async function vy(t,e,r,i,n=Y.fromMiliseconds(Date.now())){const s={alg:Ub,typ:zb},o=Qh(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},h=gy({header:s,payload:c}),l=Oh.sign(h,i.secretKey.slice(0,32));return by({header:s,payload:c,signature:l})}var tu=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))},yy=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),my=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),wy=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}(),_y=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),xy=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Ey=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Sy=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,ru=3,My=[["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",Ey]],iu=[["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 Iy(t){return t?nu(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new xy:typeof navigator<"u"?nu(navigator.userAgent):Oy()}function Ay(t){return t!==""&&My.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 nu(t){var e=Ay(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new _y;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<ru&&(n=tu(tu([],n,!0),Py(ru-n.length),!0)):n=[];var s=n.join("."),o=Dy(t),a=Sy.exec(t);return a&&a[1]?new wy(r,s,o,a[1]):new yy(r,s,o)}function Dy(t){for(var e=0,r=iu.length;e<r;e++){var i=iu[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Oy(){var t=typeof process<"u"&&process.version;return t?new my(process.version.slice(1)):null}function Py(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.getLocalStorage=at.getLocalStorageOrThrow=at.getCrypto=at.getCryptoOrThrow=su=at.getLocation=at.getLocationOrThrow=Ja=at.getNavigator=at.getNavigatorOrThrow=ds=at.getDocument=at.getDocumentOrThrow=at.getFromWindowOrThrow=at.getFromWindow=void 0;function nn(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}at.getFromWindow=nn;function $n(t){const e=nn(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}at.getFromWindowOrThrow=$n;function Ry(){return $n("document")}at.getDocumentOrThrow=Ry;function $y(){return nn("document")}var ds=at.getDocument=$y;function Ny(){return $n("navigator")}at.getNavigatorOrThrow=Ny;function Fy(){return nn("navigator")}var Ja=at.getNavigator=Fy;function Ty(){return $n("location")}at.getLocationOrThrow=Ty;function Cy(){return nn("location")}var su=at.getLocation=Cy;function By(){return $n("crypto")}at.getCryptoOrThrow=By;function Ly(){return nn("crypto")}at.getCrypto=Ly;function qy(){return $n("localStorage")}at.getLocalStorageOrThrow=qy;function Uy(){return nn("localStorage")}at.getLocalStorage=Uy;var Ya={};Object.defineProperty(Ya,"__esModule",{value:!0});var ou=Ya.getWindowMetadata=void 0;const au=at;function zy(){let t,e;try{t=au.getDocumentOrThrow(),e=au.getLocationOrThrow()}catch{return null}function r(){const v=t.getElementsByTagName("link"),M=[];for(let I=0;I<v.length;I++){const S=v[I],D=S.getAttribute("rel");if(D&&D.toLowerCase().indexOf("icon")>-1){const F=S.getAttribute("href");if(F)if(F.toLowerCase().indexOf("https:")===-1&&F.toLowerCase().indexOf("http:")===-1&&F.indexOf("//")!==0){let T=e.protocol+"//"+e.host;if(F.indexOf("/")===0)T+=F;else{const O=e.pathname.split("/");O.pop();const $=O.join("/");T+=$+"/"+F}M.push(T)}else if(F.indexOf("//")===0){const T=e.protocol+F;M.push(T)}else M.push(F)}}return M}function i(...v){const M=t.getElementsByTagName("meta");for(let I=0;I<M.length;I++){const S=M[I],D=["itemprop","property","name"].map(F=>S.getAttribute(F)).filter(F=>F?v.includes(F):!1);if(D.length&&D){const F=S.getAttribute("content");if(F)return F}}return""}function n(){let v=i("name","og:site_name","og:title","twitter:title");return v||(v=t.title),v}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}}ou=Ya.getWindowMetadata=zy;var ls={},ky=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),fu="%[a-f0-9]{2}",cu=new RegExp("("+fu+")|([^%]+?)","gi"),hu=new RegExp("("+fu+")+","gi");function Xa(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),i=t.slice(e);return Array.prototype.concat.call([],Xa(r),Xa(i))}function jy(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(cu)||[],r=1;r<e.length;r++)t=Xa(e,r).join(""),e=t.match(cu)||[];return t}}function Ky(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=hu.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=jy(r[0]);i!==r[0]&&(e[r[0]]=i)}r=hu.exec(t)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var Vy=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return Ky(t)}},Hy=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},Wy=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],a=t[o];(n?e.indexOf(o)!==-1:e(o,a,t))&&(r[o]=a)}return r};(function(t){const e=ky,r=Vy,i=Hy,n=Wy,s=O=>O==null,o=Symbol("encodeFragmentIdentifier");function a(O){switch(O.arrayFormat){case"index":return $=>(N,C)=>{const L=N.length;return C===void 0||O.skipNull&&C===null||O.skipEmptyString&&C===""?N:C===null?[...N,[l($,O),"[",L,"]"].join("")]:[...N,[l($,O),"[",l(L,O),"]=",l(C,O)].join("")]};case"bracket":return $=>(N,C)=>C===void 0||O.skipNull&&C===null||O.skipEmptyString&&C===""?N:C===null?[...N,[l($,O),"[]"].join("")]:[...N,[l($,O),"[]=",l(C,O)].join("")];case"colon-list-separator":return $=>(N,C)=>C===void 0||O.skipNull&&C===null||O.skipEmptyString&&C===""?N:C===null?[...N,[l($,O),":list="].join("")]:[...N,[l($,O),":list=",l(C,O)].join("")];case"comma":case"separator":case"bracket-separator":{const $=O.arrayFormat==="bracket-separator"?"[]=":"=";return N=>(C,L)=>L===void 0||O.skipNull&&L===null||O.skipEmptyString&&L===""?C:(L=L===null?"":L,C.length===0?[[l(N,O),$,l(L,O)].join("")]:[[C,l(L,O)].join(O.arrayFormatSeparator)])}default:return $=>(N,C)=>C===void 0||O.skipNull&&C===null||O.skipEmptyString&&C===""?N:C===null?[...N,l($,O)]:[...N,[l($,O),"=",l(C,O)].join("")]}}function c(O){let $;switch(O.arrayFormat){case"index":return(N,C,L)=>{if($=/\[(\d*)\]$/.exec(N),N=N.replace(/\[\d*\]$/,""),!$){L[N]=C;return}L[N]===void 0&&(L[N]={}),L[N][$[1]]=C};case"bracket":return(N,C,L)=>{if($=/(\[\])$/.exec(N),N=N.replace(/\[\]$/,""),!$){L[N]=C;return}if(L[N]===void 0){L[N]=[C];return}L[N]=[].concat(L[N],C)};case"colon-list-separator":return(N,C,L)=>{if($=/(:list)$/.exec(N),N=N.replace(/:list$/,""),!$){L[N]=C;return}if(L[N]===void 0){L[N]=[C];return}L[N]=[].concat(L[N],C)};case"comma":case"separator":return(N,C,L)=>{const V=typeof C=="string"&&C.includes(O.arrayFormatSeparator),z=typeof C=="string"&&!V&&v(C,O).includes(O.arrayFormatSeparator);C=z?v(C,O):C;const H=V||z?C.split(O.arrayFormatSeparator).map(re=>v(re,O)):C===null?C:v(C,O);L[N]=H};case"bracket-separator":return(N,C,L)=>{const V=/(\[\])$/.test(N);if(N=N.replace(/\[\]$/,""),!V){L[N]=C&&v(C,O);return}const z=C===null?[]:C.split(O.arrayFormatSeparator).map(H=>v(H,O));if(L[N]===void 0){L[N]=z;return}L[N]=[].concat(L[N],z)};default:return(N,C,L)=>{if(L[N]===void 0){L[N]=C;return}L[N]=[].concat(L[N],C)}}}function h(O){if(typeof O!="string"||O.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function l(O,$){return $.encode?$.strict?e(O):encodeURIComponent(O):O}function v(O,$){return $.decode?r(O):O}function M(O){return Array.isArray(O)?O.sort():typeof O=="object"?M(Object.keys(O)).sort(($,N)=>Number($)-Number(N)).map($=>O[$]):O}function I(O){const $=O.indexOf("#");return $!==-1&&(O=O.slice(0,$)),O}function S(O){let $="";const N=O.indexOf("#");return N!==-1&&($=O.slice(N)),$}function D(O){O=I(O);const $=O.indexOf("?");return $===-1?"":O.slice($+1)}function F(O,$){return $.parseNumbers&&!Number.isNaN(Number(O))&&typeof O=="string"&&O.trim()!==""?O=Number(O):$.parseBooleans&&O!==null&&(O.toLowerCase()==="true"||O.toLowerCase()==="false")&&(O=O.toLowerCase()==="true"),O}function T(O,$){$=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},$),h($.arrayFormatSeparator);const N=c($),C=Object.create(null);if(typeof O!="string"||(O=O.trim().replace(/^[?#&]/,""),!O))return C;for(const L of O.split("&")){if(L==="")continue;let[V,z]=i($.decode?L.replace(/\+/g," "):L,"=");z=z===void 0?null:["comma","separator","bracket-separator"].includes($.arrayFormat)?z:v(z,$),N(v(V,$),z,C)}for(const L of Object.keys(C)){const V=C[L];if(typeof V=="object"&&V!==null)for(const z of Object.keys(V))V[z]=F(V[z],$);else C[L]=F(V,$)}return $.sort===!1?C:($.sort===!0?Object.keys(C).sort():Object.keys(C).sort($.sort)).reduce((L,V)=>{const z=C[V];return z&&typeof z=="object"&&!Array.isArray(z)?L[V]=M(z):L[V]=z,L},Object.create(null))}t.extract=D,t.parse=T,t.stringify=(O,$)=>{if(!O)return"";$=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},$),h($.arrayFormatSeparator);const N=z=>$.skipNull&&s(O[z])||$.skipEmptyString&&O[z]==="",C=a($),L={};for(const z of Object.keys(O))N(z)||(L[z]=O[z]);const V=Object.keys(L);return $.sort!==!1&&V.sort($.sort),V.map(z=>{const H=O[z];return H===void 0?"":H===null?l(z,$):Array.isArray(H)?H.length===0&&$.arrayFormat==="bracket-separator"?l(z,$)+"[]":H.reduce(C(z),[]).join("&"):l(z,$)+"="+l(H,$)}).filter(z=>z.length>0).join("&")},t.parseUrl=(O,$)=>{$=Object.assign({decode:!0},$);const[N,C]=i(O,"#");return Object.assign({url:N.split("?")[0]||"",query:T(D(O),$)},$&&$.parseFragmentIdentifier&&C?{fragmentIdentifier:v(C,$)}:{})},t.stringifyUrl=(O,$)=>{$=Object.assign({encode:!0,strict:!0,[o]:!0},$);const N=I(O.url).split("?")[0]||"",C=t.extract(O.url),L=t.parse(C,{sort:!1}),V=Object.assign(L,O.query);let z=t.stringify(V,$);z&&(z=`?${z}`);let H=S(O.url);return O.fragmentIdentifier&&(H=`#${$[o]?l(O.fragmentIdentifier,$):O.fragmentIdentifier}`),`${N}${z}${H}`},t.pick=(O,$,N)=>{N=Object.assign({parseFragmentIdentifier:!0,[o]:!1},N);const{url:C,query:L,fragmentIdentifier:V}=t.parseUrl(O,N);return t.stringifyUrl({url:C,query:n(L,$),fragmentIdentifier:V},N)},t.exclude=(O,$,N)=>{const C=Array.isArray($)?L=>!$.includes(L):(L,V)=>!$(L,V);return t.pick(O,C,N)}})(ls);const Gy="logger/5.7.0";let uu=!1,du=!1;const vo={debug:1,default:2,info:2,warning:3,error:4,off:5};let lu=vo.default,Za=null;function Jy(){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 pu=Jy();var Qa;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(Qa||(Qa={}));var Fr;(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"})(Fr||(Fr={}));const gu="0123456789abcdef";class Ee{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();vo[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(lu>vo[i])&&console.log.apply(console,r)}debug(...e){this._log(Ee.levels.DEBUG,e)}info(...e){this._log(Ee.levels.INFO,e)}warn(...e){this._log(Ee.levels.WARNING,e)}makeError(e,r,i){if(du)return this.makeError("censored error",r,{});r||(r=Ee.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 v=0;v<h.length;v++)l+=gu[h[v]>>4],l+=gu[h[v]&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 Fr.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 Fr.CALL_EXCEPTION:case Fr.INSUFFICIENT_FUNDS:case Fr.MISSING_NEW:case Fr.NONCE_EXPIRED:case Fr.REPLACEMENT_UNDERPRICED:case Fr.TRANSACTION_REPLACED:case Fr.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,Ee.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){pu&&this.throwError("platform missing String.prototype.normalize",Ee.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:pu})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Ee.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Ee.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,Ee.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,Ee.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Ee.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",Ee.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ee.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return Za||(Za=new Ee(Gy)),Za}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Ee.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),uu){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ee.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}du=!!e,uu=!!r}static setLogLevel(e){const r=vo[e.toLowerCase()];if(r==null){Ee.globalLogger().warn("invalid log level - "+e);return}lu=r}static from(e){return new Ee(e)}}Ee.errors=Fr,Ee.levels=Qa;const Yy="bytes/5.7.0",yt=new Ee(Yy);function bu(t){return!!t.toHexString}function ps(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return ps(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Xy(t){return ur(t)&&!(t.length%2)||Nn(t)}function vu(t){return typeof t=="number"&&t==t&&t%1===0}function Nn(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!vu(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!vu(r)||r<0||r>=256)return!1}return!0}function xt(t,e){if(e||(e={}),typeof t=="number"){yt.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),ps(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),bu(t)&&(t=t.toHexString()),ur(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":yt.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 ps(new Uint8Array(i))}return Nn(t)?ps(new Uint8Array(t)):yt.throwArgumentError("invalid arrayify value","value",t)}function Zy(t,e){t=xt(t),t.length>e&&yt.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),ps(r)}function ur(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const ef="0123456789abcdef";function Yt(t,e){if(e||(e={}),typeof t=="number"){yt.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=ef[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),bu(t))return t.toHexString();if(ur(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":yt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Nn(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=ef[(n&240)>>4]+ef[n&15]}return r}return yt.throwArgumentError("invalid hexlify value","value",t)}function Qy(t){if(typeof t!="string")t=Yt(t);else if(!ur(t)||t.length%2)return null;return(t.length-2)/2}function yu(t,e,r){return typeof t!="string"?t=Yt(t):(!ur(t)||t.length%2)&&yt.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Ti(t,e){for(typeof t!="string"?t=Yt(t):ur(t)||yt.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&yt.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function mu(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Xy(t)){let r=xt(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Yt(r.slice(0,32)),e.s=Yt(r.slice(32,64))):r.length===65?(e.r=Yt(r.slice(0,32)),e.s=Yt(r.slice(32,64)),e.v=r[64]):yt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:yt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Yt(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=Zy(xt(e._vs),32);e._vs=Yt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&yt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=Yt(n);e.s==null?e.s=o:e.s!==o&&yt.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?yt.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&&yt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!ur(e.r)?yt.throwArgumentError("signature missing or invalid r","signature",t):e.r=Ti(e.r,32),e.s==null||!ur(e.s)?yt.throwArgumentError("signature missing or invalid s","signature",t):e.s=Ti(e.s,32);const r=xt(e.s);r[0]>=128&&yt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Yt(r);e._vs&&(ur(e._vs)||yt.throwArgumentError("signature invalid _vs","signature",t),e._vs=Ti(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&yt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var wu={exports:{}},em={},tm=Object.freeze({__proto__:null,default:em}),tf=ua(tm);(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=tf.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,y=0,A=b;A<m;A+=_)y=h(f,A,A+_,u),this.imuln(E),this.words[0]+y<67108864?this.words[0]+=y:this._iaddn(y);if(d!==0){var j=1;for(y=h(f,A,f.length,u),A=0;A<d;A++)j*=u;this.imuln(j),this.words[0]+y<67108864?this.words[0]+=y:this._iaddn(y)}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")]=v}catch{s.prototype.inspect=v}else s.prototype.inspect=v;function v(){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 y=I[f],A=S[f];b="";var j=this.clone();for(j.negative=0;!j.isZero();){var x=j.modrn(A).toString(f);j=j.idivn(A),j.isZero()?b=x+b:b=M[y-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 F(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 T(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 y=1;y<b;y++){for(var A=m>>>26,j=m&67108863,x=Math.min(y,f.length-1),B=Math.max(0,y-p.length+1);B<=x;B++){var U=y-B|0;_=p.words[U]|0,E=f.words[B]|0,w=_*E+j,A+=w/67108864|0,j=w&67108863}u.words[y]=j|0,m=A|0}return m!==0?u.words[y]=m|0:u.length--,u._strip()}var O=function(f,u,b){var _=f.words,E=u.words,w=b.words,d=0,m,y,A,j=_[0]|0,x=j&8191,B=j>>>13,U=_[1]|0,k=U&8191,K=U>>>13,J=_[2]|0,X=J&8191,G=J>>>13,ne=_[3]|0,Q=ne&8191,ee=ne>>>13,qe=_[4]|0,Ue=qe&8191,he=qe>>>13,Pe=_[5]|0,Re=Pe&8191,ae=Pe>>>13,$e=_[6]|0,Ne=$e&8191,ce=$e>>>13,Fe=_[7]|0,Te=Fe&8191,oe=Fe>>>13,De=_[8]|0,Ce=De&8191,ie=De>>>13,Ve=_[9]|0,He=Ve&8191,pe=Ve>>>13,We=E[0]|0,Be=We&8191,de=We>>>13,Ge=E[1]|0,Xe=Ge&8191,se=Ge>>>13,Je=E[2]|0,Ze=Je&8191,ge=Je>>>13,ze=E[3]|0,Oe=ze&8191,ue=ze>>>13,ke=E[4]|0,je=ke&8191,fe=ke>>>13,Qe=E[5]|0,et=Qe&8191,be=Qe>>>13,tt=E[6]|0,rt=tt&8191,le=tt>>>13,Ke=E[7]|0,Ae=Ke&8191,ve=Ke>>>13,it=E[8]|0,nt=it&8191,ye=it>>>13,st=E[9]|0,xe=st&8191,Ye=st>>>13;b.negative=f.negative^u.negative,b.length=19,m=Math.imul(x,Be),y=Math.imul(x,de),y=y+Math.imul(B,Be)|0,A=Math.imul(B,de);var ar=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(ar>>>26)|0,ar&=67108863,m=Math.imul(k,Be),y=Math.imul(k,de),y=y+Math.imul(K,Be)|0,A=Math.imul(K,de),m=m+Math.imul(x,Xe)|0,y=y+Math.imul(x,se)|0,y=y+Math.imul(B,Xe)|0,A=A+Math.imul(B,se)|0;var fr=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(fr>>>26)|0,fr&=67108863,m=Math.imul(X,Be),y=Math.imul(X,de),y=y+Math.imul(G,Be)|0,A=Math.imul(G,de),m=m+Math.imul(k,Xe)|0,y=y+Math.imul(k,se)|0,y=y+Math.imul(K,Xe)|0,A=A+Math.imul(K,se)|0,m=m+Math.imul(x,Ze)|0,y=y+Math.imul(x,ge)|0,y=y+Math.imul(B,Ze)|0,A=A+Math.imul(B,ge)|0;var cr=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(cr>>>26)|0,cr&=67108863,m=Math.imul(Q,Be),y=Math.imul(Q,de),y=y+Math.imul(ee,Be)|0,A=Math.imul(ee,de),m=m+Math.imul(X,Xe)|0,y=y+Math.imul(X,se)|0,y=y+Math.imul(G,Xe)|0,A=A+Math.imul(G,se)|0,m=m+Math.imul(k,Ze)|0,y=y+Math.imul(k,ge)|0,y=y+Math.imul(K,Ze)|0,A=A+Math.imul(K,ge)|0,m=m+Math.imul(x,Oe)|0,y=y+Math.imul(x,ue)|0,y=y+Math.imul(B,Oe)|0,A=A+Math.imul(B,ue)|0;var hr=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(hr>>>26)|0,hr&=67108863,m=Math.imul(Ue,Be),y=Math.imul(Ue,de),y=y+Math.imul(he,Be)|0,A=Math.imul(he,de),m=m+Math.imul(Q,Xe)|0,y=y+Math.imul(Q,se)|0,y=y+Math.imul(ee,Xe)|0,A=A+Math.imul(ee,se)|0,m=m+Math.imul(X,Ze)|0,y=y+Math.imul(X,ge)|0,y=y+Math.imul(G,Ze)|0,A=A+Math.imul(G,ge)|0,m=m+Math.imul(k,Oe)|0,y=y+Math.imul(k,ue)|0,y=y+Math.imul(K,Oe)|0,A=A+Math.imul(K,ue)|0,m=m+Math.imul(x,je)|0,y=y+Math.imul(x,fe)|0,y=y+Math.imul(B,je)|0,A=A+Math.imul(B,fe)|0;var wt=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(wt>>>26)|0,wt&=67108863,m=Math.imul(Re,Be),y=Math.imul(Re,de),y=y+Math.imul(ae,Be)|0,A=Math.imul(ae,de),m=m+Math.imul(Ue,Xe)|0,y=y+Math.imul(Ue,se)|0,y=y+Math.imul(he,Xe)|0,A=A+Math.imul(he,se)|0,m=m+Math.imul(Q,Ze)|0,y=y+Math.imul(Q,ge)|0,y=y+Math.imul(ee,Ze)|0,A=A+Math.imul(ee,ge)|0,m=m+Math.imul(X,Oe)|0,y=y+Math.imul(X,ue)|0,y=y+Math.imul(G,Oe)|0,A=A+Math.imul(G,ue)|0,m=m+Math.imul(k,je)|0,y=y+Math.imul(k,fe)|0,y=y+Math.imul(K,je)|0,A=A+Math.imul(K,fe)|0,m=m+Math.imul(x,et)|0,y=y+Math.imul(x,be)|0,y=y+Math.imul(B,et)|0,A=A+Math.imul(B,be)|0;var xi=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(xi>>>26)|0,xi&=67108863,m=Math.imul(Ne,Be),y=Math.imul(Ne,de),y=y+Math.imul(ce,Be)|0,A=Math.imul(ce,de),m=m+Math.imul(Re,Xe)|0,y=y+Math.imul(Re,se)|0,y=y+Math.imul(ae,Xe)|0,A=A+Math.imul(ae,se)|0,m=m+Math.imul(Ue,Ze)|0,y=y+Math.imul(Ue,ge)|0,y=y+Math.imul(he,Ze)|0,A=A+Math.imul(he,ge)|0,m=m+Math.imul(Q,Oe)|0,y=y+Math.imul(Q,ue)|0,y=y+Math.imul(ee,Oe)|0,A=A+Math.imul(ee,ue)|0,m=m+Math.imul(X,je)|0,y=y+Math.imul(X,fe)|0,y=y+Math.imul(G,je)|0,A=A+Math.imul(G,fe)|0,m=m+Math.imul(k,et)|0,y=y+Math.imul(k,be)|0,y=y+Math.imul(K,et)|0,A=A+Math.imul(K,be)|0,m=m+Math.imul(x,rt)|0,y=y+Math.imul(x,le)|0,y=y+Math.imul(B,rt)|0,A=A+Math.imul(B,le)|0;var Ei=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,m=Math.imul(Te,Be),y=Math.imul(Te,de),y=y+Math.imul(oe,Be)|0,A=Math.imul(oe,de),m=m+Math.imul(Ne,Xe)|0,y=y+Math.imul(Ne,se)|0,y=y+Math.imul(ce,Xe)|0,A=A+Math.imul(ce,se)|0,m=m+Math.imul(Re,Ze)|0,y=y+Math.imul(Re,ge)|0,y=y+Math.imul(ae,Ze)|0,A=A+Math.imul(ae,ge)|0,m=m+Math.imul(Ue,Oe)|0,y=y+Math.imul(Ue,ue)|0,y=y+Math.imul(he,Oe)|0,A=A+Math.imul(he,ue)|0,m=m+Math.imul(Q,je)|0,y=y+Math.imul(Q,fe)|0,y=y+Math.imul(ee,je)|0,A=A+Math.imul(ee,fe)|0,m=m+Math.imul(X,et)|0,y=y+Math.imul(X,be)|0,y=y+Math.imul(G,et)|0,A=A+Math.imul(G,be)|0,m=m+Math.imul(k,rt)|0,y=y+Math.imul(k,le)|0,y=y+Math.imul(K,rt)|0,A=A+Math.imul(K,le)|0,m=m+Math.imul(x,Ae)|0,y=y+Math.imul(x,ve)|0,y=y+Math.imul(B,Ae)|0,A=A+Math.imul(B,ve)|0;var Si=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Si>>>26)|0,Si&=67108863,m=Math.imul(Ce,Be),y=Math.imul(Ce,de),y=y+Math.imul(ie,Be)|0,A=Math.imul(ie,de),m=m+Math.imul(Te,Xe)|0,y=y+Math.imul(Te,se)|0,y=y+Math.imul(oe,Xe)|0,A=A+Math.imul(oe,se)|0,m=m+Math.imul(Ne,Ze)|0,y=y+Math.imul(Ne,ge)|0,y=y+Math.imul(ce,Ze)|0,A=A+Math.imul(ce,ge)|0,m=m+Math.imul(Re,Oe)|0,y=y+Math.imul(Re,ue)|0,y=y+Math.imul(ae,Oe)|0,A=A+Math.imul(ae,ue)|0,m=m+Math.imul(Ue,je)|0,y=y+Math.imul(Ue,fe)|0,y=y+Math.imul(he,je)|0,A=A+Math.imul(he,fe)|0,m=m+Math.imul(Q,et)|0,y=y+Math.imul(Q,be)|0,y=y+Math.imul(ee,et)|0,A=A+Math.imul(ee,be)|0,m=m+Math.imul(X,rt)|0,y=y+Math.imul(X,le)|0,y=y+Math.imul(G,rt)|0,A=A+Math.imul(G,le)|0,m=m+Math.imul(k,Ae)|0,y=y+Math.imul(k,ve)|0,y=y+Math.imul(K,Ae)|0,A=A+Math.imul(K,ve)|0,m=m+Math.imul(x,nt)|0,y=y+Math.imul(x,ye)|0,y=y+Math.imul(B,nt)|0,A=A+Math.imul(B,ye)|0;var Mi=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,m=Math.imul(He,Be),y=Math.imul(He,de),y=y+Math.imul(pe,Be)|0,A=Math.imul(pe,de),m=m+Math.imul(Ce,Xe)|0,y=y+Math.imul(Ce,se)|0,y=y+Math.imul(ie,Xe)|0,A=A+Math.imul(ie,se)|0,m=m+Math.imul(Te,Ze)|0,y=y+Math.imul(Te,ge)|0,y=y+Math.imul(oe,Ze)|0,A=A+Math.imul(oe,ge)|0,m=m+Math.imul(Ne,Oe)|0,y=y+Math.imul(Ne,ue)|0,y=y+Math.imul(ce,Oe)|0,A=A+Math.imul(ce,ue)|0,m=m+Math.imul(Re,je)|0,y=y+Math.imul(Re,fe)|0,y=y+Math.imul(ae,je)|0,A=A+Math.imul(ae,fe)|0,m=m+Math.imul(Ue,et)|0,y=y+Math.imul(Ue,be)|0,y=y+Math.imul(he,et)|0,A=A+Math.imul(he,be)|0,m=m+Math.imul(Q,rt)|0,y=y+Math.imul(Q,le)|0,y=y+Math.imul(ee,rt)|0,A=A+Math.imul(ee,le)|0,m=m+Math.imul(X,Ae)|0,y=y+Math.imul(X,ve)|0,y=y+Math.imul(G,Ae)|0,A=A+Math.imul(G,ve)|0,m=m+Math.imul(k,nt)|0,y=y+Math.imul(k,ye)|0,y=y+Math.imul(K,nt)|0,A=A+Math.imul(K,ye)|0,m=m+Math.imul(x,xe)|0,y=y+Math.imul(x,Ye)|0,y=y+Math.imul(B,xe)|0,A=A+Math.imul(B,Ye)|0;var Ii=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,m=Math.imul(He,Xe),y=Math.imul(He,se),y=y+Math.imul(pe,Xe)|0,A=Math.imul(pe,se),m=m+Math.imul(Ce,Ze)|0,y=y+Math.imul(Ce,ge)|0,y=y+Math.imul(ie,Ze)|0,A=A+Math.imul(ie,ge)|0,m=m+Math.imul(Te,Oe)|0,y=y+Math.imul(Te,ue)|0,y=y+Math.imul(oe,Oe)|0,A=A+Math.imul(oe,ue)|0,m=m+Math.imul(Ne,je)|0,y=y+Math.imul(Ne,fe)|0,y=y+Math.imul(ce,je)|0,A=A+Math.imul(ce,fe)|0,m=m+Math.imul(Re,et)|0,y=y+Math.imul(Re,be)|0,y=y+Math.imul(ae,et)|0,A=A+Math.imul(ae,be)|0,m=m+Math.imul(Ue,rt)|0,y=y+Math.imul(Ue,le)|0,y=y+Math.imul(he,rt)|0,A=A+Math.imul(he,le)|0,m=m+Math.imul(Q,Ae)|0,y=y+Math.imul(Q,ve)|0,y=y+Math.imul(ee,Ae)|0,A=A+Math.imul(ee,ve)|0,m=m+Math.imul(X,nt)|0,y=y+Math.imul(X,ye)|0,y=y+Math.imul(G,nt)|0,A=A+Math.imul(G,ye)|0,m=m+Math.imul(k,xe)|0,y=y+Math.imul(k,Ye)|0,y=y+Math.imul(K,xe)|0,A=A+Math.imul(K,Ye)|0;var Pr=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,m=Math.imul(He,Ze),y=Math.imul(He,ge),y=y+Math.imul(pe,Ze)|0,A=Math.imul(pe,ge),m=m+Math.imul(Ce,Oe)|0,y=y+Math.imul(Ce,ue)|0,y=y+Math.imul(ie,Oe)|0,A=A+Math.imul(ie,ue)|0,m=m+Math.imul(Te,je)|0,y=y+Math.imul(Te,fe)|0,y=y+Math.imul(oe,je)|0,A=A+Math.imul(oe,fe)|0,m=m+Math.imul(Ne,et)|0,y=y+Math.imul(Ne,be)|0,y=y+Math.imul(ce,et)|0,A=A+Math.imul(ce,be)|0,m=m+Math.imul(Re,rt)|0,y=y+Math.imul(Re,le)|0,y=y+Math.imul(ae,rt)|0,A=A+Math.imul(ae,le)|0,m=m+Math.imul(Ue,Ae)|0,y=y+Math.imul(Ue,ve)|0,y=y+Math.imul(he,Ae)|0,A=A+Math.imul(he,ve)|0,m=m+Math.imul(Q,nt)|0,y=y+Math.imul(Q,ye)|0,y=y+Math.imul(ee,nt)|0,A=A+Math.imul(ee,ye)|0,m=m+Math.imul(X,xe)|0,y=y+Math.imul(X,Ye)|0,y=y+Math.imul(G,xe)|0,A=A+Math.imul(G,Ye)|0;var Ai=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,m=Math.imul(He,Oe),y=Math.imul(He,ue),y=y+Math.imul(pe,Oe)|0,A=Math.imul(pe,ue),m=m+Math.imul(Ce,je)|0,y=y+Math.imul(Ce,fe)|0,y=y+Math.imul(ie,je)|0,A=A+Math.imul(ie,fe)|0,m=m+Math.imul(Te,et)|0,y=y+Math.imul(Te,be)|0,y=y+Math.imul(oe,et)|0,A=A+Math.imul(oe,be)|0,m=m+Math.imul(Ne,rt)|0,y=y+Math.imul(Ne,le)|0,y=y+Math.imul(ce,rt)|0,A=A+Math.imul(ce,le)|0,m=m+Math.imul(Re,Ae)|0,y=y+Math.imul(Re,ve)|0,y=y+Math.imul(ae,Ae)|0,A=A+Math.imul(ae,ve)|0,m=m+Math.imul(Ue,nt)|0,y=y+Math.imul(Ue,ye)|0,y=y+Math.imul(he,nt)|0,A=A+Math.imul(he,ye)|0,m=m+Math.imul(Q,xe)|0,y=y+Math.imul(Q,Ye)|0,y=y+Math.imul(ee,xe)|0,A=A+Math.imul(ee,Ye)|0;var Di=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Di>>>26)|0,Di&=67108863,m=Math.imul(He,je),y=Math.imul(He,fe),y=y+Math.imul(pe,je)|0,A=Math.imul(pe,fe),m=m+Math.imul(Ce,et)|0,y=y+Math.imul(Ce,be)|0,y=y+Math.imul(ie,et)|0,A=A+Math.imul(ie,be)|0,m=m+Math.imul(Te,rt)|0,y=y+Math.imul(Te,le)|0,y=y+Math.imul(oe,rt)|0,A=A+Math.imul(oe,le)|0,m=m+Math.imul(Ne,Ae)|0,y=y+Math.imul(Ne,ve)|0,y=y+Math.imul(ce,Ae)|0,A=A+Math.imul(ce,ve)|0,m=m+Math.imul(Re,nt)|0,y=y+Math.imul(Re,ye)|0,y=y+Math.imul(ae,nt)|0,A=A+Math.imul(ae,ye)|0,m=m+Math.imul(Ue,xe)|0,y=y+Math.imul(Ue,Ye)|0,y=y+Math.imul(he,xe)|0,A=A+Math.imul(he,Ye)|0;var Wt=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,m=Math.imul(He,et),y=Math.imul(He,be),y=y+Math.imul(pe,et)|0,A=Math.imul(pe,be),m=m+Math.imul(Ce,rt)|0,y=y+Math.imul(Ce,le)|0,y=y+Math.imul(ie,rt)|0,A=A+Math.imul(ie,le)|0,m=m+Math.imul(Te,Ae)|0,y=y+Math.imul(Te,ve)|0,y=y+Math.imul(oe,Ae)|0,A=A+Math.imul(oe,ve)|0,m=m+Math.imul(Ne,nt)|0,y=y+Math.imul(Ne,ye)|0,y=y+Math.imul(ce,nt)|0,A=A+Math.imul(ce,ye)|0,m=m+Math.imul(Re,xe)|0,y=y+Math.imul(Re,Ye)|0,y=y+Math.imul(ae,xe)|0,A=A+Math.imul(ae,Ye)|0;var Oi=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,m=Math.imul(He,rt),y=Math.imul(He,le),y=y+Math.imul(pe,rt)|0,A=Math.imul(pe,le),m=m+Math.imul(Ce,Ae)|0,y=y+Math.imul(Ce,ve)|0,y=y+Math.imul(ie,Ae)|0,A=A+Math.imul(ie,ve)|0,m=m+Math.imul(Te,nt)|0,y=y+Math.imul(Te,ye)|0,y=y+Math.imul(oe,nt)|0,A=A+Math.imul(oe,ye)|0,m=m+Math.imul(Ne,xe)|0,y=y+Math.imul(Ne,Ye)|0,y=y+Math.imul(ce,xe)|0,A=A+Math.imul(ce,Ye)|0;var Pi=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,m=Math.imul(He,Ae),y=Math.imul(He,ve),y=y+Math.imul(pe,Ae)|0,A=Math.imul(pe,ve),m=m+Math.imul(Ce,nt)|0,y=y+Math.imul(Ce,ye)|0,y=y+Math.imul(ie,nt)|0,A=A+Math.imul(ie,ye)|0,m=m+Math.imul(Te,xe)|0,y=y+Math.imul(Te,Ye)|0,y=y+Math.imul(oe,xe)|0,A=A+Math.imul(oe,Ye)|0;var Ri=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,m=Math.imul(He,nt),y=Math.imul(He,ye),y=y+Math.imul(pe,nt)|0,A=Math.imul(pe,ye),m=m+Math.imul(Ce,xe)|0,y=y+Math.imul(Ce,Ye)|0,y=y+Math.imul(ie,xe)|0,A=A+Math.imul(ie,Ye)|0;var Hs=(d+m|0)+((y&8191)<<13)|0;d=(A+(y>>>13)|0)+(Hs>>>26)|0,Hs&=67108863,m=Math.imul(He,xe),y=Math.imul(He,Ye),y=y+Math.imul(pe,xe)|0,A=Math.imul(pe,Ye);var Ws=(d+m|0)+((y&8191)<<13)|0;return d=(A+(y>>>13)|0)+(Ws>>>26)|0,Ws&=67108863,w[0]=ar,w[1]=fr,w[2]=cr,w[3]=hr,w[4]=wt,w[5]=xi,w[6]=Ei,w[7]=Si,w[8]=Mi,w[9]=Ii,w[10]=Pr,w[11]=Ai,w[12]=Di,w[13]=Wt,w[14]=Oi,w[15]=Pi,w[16]=Ri,w[17]=Hs,w[18]=Ws,d!==0&&(w[19]=d,b.length++),b};Math.imul||(O=T);function $(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),y=Math.max(0,E-p.length+1);y<=m;y++){var A=E-y,j=p.words[A]|0,x=f.words[y]|0,B=j*x,U=B&67108863;w=w+(B/67108864|0)|0,U=U+d|0,d=U&67108863,w=w+(U>>>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 N(p,f,u){return $(p,f,u)}s.prototype.mulTo=function(f,u){var b,_=this.length+f.length;return this.length===10&&f.length===10?b=O(this,f,u):_<63?b=T(this,f,u):_<1024?b=$(this,f,u):b=N(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),N(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=F(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 y=0;y<w;y++)m.words[y]=this.words[y];m.length=w}if(w!==0)if(this.length>w)for(this.length-=w,y=0;y<this.length;y++)this.words[y]=this.words[y+w];else this.words[0]=0,this.length=1;var A=0;for(y=this.length-1;y>=0&&(A!==0||y>=_);y--){var j=this.words[y]|0;this.words[y]=A<<26-E|j>>>E,A=j&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,y;if(u!=="mod"){y=new s(null),y.length=m+1,y.words=new Array(y.length);for(var A=0;A<y.length;A++)y.words[A]=0}var j=_.clone()._ishlnsubmul(E,1,m);j.negative===0&&(_=j,y&&(y.words[m]=1));for(var x=m-1;x>=0;x--){var B=(_.words[E.length+x]|0)*67108864+(_.words[E.length+x-1]|0);for(B=Math.min(B/w|0,67108863),_._ishlnsubmul(E,B,x);_.negative!==0;)B--,_.negative=0,_._ishlnsubmul(E,1,x),_.isZero()||(_.negative^=1);y&&(y.words[x]=B)}return y&&y._strip(),_._strip(),u!=="div"&&b!==0&&_.iushrn(b),{div:y||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 y=b.clone(),A=u.clone();!u.isZero();){for(var j=0,x=1;!(u.words[0]&x)&&j<26;++j,x<<=1);if(j>0)for(u.iushrn(j);j-- >0;)(_.isOdd()||E.isOdd())&&(_.iadd(y),E.isub(A)),_.iushrn(1),E.iushrn(1);for(var B=0,U=1;!(b.words[0]&U)&&B<26;++B,U<<=1);if(B>0)for(b.iushrn(B);B-- >0;)(w.isOdd()||d.isOdd())&&(w.iadd(y),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 y=0,A=1;!(b.words[0]&A)&&y<26;++y,A<<=1);if(y>0)for(b.iushrn(y);y-- >0;)E.isOdd()&&E.iadd(w),E.iushrn(1);u.cmp(b)>=0?(u.isub(b),_.isub(E)):(b.isub(u),E.isub(_))}var j;return u.cmpn(1)===0?j=_:j=E,j.cmpn(0)<0&&j.iadd(f),j},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 P(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 C={k256:null,p224:null,p192:null,p25519:null};function L(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()}L.prototype._tmp=function(){var f=new s(null);return f.words=new Array(Math.ceil(this.n/13)),f},L.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},L.prototype.split=function(f,u){f.iushrn(this.n,0,u)},L.prototype.imulK=function(f){return f.imul(this.k)};function V(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(V,L),V.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},V.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 z(){L.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(z,L);function H(){L.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(H,L);function re(){L.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(re,L),re.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(C[f])return C[f];var u;if(f==="k256")u=new V;else if(f==="p224")u=new z;else if(f==="p192")u=new H;else if(f==="p25519")u=new re;else throw new Error("Unknown prime "+f);return C[f]=u,u};function P(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}P.prototype._verify1=function(f){i(f.negative===0,"red works only with positives"),i(f.red,"red works only with red numbers")},P.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")},P.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(l(f,f.umod(this.m)._forceRed(this)),f)},P.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},P.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)},P.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},P.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)},P.prototype.isub=function(f,u){this._verify2(f,u);var b=f.isub(u);return b.cmpn(0)<0&&b.iadd(this.m),b},P.prototype.shl=function(f,u){return this._verify1(f),this.imod(f.ushln(u))},P.prototype.imul=function(f,u){return this._verify2(f,u),this.imod(f.imul(u))},P.prototype.mul=function(f,u){return this._verify2(f,u),this.imod(f.mul(u))},P.prototype.isqr=function(f){return this.imul(f,f.clone())},P.prototype.sqr=function(f){return this.mul(f,f)},P.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),y=this.m.bitLength();for(y=new s(2*y*y).toRed(this);this.pow(y,m).cmp(d)!==0;)y.redIAdd(d);for(var A=this.pow(y,_),j=this.pow(f,_.addn(1).iushrn(1)),x=this.pow(f,_),B=E;x.cmp(w)!==0;){for(var U=x,k=0;U.cmp(w)!==0;k++)U=U.redSqr();i(k<B);var K=this.pow(A,new s(1).iushln(B-k-1));j=j.redMul(K),A=K.redSqr(),x=x.redMul(A),B=k}return j},P.prototype.invm=function(f){var u=f._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},P.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,y=u.bitLength()%26;for(y===0&&(y=26),E=u.length-1;E>=0;E--){for(var A=u.words[E],j=y-1;j>=0;j--){var x=A>>j&1;if(w!==_[0]&&(w=this.sqr(w)),x===0&&d===0){m=0;continue}d<<=1,d|=x,m++,!(m!==b&&(E!==0||j!==0))&&(w=this.mul(w,_[d]),m=0,d=0)}y=26}return w},P.prototype.convertTo=function(f){var u=f.umod(this.m);return u===f?u.clone():u},P.prototype.convertFrom=function(f){var u=f.clone();return u.red=null,u},s.mont=function(f){return new g(f)};function g(p){P.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,P),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,Nt)})(wu);var me=wu.exports;const _u="bignumber/5.7.0";var yo=me.BN;const hi=new Ee(_u),rf={},xu=9007199254740991;function rm(t){return t!=null&&(lt.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||ur(t)||typeof t=="bigint"||Nn(t))}let Eu=!1;class lt{constructor(e,r){e!==rf&&hi.throwError("cannot call constructor directly; use BigNumber.from",Ee.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return ir(Me(this).fromTwos(e))}toTwos(e){return ir(Me(this).toTwos(e))}abs(){return this._hex[0]==="-"?lt.from(this._hex.substring(1)):this}add(e){return ir(Me(this).add(Me(e)))}sub(e){return ir(Me(this).sub(Me(e)))}div(e){return lt.from(e).isZero()&&mr("division-by-zero","div"),ir(Me(this).div(Me(e)))}mul(e){return ir(Me(this).mul(Me(e)))}mod(e){const r=Me(e);return r.isNeg()&&mr("division-by-zero","mod"),ir(Me(this).umod(r))}pow(e){const r=Me(e);return r.isNeg()&&mr("negative-power","pow"),ir(Me(this).pow(r))}and(e){const r=Me(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","and"),ir(Me(this).and(r))}or(e){const r=Me(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","or"),ir(Me(this).or(r))}xor(e){const r=Me(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","xor"),ir(Me(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&mr("negative-width","mask"),ir(Me(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&mr("negative-width","shl"),ir(Me(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&mr("negative-width","shr"),ir(Me(this).shrn(e))}eq(e){return Me(this).eq(Me(e))}lt(e){return Me(this).lt(Me(e))}lte(e){return Me(this).lte(Me(e))}gt(e){return Me(this).gt(Me(e))}gte(e){return Me(this).gte(Me(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Me(this).isZero()}toNumber(){try{return Me(this).toNumber()}catch{mr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return hi.throwError("this platform does not support BigInt",Ee.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Eu||(Eu=!0,hi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?hi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ee.errors.UNEXPECTED_ARGUMENT,{}):hi.throwError("BigNumber.toString does not accept parameters",Ee.errors.UNEXPECTED_ARGUMENT,{})),Me(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof lt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new lt(rf,gs(e)):e.match(/^-?[0-9]+$/)?new lt(rf,gs(new yo(e))):hi.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&mr("underflow","BigNumber.from",e),(e>=xu||e<=-xu)&&mr("overflow","BigNumber.from",e),lt.from(String(e));const r=e;if(typeof r=="bigint")return lt.from(r.toString());if(Nn(r))return lt.from(Yt(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return lt.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(ur(i)||i[0]==="-"&&ur(i.substring(1))))return lt.from(i)}return hi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function gs(t){if(typeof t!="string")return gs(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&hi.throwArgumentError("invalid hex","value",t),t=gs(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 ir(t){return lt.from(gs(t))}function Me(t){const e=lt.from(t).toHexString();return e[0]==="-"?new yo("-"+e.substring(3),16):new yo(e.substring(2),16)}function mr(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),hi.throwError(t,Ee.errors.NUMERIC_FAULT,i)}function im(t){return new yo(t,36).toString(16)}const Xt=new Ee(_u),bs={},Su=lt.from(0),Mu=lt.from(-1);function Iu(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),Xt.throwError(t,Ee.errors.NUMERIC_FAULT,n)}let vs="0";for(;vs.length<256;)vs+=vs;function nf(t){if(typeof t!="number")try{t=lt.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+vs.substring(0,t):Xt.throwArgumentError("invalid decimal size","decimals",t)}function sf(t,e){e==null&&(e=0);const r=nf(e);t=lt.from(t);const i=t.lt(Su);i&&(t=t.mul(Mu));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 ui(t,e){e==null&&(e=0);const r=nf(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&Xt.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&Xt.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Xt.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&&Iu("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const a=lt.from(s),c=lt.from(o);let h=a.mul(r).add(c);return i&&(h=h.mul(Mu)),h}class Fn{constructor(e,r,i,n){e!==bs&&Xt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ee.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=nf(n),Object.freeze(this)}static from(e){if(e instanceof Fn)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||Xt.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&&Xt.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&&Xt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Xt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Fn(bs,r,i,n)}}class Tt{constructor(e,r,i,n){e!==bs&&Xt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ee.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&&Xt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Tt.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Tt.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Tt.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Tt.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=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(r=r.subUnsafe(Au.toFormat(r.format))),r}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(r=r.addUnsafe(Au.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)&&Xt.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=Tt.from("1"+vs.substring(0,e),this.format),n=nm.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&&Xt.throwArgumentError("invalid byte width","width",e);const r=lt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Ti(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Tt.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!rm(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),Tt.fromString(sf(e,r),Fn.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=Fn.from(r),n=ui(e,i.decimals);!i.signed&&n.lt(Su)&&Iu("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Ti(s,i.width/8));const o=sf(n,i.decimals);return new Tt(bs,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=Fn.from(r);if(xt(e).length>i.width/8)throw new Error("overflow");let n=lt.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=sf(n,i.decimals);return new Tt(bs,s,o,i)}static from(e,r){if(typeof e=="string")return Tt.fromString(e,r);if(Nn(e))return Tt.fromBytes(e,r);try{return Tt.fromValue(e,0,r)}catch(i){if(i.code!==Ee.errors.INVALID_ARGUMENT)throw i}return Xt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const Au=Tt.from(1),nm=Tt.from("0.5");var Du={exports:{}};/**
|
15
15
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
16
16
|
*
|
17
17
|
* @version 0.8.0
|
18
18
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
19
19
|
* @copyright Chen, Yi-Cyuan 2015-2018
|
20
20
|
* @license MIT
|
21
|
-
*/(function(r){(function(){var e="input is invalid type",t="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=Pt:s&&(n=self);var f=!n.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,u=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],m=[4,1024,262144,67108864],I=[1,256,65536,16777216],M=[6,1536,393216,100663296],D=[0,8,16,24],N=[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],k=[224,256,384,512],K=[128,256],B=["hex","buffer","arrayBuffer","array","digest"],j={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(S){return Object.prototype.toString.call(S)==="[object Array]"}),u&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(S){return typeof S=="object"&&S.buffer&&S.buffer.constructor===ArrayBuffer});for(var F=function(S,H,C){return function(q){return new v(S,H,S).update(q)[C]()}},U=function(S,H,C){return function(q,T){return new v(S,H,T).update(q)[C]()}},z=function(S,H,C){return function(q,T,y,L){return a["cshake"+S].update(q,T,y,L)[C]()}},_=function(S,H,C){return function(q,T,y,L){return a["kmac"+S].update(q,T,y,L)[C]()}},P=function(S,H,C,q){for(var T=0;T<B.length;++T){var y=B[T];S[y]=H(C,q,y)}return S},J=function(S,H){var C=F(S,H,"hex");return C.create=function(){return new v(S,H,S)},C.update=function(q){return C.create().update(q)},P(C,F,S,H)},Q=function(S,H){var C=U(S,H,"hex");return C.create=function(q){return new v(S,H,q)},C.update=function(q,T){return C.create(T).update(q)},P(C,U,S,H)},R=function(S,H){var C=j[S],q=z(S,H,"hex");return q.create=function(T,y,L){return!y&&!L?a["shake"+S].create(T):new v(S,H,T).bytepad([y,L],C)},q.update=function(T,y,L,G){return q.create(y,L,G).update(T)},P(q,z,S,H)},p=function(S,H){var C=j[S],q=_(S,H,"hex");return q.create=function(T,y,L){return new O(S,H,y).bytepad(["KMAC",L],C).bytepad([T],C)},q.update=function(T,y,L,G){return q.create(T,L,G).update(y)},P(q,_,S,H)},l=[{name:"keccak",padding:I,bits:k,createMethod:J},{name:"sha3",padding:M,bits:k,createMethod:J},{name:"shake",padding:g,bits:K,createMethod:Q},{name:"cshake",padding:m,bits:K,createMethod:R},{name:"kmac",padding:m,bits:K,createMethod:p}],a={},c=[],b=0;b<l.length;++b)for(var A=l[b],E=A.bits,x=0;x<E.length;++x){var d=A.name+"_"+E[x];if(c.push(d),a[d]=A.createMethod(E[x],A.padding),A.name!=="sha3"){var w=A.name+E[x];c.push(w),a[w]=a[d]}}function v(S,H,C){this.blocks=[],this.s=[],this.padding=H,this.outputBits=C,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(S<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=C>>5,this.extraBytes=(C&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}v.prototype.update=function(S){if(this.finalized)throw new Error(t);var H,C=typeof S;if(C!=="string"){if(C==="object"){if(S===null)throw new Error(e);if(u&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!u||!ArrayBuffer.isView(S)))throw new Error(e)}else throw new Error(e);H=!0}for(var q=this.blocks,T=this.byteCount,y=S.length,L=this.blockCount,G=0,Y=this.s,X,ee;G<y;){if(this.reset)for(this.reset=!1,q[0]=this.block,X=1;X<L+1;++X)q[X]=0;if(H)for(X=this.start;G<y&&X<T;++G)q[X>>2]|=S[G]<<D[X++&3];else for(X=this.start;G<y&&X<T;++G)ee=S.charCodeAt(G),ee<128?q[X>>2]|=ee<<D[X++&3]:ee<2048?(q[X>>2]|=(192|ee>>6)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]):ee<55296||ee>=57344?(q[X>>2]|=(224|ee>>12)<<D[X++&3],q[X>>2]|=(128|ee>>6&63)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]):(ee=65536+((ee&1023)<<10|S.charCodeAt(++G)&1023),q[X>>2]|=(240|ee>>18)<<D[X++&3],q[X>>2]|=(128|ee>>12&63)<<D[X++&3],q[X>>2]|=(128|ee>>6&63)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]);if(this.lastByteIndex=X,X>=T){for(this.start=X-T,this.block=q[L],X=0;X<L;++X)Y[X]^=q[X];W(Y),this.reset=!0}else this.start=X}return this},v.prototype.encode=function(S,H){var C=S&255,q=1,T=[C];for(S=S>>8,C=S&255;C>0;)T.unshift(C),S=S>>8,C=S&255,++q;return H?T.push(q):T.unshift(q),this.update(T),T.length},v.prototype.encodeString=function(S){var H,C=typeof S;if(C!=="string"){if(C==="object"){if(S===null)throw new Error(e);if(u&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!u||!ArrayBuffer.isView(S)))throw new Error(e)}else throw new Error(e);H=!0}var q=0,T=S.length;if(H)q=T;else for(var y=0;y<S.length;++y){var L=S.charCodeAt(y);L<128?q+=1:L<2048?q+=2:L<55296||L>=57344?q+=3:(L=65536+((L&1023)<<10|S.charCodeAt(++y)&1023),q+=4)}return q+=this.encode(q*8),this.update(S),q},v.prototype.bytepad=function(S,H){for(var C=this.encode(H),q=0;q<S.length;++q)C+=this.encodeString(S[q]);var T=H-C%H,y=[];return y.length=T,this.update(y),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var S=this.blocks,H=this.lastByteIndex,C=this.blockCount,q=this.s;if(S[H>>2]|=this.padding[H&3],this.lastByteIndex===this.byteCount)for(S[0]=S[C],H=1;H<C+1;++H)S[H]=0;for(S[C-1]|=2147483648,H=0;H<C;++H)q[H]^=S[H];W(q)}},v.prototype.toString=v.prototype.hex=function(){this.finalize();for(var S=this.blockCount,H=this.s,C=this.outputBlocks,q=this.extraBytes,T=0,y=0,L="",G;y<C;){for(T=0;T<S&&y<C;++T,++y)G=H[T],L+=h[G>>4&15]+h[G&15]+h[G>>12&15]+h[G>>8&15]+h[G>>20&15]+h[G>>16&15]+h[G>>28&15]+h[G>>24&15];y%S===0&&(W(H),T=0)}return q&&(G=H[T],L+=h[G>>4&15]+h[G&15],q>1&&(L+=h[G>>12&15]+h[G>>8&15]),q>2&&(L+=h[G>>20&15]+h[G>>16&15])),L},v.prototype.arrayBuffer=function(){this.finalize();var S=this.blockCount,H=this.s,C=this.outputBlocks,q=this.extraBytes,T=0,y=0,L=this.outputBits>>3,G;q?G=new ArrayBuffer(C+1<<2):G=new ArrayBuffer(L);for(var Y=new Uint32Array(G);y<C;){for(T=0;T<S&&y<C;++T,++y)Y[y]=H[T];y%S===0&&W(H)}return q&&(Y[T]=H[T],G=G.slice(0,L)),G},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.digest=v.prototype.array=function(){this.finalize();for(var S=this.blockCount,H=this.s,C=this.outputBlocks,q=this.extraBytes,T=0,y=0,L=[],G,Y;y<C;){for(T=0;T<S&&y<C;++T,++y)G=y<<2,Y=H[T],L[G]=Y&255,L[G+1]=Y>>8&255,L[G+2]=Y>>16&255,L[G+3]=Y>>24&255;y%S===0&&W(H)}return q&&(G=y<<2,Y=H[T],L[G]=Y&255,q>1&&(L[G+1]=Y>>8&255),q>2&&(L[G+2]=Y>>16&255)),L};function O(S,H,C){v.call(this,S,H,C)}O.prototype=new v,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),v.prototype.finalize.call(this)};var W=function(S){var H,C,q,T,y,L,G,Y,X,ee,we,Se,he,Re,xe,se,ve,le,ie,ue,fe,te,pe,_e,re,Ae,Ee,oe,De,Me,Oe,We,Qe,Ie,et,tt,Ne,Te,Ce,de,Fe,Be,ce,Ue,$e,me,ze,ke,ge,Le,Pe,ye,Ke,it,qe,nt,Je,rt,rr,ir,nr,sr,yt;for(q=0;q<48;q+=2)T=S[0]^S[10]^S[20]^S[30]^S[40],y=S[1]^S[11]^S[21]^S[31]^S[41],L=S[2]^S[12]^S[22]^S[32]^S[42],G=S[3]^S[13]^S[23]^S[33]^S[43],Y=S[4]^S[14]^S[24]^S[34]^S[44],X=S[5]^S[15]^S[25]^S[35]^S[45],ee=S[6]^S[16]^S[26]^S[36]^S[46],we=S[7]^S[17]^S[27]^S[37]^S[47],Se=S[8]^S[18]^S[28]^S[38]^S[48],he=S[9]^S[19]^S[29]^S[39]^S[49],H=Se^(L<<1|G>>>31),C=he^(G<<1|L>>>31),S[0]^=H,S[1]^=C,S[10]^=H,S[11]^=C,S[20]^=H,S[21]^=C,S[30]^=H,S[31]^=C,S[40]^=H,S[41]^=C,H=T^(Y<<1|X>>>31),C=y^(X<<1|Y>>>31),S[2]^=H,S[3]^=C,S[12]^=H,S[13]^=C,S[22]^=H,S[23]^=C,S[32]^=H,S[33]^=C,S[42]^=H,S[43]^=C,H=L^(ee<<1|we>>>31),C=G^(we<<1|ee>>>31),S[4]^=H,S[5]^=C,S[14]^=H,S[15]^=C,S[24]^=H,S[25]^=C,S[34]^=H,S[35]^=C,S[44]^=H,S[45]^=C,H=Y^(Se<<1|he>>>31),C=X^(he<<1|Se>>>31),S[6]^=H,S[7]^=C,S[16]^=H,S[17]^=C,S[26]^=H,S[27]^=C,S[36]^=H,S[37]^=C,S[46]^=H,S[47]^=C,H=ee^(T<<1|y>>>31),C=we^(y<<1|T>>>31),S[8]^=H,S[9]^=C,S[18]^=H,S[19]^=C,S[28]^=H,S[29]^=C,S[38]^=H,S[39]^=C,S[48]^=H,S[49]^=C,Re=S[0],xe=S[1],me=S[11]<<4|S[10]>>>28,ze=S[10]<<4|S[11]>>>28,oe=S[20]<<3|S[21]>>>29,De=S[21]<<3|S[20]>>>29,ir=S[31]<<9|S[30]>>>23,nr=S[30]<<9|S[31]>>>23,Be=S[40]<<18|S[41]>>>14,ce=S[41]<<18|S[40]>>>14,Ie=S[2]<<1|S[3]>>>31,et=S[3]<<1|S[2]>>>31,se=S[13]<<12|S[12]>>>20,ve=S[12]<<12|S[13]>>>20,ke=S[22]<<10|S[23]>>>22,ge=S[23]<<10|S[22]>>>22,Me=S[33]<<13|S[32]>>>19,Oe=S[32]<<13|S[33]>>>19,sr=S[42]<<2|S[43]>>>30,yt=S[43]<<2|S[42]>>>30,it=S[5]<<30|S[4]>>>2,qe=S[4]<<30|S[5]>>>2,tt=S[14]<<6|S[15]>>>26,Ne=S[15]<<6|S[14]>>>26,le=S[25]<<11|S[24]>>>21,ie=S[24]<<11|S[25]>>>21,Le=S[34]<<15|S[35]>>>17,Pe=S[35]<<15|S[34]>>>17,We=S[45]<<29|S[44]>>>3,Qe=S[44]<<29|S[45]>>>3,_e=S[6]<<28|S[7]>>>4,re=S[7]<<28|S[6]>>>4,nt=S[17]<<23|S[16]>>>9,Je=S[16]<<23|S[17]>>>9,Te=S[26]<<25|S[27]>>>7,Ce=S[27]<<25|S[26]>>>7,ue=S[36]<<21|S[37]>>>11,fe=S[37]<<21|S[36]>>>11,ye=S[47]<<24|S[46]>>>8,Ke=S[46]<<24|S[47]>>>8,Ue=S[8]<<27|S[9]>>>5,$e=S[9]<<27|S[8]>>>5,Ae=S[18]<<20|S[19]>>>12,Ee=S[19]<<20|S[18]>>>12,rt=S[29]<<7|S[28]>>>25,rr=S[28]<<7|S[29]>>>25,de=S[38]<<8|S[39]>>>24,Fe=S[39]<<8|S[38]>>>24,te=S[48]<<14|S[49]>>>18,pe=S[49]<<14|S[48]>>>18,S[0]=Re^~se&le,S[1]=xe^~ve&ie,S[10]=_e^~Ae&oe,S[11]=re^~Ee&De,S[20]=Ie^~tt&Te,S[21]=et^~Ne&Ce,S[30]=Ue^~me&ke,S[31]=$e^~ze&ge,S[40]=it^~nt&rt,S[41]=qe^~Je&rr,S[2]=se^~le&ue,S[3]=ve^~ie&fe,S[12]=Ae^~oe&Me,S[13]=Ee^~De&Oe,S[22]=tt^~Te&de,S[23]=Ne^~Ce&Fe,S[32]=me^~ke&Le,S[33]=ze^~ge&Pe,S[42]=nt^~rt&ir,S[43]=Je^~rr&nr,S[4]=le^~ue&te,S[5]=ie^~fe&pe,S[14]=oe^~Me&We,S[15]=De^~Oe&Qe,S[24]=Te^~de&Be,S[25]=Ce^~Fe&ce,S[34]=ke^~Le&ye,S[35]=ge^~Pe&Ke,S[44]=rt^~ir&sr,S[45]=rr^~nr&yt,S[6]=ue^~te&Re,S[7]=fe^~pe&xe,S[16]=Me^~We&_e,S[17]=Oe^~Qe&re,S[26]=de^~Be&Ie,S[27]=Fe^~ce&et,S[36]=Le^~ye&Ue,S[37]=Pe^~Ke&$e,S[46]=ir^~sr&it,S[47]=nr^~yt&qe,S[8]=te^~Re&se,S[9]=pe^~xe&ve,S[18]=We^~_e&Ae,S[19]=Qe^~re&Ee,S[28]=Be^~Ie&tt,S[29]=ce^~et&Ne,S[38]=ye^~Ue&me,S[39]=Ke^~$e&ze,S[48]=sr^~it&nt,S[49]=yt^~qe&Je,S[0]^=N[q],S[1]^=N[q+1]};if(f)r.exports=a;else for(b=0;b<c.length;++b)n[c[b]]=a[c[b]]})()})(Qc);var ub=Qc.exports;const db="logger/5.7.0";let Xc=!1,Zc=!1;const Vs={debug:1,default:2,info:2,warning:3,error:4,off:5};let eh=Vs.default,ho=null;function lb(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(r){return r.message}return null}const th=lb();var uo;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(uo||(uo={}));var Mr;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Mr||(Mr={}));const rh="0123456789abcdef";class Ve{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();Vs[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(eh>Vs[i])&&console.log.apply(console,t)}debug(...e){this._log(Ve.levels.DEBUG,e)}info(...e){this._log(Ve.levels.INFO,e)}warn(...e){this._log(Ve.levels.WARNING,e)}makeError(e,t,i){if(Zc)return this.makeError("censored error",t,{});t||(t=Ve.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(u=>{const h=i[u];try{if(h instanceof Uint8Array){let g="";for(let m=0;m<h.length;m++)g+=rh[h[m]>>4],g+=rh[h[m]&15];n.push(u+"=Uint8Array(0x"+g+")")}else n.push(u+"="+JSON.stringify(h))}catch{n.push(u+"="+JSON.stringify(i[u].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const s=e;let o="";switch(t){case Mr.NUMERIC_FAULT:{o="NUMERIC_FAULT";const u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":o+="-"+u;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Mr.CALL_EXCEPTION:case Mr.INSUFFICIENT_FUNDS:case Mr.MISSING_NEW:case Mr.NONCE_EXPIRED:case Mr.REPLACEMENT_UNDERPRICED:case Mr.TRANSACTION_REPLACED:case Mr.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(u){f[u]=i[u]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,Ve.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){th&&this.throwError("platform missing String.prototype.normalize",Ve.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:th})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",e<t&&this.throwError("missing argument"+i,Ve.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+i,Ve.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",Ve.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return ho||(ho=new Ve(db)),ho}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Xc){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Zc=!!e,Xc=!!t}static setLogLevel(e){const t=Vs[e.toLowerCase()];if(t==null){Ve.globalLogger().warn("invalid log level - "+e);return}eh=t}static from(e){return new Ve(e)}}Ve.errors=Mr,Ve.levels=uo;const pb="bytes/5.7.0",vt=new Ve(pb);function ih(r){return!!r.toHexString}function dn(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return dn(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function gb(r){return or(r)&&!(r.length%2)||ln(r)}function nh(r){return typeof r=="number"&&r==r&&r%1===0}function ln(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!nh(r.length)||r.length<0)return!1;for(let e=0;e<r.length;e++){const t=r[e];if(!nh(t)||t<0||t>=256)return!1}return!0}function lt(r,e){if(e||(e={}),typeof r=="number"){vt.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),dn(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),ih(r)&&(r=r.toHexString()),or(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":vt.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let n=0;n<t.length;n+=2)i.push(parseInt(t.substring(n,n+2),16));return dn(new Uint8Array(i))}return ln(r)?dn(new Uint8Array(r)):vt.throwArgumentError("invalid arrayify value","value",r)}function bb(r){const e=r.map(n=>lt(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),dn(i)}function vb(r,e){r=lt(r),r.length>e&&vt.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),dn(t)}function or(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const lo="0123456789abcdef";function Ht(r,e){if(e||(e={}),typeof r=="number"){vt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=lo[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),ih(r))return r.toHexString();if(or(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":vt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(ln(r)){let t="0x";for(let i=0;i<r.length;i++){let n=r[i];t+=lo[(n&240)>>4]+lo[n&15]}return t}return vt.throwArgumentError("invalid hexlify value","value",r)}function mb(r){if(typeof r!="string")r=Ht(r);else if(!or(r)||r.length%2)return null;return(r.length-2)/2}function sh(r,e,t){return typeof r!="string"?r=Ht(r):(!or(r)||r.length%2)&&vt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Fr(r,e){for(typeof r!="string"?r=Ht(r):or(r)||vt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&vt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function ah(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(gb(r)){let t=lt(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Ht(t.slice(0,32)),e.s=Ht(t.slice(32,64))):t.length===65?(e.r=Ht(t.slice(0,32)),e.s=Ht(t.slice(32,64)),e.v=t[64]):vt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:vt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Ht(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const n=vb(lt(e._vs),32);e._vs=Ht(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&vt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;const o=Ht(n);e.s==null?e.s=o:e.s!==o&&vt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?vt.throwArgumentError("signature missing v and recoveryParam","signature",r):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&&vt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!or(e.r)?vt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Fr(e.r,32),e.s==null||!or(e.s)?vt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Fr(e.s,32);const t=lt(e.s);t[0]>=128&&vt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=Ht(t);e._vs&&(or(e._vs)||vt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Fr(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&vt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function po(r){return"0x"+ub.keccak_256(lt(r))}var oh={exports:{}};(function(r){(function(e,t){function i(l,a){if(!l)throw new Error(a||"Assertion failed")}function n(l,a){l.super_=a;var c=function(){};c.prototype=a.prototype,l.prototype=new c,l.prototype.constructor=l}function s(l,a,c){if(s.isBN(l))return l;this.negative=0,this.words=null,this.length=0,this.red=null,l!==null&&((a==="le"||a==="be")&&(c=a,a=10),this._init(l||0,a||10,c||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=qs.Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,c){return a.cmp(c)>0?a:c},s.min=function(a,c){return a.cmp(c)<0?a:c},s.prototype._init=function(a,c,b){if(typeof a=="number")return this._initNumber(a,c,b);if(typeof a=="object")return this._initArray(a,c,b);c==="hex"&&(c=16),i(c===(c|0)&&c>=2&&c<=36),a=a.toString().replace(/\s+/g,"");var A=0;a[0]==="-"&&(A++,this.negative=1),A<a.length&&(c===16?this._parseHex(a,A,b):(this._parseBase(a,c,A),b==="le"&&this._initArray(this.toArray(),c,b)))},s.prototype._initNumber=function(a,c,b){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(i(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),c,b)},s.prototype._initArray=function(a,c,b){if(i(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var E,x,d=0;if(b==="be")for(A=a.length-1,E=0;A>=0;A-=3)x=a[A]|a[A-1]<<8|a[A-2]<<16,this.words[E]|=x<<d&67108863,this.words[E+1]=x>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);else if(b==="le")for(A=0,E=0;A<a.length;A+=3)x=a[A]|a[A+1]<<8|a[A+2]<<16,this.words[E]|=x<<d&67108863,this.words[E+1]=x>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);return this._strip()};function f(l,a){var c=l.charCodeAt(a);if(c>=48&&c<=57)return c-48;if(c>=65&&c<=70)return c-55;if(c>=97&&c<=102)return c-87;i(!1,"Invalid character in "+l)}function u(l,a,c){var b=f(l,c);return c-1>=a&&(b|=f(l,c-1)<<4),b}s.prototype._parseHex=function(a,c,b){this.length=Math.ceil((a.length-c)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var E=0,x=0,d;if(b==="be")for(A=a.length-1;A>=c;A-=2)d=u(a,c,A)<<E,this.words[x]|=d&67108863,E>=18?(E-=18,x+=1,this.words[x]|=d>>>26):E+=8;else{var w=a.length-c;for(A=w%2===0?c+1:c;A<a.length;A+=2)d=u(a,c,A)<<E,this.words[x]|=d&67108863,E>=18?(E-=18,x+=1,this.words[x]|=d>>>26):E+=8}this._strip()};function h(l,a,c,b){for(var A=0,E=0,x=Math.min(l.length,c),d=a;d<x;d++){var w=l.charCodeAt(d)-48;A*=b,w>=49?E=w-49+10:w>=17?E=w-17+10:E=w,i(w>=0&&E<b,"Invalid character"),A+=E}return A}s.prototype._parseBase=function(a,c,b){this.words=[0],this.length=1;for(var A=0,E=1;E<=67108863;E*=c)A++;A--,E=E/c|0;for(var x=a.length-b,d=x%A,w=Math.min(x,x-d)+b,v=0,O=b;O<w;O+=A)v=h(a,O,O+A,c),this.imuln(E),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v);if(d!==0){var W=1;for(v=h(a,O,a.length,c),O=0;O<d;O++)W*=c;this.imuln(W),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v)}this._strip()},s.prototype.copy=function(a){a.words=new Array(this.length);for(var c=0;c<this.length;c++)a.words[c]=this.words[c];a.length=this.length,a.negative=this.negative,a.red=this.red};function g(l,a){l.words=a.words,l.length=a.length,l.negative=a.negative,l.red=a.red}if(s.prototype._move=function(a){g(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)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")]=m}catch{s.prototype.inspect=m}else s.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","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"],M=[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],D=[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(a,c){a=a||10,c=c|0||1;var b;if(a===16||a==="hex"){b="";for(var A=0,E=0,x=0;x<this.length;x++){var d=this.words[x],w=((d<<A|E)&16777215).toString(16);E=d>>>24-A&16777215,A+=2,A>=26&&(A-=26,x--),E!==0||x!==this.length-1?b=I[6-w.length]+w+b:b=w+b}for(E!==0&&(b=E.toString(16)+b);b.length%c!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(a===(a|0)&&a>=2&&a<=36){var v=M[a],O=D[a];b="";var W=this.clone();for(W.negative=0;!W.isZero();){var S=W.modrn(O).toString(a);W=W.idivn(O),W.isZero()?b=S+b:b=I[v-S.length]+S+b}for(this.isZero()&&(b="0"+b);b.length%c!==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 a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(a,c){return this.toArrayLike(o,a,c)}),s.prototype.toArray=function(a,c){return this.toArrayLike(Array,a,c)};var N=function(a,c){return a.allocUnsafe?a.allocUnsafe(c):new a(c)};s.prototype.toArrayLike=function(a,c,b){this._strip();var A=this.byteLength(),E=b||Math.max(1,A);i(A<=E,"byte array longer than desired length"),i(E>0,"Requested array length <= 0");var x=N(a,E),d=c==="le"?"LE":"BE";return this["_toArrayLike"+d](x,A),x},s.prototype._toArrayLikeLE=function(a,c){for(var b=0,A=0,E=0,x=0;E<this.length;E++){var d=this.words[E]<<x|A;a[b++]=d&255,b<a.length&&(a[b++]=d>>8&255),b<a.length&&(a[b++]=d>>16&255),x===6?(b<a.length&&(a[b++]=d>>24&255),A=0,x=0):(A=d>>>24,x+=2)}if(b<a.length)for(a[b++]=A;b<a.length;)a[b++]=0},s.prototype._toArrayLikeBE=function(a,c){for(var b=a.length-1,A=0,E=0,x=0;E<this.length;E++){var d=this.words[E]<<x|A;a[b--]=d&255,b>=0&&(a[b--]=d>>8&255),b>=0&&(a[b--]=d>>16&255),x===6?(b>=0&&(a[b--]=d>>24&255),A=0,x=0):(A=d>>>24,x+=2)}if(b>=0)for(a[b--]=A;b>=0;)a[b--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.prototype._countBits=function(a){var c=a,b=0;return c>=4096&&(b+=13,c>>>=13),c>=64&&(b+=7,c>>>=7),c>=8&&(b+=4,c>>>=4),c>=2&&(b+=2,c>>>=2),b+c},s.prototype._zeroBits=function(a){if(a===0)return 26;var c=a,b=0;return c&8191||(b+=13,c>>>=13),c&127||(b+=7,c>>>=7),c&15||(b+=4,c>>>=4),c&3||(b+=2,c>>>=2),c&1||b++,b},s.prototype.bitLength=function(){var a=this.words[this.length-1],c=this._countBits(a);return(this.length-1)*26+c};function k(l){for(var a=new Array(l.bitLength()),c=0;c<a.length;c++){var b=c/26|0,A=c%26;a[c]=l.words[b]>>>A&1}return a}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,c=0;c<this.length;c++){var b=this._zeroBits(this.words[c]);if(a+=b,b!==26)break}return a},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).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(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var c=0;c<a.length;c++)this.words[c]=this.words[c]|a.words[c];return this._strip()},s.prototype.ior=function(a){return i((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.prototype.iuand=function(a){var c;this.length>a.length?c=a:c=this;for(var b=0;b<c.length;b++)this.words[b]=this.words[b]&a.words[b];return this.length=c.length,this._strip()},s.prototype.iand=function(a){return i((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.prototype.iuxor=function(a){var c,b;this.length>a.length?(c=this,b=a):(c=a,b=this);for(var A=0;A<b.length;A++)this.words[A]=c.words[A]^b.words[A];if(this!==c)for(;A<c.length;A++)this.words[A]=c.words[A];return this.length=c.length,this._strip()},s.prototype.ixor=function(a){return i((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.prototype.inotn=function(a){i(typeof a=="number"&&a>=0);var c=Math.ceil(a/26)|0,b=a%26;this._expand(c),b>0&&c--;for(var A=0;A<c;A++)this.words[A]=~this.words[A]&67108863;return b>0&&(this.words[A]=~this.words[A]&67108863>>26-b),this._strip()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.prototype.setn=function(a,c){i(typeof a=="number"&&a>=0);var b=a/26|0,A=a%26;return this._expand(b+1),c?this.words[b]=this.words[b]|1<<A:this.words[b]=this.words[b]&~(1<<A),this._strip()},s.prototype.iadd=function(a){var c;if(this.negative!==0&&a.negative===0)return this.negative=0,c=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,c=this.isub(a),a.negative=1,c._normSign();var b,A;this.length>a.length?(b=this,A=a):(b=a,A=this);for(var E=0,x=0;x<A.length;x++)c=(b.words[x]|0)+(A.words[x]|0)+E,this.words[x]=c&67108863,E=c>>>26;for(;E!==0&&x<b.length;x++)c=(b.words[x]|0)+E,this.words[x]=c&67108863,E=c>>>26;if(this.length=b.length,E!==0)this.words[this.length]=E,this.length++;else if(b!==this)for(;x<b.length;x++)this.words[x]=b.words[x];return this},s.prototype.add=function(a){var c;return a.negative!==0&&this.negative===0?(a.negative=0,c=this.sub(a),a.negative^=1,c):a.negative===0&&this.negative!==0?(this.negative=0,c=a.sub(this),this.negative=1,c):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},s.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var c=this.iadd(a);return a.negative=1,c._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var b=this.cmp(a);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,E;b>0?(A=this,E=a):(A=a,E=this);for(var x=0,d=0;d<E.length;d++)c=(A.words[d]|0)-(E.words[d]|0)+x,x=c>>26,this.words[d]=c&67108863;for(;x!==0&&d<A.length;d++)c=(A.words[d]|0)+x,x=c>>26,this.words[d]=c&67108863;if(x===0&&d<A.length&&A!==this)for(;d<A.length;d++)this.words[d]=A.words[d];return this.length=Math.max(this.length,d),A!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function K(l,a,c){c.negative=a.negative^l.negative;var b=l.length+a.length|0;c.length=b,b=b-1|0;var A=l.words[0]|0,E=a.words[0]|0,x=A*E,d=x&67108863,w=x/67108864|0;c.words[0]=d;for(var v=1;v<b;v++){for(var O=w>>>26,W=w&67108863,S=Math.min(v,a.length-1),H=Math.max(0,v-l.length+1);H<=S;H++){var C=v-H|0;A=l.words[C]|0,E=a.words[H]|0,x=A*E+W,O+=x/67108864|0,W=x&67108863}c.words[v]=W|0,w=O|0}return w!==0?c.words[v]=w|0:c.length--,c._strip()}var B=function(a,c,b){var A=a.words,E=c.words,x=b.words,d=0,w,v,O,W=A[0]|0,S=W&8191,H=W>>>13,C=A[1]|0,q=C&8191,T=C>>>13,y=A[2]|0,L=y&8191,G=y>>>13,Y=A[3]|0,X=Y&8191,ee=Y>>>13,we=A[4]|0,Se=we&8191,he=we>>>13,Re=A[5]|0,xe=Re&8191,se=Re>>>13,ve=A[6]|0,le=ve&8191,ie=ve>>>13,ue=A[7]|0,fe=ue&8191,te=ue>>>13,pe=A[8]|0,_e=pe&8191,re=pe>>>13,Ae=A[9]|0,Ee=Ae&8191,oe=Ae>>>13,De=E[0]|0,Me=De&8191,Oe=De>>>13,We=E[1]|0,Qe=We&8191,Ie=We>>>13,et=E[2]|0,tt=et&8191,Ne=et>>>13,Te=E[3]|0,Ce=Te&8191,de=Te>>>13,Fe=E[4]|0,Be=Fe&8191,ce=Fe>>>13,Ue=E[5]|0,$e=Ue&8191,me=Ue>>>13,ze=E[6]|0,ke=ze&8191,ge=ze>>>13,Le=E[7]|0,Pe=Le&8191,ye=Le>>>13,Ke=E[8]|0,it=Ke&8191,qe=Ke>>>13,nt=E[9]|0,Je=nt&8191,rt=nt>>>13;b.negative=a.negative^c.negative,b.length=19,w=Math.imul(S,Me),v=Math.imul(S,Oe),v=v+Math.imul(H,Me)|0,O=Math.imul(H,Oe);var rr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(rr>>>26)|0,rr&=67108863,w=Math.imul(q,Me),v=Math.imul(q,Oe),v=v+Math.imul(T,Me)|0,O=Math.imul(T,Oe),w=w+Math.imul(S,Qe)|0,v=v+Math.imul(S,Ie)|0,v=v+Math.imul(H,Qe)|0,O=O+Math.imul(H,Ie)|0;var ir=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ir>>>26)|0,ir&=67108863,w=Math.imul(L,Me),v=Math.imul(L,Oe),v=v+Math.imul(G,Me)|0,O=Math.imul(G,Oe),w=w+Math.imul(q,Qe)|0,v=v+Math.imul(q,Ie)|0,v=v+Math.imul(T,Qe)|0,O=O+Math.imul(T,Ie)|0,w=w+Math.imul(S,tt)|0,v=v+Math.imul(S,Ne)|0,v=v+Math.imul(H,tt)|0,O=O+Math.imul(H,Ne)|0;var nr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(nr>>>26)|0,nr&=67108863,w=Math.imul(X,Me),v=Math.imul(X,Oe),v=v+Math.imul(ee,Me)|0,O=Math.imul(ee,Oe),w=w+Math.imul(L,Qe)|0,v=v+Math.imul(L,Ie)|0,v=v+Math.imul(G,Qe)|0,O=O+Math.imul(G,Ie)|0,w=w+Math.imul(q,tt)|0,v=v+Math.imul(q,Ne)|0,v=v+Math.imul(T,tt)|0,O=O+Math.imul(T,Ne)|0,w=w+Math.imul(S,Ce)|0,v=v+Math.imul(S,de)|0,v=v+Math.imul(H,Ce)|0,O=O+Math.imul(H,de)|0;var sr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(sr>>>26)|0,sr&=67108863,w=Math.imul(Se,Me),v=Math.imul(Se,Oe),v=v+Math.imul(he,Me)|0,O=Math.imul(he,Oe),w=w+Math.imul(X,Qe)|0,v=v+Math.imul(X,Ie)|0,v=v+Math.imul(ee,Qe)|0,O=O+Math.imul(ee,Ie)|0,w=w+Math.imul(L,tt)|0,v=v+Math.imul(L,Ne)|0,v=v+Math.imul(G,tt)|0,O=O+Math.imul(G,Ne)|0,w=w+Math.imul(q,Ce)|0,v=v+Math.imul(q,de)|0,v=v+Math.imul(T,Ce)|0,O=O+Math.imul(T,de)|0,w=w+Math.imul(S,Be)|0,v=v+Math.imul(S,ce)|0,v=v+Math.imul(H,Be)|0,O=O+Math.imul(H,ce)|0;var yt=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(yt>>>26)|0,yt&=67108863,w=Math.imul(xe,Me),v=Math.imul(xe,Oe),v=v+Math.imul(se,Me)|0,O=Math.imul(se,Oe),w=w+Math.imul(Se,Qe)|0,v=v+Math.imul(Se,Ie)|0,v=v+Math.imul(he,Qe)|0,O=O+Math.imul(he,Ie)|0,w=w+Math.imul(X,tt)|0,v=v+Math.imul(X,Ne)|0,v=v+Math.imul(ee,tt)|0,O=O+Math.imul(ee,Ne)|0,w=w+Math.imul(L,Ce)|0,v=v+Math.imul(L,de)|0,v=v+Math.imul(G,Ce)|0,O=O+Math.imul(G,de)|0,w=w+Math.imul(q,Be)|0,v=v+Math.imul(q,ce)|0,v=v+Math.imul(T,Be)|0,O=O+Math.imul(T,ce)|0,w=w+Math.imul(S,$e)|0,v=v+Math.imul(S,me)|0,v=v+Math.imul(H,$e)|0,O=O+Math.imul(H,me)|0;var hi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(hi>>>26)|0,hi&=67108863,w=Math.imul(le,Me),v=Math.imul(le,Oe),v=v+Math.imul(ie,Me)|0,O=Math.imul(ie,Oe),w=w+Math.imul(xe,Qe)|0,v=v+Math.imul(xe,Ie)|0,v=v+Math.imul(se,Qe)|0,O=O+Math.imul(se,Ie)|0,w=w+Math.imul(Se,tt)|0,v=v+Math.imul(Se,Ne)|0,v=v+Math.imul(he,tt)|0,O=O+Math.imul(he,Ne)|0,w=w+Math.imul(X,Ce)|0,v=v+Math.imul(X,de)|0,v=v+Math.imul(ee,Ce)|0,O=O+Math.imul(ee,de)|0,w=w+Math.imul(L,Be)|0,v=v+Math.imul(L,ce)|0,v=v+Math.imul(G,Be)|0,O=O+Math.imul(G,ce)|0,w=w+Math.imul(q,$e)|0,v=v+Math.imul(q,me)|0,v=v+Math.imul(T,$e)|0,O=O+Math.imul(T,me)|0,w=w+Math.imul(S,ke)|0,v=v+Math.imul(S,ge)|0,v=v+Math.imul(H,ke)|0,O=O+Math.imul(H,ge)|0;var ui=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ui>>>26)|0,ui&=67108863,w=Math.imul(fe,Me),v=Math.imul(fe,Oe),v=v+Math.imul(te,Me)|0,O=Math.imul(te,Oe),w=w+Math.imul(le,Qe)|0,v=v+Math.imul(le,Ie)|0,v=v+Math.imul(ie,Qe)|0,O=O+Math.imul(ie,Ie)|0,w=w+Math.imul(xe,tt)|0,v=v+Math.imul(xe,Ne)|0,v=v+Math.imul(se,tt)|0,O=O+Math.imul(se,Ne)|0,w=w+Math.imul(Se,Ce)|0,v=v+Math.imul(Se,de)|0,v=v+Math.imul(he,Ce)|0,O=O+Math.imul(he,de)|0,w=w+Math.imul(X,Be)|0,v=v+Math.imul(X,ce)|0,v=v+Math.imul(ee,Be)|0,O=O+Math.imul(ee,ce)|0,w=w+Math.imul(L,$e)|0,v=v+Math.imul(L,me)|0,v=v+Math.imul(G,$e)|0,O=O+Math.imul(G,me)|0,w=w+Math.imul(q,ke)|0,v=v+Math.imul(q,ge)|0,v=v+Math.imul(T,ke)|0,O=O+Math.imul(T,ge)|0,w=w+Math.imul(S,Pe)|0,v=v+Math.imul(S,ye)|0,v=v+Math.imul(H,Pe)|0,O=O+Math.imul(H,ye)|0;var di=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(di>>>26)|0,di&=67108863,w=Math.imul(_e,Me),v=Math.imul(_e,Oe),v=v+Math.imul(re,Me)|0,O=Math.imul(re,Oe),w=w+Math.imul(fe,Qe)|0,v=v+Math.imul(fe,Ie)|0,v=v+Math.imul(te,Qe)|0,O=O+Math.imul(te,Ie)|0,w=w+Math.imul(le,tt)|0,v=v+Math.imul(le,Ne)|0,v=v+Math.imul(ie,tt)|0,O=O+Math.imul(ie,Ne)|0,w=w+Math.imul(xe,Ce)|0,v=v+Math.imul(xe,de)|0,v=v+Math.imul(se,Ce)|0,O=O+Math.imul(se,de)|0,w=w+Math.imul(Se,Be)|0,v=v+Math.imul(Se,ce)|0,v=v+Math.imul(he,Be)|0,O=O+Math.imul(he,ce)|0,w=w+Math.imul(X,$e)|0,v=v+Math.imul(X,me)|0,v=v+Math.imul(ee,$e)|0,O=O+Math.imul(ee,me)|0,w=w+Math.imul(L,ke)|0,v=v+Math.imul(L,ge)|0,v=v+Math.imul(G,ke)|0,O=O+Math.imul(G,ge)|0,w=w+Math.imul(q,Pe)|0,v=v+Math.imul(q,ye)|0,v=v+Math.imul(T,Pe)|0,O=O+Math.imul(T,ye)|0,w=w+Math.imul(S,it)|0,v=v+Math.imul(S,qe)|0,v=v+Math.imul(H,it)|0,O=O+Math.imul(H,qe)|0;var li=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(li>>>26)|0,li&=67108863,w=Math.imul(Ee,Me),v=Math.imul(Ee,Oe),v=v+Math.imul(oe,Me)|0,O=Math.imul(oe,Oe),w=w+Math.imul(_e,Qe)|0,v=v+Math.imul(_e,Ie)|0,v=v+Math.imul(re,Qe)|0,O=O+Math.imul(re,Ie)|0,w=w+Math.imul(fe,tt)|0,v=v+Math.imul(fe,Ne)|0,v=v+Math.imul(te,tt)|0,O=O+Math.imul(te,Ne)|0,w=w+Math.imul(le,Ce)|0,v=v+Math.imul(le,de)|0,v=v+Math.imul(ie,Ce)|0,O=O+Math.imul(ie,de)|0,w=w+Math.imul(xe,Be)|0,v=v+Math.imul(xe,ce)|0,v=v+Math.imul(se,Be)|0,O=O+Math.imul(se,ce)|0,w=w+Math.imul(Se,$e)|0,v=v+Math.imul(Se,me)|0,v=v+Math.imul(he,$e)|0,O=O+Math.imul(he,me)|0,w=w+Math.imul(X,ke)|0,v=v+Math.imul(X,ge)|0,v=v+Math.imul(ee,ke)|0,O=O+Math.imul(ee,ge)|0,w=w+Math.imul(L,Pe)|0,v=v+Math.imul(L,ye)|0,v=v+Math.imul(G,Pe)|0,O=O+Math.imul(G,ye)|0,w=w+Math.imul(q,it)|0,v=v+Math.imul(q,qe)|0,v=v+Math.imul(T,it)|0,O=O+Math.imul(T,qe)|0,w=w+Math.imul(S,Je)|0,v=v+Math.imul(S,rt)|0,v=v+Math.imul(H,Je)|0,O=O+Math.imul(H,rt)|0;var pi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(pi>>>26)|0,pi&=67108863,w=Math.imul(Ee,Qe),v=Math.imul(Ee,Ie),v=v+Math.imul(oe,Qe)|0,O=Math.imul(oe,Ie),w=w+Math.imul(_e,tt)|0,v=v+Math.imul(_e,Ne)|0,v=v+Math.imul(re,tt)|0,O=O+Math.imul(re,Ne)|0,w=w+Math.imul(fe,Ce)|0,v=v+Math.imul(fe,de)|0,v=v+Math.imul(te,Ce)|0,O=O+Math.imul(te,de)|0,w=w+Math.imul(le,Be)|0,v=v+Math.imul(le,ce)|0,v=v+Math.imul(ie,Be)|0,O=O+Math.imul(ie,ce)|0,w=w+Math.imul(xe,$e)|0,v=v+Math.imul(xe,me)|0,v=v+Math.imul(se,$e)|0,O=O+Math.imul(se,me)|0,w=w+Math.imul(Se,ke)|0,v=v+Math.imul(Se,ge)|0,v=v+Math.imul(he,ke)|0,O=O+Math.imul(he,ge)|0,w=w+Math.imul(X,Pe)|0,v=v+Math.imul(X,ye)|0,v=v+Math.imul(ee,Pe)|0,O=O+Math.imul(ee,ye)|0,w=w+Math.imul(L,it)|0,v=v+Math.imul(L,qe)|0,v=v+Math.imul(G,it)|0,O=O+Math.imul(G,qe)|0,w=w+Math.imul(q,Je)|0,v=v+Math.imul(q,rt)|0,v=v+Math.imul(T,Je)|0,O=O+Math.imul(T,rt)|0;var Ar=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(Ar>>>26)|0,Ar&=67108863,w=Math.imul(Ee,tt),v=Math.imul(Ee,Ne),v=v+Math.imul(oe,tt)|0,O=Math.imul(oe,Ne),w=w+Math.imul(_e,Ce)|0,v=v+Math.imul(_e,de)|0,v=v+Math.imul(re,Ce)|0,O=O+Math.imul(re,de)|0,w=w+Math.imul(fe,Be)|0,v=v+Math.imul(fe,ce)|0,v=v+Math.imul(te,Be)|0,O=O+Math.imul(te,ce)|0,w=w+Math.imul(le,$e)|0,v=v+Math.imul(le,me)|0,v=v+Math.imul(ie,$e)|0,O=O+Math.imul(ie,me)|0,w=w+Math.imul(xe,ke)|0,v=v+Math.imul(xe,ge)|0,v=v+Math.imul(se,ke)|0,O=O+Math.imul(se,ge)|0,w=w+Math.imul(Se,Pe)|0,v=v+Math.imul(Se,ye)|0,v=v+Math.imul(he,Pe)|0,O=O+Math.imul(he,ye)|0,w=w+Math.imul(X,it)|0,v=v+Math.imul(X,qe)|0,v=v+Math.imul(ee,it)|0,O=O+Math.imul(ee,qe)|0,w=w+Math.imul(L,Je)|0,v=v+Math.imul(L,rt)|0,v=v+Math.imul(G,Je)|0,O=O+Math.imul(G,rt)|0;var gi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(gi>>>26)|0,gi&=67108863,w=Math.imul(Ee,Ce),v=Math.imul(Ee,de),v=v+Math.imul(oe,Ce)|0,O=Math.imul(oe,de),w=w+Math.imul(_e,Be)|0,v=v+Math.imul(_e,ce)|0,v=v+Math.imul(re,Be)|0,O=O+Math.imul(re,ce)|0,w=w+Math.imul(fe,$e)|0,v=v+Math.imul(fe,me)|0,v=v+Math.imul(te,$e)|0,O=O+Math.imul(te,me)|0,w=w+Math.imul(le,ke)|0,v=v+Math.imul(le,ge)|0,v=v+Math.imul(ie,ke)|0,O=O+Math.imul(ie,ge)|0,w=w+Math.imul(xe,Pe)|0,v=v+Math.imul(xe,ye)|0,v=v+Math.imul(se,Pe)|0,O=O+Math.imul(se,ye)|0,w=w+Math.imul(Se,it)|0,v=v+Math.imul(Se,qe)|0,v=v+Math.imul(he,it)|0,O=O+Math.imul(he,qe)|0,w=w+Math.imul(X,Je)|0,v=v+Math.imul(X,rt)|0,v=v+Math.imul(ee,Je)|0,O=O+Math.imul(ee,rt)|0;var bi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(bi>>>26)|0,bi&=67108863,w=Math.imul(Ee,Be),v=Math.imul(Ee,ce),v=v+Math.imul(oe,Be)|0,O=Math.imul(oe,ce),w=w+Math.imul(_e,$e)|0,v=v+Math.imul(_e,me)|0,v=v+Math.imul(re,$e)|0,O=O+Math.imul(re,me)|0,w=w+Math.imul(fe,ke)|0,v=v+Math.imul(fe,ge)|0,v=v+Math.imul(te,ke)|0,O=O+Math.imul(te,ge)|0,w=w+Math.imul(le,Pe)|0,v=v+Math.imul(le,ye)|0,v=v+Math.imul(ie,Pe)|0,O=O+Math.imul(ie,ye)|0,w=w+Math.imul(xe,it)|0,v=v+Math.imul(xe,qe)|0,v=v+Math.imul(se,it)|0,O=O+Math.imul(se,qe)|0,w=w+Math.imul(Se,Je)|0,v=v+Math.imul(Se,rt)|0,v=v+Math.imul(he,Je)|0,O=O+Math.imul(he,rt)|0;var kt=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(kt>>>26)|0,kt&=67108863,w=Math.imul(Ee,$e),v=Math.imul(Ee,me),v=v+Math.imul(oe,$e)|0,O=Math.imul(oe,me),w=w+Math.imul(_e,ke)|0,v=v+Math.imul(_e,ge)|0,v=v+Math.imul(re,ke)|0,O=O+Math.imul(re,ge)|0,w=w+Math.imul(fe,Pe)|0,v=v+Math.imul(fe,ye)|0,v=v+Math.imul(te,Pe)|0,O=O+Math.imul(te,ye)|0,w=w+Math.imul(le,it)|0,v=v+Math.imul(le,qe)|0,v=v+Math.imul(ie,it)|0,O=O+Math.imul(ie,qe)|0,w=w+Math.imul(xe,Je)|0,v=v+Math.imul(xe,rt)|0,v=v+Math.imul(se,Je)|0,O=O+Math.imul(se,rt)|0;var vi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(vi>>>26)|0,vi&=67108863,w=Math.imul(Ee,ke),v=Math.imul(Ee,ge),v=v+Math.imul(oe,ke)|0,O=Math.imul(oe,ge),w=w+Math.imul(_e,Pe)|0,v=v+Math.imul(_e,ye)|0,v=v+Math.imul(re,Pe)|0,O=O+Math.imul(re,ye)|0,w=w+Math.imul(fe,it)|0,v=v+Math.imul(fe,qe)|0,v=v+Math.imul(te,it)|0,O=O+Math.imul(te,qe)|0,w=w+Math.imul(le,Je)|0,v=v+Math.imul(le,rt)|0,v=v+Math.imul(ie,Je)|0,O=O+Math.imul(ie,rt)|0;var mi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(mi>>>26)|0,mi&=67108863,w=Math.imul(Ee,Pe),v=Math.imul(Ee,ye),v=v+Math.imul(oe,Pe)|0,O=Math.imul(oe,ye),w=w+Math.imul(_e,it)|0,v=v+Math.imul(_e,qe)|0,v=v+Math.imul(re,it)|0,O=O+Math.imul(re,qe)|0,w=w+Math.imul(fe,Je)|0,v=v+Math.imul(fe,rt)|0,v=v+Math.imul(te,Je)|0,O=O+Math.imul(te,rt)|0;var yi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(yi>>>26)|0,yi&=67108863,w=Math.imul(Ee,it),v=Math.imul(Ee,qe),v=v+Math.imul(oe,it)|0,O=Math.imul(oe,qe),w=w+Math.imul(_e,Je)|0,v=v+Math.imul(_e,rt)|0,v=v+Math.imul(re,Je)|0,O=O+Math.imul(re,rt)|0;var ws=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ws>>>26)|0,ws&=67108863,w=Math.imul(Ee,Je),v=Math.imul(Ee,rt),v=v+Math.imul(oe,Je)|0,O=Math.imul(oe,rt);var _s=(d+w|0)+((v&8191)<<13)|0;return d=(O+(v>>>13)|0)+(_s>>>26)|0,_s&=67108863,x[0]=rr,x[1]=ir,x[2]=nr,x[3]=sr,x[4]=yt,x[5]=hi,x[6]=ui,x[7]=di,x[8]=li,x[9]=pi,x[10]=Ar,x[11]=gi,x[12]=bi,x[13]=kt,x[14]=vi,x[15]=mi,x[16]=yi,x[17]=ws,x[18]=_s,d!==0&&(x[19]=d,b.length++),b};Math.imul||(B=K);function j(l,a,c){c.negative=a.negative^l.negative,c.length=l.length+a.length;for(var b=0,A=0,E=0;E<c.length-1;E++){var x=A;A=0;for(var d=b&67108863,w=Math.min(E,a.length-1),v=Math.max(0,E-l.length+1);v<=w;v++){var O=E-v,W=l.words[O]|0,S=a.words[v]|0,H=W*S,C=H&67108863;x=x+(H/67108864|0)|0,C=C+d|0,d=C&67108863,x=x+(C>>>26)|0,A+=x>>>26,x&=67108863}c.words[E]=d,b=x,x=A}return b!==0?c.words[E]=b:c.length--,c._strip()}function F(l,a,c){return j(l,a,c)}s.prototype.mulTo=function(a,c){var b,A=this.length+a.length;return this.length===10&&a.length===10?b=B(this,a,c):A<63?b=K(this,a,c):A<1024?b=j(this,a,c):b=F(this,a,c),b},s.prototype.mul=function(a){var c=new s(null);return c.words=new Array(this.length+a.length),this.mulTo(a,c)},s.prototype.mulf=function(a){var c=new s(null);return c.words=new Array(this.length+a.length),F(this,a,c)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.prototype.imuln=function(a){var c=a<0;c&&(a=-a),i(typeof a=="number"),i(a<67108864);for(var b=0,A=0;A<this.length;A++){var E=(this.words[A]|0)*a,x=(E&67108863)+(b&67108863);b>>=26,b+=E/67108864|0,b+=x>>>26,this.words[A]=x&67108863}return b!==0&&(this.words[A]=b,this.length++),c?this.ineg():this},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var c=k(a);if(c.length===0)return new s(1);for(var b=this,A=0;A<c.length&&c[A]===0;A++,b=b.sqr());if(++A<c.length)for(var E=b.sqr();A<c.length;A++,E=E.sqr())c[A]!==0&&(b=b.mul(E));return b},s.prototype.iushln=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26,A=67108863>>>26-c<<26-c,E;if(c!==0){var x=0;for(E=0;E<this.length;E++){var d=this.words[E]&A,w=(this.words[E]|0)-d<<c;this.words[E]=w|x,x=d>>>26-c}x&&(this.words[E]=x,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(a){return i(this.negative===0),this.iushln(a)},s.prototype.iushrn=function(a,c,b){i(typeof a=="number"&&a>=0);var A;c?A=(c-c%26)/26:A=0;var E=a%26,x=Math.min((a-E)/26,this.length),d=67108863^67108863>>>E<<E,w=b;if(A-=x,A=Math.max(0,A),w){for(var v=0;v<x;v++)w.words[v]=this.words[v];w.length=x}if(x!==0)if(this.length>x)for(this.length-=x,v=0;v<this.length;v++)this.words[v]=this.words[v+x];else this.words[0]=0,this.length=1;var O=0;for(v=this.length-1;v>=0&&(O!==0||v>=A);v--){var W=this.words[v]|0;this.words[v]=O<<26-E|W>>>E,O=W&d}return w&&O!==0&&(w.words[w.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,c,b){return i(this.negative===0),this.iushrn(a,c,b)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26,A=1<<c;if(this.length<=b)return!1;var E=this.words[b];return!!(E&A)},s.prototype.imaskn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(c!==0&&b++,this.length=Math.min(b,this.length),c!==0){var A=67108863^67108863>>>c<<c;this.words[this.length-1]&=A}return this._strip()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.prototype.iaddn=function(a){return i(typeof a=="number"),i(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},s.prototype._iaddn=function(a){this.words[0]+=a;for(var c=0;c<this.length&&this.words[c]>=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},s.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c<this.length&&this.words[c]<0;c++)this.words[c]+=67108864,this.words[c+1]-=1;return this._strip()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,c,b){var A=a.length+b,E;this._expand(A);var x,d=0;for(E=0;E<a.length;E++){x=(this.words[E+b]|0)+d;var w=(a.words[E]|0)*c;x-=w&67108863,d=(x>>26)-(w/67108864|0),this.words[E+b]=x&67108863}for(;E<this.length-b;E++)x=(this.words[E+b]|0)+d,d=x>>26,this.words[E+b]=x&67108863;if(d===0)return this._strip();for(i(d===-1),d=0,E=0;E<this.length;E++)x=-(this.words[E]|0)+d,d=x>>26,this.words[E]=x&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,c){var b=this.length-a.length,A=this.clone(),E=a,x=E.words[E.length-1]|0,d=this._countBits(x);b=26-d,b!==0&&(E=E.ushln(b),A.iushln(b),x=E.words[E.length-1]|0);var w=A.length-E.length,v;if(c!=="mod"){v=new s(null),v.length=w+1,v.words=new Array(v.length);for(var O=0;O<v.length;O++)v.words[O]=0}var W=A.clone()._ishlnsubmul(E,1,w);W.negative===0&&(A=W,v&&(v.words[w]=1));for(var S=w-1;S>=0;S--){var H=(A.words[E.length+S]|0)*67108864+(A.words[E.length+S-1]|0);for(H=Math.min(H/x|0,67108863),A._ishlnsubmul(E,H,S);A.negative!==0;)H--,A.negative=0,A._ishlnsubmul(E,1,S),A.isZero()||(A.negative^=1);v&&(v.words[S]=H)}return v&&v._strip(),A._strip(),c!=="div"&&b!==0&&A.iushrn(b),{div:v||null,mod:A}},s.prototype.divmod=function(a,c,b){if(i(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var A,E,x;return this.negative!==0&&a.negative===0?(x=this.neg().divmod(a,c),c!=="mod"&&(A=x.div.neg()),c!=="div"&&(E=x.mod.neg(),b&&E.negative!==0&&E.iadd(a)),{div:A,mod:E}):this.negative===0&&a.negative!==0?(x=this.divmod(a.neg(),c),c!=="mod"&&(A=x.div.neg()),{div:A,mod:x.mod}):this.negative&a.negative?(x=this.neg().divmod(a.neg(),c),c!=="div"&&(E=x.mod.neg(),b&&E.negative!==0&&E.isub(a)),{div:x.div,mod:E}):a.length>this.length||this.cmp(a)<0?{div:new s(0),mod:this}:a.length===1?c==="div"?{div:this.divn(a.words[0]),mod:null}:c==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,c)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.prototype.divRound=function(a){var c=this.divmod(a);if(c.mod.isZero())return c.div;var b=c.div.negative!==0?c.mod.isub(a):c.mod,A=a.ushrn(1),E=a.andln(1),x=b.cmp(A);return x<0||E===1&&x===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},s.prototype.modrn=function(a){var c=a<0;c&&(a=-a),i(a<=67108863);for(var b=(1<<26)%a,A=0,E=this.length-1;E>=0;E--)A=(b*A+(this.words[E]|0))%a;return c?-A:A},s.prototype.modn=function(a){return this.modrn(a)},s.prototype.idivn=function(a){var c=a<0;c&&(a=-a),i(a<=67108863);for(var b=0,A=this.length-1;A>=0;A--){var E=(this.words[A]|0)+b*67108864;this.words[A]=E/a|0,b=E%a}return this._strip(),c?this.ineg():this},s.prototype.divn=function(a){return this.clone().idivn(a)},s.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var c=this,b=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var A=new s(1),E=new s(0),x=new s(0),d=new s(1),w=0;c.isEven()&&b.isEven();)c.iushrn(1),b.iushrn(1),++w;for(var v=b.clone(),O=c.clone();!c.isZero();){for(var W=0,S=1;!(c.words[0]&S)&&W<26;++W,S<<=1);if(W>0)for(c.iushrn(W);W-- >0;)(A.isOdd()||E.isOdd())&&(A.iadd(v),E.isub(O)),A.iushrn(1),E.iushrn(1);for(var H=0,C=1;!(b.words[0]&C)&&H<26;++H,C<<=1);if(H>0)for(b.iushrn(H);H-- >0;)(x.isOdd()||d.isOdd())&&(x.iadd(v),d.isub(O)),x.iushrn(1),d.iushrn(1);c.cmp(b)>=0?(c.isub(b),A.isub(x),E.isub(d)):(b.isub(c),x.isub(A),d.isub(E))}return{a:x,b:d,gcd:b.iushln(w)}},s.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var c=this,b=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var A=new s(1),E=new s(0),x=b.clone();c.cmpn(1)>0&&b.cmpn(1)>0;){for(var d=0,w=1;!(c.words[0]&w)&&d<26;++d,w<<=1);if(d>0)for(c.iushrn(d);d-- >0;)A.isOdd()&&A.iadd(x),A.iushrn(1);for(var v=0,O=1;!(b.words[0]&O)&&v<26;++v,O<<=1);if(v>0)for(b.iushrn(v);v-- >0;)E.isOdd()&&E.iadd(x),E.iushrn(1);c.cmp(b)>=0?(c.isub(b),A.isub(E)):(b.isub(c),E.isub(A))}var W;return c.cmpn(1)===0?W=A:W=E,W.cmpn(0)<0&&W.iadd(a),W},s.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var c=this.clone(),b=a.clone();c.negative=0,b.negative=0;for(var A=0;c.isEven()&&b.isEven();A++)c.iushrn(1),b.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;b.isEven();)b.iushrn(1);var E=c.cmp(b);if(E<0){var x=c;c=b,b=x}else if(E===0||b.cmpn(1)===0)break;c.isub(b)}while(!0);return b.iushln(A)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.prototype.bincn=function(a){i(typeof a=="number");var c=a%26,b=(a-c)/26,A=1<<c;if(this.length<=b)return this._expand(b+1),this.words[b]|=A,this;for(var E=A,x=b;E!==0&&x<this.length;x++){var d=this.words[x]|0;d+=E,E=d>>>26,d&=67108863,this.words[x]=d}return E!==0&&(this.words[x]=E,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(a){var c=a<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this._strip();var b;if(this.length>1)b=1;else{c&&(a=-a),i(a<=67108863,"Number is too big");var A=this.words[0]|0;b=A===a?0:A<a?-1:1}return this.negative!==0?-b|0:b},s.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var c=this.ucmp(a);return this.negative!==0?-c|0:c},s.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var c=0,b=this.length-1;b>=0;b--){var A=this.words[b]|0,E=a.words[b]|0;if(A!==E){A<E?c=-1:A>E&&(c=1);break}}return c},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new R(a)},s.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},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(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var U={k256:null,p224:null,p192:null,p25519:null};function z(l,a){this.name=l,this.p=new s(a,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},z.prototype.ireduce=function(a){var c=a,b;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),b=c.bitLength();while(b>this.n);var A=b<this.n?-1:c.ucmp(this.p);return A===0?(c.words[0]=0,c.length=1):A>0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},z.prototype.split=function(a,c){a.iushrn(this.n,0,c)},z.prototype.imulK=function(a){return a.imul(this.k)};function _(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(_,z),_.prototype.split=function(a,c){for(var b=4194303,A=Math.min(a.length,9),E=0;E<A;E++)c.words[E]=a.words[E];if(c.length=A,a.length<=9){a.words[0]=0,a.length=1;return}var x=a.words[9];for(c.words[c.length++]=x&b,E=10;E<a.length;E++){var d=a.words[E]|0;a.words[E-10]=(d&b)<<4|x>>>22,x=d}x>>>=22,a.words[E-10]=x,x===0&&a.length>10?a.length-=10:a.length-=9},_.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var c=0,b=0;b<a.length;b++){var A=a.words[b]|0;c+=A*977,a.words[b]=c&67108863,c=A*64+(c/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function P(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(P,z);function J(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(J,z);function Q(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Q,z),Q.prototype.imulK=function(a){for(var c=0,b=0;b<a.length;b++){var A=(a.words[b]|0)*19+c,E=A&67108863;A>>>=26,a.words[b]=E,c=A}return c!==0&&(a.words[a.length++]=c),a},s._prime=function(a){if(U[a])return U[a];var c;if(a==="k256")c=new _;else if(a==="p224")c=new P;else if(a==="p192")c=new J;else if(a==="p25519")c=new Q;else throw new Error("Unknown prime "+a);return U[a]=c,c};function R(l){if(typeof l=="string"){var a=s._prime(l);this.m=a.p,this.prime=a}else i(l.gtn(1),"modulus must be greater than 1"),this.m=l,this.prime=null}R.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},R.prototype._verify2=function(a,c){i((a.negative|c.negative)===0,"red works only with positives"),i(a.red&&a.red===c.red,"red works only with red numbers")},R.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(g(a,a.umod(this.m)._forceRed(this)),a)},R.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},R.prototype.add=function(a,c){this._verify2(a,c);var b=a.add(c);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},R.prototype.iadd=function(a,c){this._verify2(a,c);var b=a.iadd(c);return b.cmp(this.m)>=0&&b.isub(this.m),b},R.prototype.sub=function(a,c){this._verify2(a,c);var b=a.sub(c);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},R.prototype.isub=function(a,c){this._verify2(a,c);var b=a.isub(c);return b.cmpn(0)<0&&b.iadd(this.m),b},R.prototype.shl=function(a,c){return this._verify1(a),this.imod(a.ushln(c))},R.prototype.imul=function(a,c){return this._verify2(a,c),this.imod(a.imul(c))},R.prototype.mul=function(a,c){return this._verify2(a,c),this.imod(a.mul(c))},R.prototype.isqr=function(a){return this.imul(a,a.clone())},R.prototype.sqr=function(a){return this.mul(a,a)},R.prototype.sqrt=function(a){if(a.isZero())return a.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var b=this.m.add(new s(1)).iushrn(2);return this.pow(a,b)}for(var A=this.m.subn(1),E=0;!A.isZero()&&A.andln(1)===0;)E++,A.iushrn(1);i(!A.isZero());var x=new s(1).toRed(this),d=x.redNeg(),w=this.m.subn(1).iushrn(1),v=this.m.bitLength();for(v=new s(2*v*v).toRed(this);this.pow(v,w).cmp(d)!==0;)v.redIAdd(d);for(var O=this.pow(v,A),W=this.pow(a,A.addn(1).iushrn(1)),S=this.pow(a,A),H=E;S.cmp(x)!==0;){for(var C=S,q=0;C.cmp(x)!==0;q++)C=C.redSqr();i(q<H);var T=this.pow(O,new s(1).iushln(H-q-1));W=W.redMul(T),O=T.redSqr(),S=S.redMul(O),H=q}return W},R.prototype.invm=function(a){var c=a._invmp(this.m);return c.negative!==0?(c.negative=0,this.imod(c).redNeg()):this.imod(c)},R.prototype.pow=function(a,c){if(c.isZero())return new s(1).toRed(this);if(c.cmpn(1)===0)return a.clone();var b=4,A=new Array(1<<b);A[0]=new s(1).toRed(this),A[1]=a;for(var E=2;E<A.length;E++)A[E]=this.mul(A[E-1],a);var x=A[0],d=0,w=0,v=c.bitLength()%26;for(v===0&&(v=26),E=c.length-1;E>=0;E--){for(var O=c.words[E],W=v-1;W>=0;W--){var S=O>>W&1;if(x!==A[0]&&(x=this.sqr(x)),S===0&&d===0){w=0;continue}d<<=1,d|=S,w++,!(w!==b&&(E!==0||W!==0))&&(x=this.mul(x,A[d]),w=0,d=0)}v=26}return x},R.prototype.convertTo=function(a){var c=a.umod(this.m);return c===a?c.clone():c},R.prototype.convertFrom=function(a){var c=a.clone();return c.red=null,c},s.mont=function(a){return new p(a)};function p(l){R.call(this,l),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(p,R),p.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},p.prototype.convertFrom=function(a){var c=this.imod(a.mul(this.rinv));return c.red=null,c},p.prototype.imul=function(a,c){if(a.isZero()||c.isZero())return a.words[0]=0,a.length=1,a;var b=a.imul(c),A=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(A).iushrn(this.shift),x=E;return E.cmp(this.m)>=0?x=E.isub(this.m):E.cmpn(0)<0&&(x=E.iadd(this.m)),x._forceRed(this)},p.prototype.mul=function(a,c){if(a.isZero()||c.isZero())return new s(0)._forceRed(this);var b=a.mul(c),A=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(A).iushrn(this.shift),x=E;return E.cmp(this.m)>=0?x=E.isub(this.m):E.cmpn(0)<0&&(x=E.iadd(this.m)),x._forceRed(this)},p.prototype.invm=function(a){var c=this.imod(a._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(r,Pt)})(oh);var je=oh.exports;const fh="bignumber/5.7.0";var Gs=je.BN;const Zr=new Ve(fh),go={},ch=9007199254740991;function yb(r){return r!=null&&(ot.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||or(r)||typeof r=="bigint"||ln(r))}let hh=!1;class ot{constructor(e,t){e!==go&&Zr.throwError("cannot call constructor directly; use BigNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Xt(Xe(this).fromTwos(e))}toTwos(e){return Xt(Xe(this).toTwos(e))}abs(){return this._hex[0]==="-"?ot.from(this._hex.substring(1)):this}add(e){return Xt(Xe(this).add(Xe(e)))}sub(e){return Xt(Xe(this).sub(Xe(e)))}div(e){return ot.from(e).isZero()&&lr("division-by-zero","div"),Xt(Xe(this).div(Xe(e)))}mul(e){return Xt(Xe(this).mul(Xe(e)))}mod(e){const t=Xe(e);return t.isNeg()&&lr("division-by-zero","mod"),Xt(Xe(this).umod(t))}pow(e){const t=Xe(e);return t.isNeg()&&lr("negative-power","pow"),Xt(Xe(this).pow(t))}and(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&lr("unbound-bitwise-result","and"),Xt(Xe(this).and(t))}or(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&lr("unbound-bitwise-result","or"),Xt(Xe(this).or(t))}xor(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&lr("unbound-bitwise-result","xor"),Xt(Xe(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&lr("negative-width","mask"),Xt(Xe(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&lr("negative-width","shl"),Xt(Xe(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&lr("negative-width","shr"),Xt(Xe(this).shrn(e))}eq(e){return Xe(this).eq(Xe(e))}lt(e){return Xe(this).lt(Xe(e))}lte(e){return Xe(this).lte(Xe(e))}gt(e){return Xe(this).gt(Xe(e))}gte(e){return Xe(this).gte(Xe(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Xe(this).isZero()}toNumber(){try{return Xe(this).toNumber()}catch{lr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Zr.throwError("this platform does not support BigInt",Ve.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?hh||(hh=!0,Zr.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Zr.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ve.errors.UNEXPECTED_ARGUMENT,{}):Zr.throwError("BigNumber.toString does not accept parameters",Ve.errors.UNEXPECTED_ARGUMENT,{})),Xe(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof ot)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new ot(go,jn(e)):e.match(/^-?[0-9]+$/)?new ot(go,jn(new Gs(e))):Zr.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&lr("underflow","BigNumber.from",e),(e>=ch||e<=-ch)&&lr("overflow","BigNumber.from",e),ot.from(String(e));const t=e;if(typeof t=="bigint")return ot.from(t.toString());if(ln(t))return ot.from(Ht(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return ot.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(or(i)||i[0]==="-"&&or(i.substring(1))))return ot.from(i)}return Zr.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function jn(r){if(typeof r!="string")return jn(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&Zr.throwArgumentError("invalid hex","value",r),r=jn(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function Xt(r){return ot.from(jn(r))}function Xe(r){const e=ot.from(r).toHexString();return e[0]==="-"?new Gs("-"+e.substring(3),16):new Gs(e.substring(2),16)}function lr(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),Zr.throwError(r,Ve.errors.NUMERIC_FAULT,i)}function wb(r){return new Gs(r,36).toString(16)}const Vt=new Ve(fh),Hn={},uh=ot.from(0),dh=ot.from(-1);function lh(r,e,t,i){const n={fault:e,operation:t};return i!==void 0&&(n.value=i),Vt.throwError(r,Ve.errors.NUMERIC_FAULT,n)}let Vn="0";for(;Vn.length<256;)Vn+=Vn;function bo(r){if(typeof r!="number")try{r=ot.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+Vn.substring(0,r):Vt.throwArgumentError("invalid decimal size","decimals",r)}function vo(r,e){e==null&&(e=0);const t=bo(e);r=ot.from(r);const i=r.lt(uh);i&&(r=r.mul(dh));let n=r.mod(t).toString();for(;n.length<t.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=r.div(t).toString();return t.length===1?r=s:r=s+"."+n,i&&(r="-"+r),r}function ei(r,e){e==null&&(e=0);const t=bo(e);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Vt.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Vt.throwArgumentError("missing value","value",r);const n=r.split(".");n.length>2&&Vt.throwArgumentError("too many decimal points","value",r);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>t.length-1&&lh("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<t.length-1;)o+="0";const f=ot.from(s),u=ot.from(o);let h=f.mul(t).add(u);return i&&(h=h.mul(dh)),h}class pn{constructor(e,t,i,n){e!==Hn&&Vt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=i,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=bo(n),Object.freeze(this)}static from(e){if(e instanceof pn)return e;typeof e=="number"&&(e=`fixed128x${e}`);let t=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")t=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||Vt.throwArgumentError("invalid fixed format","format",e),t=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,f,u)=>e[o]==null?u:(typeof e[o]!==f&&Vt.throwArgumentError("invalid fixed format ("+o+" not "+f+")","format."+o,e[o]),e[o]);t=s("signed","boolean",t),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Vt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Vt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new pn(Hn,t,i,n)}}class Nt{constructor(e,t,i,n){e!==Hn&&Vt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Vt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=ei(this._value,this.format.decimals),i=ei(e._value,e.format.decimals);return Nt.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=ei(this._value,this.format.decimals),i=ei(e._value,e.format.decimals);return Nt.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=ei(this._value,this.format.decimals),i=ei(e._value,e.format.decimals);return Nt.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=ei(this._value,this.format.decimals),i=ei(e._value,e.format.decimals);return Nt.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Nt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(ph.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Nt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(ph.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Vt.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=Nt.from("1"+Vn.substring(0,e),this.format),n=_b.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&&Vt.throwArgumentError("invalid byte width","width",e);const t=ot.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Fr(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Nt.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!yb(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),Nt.fromString(vo(e,t),pn.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=pn.from(t),n=ei(e,i.decimals);!i.signed&&n.lt(uh)&&lh("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Fr(s,i.width/8));const o=vo(n,i.decimals);return new Nt(Hn,s,o,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=pn.from(t);if(lt(e).length>i.width/8)throw new Error("overflow");let n=ot.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=vo(n,i.decimals);return new Nt(Hn,s,o,i)}static from(e,t){if(typeof e=="string")return Nt.fromString(e,t);if(ln(e))return Nt.fromBytes(e,t);try{return Nt.fromValue(e,0,t)}catch(i){if(i.code!==Ve.errors.INVALID_ARGUMENT)throw i}return Vt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const ph=Nt.from(1),_b=Nt.from("0.5"),xb="strings/5.7.0",gh=new Ve(xb);var Ws;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Ws||(Ws={}));var gn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(gn||(gn={}));function Ab(r,e,t,i,n){return gh.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function bh(r,e,t,i,n){if(r===gn.BAD_PREFIX||r===gn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)s++;return s}return r===gn.OVERRUN?t.length-e-1:0}function Eb(r,e,t,i,n){return r===gn.OVERLONG?(i.push(n),0):(i.push(65533),bh(r,e,t))}Object.freeze({error:Ab,ignore:bh,replace:Eb});function mo(r,e=Ws.current){e!=Ws.current&&(gh.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);if(n<128)t.push(n);else if(n<2048)t.push(n>>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;const s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return lt(t)}function Sb(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t<r.length;t+=4)e.push(parseInt(r.substring(t,t+4),16));return e}function yo(r,e){e||(e=function(n){return[parseInt(n,16)]});let t=0,i={};return r.split(",").forEach(n=>{let s=n.split(":");t+=parseInt(s[0],16),i[t]=e(s[1])}),i}function vh(r){let e=0;return r.split(",").map(t=>{let i=t.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}vh("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(r=>parseInt(r,16)),yo("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),yo("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),yo("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",Sb),vh("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const mh="hash/5.7.0";function Mb(r){r=atob(r);const e=[];for(let t=0;t<r.length;t++)e.push(r.charCodeAt(t));return lt(e)}function yh(r,e){e==null&&(e=1);const t=[],i=t.forEach,n=function(s,o){i.call(s,function(f){o>0&&Array.isArray(f)?n(f,o-1):t.push(f)})};return n(r,e),t}function Ib(r){const e={};for(let t=0;t<r.length;t++){const i=r[t];e[i[0]]=i[1]}return e}function Db(r){let e=0;function t(){return r[e++]<<8|r[e++]}let i=t(),n=1,s=[0,1];for(let U=1;U<i;U++)s.push(n+=t());let o=t(),f=e;e+=o;let u=0,h=0;function g(){return u==0&&(h=h<<8|r[e++],u=8),h>>--u&1}const m=31,I=Math.pow(2,m),M=I>>>1,D=M>>1,N=I-1;let k=0;for(let U=0;U<m;U++)k=k<<1|g();let K=[],B=0,j=I;for(;;){let U=Math.floor(((k-B+1)*n-1)/j),z=0,_=i;for(;_-z>1;){let Q=z+_>>>1;U<s[Q]?_=Q:z=Q}if(z==0)break;K.push(z);let P=B+Math.floor(j*s[z]/n),J=B+Math.floor(j*s[z+1]/n)-1;for(;!((P^J)&M);)k=k<<1&N|g(),P=P<<1&N,J=J<<1&N|1;for(;P&~J&D;)k=k&M|k<<1&N>>>1|g(),P=P<<1^M,J=(J^M)<<1|M|1;B=P,j=1+J-P}let F=i-4;return K.map(U=>{switch(U-F){case 3:return F+65792+(r[f++]<<16|r[f++]<<8|r[f++]);case 2:return F+256+(r[f++]<<8|r[f++]);case 1:return F+r[f++];default:return U-1}})}function Ob(r){let e=0;return()=>r[e++]}function Pb(r){return Ob(Db(r))}function Rb(r){return r&1?~r>>1:r>>1}function Nb(r,e){let t=Array(r);for(let i=0;i<r;i++)t[i]=1+e();return t}function wh(r,e){let t=Array(r);for(let i=0,n=-1;i<r;i++)t[i]=n+=1+e();return t}function Cb(r,e){let t=Array(r);for(let i=0,n=0;i<r;i++)t[i]=n+=Rb(e());return t}function Js(r,e){let t=wh(r(),r),i=r(),n=wh(i,r),s=Nb(i,r);for(let o=0;o<i;o++)for(let f=0;f<s[o];f++)t.push(n[o]+f);return e?t.map(o=>e[o]):t}function Tb(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(Bb(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(Lb(t,r))}return Ib(yh(e))}function Fb(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function _h(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)Cb(r,t).forEach((s,o)=>i[o].push(s));return i}function Bb(r,e){let t=1+e(),i=e(),n=Fb(e),s=_h(n.length,1+r,e);return yh(s.map((o,f)=>{const u=o[0],h=o.slice(1);return Array(n[f]).fill(void 0).map((g,m)=>{let I=m*i;return[u+m*t,h.map(M=>M+I)]})}))}function Lb(r,e){let t=1+e();return _h(t,1+r,e).map(n=>[n[0],n.slice(1)])}function qb(r){let e=Js(r).sort((i,n)=>i-n);return t();function t(){let i=[];for(;;){let h=Js(r,e);if(h.length==0)break;i.push({set:new Set(h),node:t()})}i.sort((h,g)=>g.set.size-h.set.size);let n=r(),s=n%3;n=n/3|0;let o=!!(n&1);n>>=1;let f=n==1,u=n==2;return{branches:i,valid:s,fe0f:o,save:f,check:u}}}function Ub(){return Pb(Mb("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const Ys=Ub();new Set(Js(Ys)),new Set(Js(Ys)),Tb(Ys),qb(Ys),new Ve(mh),new Uint8Array(32).fill(0);const $b=`Ethereum Signed Message:
|
22
|
-
`;function xh(r){return typeof r=="string"&&(r=mo(r)),po(bb([mo($b),mo(String(r.length)),r]))}const zb="rlp/5.7.0";new Ve(zb);const kb="address/5.7.0",Gn=new Ve(kb);function Ah(r){or(r,20)||Gn.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);const i=lt(po(t));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 Kb=9007199254740991;function jb(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const wo={};for(let r=0;r<10;r++)wo[String(r)]=String(r);for(let r=0;r<26;r++)wo[String.fromCharCode(65+r)]=String(10+r);const Eh=Math.floor(jb(Kb));function Hb(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>wo[i]).join("");for(;e.length>=Eh;){let i=e.substring(0,Eh);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Vb(r){let e=null;if(typeof r!="string"&&Gn.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=Ah(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&Gn.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Hb(r)&&Gn.throwArgumentError("bad icap checksum","address",r),e=wb(r.substring(4));e.length<40;)e="0"+e;e=Ah("0x"+e)}else Gn.throwArgumentError("invalid address","address",r);return e}const Gb="properties/5.7.0";new Ve(Gb);function Wn(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}new Ve(mh),new Uint8Array(32).fill(0),ot.from(-1);const Wb=ot.from(0),Jb=ot.from(1);ot.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Fr(Jb.toHexString(),32),Fr(Wb.toHexString(),32);var fr={},Ze={},$i=Sh;function Sh(r,e){if(!r)throw new Error(e||"Assertion failed")}Sh.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var bn={exports:{}};typeof Object.create=="function"?bn.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:bn.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}};var Yb=$i,Qb=bn.exports;Ze.inherits=Qb;function Xb(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Zb(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n<r.length;n+=2)t.push(parseInt(r[n]+r[n+1],16))}else for(var i=0,n=0;n<r.length;n++){var s=r.charCodeAt(n);s<128?t[i++]=s:s<2048?(t[i++]=s>>6|192,t[i++]=s&63|128):Xb(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n<r.length;n++)t[n]=r[n]|0;return t}Ze.toArray=Zb;function ev(r){for(var e="",t=0;t<r.length;t++)e+=Ih(r[t].toString(16));return e}Ze.toHex=ev;function Mh(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ze.htonl=Mh;function tv(r,e){for(var t="",i=0;i<r.length;i++){var n=r[i];e==="little"&&(n=Mh(n)),t+=Dh(n.toString(16))}return t}Ze.toHex32=tv;function Ih(r){return r.length===1?"0"+r:r}Ze.zero2=Ih;function Dh(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Ze.zero8=Dh;function rv(r,e,t,i){var n=t-e;Yb(n%4===0);for(var s=new Array(n/4),o=0,f=e;o<s.length;o++,f+=4){var u;i==="big"?u=r[f]<<24|r[f+1]<<16|r[f+2]<<8|r[f+3]:u=r[f+3]<<24|r[f+2]<<16|r[f+1]<<8|r[f],s[o]=u>>>0}return s}Ze.join32=rv;function iv(r,e){for(var t=new Array(r.length*4),i=0,n=0;i<r.length;i++,n+=4){var s=r[i];e==="big"?(t[n]=s>>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ze.split32=iv;function nv(r,e){return r>>>e|r<<32-e}Ze.rotr32=nv;function sv(r,e){return r<<e|r>>>32-e}Ze.rotl32=sv;function av(r,e){return r+e>>>0}Ze.sum32=av;function ov(r,e,t){return r+e+t>>>0}Ze.sum32_3=ov;function fv(r,e,t,i){return r+e+t+i>>>0}Ze.sum32_4=fv;function cv(r,e,t,i,n){return r+e+t+i+n>>>0}Ze.sum32_5=cv;function hv(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o<i?1:0)+t+n;r[e]=f>>>0,r[e+1]=o}Ze.sum64=hv;function uv(r,e,t,i){var n=e+i>>>0,s=(n<e?1:0)+r+t;return s>>>0}Ze.sum64_hi=uv;function dv(r,e,t,i){var n=e+i;return n>>>0}Ze.sum64_lo=dv;function lv(r,e,t,i,n,s,o,f){var u=0,h=e;h=h+i>>>0,u+=h<e?1:0,h=h+s>>>0,u+=h<s?1:0,h=h+f>>>0,u+=h<f?1:0;var g=r+t+n+o+u;return g>>>0}Ze.sum64_4_hi=lv;function pv(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ze.sum64_4_lo=pv;function gv(r,e,t,i,n,s,o,f,u,h){var g=0,m=e;m=m+i>>>0,g+=m<e?1:0,m=m+s>>>0,g+=m<s?1:0,m=m+f>>>0,g+=m<f?1:0,m=m+h>>>0,g+=m<h?1:0;var I=r+t+n+o+u+g;return I>>>0}Ze.sum64_5_hi=gv;function bv(r,e,t,i,n,s,o,f,u,h){var g=e+i+s+f+h;return g>>>0}Ze.sum64_5_lo=bv;function vv(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ze.rotr64_hi=vv;function mv(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ze.rotr64_lo=mv;function yv(r,e,t){return r>>>t}Ze.shr64_hi=yv;function wv(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ze.shr64_lo=wv;var vn={},Oh=Ze,_v=$i;function Qs(){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}vn.BlockHash=Qs,Qs.prototype.update=function(e,t){if(e=Oh.toArray(e,t),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=Oh.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},Qs.prototype.digest=function(e){return this.update(this._pad()),_v(this.pending===null),this._digest(e)},Qs.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,i=t-(e+this.padLength)%t,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 mn={},Br={},xv=Ze,Lr=xv.rotr32;function Av(r,e,t,i){if(r===0)return Ph(e,t,i);if(r===1||r===3)return Nh(e,t,i);if(r===2)return Rh(e,t,i)}Br.ft_1=Av;function Ph(r,e,t){return r&e^~r&t}Br.ch32=Ph;function Rh(r,e,t){return r&e^r&t^e&t}Br.maj32=Rh;function Nh(r,e,t){return r^e^t}Br.p32=Nh;function Ev(r){return Lr(r,2)^Lr(r,13)^Lr(r,22)}Br.s0_256=Ev;function Sv(r){return Lr(r,6)^Lr(r,11)^Lr(r,25)}Br.s1_256=Sv;function Mv(r){return Lr(r,7)^Lr(r,18)^r>>>3}Br.g0_256=Mv;function Iv(r){return Lr(r,17)^Lr(r,19)^r>>>10}Br.g1_256=Iv;var yn=Ze,Dv=vn,Ov=Br,_o=yn.rotl32,Jn=yn.sum32,Pv=yn.sum32_5,Rv=Ov.ft_1,Ch=Dv.BlockHash,Nv=[1518500249,1859775393,2400959708,3395469782];function qr(){if(!(this instanceof qr))return new qr;Ch.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}yn.inherits(qr,Ch);var Cv=qr;qr.blockSize=512,qr.outSize=160,qr.hmacStrength=80,qr.padLength=64,qr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=_o(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],f=this.h[2],u=this.h[3],h=this.h[4];for(n=0;n<i.length;n++){var g=~~(n/20),m=Pv(_o(s,5),Rv(g,o,f,u),h,i[n],Nv[g]);h=u,u=f,f=_o(o,30),o=s,s=m}this.h[0]=Jn(this.h[0],s),this.h[1]=Jn(this.h[1],o),this.h[2]=Jn(this.h[2],f),this.h[3]=Jn(this.h[3],u),this.h[4]=Jn(this.h[4],h)},qr.prototype._digest=function(e){return e==="hex"?yn.toHex32(this.h,"big"):yn.split32(this.h,"big")};var wn=Ze,Tv=vn,_n=Br,Fv=$i,Ir=wn.sum32,Bv=wn.sum32_4,Lv=wn.sum32_5,qv=_n.ch32,Uv=_n.maj32,$v=_n.s0_256,zv=_n.s1_256,kv=_n.g0_256,Kv=_n.g1_256,Th=Tv.BlockHash,jv=[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 Ur(){if(!(this instanceof Ur))return new Ur;Th.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=jv,this.W=new Array(64)}wn.inherits(Ur,Th);var Fh=Ur;Ur.blockSize=512,Ur.outSize=256,Ur.hmacStrength=192,Ur.padLength=64,Ur.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=Bv(Kv(i[n-2]),i[n-7],kv(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],f=this.h[2],u=this.h[3],h=this.h[4],g=this.h[5],m=this.h[6],I=this.h[7];for(Fv(this.k.length===i.length),n=0;n<i.length;n++){var M=Lv(I,zv(h),qv(h,g,m),this.k[n],i[n]),D=Ir($v(s),Uv(s,o,f));I=m,m=g,g=h,h=Ir(u,M),u=f,f=o,o=s,s=Ir(M,D)}this.h[0]=Ir(this.h[0],s),this.h[1]=Ir(this.h[1],o),this.h[2]=Ir(this.h[2],f),this.h[3]=Ir(this.h[3],u),this.h[4]=Ir(this.h[4],h),this.h[5]=Ir(this.h[5],g),this.h[6]=Ir(this.h[6],m),this.h[7]=Ir(this.h[7],I)},Ur.prototype._digest=function(e){return e==="hex"?wn.toHex32(this.h,"big"):wn.split32(this.h,"big")};var xo=Ze,Bh=Fh;function ti(){if(!(this instanceof ti))return new ti;Bh.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}xo.inherits(ti,Bh);var Hv=ti;ti.blockSize=512,ti.outSize=224,ti.hmacStrength=192,ti.padLength=64,ti.prototype._digest=function(e){return e==="hex"?xo.toHex32(this.h.slice(0,7),"big"):xo.split32(this.h.slice(0,7),"big")};var Zt=Ze,Vv=vn,Gv=$i,$r=Zt.rotr64_hi,zr=Zt.rotr64_lo,Lh=Zt.shr64_hi,qh=Zt.shr64_lo,xi=Zt.sum64,Ao=Zt.sum64_hi,Eo=Zt.sum64_lo,Wv=Zt.sum64_4_hi,Jv=Zt.sum64_4_lo,Yv=Zt.sum64_5_hi,Qv=Zt.sum64_5_lo,Uh=Vv.BlockHash,Xv=[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 Dr(){if(!(this instanceof Dr))return new Dr;Uh.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Xv,this.W=new Array(160)}Zt.inherits(Dr,Uh);var $h=Dr;Dr.blockSize=1024,Dr.outSize=512,Dr.hmacStrength=192,Dr.padLength=128,Dr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n<i.length;n+=2){var s=c2(i[n-4],i[n-3]),o=h2(i[n-4],i[n-3]),f=i[n-14],u=i[n-13],h=o2(i[n-30],i[n-29]),g=f2(i[n-30],i[n-29]),m=i[n-32],I=i[n-31];i[n]=Wv(s,o,f,u,h,g,m,I),i[n+1]=Jv(s,o,f,u,h,g,m,I)}},Dr.prototype._update=function(e,t){this._prepareBlock(e,t);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],f=this.h[3],u=this.h[4],h=this.h[5],g=this.h[6],m=this.h[7],I=this.h[8],M=this.h[9],D=this.h[10],N=this.h[11],k=this.h[12],K=this.h[13],B=this.h[14],j=this.h[15];Gv(this.k.length===i.length);for(var F=0;F<i.length;F+=2){var U=B,z=j,_=s2(I,M),P=a2(I,M),J=Zv(I,M,D,N,k),Q=e2(I,M,D,N,k,K),R=this.k[F],p=this.k[F+1],l=i[F],a=i[F+1],c=Yv(U,z,_,P,J,Q,R,p,l,a),b=Qv(U,z,_,P,J,Q,R,p,l,a);U=i2(n,s),z=n2(n,s),_=t2(n,s,o,f,u),P=r2(n,s,o,f,u,h);var A=Ao(U,z,_,P),E=Eo(U,z,_,P);B=k,j=K,k=D,K=N,D=I,N=M,I=Ao(g,m,c,b),M=Eo(m,m,c,b),g=u,m=h,u=o,h=f,o=n,f=s,n=Ao(c,b,A,E),s=Eo(c,b,A,E)}xi(this.h,0,n,s),xi(this.h,2,o,f),xi(this.h,4,u,h),xi(this.h,6,g,m),xi(this.h,8,I,M),xi(this.h,10,D,N),xi(this.h,12,k,K),xi(this.h,14,B,j)},Dr.prototype._digest=function(e){return e==="hex"?Zt.toHex32(this.h,"big"):Zt.split32(this.h,"big")};function Zv(r,e,t,i,n){var s=r&t^~r&n;return s<0&&(s+=4294967296),s}function e2(r,e,t,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function t2(r,e,t,i,n){var s=r&t^r&n^t&n;return s<0&&(s+=4294967296),s}function r2(r,e,t,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function i2(r,e){var t=$r(r,e,28),i=$r(e,r,2),n=$r(e,r,7),s=t^i^n;return s<0&&(s+=4294967296),s}function n2(r,e){var t=zr(r,e,28),i=zr(e,r,2),n=zr(e,r,7),s=t^i^n;return s<0&&(s+=4294967296),s}function s2(r,e){var t=$r(r,e,14),i=$r(r,e,18),n=$r(e,r,9),s=t^i^n;return s<0&&(s+=4294967296),s}function a2(r,e){var t=zr(r,e,14),i=zr(r,e,18),n=zr(e,r,9),s=t^i^n;return s<0&&(s+=4294967296),s}function o2(r,e){var t=$r(r,e,1),i=$r(r,e,8),n=Lh(r,e,7),s=t^i^n;return s<0&&(s+=4294967296),s}function f2(r,e){var t=zr(r,e,1),i=zr(r,e,8),n=qh(r,e,7),s=t^i^n;return s<0&&(s+=4294967296),s}function c2(r,e){var t=$r(r,e,19),i=$r(e,r,29),n=Lh(r,e,6),s=t^i^n;return s<0&&(s+=4294967296),s}function h2(r,e){var t=zr(r,e,19),i=zr(e,r,29),n=qh(r,e,6),s=t^i^n;return s<0&&(s+=4294967296),s}var So=Ze,zh=$h;function ri(){if(!(this instanceof ri))return new ri;zh.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}So.inherits(ri,zh);var u2=ri;ri.blockSize=1024,ri.outSize=384,ri.hmacStrength=192,ri.padLength=128,ri.prototype._digest=function(e){return e==="hex"?So.toHex32(this.h.slice(0,12),"big"):So.split32(this.h.slice(0,12),"big")},mn.sha1=Cv,mn.sha224=Hv,mn.sha256=Fh,mn.sha384=u2,mn.sha512=$h;var kh={},zi=Ze,d2=vn,Xs=zi.rotl32,Kh=zi.sum32,Yn=zi.sum32_3,jh=zi.sum32_4,Hh=d2.BlockHash;function kr(){if(!(this instanceof kr))return new kr;Hh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}zi.inherits(kr,Hh),kh.ripemd160=kr,kr.blockSize=512,kr.outSize=160,kr.hmacStrength=192,kr.padLength=64,kr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,h=n,g=s,m=o,I=f,M=0;M<80;M++){var D=Kh(Xs(jh(i,Vh(M,n,s,o),e[g2[M]+t],l2(M)),v2[M]),f);i=f,f=o,o=Xs(s,10),s=n,n=D,D=Kh(Xs(jh(u,Vh(79-M,h,g,m),e[b2[M]+t],p2(M)),m2[M]),I),u=I,I=m,m=Xs(g,10),g=h,h=D}D=Yn(this.h[1],s,m),this.h[1]=Yn(this.h[2],o,I),this.h[2]=Yn(this.h[3],f,u),this.h[3]=Yn(this.h[4],i,h),this.h[4]=Yn(this.h[0],n,g),this.h[0]=D},kr.prototype._digest=function(e){return e==="hex"?zi.toHex32(this.h,"little"):zi.split32(this.h,"little")};function Vh(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function l2(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function p2(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var g2=[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],b2=[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],m2=[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],y2=Ze,w2=$i;function xn(r,e,t){if(!(this instanceof xn))return new xn(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(y2.toArray(e,t))}var _2=xn;xn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),w2(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=new this.Hash().update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=new this.Hash().update(e)},xn.prototype.update=function(e,t){return this.inner.update(e,t),this},xn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(r){var e=r;e.utils=Ze,e.common=vn,e.sha=mn,e.ripemd=kh,e.hmac=_2,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}(fr);function An(r,e,t){return t={path:e,exports:{},require:function(i,n){return x2(i,n??t.path)}},r(t,t.exports),t.exports}function x2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Mo=Gh;function Gh(r,e){if(!r)throw new Error(e||"Assertion failed")}Gh.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Or=An(function(r,e){var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var u=[];if(typeof o!="string"){for(var h=0;h<o.length;h++)u[h]=o[h]|0;return u}if(f==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var h=0;h<o.length;h+=2)u.push(parseInt(o[h]+o[h+1],16))}else for(var h=0;h<o.length;h++){var g=o.charCodeAt(h),m=g>>8,I=g&255;m?u.push(m,I):u.push(I)}return u}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",u=0;u<o.length;u++)f+=n(o[u].toString(16));return f}t.toHex=s,t.encode=function(f,u){return u==="hex"?s(f):f}}),cr=An(function(r,e){var t=e;t.assert=Mo,t.toArray=Or.toArray,t.zero2=Or.zero2,t.toHex=Or.toHex,t.encode=Or.encode;function i(u,h,g){var m=new Array(Math.max(u.bitLength(),g)+1);m.fill(0);for(var I=1<<h+1,M=u.clone(),D=0;D<m.length;D++){var N,k=M.andln(I-1);M.isOdd()?(k>(I>>1)-1?N=(I>>1)-k:N=k,M.isubn(N)):N=0,m[D]=N,M.iushrn(1)}return m}t.getNAF=i;function n(u,h){var g=[[],[]];u=u.clone(),h=h.clone();for(var m=0,I=0,M;u.cmpn(-m)>0||h.cmpn(-I)>0;){var D=u.andln(3)+m&3,N=h.andln(3)+I&3;D===3&&(D=-1),N===3&&(N=-1);var k;D&1?(M=u.andln(7)+m&7,(M===3||M===5)&&N===2?k=-D:k=D):k=0,g[0].push(k);var K;N&1?(M=h.andln(7)+I&7,(M===3||M===5)&&D===2?K=-N:K=N):K=0,g[1].push(K),2*m===k+1&&(m=1-m),2*I===K+1&&(I=1-I),u.iushrn(1),h.iushrn(1)}return g}t.getJSF=n;function s(u,h,g){var m="_"+h;u.prototype[h]=function(){return this[m]!==void 0?this[m]:this[m]=g.call(this)}}t.cachedProperty=s;function o(u){return typeof u=="string"?t.toArray(u,"hex"):u}t.parseBytes=o;function f(u){return new je(u,"hex","le")}t.intFromLE=f}),Zs=cr.getNAF,A2=cr.getJSF,ea=cr.assert;function Ai(r,e){this.type=r,this.p=new je(e.p,16),this.red=e.prime?je.red(e.prime):je.mont(this.p),this.zero=new je(0).toRed(this.red),this.one=new je(1).toRed(this.red),this.two=new je(2).toRed(this.red),this.n=e.n&&new je(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var ki=Ai;Ai.prototype.point=function(){throw new Error("Not implemented")},Ai.prototype.validate=function(){throw new Error("Not implemented")},Ai.prototype._fixedNafMul=function(e,t){ea(e.precomputed);var i=e._getDoubles(),n=Zs(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],f,u;for(f=0;f<n.length;f+=i.step){u=0;for(var h=f+i.step-1;h>=f;h--)u=(u<<1)+n[h];o.push(u)}for(var g=this.jpoint(null,null,null),m=this.jpoint(null,null,null),I=s;I>0;I--){for(f=0;f<o.length;f++)u=o[f],u===I?m=m.mixedAdd(i.points[f]):u===-I&&(m=m.mixedAdd(i.points[f].neg()));g=g.add(m)}return g.toP()},Ai.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Zs(t,i,this._bitLength),f=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var h=0;u>=0&&o[u]===0;u--)h++;if(u>=0&&h++,f=f.dblp(h),u<0)break;var g=o[u];ea(g!==0),e.type==="affine"?g>0?f=f.mixedAdd(s[g-1>>1]):f=f.mixedAdd(s[-g-1>>1].neg()):g>0?f=f.add(s[g-1>>1]):f=f.add(s[-g-1>>1].neg())}return e.type==="affine"?f.toP():f},Ai.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,h=0,g,m,I;for(g=0;g<n;g++){I=t[g];var M=I._getNAFPoints(e);o[g]=M.wnd,f[g]=M.points}for(g=n-1;g>=1;g-=2){var D=g-1,N=g;if(o[D]!==1||o[N]!==1){u[D]=Zs(i[D],o[D],this._bitLength),u[N]=Zs(i[N],o[N],this._bitLength),h=Math.max(u[D].length,h),h=Math.max(u[N].length,h);continue}var k=[t[D],null,null,t[N]];t[D].y.cmp(t[N].y)===0?(k[1]=t[D].add(t[N]),k[2]=t[D].toJ().mixedAdd(t[N].neg())):t[D].y.cmp(t[N].y.redNeg())===0?(k[1]=t[D].toJ().mixedAdd(t[N]),k[2]=t[D].add(t[N].neg())):(k[1]=t[D].toJ().mixedAdd(t[N]),k[2]=t[D].toJ().mixedAdd(t[N].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],B=A2(i[D],i[N]);for(h=Math.max(B[0].length,h),u[D]=new Array(h),u[N]=new Array(h),m=0;m<h;m++){var j=B[0][m]|0,F=B[1][m]|0;u[D][m]=K[(j+1)*3+(F+1)],u[N][m]=0,f[D]=k}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(g=h;g>=0;g--){for(var _=0;g>=0;){var P=!0;for(m=0;m<n;m++)z[m]=u[m][g]|0,z[m]!==0&&(P=!1);if(!P)break;_++,g--}if(g>=0&&_++,U=U.dblp(_),g<0)break;for(m=0;m<n;m++){var J=z[m];J!==0&&(J>0?I=f[m][J-1>>1]:J<0&&(I=f[m][-J-1>>1].neg()),I.type==="affine"?U=U.mixedAdd(I):U=U.add(I))}}for(g=0;g<n;g++)f[g]=null;return s?U:U.toP()};function pr(r,e){this.curve=r,this.type=e,this.precomputed=null}Ai.BasePoint=pr,pr.prototype.eq=function(){throw new Error("Not implemented")},pr.prototype.validate=function(){return this.curve.validate(this)},Ai.prototype.decodePoint=function(e,t){e=cr.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?ea(e[e.length-1]%2===0):e[0]===7&&ea(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")},pr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},pr.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},pr.prototype.encode=function(e,t){return cr.encode(this._encode(t),e)},pr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},pr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},pr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},pr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}},pr.prototype._getBeta=function(){return null},pr.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var Io=An(function(r){typeof Object.create=="function"?r.exports=function(t,i){i&&(t.super_=i,t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,i){if(i){t.super_=i;var n=function(){};n.prototype=i.prototype,t.prototype=new n,t.prototype.constructor=t}}}),E2=cr.assert;function gr(r){ki.call(this,"short",r),this.a=new je(r.a,16).toRed(this.red),this.b=new je(r.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(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Io(gr,ki);var S2=gr;gr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new je(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new je(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],E2(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new je(f.a,16),b:new je(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}},gr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:je.mont(e),i=new je(2).toRed(t).redInvm(),n=i.redNeg(),s=new je(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]},gr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new je(1),o=new je(0),f=new je(0),u=new je(1),h,g,m,I,M,D,N,k=0,K,B;i.cmpn(0)!==0;){var j=n.div(i);K=n.sub(j.mul(i)),B=f.sub(j.mul(s));var F=u.sub(j.mul(o));if(!m&&K.cmp(t)<0)h=N.neg(),g=s,m=K.neg(),I=B;else if(m&&++k===2)break;N=K,n=i,i=K,f=s,s=B,u=o,o=F}M=K.neg(),D=B;var U=m.sqr().add(I.sqr()),z=M.sqr().add(D.sqr());return z.cmp(U)>=0&&(M=h,D=g),m.negative&&(m=m.neg(),I=I.neg()),M.negative&&(M=M.neg(),D=D.neg()),[{a:m,b:I},{a:M,b:D}]},gr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),h=s.mul(i.b),g=o.mul(n.b),m=e.sub(f).sub(u),I=h.add(g).neg();return{k1:m,k2:I}},gr.prototype.pointFromX=function(e,t){e=new je(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(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},gr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},gr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var f=this._endoSplit(t[o]),u=e[o],h=u._getBeta();f.k1.negative&&(f.k1.ineg(),u=u.neg(!0)),f.k2.negative&&(f.k2.ineg(),h=h.neg(!0)),n[o*2]=u,n[o*2+1]=h,s[o*2]=f.k1,s[o*2+1]=f.k2}for(var g=this._wnafMulAdd(1,n,s,o*2,i),m=0;m<o*2;m++)n[m]=null,s[m]=null;return g};function Et(r,e,t,i){ki.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new je(e,16),this.y=new je(t,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)}Io(Et,ki.BasePoint),gr.prototype.point=function(e,t,i){return new Et(this,e,t,i)},gr.prototype.pointFromJSON=function(e,t){return Et.fromJSON(this,e,t)},Et.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=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=t,t.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 t}},Et.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]},Et.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(f){return e.point(f[0],f[1],i)}var o=t[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},Et.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)+">"},Et.prototype.isInfinity=function(){return this.inf},Et.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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Et.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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)},Et.prototype.getX=function(){return this.x.fromRed()},Et.prototype.getY=function(){return this.y.fromRed()},Et.prototype.mul=function(e){return e=new je(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)},Et.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Et.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Et.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)},Et.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.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 t},Et.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 Ct(r,e,t,i){ki.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new je(0)):(this.x=new je(e,16),this.y=new je(t,16),this.z=new je(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}Io(Ct,ki.BasePoint),gr.prototype.jpoint=function(e,t,i){return new Ct(this,e,t,i)},Ct.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)},Ct.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ct.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),h=o.redSub(f);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),m=g.redMul(u),I=n.redMul(g),M=h.redSqr().redIAdd(m).redISub(I).redISub(I),D=h.redMul(I.redISub(M)).redISub(o.redMul(m)),N=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(M,D,N)},Ct.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),g=h.redMul(f),m=i.redMul(h),I=u.redSqr().redIAdd(g).redISub(m).redISub(m),M=u.redMul(m.redISub(I)).redISub(s.redMul(g)),D=this.z.redMul(f);return this.curve.jpoint(I,M,D)},Ct.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,f=this.y,u=this.z,h=u.redSqr().redSqr(),g=f.redAdd(f);for(t=0;t<e;t++){var m=o.redSqr(),I=g.redSqr(),M=I.redSqr(),D=m.redAdd(m).redIAdd(m).redIAdd(n.redMul(h)),N=o.redMul(I),k=D.redSqr().redISub(N.redAdd(N)),K=N.redISub(k),B=D.redMul(K);B=B.redIAdd(B).redISub(M);var j=g.redMul(u);t+1<e&&(h=h.redMul(M)),o=k,u=j,g=B}return this.curve.jpoint(o,g.redMul(s),u)},Ct.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Ct.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n),h=u.redSqr().redISub(f).redISub(f),g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),e=h,t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),I=this.y.redSqr(),M=I.redSqr(),D=this.x.redAdd(I).redSqr().redISub(m).redISub(M);D=D.redIAdd(D);var N=m.redAdd(m).redIAdd(m),k=N.redSqr(),K=M.redIAdd(M);K=K.redIAdd(K),K=K.redIAdd(K),e=k.redISub(D).redISub(D),t=N.redMul(D.redISub(e)).redISub(K),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)},Ct.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=u.redSqr().redISub(f).redISub(f);e=h;var g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),I=this.y.redSqr(),M=this.x.redMul(I),D=this.x.redSub(m).redMul(this.x.redAdd(m));D=D.redAdd(D).redIAdd(D);var N=M.redIAdd(M);N=N.redIAdd(N);var k=N.redAdd(N);e=D.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(I).redISub(m);var K=I.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),t=D.redMul(N.redISub(e)).redISub(K)}return this.curve.jpoint(e,t,i)},Ct.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),f=i.redSqr(),u=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=t.redAdd(t);h=h.redIAdd(h);var g=h.redMul(f),m=u.redSqr().redISub(g.redAdd(g)),I=g.redISub(m),M=f.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=u.redMul(I).redISub(M),N=i.redAdd(i).redMul(n);return this.curve.jpoint(m,D,N)},Ct.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(o);var u=f.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var g=s.redIAdd(f).redSqr().redISub(o).redISub(u).redISub(h),m=t.redMul(g);m=m.redIAdd(m),m=m.redIAdd(m);var I=this.x.redMul(u).redISub(m);I=I.redIAdd(I),I=I.redIAdd(I);var M=this.y.redMul(g.redMul(h.redISub(g)).redISub(f.redMul(u)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=this.z.redAdd(f).redSqr().redISub(i).redISub(u);return this.curve.jpoint(I,M,D)},Ct.prototype.mul=function(e,t){return e=new je(e,t),this.curve._wnafMul(this,e)},Ct.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Ct.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){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}},Ct.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)+">"},Ct.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ta=An(function(r,e){var t=e;t.base=ki,t.short=S2,t.mont=null,t.edwards=null}),ra=An(function(r,e){var t=e,i=cr.assert;function n(f){f.type==="short"?this.curve=new ta.short(f):f.type==="edwards"?this.curve=new ta.edwards(f):this.curve=new ta.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,u){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var h=new n(u);return Object.defineProperty(t,f,{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:fr.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:fr.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:fr.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:fr.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:fr.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:fr.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:fr.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:fr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ei(r){if(!(this instanceof Ei))return new Ei(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Or.toArray(r.entropy,r.entropyEnc||"hex"),t=Or.toArray(r.nonce,r.nonceEnc||"hex"),i=Or.toArray(r.pers,r.persEnc||"hex");Mo(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var Wh=Ei;Ei.prototype._init=function(e,t,i){var n=e.concat(t).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},Ei.prototype._hmac=function(){return new fr.hmac(this.hash,this.K)},Ei.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.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())},Ei.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Or.toArray(e,t),i=Or.toArray(i,n),Mo(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Ei.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Or.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++,Or.encode(o,t)};var Do=cr.assert;function Ut(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Oo=Ut;Ut.fromPublic=function(e,t,i){return t instanceof Ut?t:new Ut(e,{pub:t,pubEnc:i})},Ut.fromPrivate=function(e,t,i){return t instanceof Ut?t:new Ut(e,{priv:t,privEnc:i})},Ut.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"}},Ut.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},Ut.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Ut.prototype._importPrivate=function(e,t){this.priv=new je(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},Ut.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Do(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Do(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,t)},Ut.prototype.derive=function(e){return e.validate()||Do(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Ut.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},Ut.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},Ut.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var M2=cr.assert;function ia(r,e){if(r instanceof ia)return r;this._importDER(r,e)||(M2(r.r&&r.s,"Signature without r or s"),this.r=new je(r.r,16),this.s=new je(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var na=ia;function I2(){this.place=0}function Po(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Jh(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}ia.prototype._importDER=function(e,t){e=cr.toArray(e,t);var i=new I2;if(e[i.place++]!==48)return!1;var n=Po(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Po(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 f=Po(e,i);if(f===!1||e.length!==f+i.place)return!1;var u=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;return this.r=new je(o),this.s=new je(u),this.recoveryParam=null,!0};function Ro(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}ia.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Jh(t),i=Jh(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Ro(n,t.length),n=n.concat(t),n.push(2),Ro(n,i.length);var s=n.concat(i),o=[48];return Ro(o,s.length),o=o.concat(s),cr.encode(o,e)};var D2=function(){throw new Error("unsupported")},Yh=cr.assert;function br(r){if(!(this instanceof br))return new br(r);typeof r=="string"&&(Yh(Object.prototype.hasOwnProperty.call(ra,r),"Unknown curve "+r),r=ra[r]),r instanceof ra.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var O2=br;br.prototype.keyPair=function(e){return new Oo(this,e)},br.prototype.keyFromPrivate=function(e,t){return Oo.fromPrivate(this,e,t)},br.prototype.keyFromPublic=function(e,t){return Oo.fromPublic(this,e,t)},br.prototype.genKeyPair=function(e){e||(e={});for(var t=new Wh({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||D2(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new je(2));;){var s=new je(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},br.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},br.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new je(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new Wh({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new je(1)),g=0;;g++){var m=n.k?n.k(g):new je(u.generate(this.n.byteLength()));if(m=this._truncateToN(m,!0),!(m.cmpn(1)<=0||m.cmp(h)>=0)){var I=this.g.mul(m);if(!I.isInfinity()){var M=I.getX(),D=M.umod(this.n);if(D.cmpn(0)!==0){var N=m.invm(this.n).mul(D.mul(t.getPrivate()).iadd(e));if(N=N.umod(this.n),N.cmpn(0)!==0){var k=(I.getY().isOdd()?1:0)|(M.cmp(D)!==0?2:0);return n.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),k^=1),new na({r:D,s:N,recoveryParam:k})}}}}}},br.prototype.verify=function(e,t,i,n){e=this._truncateToN(new je(e,16)),i=this.keyFromPublic(i,n),t=new na(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),u=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(u,i.getPublic(),h),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(u,i.getPublic(),h),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)},br.prototype.recoverPubKey=function(r,e,t,i){Yh((3&t)===t,"The recovery param is more than two bits"),e=new na(e,i);var n=this.n,s=new je(r),o=e.r,f=e.s,u=t&1,h=t>>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),u):o=this.curve.pointFromX(o,u);var g=e.r.invm(n),m=n.sub(s).mul(g).umod(n),I=f.mul(g).umod(n);return this.g.mulAdd(m,o,I)},br.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new na(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var P2=An(function(r,e){var t=e;t.version="6.5.4",t.utils=cr,t.rand=function(){throw new Error("unsupported")},t.curve=ta,t.curves=ra,t.ec=O2,t.eddsa=null}),R2=P2.ec;const N2="signing-key/5.7.0",No=new Ve(N2);let Co=null;function Kr(){return Co||(Co=new R2("secp256k1")),Co}class C2{constructor(e){Wn(this,"curve","secp256k1"),Wn(this,"privateKey",Ht(e)),mb(this.privateKey)!==32&&No.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Kr().keyFromPrivate(lt(this.privateKey));Wn(this,"publicKey","0x"+t.getPublic(!1,"hex")),Wn(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Wn(this,"_isSigningKey",!0)}_addPoint(e){const t=Kr().keyFromPublic(lt(this.publicKey)),i=Kr().keyFromPublic(lt(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Kr().keyFromPrivate(lt(this.privateKey)),i=lt(e);i.length!==32&&No.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return ah({recoveryParam:n.recoveryParam,r:Fr("0x"+n.r.toString(16),32),s:Fr("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Kr().keyFromPrivate(lt(this.privateKey)),i=Kr().keyFromPublic(lt(Qh(e)));return Fr("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function T2(r,e){const t=ah(e),i={r:lt(t.r),s:lt(t.s)};return"0x"+Kr().recoverPubKey(lt(r),i,t.recoveryParam).encode("hex",!1)}function Qh(r,e){const t=lt(r);if(t.length===32){const i=new C2(t);return e?"0x"+Kr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Ht(t):"0x"+Kr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Kr().keyFromPublic(t).getPublic(!0,"hex"):Ht(t)}return No.throwArgumentError("invalid public or private key","key","[REDACTED]")}const F2="transactions/5.7.0";new Ve(F2);var Xh;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(Xh||(Xh={}));function B2(r){const e=Qh(r);return Vb(sh(po(sh(e,1)),12))}function L2(r,e){return B2(T2(lt(r),e))}var To={},sa={};Object.defineProperty(sa,"__esModule",{value:!0});var $t=He,Fo=ar,q2=20;function U2(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],m=t[19]<<24|t[18]<<16|t[17]<<8|t[16],I=t[23]<<24|t[22]<<16|t[21]<<8|t[20],M=t[27]<<24|t[26]<<16|t[25]<<8|t[24],D=t[31]<<24|t[30]<<16|t[29]<<8|t[28],N=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],K=e[11]<<24|e[10]<<16|e[9]<<8|e[8],B=e[15]<<24|e[14]<<16|e[13]<<8|e[12],j=i,F=n,U=s,z=o,_=f,P=u,J=h,Q=g,R=m,p=I,l=M,a=D,c=N,b=k,A=K,E=B,x=0;x<q2;x+=2)j=j+_|0,c^=j,c=c>>>32-16|c<<16,R=R+c|0,_^=R,_=_>>>32-12|_<<12,F=F+P|0,b^=F,b=b>>>32-16|b<<16,p=p+b|0,P^=p,P=P>>>32-12|P<<12,U=U+J|0,A^=U,A=A>>>32-16|A<<16,l=l+A|0,J^=l,J=J>>>32-12|J<<12,z=z+Q|0,E^=z,E=E>>>32-16|E<<16,a=a+E|0,Q^=a,Q=Q>>>32-12|Q<<12,U=U+J|0,A^=U,A=A>>>32-8|A<<8,l=l+A|0,J^=l,J=J>>>32-7|J<<7,z=z+Q|0,E^=z,E=E>>>32-8|E<<8,a=a+E|0,Q^=a,Q=Q>>>32-7|Q<<7,F=F+P|0,b^=F,b=b>>>32-8|b<<8,p=p+b|0,P^=p,P=P>>>32-7|P<<7,j=j+_|0,c^=j,c=c>>>32-8|c<<8,R=R+c|0,_^=R,_=_>>>32-7|_<<7,j=j+P|0,E^=j,E=E>>>32-16|E<<16,l=l+E|0,P^=l,P=P>>>32-12|P<<12,F=F+J|0,c^=F,c=c>>>32-16|c<<16,a=a+c|0,J^=a,J=J>>>32-12|J<<12,U=U+Q|0,b^=U,b=b>>>32-16|b<<16,R=R+b|0,Q^=R,Q=Q>>>32-12|Q<<12,z=z+_|0,A^=z,A=A>>>32-16|A<<16,p=p+A|0,_^=p,_=_>>>32-12|_<<12,U=U+Q|0,b^=U,b=b>>>32-8|b<<8,R=R+b|0,Q^=R,Q=Q>>>32-7|Q<<7,z=z+_|0,A^=z,A=A>>>32-8|A<<8,p=p+A|0,_^=p,_=_>>>32-7|_<<7,F=F+J|0,c^=F,c=c>>>32-8|c<<8,a=a+c|0,J^=a,J=J>>>32-7|J<<7,j=j+P|0,E^=j,E=E>>>32-8|E<<8,l=l+E|0,P^=l,P=P>>>32-7|P<<7;$t.writeUint32LE(j+i|0,r,0),$t.writeUint32LE(F+n|0,r,4),$t.writeUint32LE(U+s|0,r,8),$t.writeUint32LE(z+o|0,r,12),$t.writeUint32LE(_+f|0,r,16),$t.writeUint32LE(P+u|0,r,20),$t.writeUint32LE(J+h|0,r,24),$t.writeUint32LE(Q+g|0,r,28),$t.writeUint32LE(R+m|0,r,32),$t.writeUint32LE(p+I|0,r,36),$t.writeUint32LE(l+M|0,r,40),$t.writeUint32LE(a+D|0,r,44),$t.writeUint32LE(c+N|0,r,48),$t.writeUint32LE(b+k|0,r,52),$t.writeUint32LE(A+K|0,r,56),$t.writeUint32LE(E+B|0,r,60)}function Zh(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<t.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=n}for(var f=new Uint8Array(64),u=0;u<t.length;u+=64){U2(f,s,r);for(var h=u;h<u+64&&h<t.length;h++)i[h]=t[h]^f[h-u];z2(s,0,o)}return Fo.wipe(f),n===0&&Fo.wipe(s),i}sa.streamXOR=Zh;function $2(r,e,t,i){return i===void 0&&(i=0),Fo.wipe(t),Zh(r,e,t,t,i)}sa.stream=$2;function z2(r,e,t){for(var i=1;t--;)i=i+(r[e]&255)|0,r[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var eu={},Si={};Object.defineProperty(Si,"__esModule",{value:!0});function k2(r,e,t){return~(r-1)&e|r-1&t}Si.select=k2;function K2(r,e){return(r|0)-(e|0)-1>>>31&1}Si.lessOrEqual=K2;function tu(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i<r.length;i++)t|=r[i]^e[i];return 1&t-1>>>8}Si.compare=tu;function j2(r,e){return r.length===0||e.length===0?!1:tu(r,e)!==0}Si.equal=j2,function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Si,t=ar;r.DIGEST_LENGTH=16;var i=function(){function o(f){this.digestLength=r.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var u=f[0]|f[1]<<8;this._r[0]=u&8191;var h=f[2]|f[3]<<8;this._r[1]=(u>>>13|h<<3)&8191;var g=f[4]|f[5]<<8;this._r[2]=(h>>>10|g<<6)&7939;var m=f[6]|f[7]<<8;this._r[3]=(g>>>7|m<<9)&8191;var I=f[8]|f[9]<<8;this._r[4]=(m>>>4|I<<12)&255,this._r[5]=I>>>1&8190;var M=f[10]|f[11]<<8;this._r[6]=(I>>>14|M<<2)&8191;var D=f[12]|f[13]<<8;this._r[7]=(M>>>11|D<<5)&8065;var N=f[14]|f[15]<<8;this._r[8]=(D>>>8|N<<8)&8191,this._r[9]=N>>>5&127,this._pad[0]=f[16]|f[17]<<8,this._pad[1]=f[18]|f[19]<<8,this._pad[2]=f[20]|f[21]<<8,this._pad[3]=f[22]|f[23]<<8,this._pad[4]=f[24]|f[25]<<8,this._pad[5]=f[26]|f[27]<<8,this._pad[6]=f[28]|f[29]<<8,this._pad[7]=f[30]|f[31]<<8}return o.prototype._blocks=function(f,u,h){for(var g=this._fin?0:2048,m=this._h[0],I=this._h[1],M=this._h[2],D=this._h[3],N=this._h[4],k=this._h[5],K=this._h[6],B=this._h[7],j=this._h[8],F=this._h[9],U=this._r[0],z=this._r[1],_=this._r[2],P=this._r[3],J=this._r[4],Q=this._r[5],R=this._r[6],p=this._r[7],l=this._r[8],a=this._r[9];h>=16;){var c=f[u+0]|f[u+1]<<8;m+=c&8191;var b=f[u+2]|f[u+3]<<8;I+=(c>>>13|b<<3)&8191;var A=f[u+4]|f[u+5]<<8;M+=(b>>>10|A<<6)&8191;var E=f[u+6]|f[u+7]<<8;D+=(A>>>7|E<<9)&8191;var x=f[u+8]|f[u+9]<<8;N+=(E>>>4|x<<12)&8191,k+=x>>>1&8191;var d=f[u+10]|f[u+11]<<8;K+=(x>>>14|d<<2)&8191;var w=f[u+12]|f[u+13]<<8;B+=(d>>>11|w<<5)&8191;var v=f[u+14]|f[u+15]<<8;j+=(w>>>8|v<<8)&8191,F+=v>>>5|g;var O=0,W=O;W+=m*U,W+=I*(5*a),W+=M*(5*l),W+=D*(5*p),W+=N*(5*R),O=W>>>13,W&=8191,W+=k*(5*Q),W+=K*(5*J),W+=B*(5*P),W+=j*(5*_),W+=F*(5*z),O+=W>>>13,W&=8191;var S=O;S+=m*z,S+=I*U,S+=M*(5*a),S+=D*(5*l),S+=N*(5*p),O=S>>>13,S&=8191,S+=k*(5*R),S+=K*(5*Q),S+=B*(5*J),S+=j*(5*P),S+=F*(5*_),O+=S>>>13,S&=8191;var H=O;H+=m*_,H+=I*z,H+=M*U,H+=D*(5*a),H+=N*(5*l),O=H>>>13,H&=8191,H+=k*(5*p),H+=K*(5*R),H+=B*(5*Q),H+=j*(5*J),H+=F*(5*P),O+=H>>>13,H&=8191;var C=O;C+=m*P,C+=I*_,C+=M*z,C+=D*U,C+=N*(5*a),O=C>>>13,C&=8191,C+=k*(5*l),C+=K*(5*p),C+=B*(5*R),C+=j*(5*Q),C+=F*(5*J),O+=C>>>13,C&=8191;var q=O;q+=m*J,q+=I*P,q+=M*_,q+=D*z,q+=N*U,O=q>>>13,q&=8191,q+=k*(5*a),q+=K*(5*l),q+=B*(5*p),q+=j*(5*R),q+=F*(5*Q),O+=q>>>13,q&=8191;var T=O;T+=m*Q,T+=I*J,T+=M*P,T+=D*_,T+=N*z,O=T>>>13,T&=8191,T+=k*U,T+=K*(5*a),T+=B*(5*l),T+=j*(5*p),T+=F*(5*R),O+=T>>>13,T&=8191;var y=O;y+=m*R,y+=I*Q,y+=M*J,y+=D*P,y+=N*_,O=y>>>13,y&=8191,y+=k*z,y+=K*U,y+=B*(5*a),y+=j*(5*l),y+=F*(5*p),O+=y>>>13,y&=8191;var L=O;L+=m*p,L+=I*R,L+=M*Q,L+=D*J,L+=N*P,O=L>>>13,L&=8191,L+=k*_,L+=K*z,L+=B*U,L+=j*(5*a),L+=F*(5*l),O+=L>>>13,L&=8191;var G=O;G+=m*l,G+=I*p,G+=M*R,G+=D*Q,G+=N*J,O=G>>>13,G&=8191,G+=k*P,G+=K*_,G+=B*z,G+=j*U,G+=F*(5*a),O+=G>>>13,G&=8191;var Y=O;Y+=m*a,Y+=I*l,Y+=M*p,Y+=D*R,Y+=N*Q,O=Y>>>13,Y&=8191,Y+=k*J,Y+=K*P,Y+=B*_,Y+=j*z,Y+=F*U,O+=Y>>>13,Y&=8191,O=(O<<2)+O|0,O=O+W|0,W=O&8191,O=O>>>13,S+=O,m=W,I=S,M=H,D=C,N=q,k=T,K=y,B=L,j=G,F=Y,u+=16,h-=16}this._h[0]=m,this._h[1]=I,this._h[2]=M,this._h[3]=D,this._h[4]=N,this._h[5]=k,this._h[6]=K,this._h[7]=B,this._h[8]=j,this._h[9]=F},o.prototype.finish=function(f,u){u===void 0&&(u=0);var h=new Uint16Array(10),g,m,I,M;if(this._leftover){for(M=this._leftover,this._buffer[M++]=1;M<16;M++)this._buffer[M]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,M=2;M<10;M++)this._h[M]+=g,g=this._h[M]>>>13,this._h[M]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,h[0]=this._h[0]+5,g=h[0]>>>13,h[0]&=8191,M=1;M<10;M++)h[M]=this._h[M]+g,g=h[M]>>>13,h[M]&=8191;for(h[9]-=8192,m=(g^1)-1,M=0;M<10;M++)h[M]&=m;for(m=~m,M=0;M<10;M++)this._h[M]=this._h[M]&m|h[M];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,I=this._h[0]+this._pad[0],this._h[0]=I&65535,M=1;M<8;M++)I=(this._h[M]+this._pad[M]|0)+(I>>>16)|0,this._h[M]=I&65535;return f[u+0]=this._h[0]>>>0,f[u+1]=this._h[0]>>>8,f[u+2]=this._h[1]>>>0,f[u+3]=this._h[1]>>>8,f[u+4]=this._h[2]>>>0,f[u+5]=this._h[2]>>>8,f[u+6]=this._h[3]>>>0,f[u+7]=this._h[3]>>>8,f[u+8]=this._h[4]>>>0,f[u+9]=this._h[4]>>>8,f[u+10]=this._h[5]>>>0,f[u+11]=this._h[5]>>>8,f[u+12]=this._h[6]>>>0,f[u+13]=this._h[6]>>>8,f[u+14]=this._h[7]>>>0,f[u+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(f){var u=0,h=f.length,g;if(this._leftover){g=16-this._leftover,g>h&&(g=h);for(var m=0;m<g;m++)this._buffer[this._leftover+m]=f[u+m];if(h-=g,u+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(h>=16&&(g=h-h%16,this._blocks(f,u,g),u+=g,h-=g),h){for(var m=0;m<h;m++)this._buffer[this._leftover+m]=f[u+m];this._leftover+=h}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var f=new Uint8Array(16);return this.finish(f),f},o.prototype.clean=function(){return t.wipe(this._buffer),t.wipe(this._r),t.wipe(this._h),t.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();r.Poly1305=i;function n(o,f){var u=new i(o);u.update(f);var h=u.digest();return u.clean(),h}r.oneTimeAuth=n;function s(o,f){return o.length!==r.DIGEST_LENGTH||f.length!==r.DIGEST_LENGTH?!1:e.equal(o,f)}r.equal=s}(eu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=sa,t=eu,i=ar,n=He,s=Si;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var o=new Uint8Array(16),f=function(){function u(h){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,h.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(h)}return u.prototype.seal=function(h,g,m,I){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var M=new Uint8Array(16);M.set(h,M.length-h.length);var D=new Uint8Array(32);e.stream(this._key,M,D,4);var N=g.length+this.tagLength,k;if(I){if(I.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");k=I}else k=new Uint8Array(N);return e.streamXOR(this._key,M,g,k,4),this._authenticate(k.subarray(k.length-this.tagLength,k.length),D,k.subarray(0,k.length-this.tagLength),m),i.wipe(M),k},u.prototype.open=function(h,g,m,I){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var M=new Uint8Array(16);M.set(h,M.length-h.length);var D=new Uint8Array(32);e.stream(this._key,M,D,4);var N=new Uint8Array(this.tagLength);if(this._authenticate(N,D,g.subarray(0,g.length-this.tagLength),m),!s.equal(N,g.subarray(g.length-this.tagLength,g.length)))return null;var k=g.length-this.tagLength,K;if(I){if(I.length!==k)throw new Error("ChaCha20Poly1305: incorrect destination length");K=I}else K=new Uint8Array(k);return e.streamXOR(this._key,M,g.subarray(0,g.length-this.tagLength),K,4),i.wipe(M),K},u.prototype.clean=function(){return i.wipe(this._key),this},u.prototype._authenticate=function(h,g,m,I){var M=new t.Poly1305(g);I&&(M.update(I),I.length%16>0&&M.update(o.subarray(I.length%16))),M.update(m),m.length%16>0&&M.update(o.subarray(m.length%16));var D=new Uint8Array(8);I&&n.writeUint64LE(I.length,D),M.update(D),n.writeUint64LE(m.length,D),M.update(D);for(var N=M.digest(),k=0;k<N.length;k++)h[k]=N[k];M.clean(),i.wipe(N),i.wipe(D)},u}();r.ChaCha20Poly1305=f}(To);var ru={},Qn={},Bo={};Object.defineProperty(Bo,"__esModule",{value:!0});function H2(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}Bo.isSerializableHash=H2,Object.defineProperty(Qn,"__esModule",{value:!0});var jr=Bo,V2=Si,G2=ar,iu=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),jr.isSerializableHash(this._inner)&&jr.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),G2.wipe(i)}return r.prototype.reset=function(){if(!jr.isSerializableHash(this._inner)||!jr.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.clean=function(){jr.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),jr.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(e){return this._inner.update(e),this},r.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(!jr.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(e){if(!jr.isSerializableHash(this._inner)||!jr.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(e){if(!jr.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},r}();Qn.HMAC=iu;function W2(r,e,t){var i=new iu(r,e);i.update(t);var n=i.digest();return i.clean(),n}Qn.hmac=W2,Qn.equal=V2.equal,Object.defineProperty(ru,"__esModule",{value:!0});var nu=Qn,su=ar,J2=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=nu.hmac(this._hash,i,t);this._hmac=new nu.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i<t.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[i]=this._buffer[this._bufpos++];return t},r.prototype.clean=function(){this._hmac.clean(),su.wipe(this._buffer),su.wipe(this._counter),this._bufpos=0},r}(),Y2=ru.HKDF=J2,Xn={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=He,t=ar;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._temp),this.reset()},f.prototype.update=function(u,h){if(h===void 0&&(h=u.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&h>0;)this._buffer[this._bufferLength++]=u[g++],h--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(g=s(this._temp,this._state,u,g,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=u[g++],h--;return this},f.prototype.finish=function(u){if(!this._finished){var h=this._bytesHashed,g=this._bufferLength,m=h/536870912|0,I=h<<3,M=h%64<56?64:128;this._buffer[g]=128;for(var D=g+1;D<M-8;D++)this._buffer[D]=0;e.writeUint32BE(m,this._buffer,M-8),e.writeUint32BE(I,this._buffer,M-4),s(this._temp,this._state,this._buffer,0,M),this._finished=!0}for(var D=0;D<this.digestLength/4;D++)e.writeUint32BE(this._state[D],u,D*4);return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(u){return this._state.set(u.state),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(u){t.wipe(u.state),u.buffer&&t.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},f}();r.SHA256=i;var n=new Int32Array([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 s(f,u,h,g,m){for(;m>=64;){for(var I=u[0],M=u[1],D=u[2],N=u[3],k=u[4],K=u[5],B=u[6],j=u[7],F=0;F<16;F++){var U=g+F*4;f[F]=e.readUint32BE(h,U)}for(var F=16;F<64;F++){var z=f[F-2],_=(z>>>17|z<<32-17)^(z>>>19|z<<32-19)^z>>>10;z=f[F-15];var P=(z>>>7|z<<32-7)^(z>>>18|z<<32-18)^z>>>3;f[F]=(_+f[F-7]|0)+(P+f[F-16]|0)}for(var F=0;F<64;F++){var _=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&K^~k&B)|0)+(j+(n[F]+f[F]|0)|0)|0,P=((I>>>2|I<<32-2)^(I>>>13|I<<32-13)^(I>>>22|I<<32-22))+(I&M^I&D^M&D)|0;j=B,B=K,K=k,k=N+_|0,N=D,D=M,M=I,I=_+P|0}u[0]+=I,u[1]+=M,u[2]+=D,u[3]+=N,u[4]+=k,u[5]+=K,u[6]+=B,u[7]+=j,g+=64,m-=64}return g}function o(f){var u=new i;u.update(f);var h=u.digest();return u.clean(),h}r.hash=o})(Xn);var Lo={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const e=_i,t=ar;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(F){const U=new Float64Array(16);if(F)for(let z=0;z<F.length;z++)U[z]=F[z];return U}const n=new Uint8Array(32);n[0]=9;const s=i([56129,1]);function o(F){let U=1;for(let z=0;z<16;z++){let _=F[z]+U+65535;U=Math.floor(_/65536),F[z]=_-U*65536}F[0]+=U-1+37*(U-1)}function f(F,U,z){const _=~(z-1);for(let P=0;P<16;P++){const J=_&(F[P]^U[P]);F[P]^=J,U[P]^=J}}function u(F,U){const z=i(),_=i();for(let P=0;P<16;P++)_[P]=U[P];o(_),o(_),o(_);for(let P=0;P<2;P++){z[0]=_[0]-65517;for(let Q=1;Q<15;Q++)z[Q]=_[Q]-65535-(z[Q-1]>>16&1),z[Q-1]&=65535;z[15]=_[15]-32767-(z[14]>>16&1);const J=z[15]>>16&1;z[14]&=65535,f(_,z,1-J)}for(let P=0;P<16;P++)F[2*P]=_[P]&255,F[2*P+1]=_[P]>>8}function h(F,U){for(let z=0;z<16;z++)F[z]=U[2*z]+(U[2*z+1]<<8);F[15]&=32767}function g(F,U,z){for(let _=0;_<16;_++)F[_]=U[_]+z[_]}function m(F,U,z){for(let _=0;_<16;_++)F[_]=U[_]-z[_]}function I(F,U,z){let _,P,J=0,Q=0,R=0,p=0,l=0,a=0,c=0,b=0,A=0,E=0,x=0,d=0,w=0,v=0,O=0,W=0,S=0,H=0,C=0,q=0,T=0,y=0,L=0,G=0,Y=0,X=0,ee=0,we=0,Se=0,he=0,Re=0,xe=z[0],se=z[1],ve=z[2],le=z[3],ie=z[4],ue=z[5],fe=z[6],te=z[7],pe=z[8],_e=z[9],re=z[10],Ae=z[11],Ee=z[12],oe=z[13],De=z[14],Me=z[15];_=U[0],J+=_*xe,Q+=_*se,R+=_*ve,p+=_*le,l+=_*ie,a+=_*ue,c+=_*fe,b+=_*te,A+=_*pe,E+=_*_e,x+=_*re,d+=_*Ae,w+=_*Ee,v+=_*oe,O+=_*De,W+=_*Me,_=U[1],Q+=_*xe,R+=_*se,p+=_*ve,l+=_*le,a+=_*ie,c+=_*ue,b+=_*fe,A+=_*te,E+=_*pe,x+=_*_e,d+=_*re,w+=_*Ae,v+=_*Ee,O+=_*oe,W+=_*De,S+=_*Me,_=U[2],R+=_*xe,p+=_*se,l+=_*ve,a+=_*le,c+=_*ie,b+=_*ue,A+=_*fe,E+=_*te,x+=_*pe,d+=_*_e,w+=_*re,v+=_*Ae,O+=_*Ee,W+=_*oe,S+=_*De,H+=_*Me,_=U[3],p+=_*xe,l+=_*se,a+=_*ve,c+=_*le,b+=_*ie,A+=_*ue,E+=_*fe,x+=_*te,d+=_*pe,w+=_*_e,v+=_*re,O+=_*Ae,W+=_*Ee,S+=_*oe,H+=_*De,C+=_*Me,_=U[4],l+=_*xe,a+=_*se,c+=_*ve,b+=_*le,A+=_*ie,E+=_*ue,x+=_*fe,d+=_*te,w+=_*pe,v+=_*_e,O+=_*re,W+=_*Ae,S+=_*Ee,H+=_*oe,C+=_*De,q+=_*Me,_=U[5],a+=_*xe,c+=_*se,b+=_*ve,A+=_*le,E+=_*ie,x+=_*ue,d+=_*fe,w+=_*te,v+=_*pe,O+=_*_e,W+=_*re,S+=_*Ae,H+=_*Ee,C+=_*oe,q+=_*De,T+=_*Me,_=U[6],c+=_*xe,b+=_*se,A+=_*ve,E+=_*le,x+=_*ie,d+=_*ue,w+=_*fe,v+=_*te,O+=_*pe,W+=_*_e,S+=_*re,H+=_*Ae,C+=_*Ee,q+=_*oe,T+=_*De,y+=_*Me,_=U[7],b+=_*xe,A+=_*se,E+=_*ve,x+=_*le,d+=_*ie,w+=_*ue,v+=_*fe,O+=_*te,W+=_*pe,S+=_*_e,H+=_*re,C+=_*Ae,q+=_*Ee,T+=_*oe,y+=_*De,L+=_*Me,_=U[8],A+=_*xe,E+=_*se,x+=_*ve,d+=_*le,w+=_*ie,v+=_*ue,O+=_*fe,W+=_*te,S+=_*pe,H+=_*_e,C+=_*re,q+=_*Ae,T+=_*Ee,y+=_*oe,L+=_*De,G+=_*Me,_=U[9],E+=_*xe,x+=_*se,d+=_*ve,w+=_*le,v+=_*ie,O+=_*ue,W+=_*fe,S+=_*te,H+=_*pe,C+=_*_e,q+=_*re,T+=_*Ae,y+=_*Ee,L+=_*oe,G+=_*De,Y+=_*Me,_=U[10],x+=_*xe,d+=_*se,w+=_*ve,v+=_*le,O+=_*ie,W+=_*ue,S+=_*fe,H+=_*te,C+=_*pe,q+=_*_e,T+=_*re,y+=_*Ae,L+=_*Ee,G+=_*oe,Y+=_*De,X+=_*Me,_=U[11],d+=_*xe,w+=_*se,v+=_*ve,O+=_*le,W+=_*ie,S+=_*ue,H+=_*fe,C+=_*te,q+=_*pe,T+=_*_e,y+=_*re,L+=_*Ae,G+=_*Ee,Y+=_*oe,X+=_*De,ee+=_*Me,_=U[12],w+=_*xe,v+=_*se,O+=_*ve,W+=_*le,S+=_*ie,H+=_*ue,C+=_*fe,q+=_*te,T+=_*pe,y+=_*_e,L+=_*re,G+=_*Ae,Y+=_*Ee,X+=_*oe,ee+=_*De,we+=_*Me,_=U[13],v+=_*xe,O+=_*se,W+=_*ve,S+=_*le,H+=_*ie,C+=_*ue,q+=_*fe,T+=_*te,y+=_*pe,L+=_*_e,G+=_*re,Y+=_*Ae,X+=_*Ee,ee+=_*oe,we+=_*De,Se+=_*Me,_=U[14],O+=_*xe,W+=_*se,S+=_*ve,H+=_*le,C+=_*ie,q+=_*ue,T+=_*fe,y+=_*te,L+=_*pe,G+=_*_e,Y+=_*re,X+=_*Ae,ee+=_*Ee,we+=_*oe,Se+=_*De,he+=_*Me,_=U[15],W+=_*xe,S+=_*se,H+=_*ve,C+=_*le,q+=_*ie,T+=_*ue,y+=_*fe,L+=_*te,G+=_*pe,Y+=_*_e,X+=_*re,ee+=_*Ae,we+=_*Ee,Se+=_*oe,he+=_*De,Re+=_*Me,J+=38*S,Q+=38*H,R+=38*C,p+=38*q,l+=38*T,a+=38*y,c+=38*L,b+=38*G,A+=38*Y,E+=38*X,x+=38*ee,d+=38*we,w+=38*Se,v+=38*he,O+=38*Re,P=1,_=J+P+65535,P=Math.floor(_/65536),J=_-P*65536,_=Q+P+65535,P=Math.floor(_/65536),Q=_-P*65536,_=R+P+65535,P=Math.floor(_/65536),R=_-P*65536,_=p+P+65535,P=Math.floor(_/65536),p=_-P*65536,_=l+P+65535,P=Math.floor(_/65536),l=_-P*65536,_=a+P+65535,P=Math.floor(_/65536),a=_-P*65536,_=c+P+65535,P=Math.floor(_/65536),c=_-P*65536,_=b+P+65535,P=Math.floor(_/65536),b=_-P*65536,_=A+P+65535,P=Math.floor(_/65536),A=_-P*65536,_=E+P+65535,P=Math.floor(_/65536),E=_-P*65536,_=x+P+65535,P=Math.floor(_/65536),x=_-P*65536,_=d+P+65535,P=Math.floor(_/65536),d=_-P*65536,_=w+P+65535,P=Math.floor(_/65536),w=_-P*65536,_=v+P+65535,P=Math.floor(_/65536),v=_-P*65536,_=O+P+65535,P=Math.floor(_/65536),O=_-P*65536,_=W+P+65535,P=Math.floor(_/65536),W=_-P*65536,J+=P-1+37*(P-1),P=1,_=J+P+65535,P=Math.floor(_/65536),J=_-P*65536,_=Q+P+65535,P=Math.floor(_/65536),Q=_-P*65536,_=R+P+65535,P=Math.floor(_/65536),R=_-P*65536,_=p+P+65535,P=Math.floor(_/65536),p=_-P*65536,_=l+P+65535,P=Math.floor(_/65536),l=_-P*65536,_=a+P+65535,P=Math.floor(_/65536),a=_-P*65536,_=c+P+65535,P=Math.floor(_/65536),c=_-P*65536,_=b+P+65535,P=Math.floor(_/65536),b=_-P*65536,_=A+P+65535,P=Math.floor(_/65536),A=_-P*65536,_=E+P+65535,P=Math.floor(_/65536),E=_-P*65536,_=x+P+65535,P=Math.floor(_/65536),x=_-P*65536,_=d+P+65535,P=Math.floor(_/65536),d=_-P*65536,_=w+P+65535,P=Math.floor(_/65536),w=_-P*65536,_=v+P+65535,P=Math.floor(_/65536),v=_-P*65536,_=O+P+65535,P=Math.floor(_/65536),O=_-P*65536,_=W+P+65535,P=Math.floor(_/65536),W=_-P*65536,J+=P-1+37*(P-1),F[0]=J,F[1]=Q,F[2]=R,F[3]=p,F[4]=l,F[5]=a,F[6]=c,F[7]=b,F[8]=A,F[9]=E,F[10]=x,F[11]=d,F[12]=w,F[13]=v,F[14]=O,F[15]=W}function M(F,U){I(F,U,U)}function D(F,U){const z=i();for(let _=0;_<16;_++)z[_]=U[_];for(let _=253;_>=0;_--)M(z,z),_!==2&&_!==4&&I(z,z,U);for(let _=0;_<16;_++)F[_]=z[_]}function N(F,U){const z=new Uint8Array(32),_=new Float64Array(80),P=i(),J=i(),Q=i(),R=i(),p=i(),l=i();for(let A=0;A<31;A++)z[A]=F[A];z[31]=F[31]&127|64,z[0]&=248,h(_,U);for(let A=0;A<16;A++)J[A]=_[A];P[0]=R[0]=1;for(let A=254;A>=0;--A){const E=z[A>>>3]>>>(A&7)&1;f(P,J,E),f(Q,R,E),g(p,P,Q),m(P,P,Q),g(Q,J,R),m(J,J,R),M(R,p),M(l,P),I(P,Q,P),I(Q,J,p),g(p,P,Q),m(P,P,Q),M(J,P),m(Q,R,l),I(P,Q,s),g(P,P,R),I(Q,Q,P),I(P,R,l),I(R,J,_),M(J,p),f(P,J,E),f(Q,R,E)}for(let A=0;A<16;A++)_[A+16]=P[A],_[A+32]=Q[A],_[A+48]=J[A],_[A+64]=R[A];const a=_.subarray(32),c=_.subarray(16);D(a,a),I(c,c,a);const b=new Uint8Array(32);return u(b,c),b}r.scalarMult=N;function k(F){return N(F,n)}r.scalarMultBase=k;function K(F){if(F.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const U=new Uint8Array(F);return{publicKey:k(U),secretKey:U}}r.generateKeyPairFromSeed=K;function B(F){const U=(0,e.randomBytes)(32,F),z=K(U);return(0,t.wipe)(U),z}r.generateKeyPair=B;function j(F,U,z=!1){if(F.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(U.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const _=N(F,U);if(z){let P=0;for(let J=0;J<_.length;J++)P|=_[J];if(P===0)throw new Error("X25519: invalid shared key")}return _}r.sharedKey=j})(Lo);var au={},Q2="elliptic",X2="6.6.0",Z2="EC cryptography",e3="lib/elliptic.js",t3=["lib"],r3={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/"},i3={type:"git",url:"git@github.com:indutny/elliptic"},n3=["EC","Elliptic","curve","Cryptography"],s3="Fedor Indutny <fedor@indutny.com>",a3="MIT",o3={url:"https://github.com/indutny/elliptic/issues"},f3="https://github.com/indutny/elliptic",c3={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"},h3={"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"},u3={name:Q2,version:X2,description:Z2,main:e3,files:t3,scripts:r3,repository:i3,keywords:n3,author:s3,license:a3,bugs:o3,homepage:f3,devDependencies:c3,dependencies:h3},hr={},Hr={exports:{}};(function(r){(function(e,t){function i(R,p){if(!R)throw new Error(p||"Assertion failed")}function n(R,p){R.super_=p;var l=function(){};l.prototype=p.prototype,R.prototype=new l,R.prototype.constructor=R}function s(R,p,l){if(s.isBN(R))return R;this.negative=0,this.words=null,this.length=0,this.red=null,R!==null&&((p==="le"||p==="be")&&(l=p,p=10),this._init(R||0,p||10,l||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=qs.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,l){return p.cmp(l)>0?p:l},s.min=function(p,l){return p.cmp(l)<0?p:l},s.prototype._init=function(p,l,a){if(typeof p=="number")return this._initNumber(p,l,a);if(typeof p=="object")return this._initArray(p,l,a);l==="hex"&&(l=16),i(l===(l|0)&&l>=2&&l<=36),p=p.toString().replace(/\s+/g,"");var c=0;p[0]==="-"&&(c++,this.negative=1),c<p.length&&(l===16?this._parseHex(p,c,a):(this._parseBase(p,l,c),a==="le"&&this._initArray(this.toArray(),l,a)))},s.prototype._initNumber=function(p,l,a){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(i(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),a==="le"&&this._initArray(this.toArray(),l,a)},s.prototype._initArray=function(p,l,a){if(i(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var c=0;c<this.length;c++)this.words[c]=0;var b,A,E=0;if(a==="be")for(c=p.length-1,b=0;c>=0;c-=3)A=p[c]|p[c-1]<<8|p[c-2]<<16,this.words[b]|=A<<E&67108863,this.words[b+1]=A>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);else if(a==="le")for(c=0,b=0;c<p.length;c+=3)A=p[c]|p[c+1]<<8|p[c+2]<<16,this.words[b]|=A<<E&67108863,this.words[b+1]=A>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);return this.strip()};function f(R,p){var l=R.charCodeAt(p);return l>=65&&l<=70?l-55:l>=97&&l<=102?l-87:l-48&15}function u(R,p,l){var a=f(R,l);return l-1>=p&&(a|=f(R,l-1)<<4),a}s.prototype._parseHex=function(p,l,a){this.length=Math.ceil((p.length-l)/6),this.words=new Array(this.length);for(var c=0;c<this.length;c++)this.words[c]=0;var b=0,A=0,E;if(a==="be")for(c=p.length-1;c>=l;c-=2)E=u(p,l,c)<<b,this.words[A]|=E&67108863,b>=18?(b-=18,A+=1,this.words[A]|=E>>>26):b+=8;else{var x=p.length-l;for(c=x%2===0?l+1:l;c<p.length;c+=2)E=u(p,l,c)<<b,this.words[A]|=E&67108863,b>=18?(b-=18,A+=1,this.words[A]|=E>>>26):b+=8}this.strip()};function h(R,p,l,a){for(var c=0,b=Math.min(R.length,l),A=p;A<b;A++){var E=R.charCodeAt(A)-48;c*=a,E>=49?c+=E-49+10:E>=17?c+=E-17+10:c+=E}return c}s.prototype._parseBase=function(p,l,a){this.words=[0],this.length=1;for(var c=0,b=1;b<=67108863;b*=l)c++;c--,b=b/l|0;for(var A=p.length-a,E=A%c,x=Math.min(A,A-E)+a,d=0,w=a;w<x;w+=c)d=h(p,w,w+c,l),this.imuln(b),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(E!==0){var v=1;for(d=h(p,w,p.length,l),w=0;w<E;w++)v*=l;this.imuln(v),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var l=0;l<this.length;l++)p.words[l]=this.words[l];p.length=this.length,p.negative=this.negative,p.red=this.red},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)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 g=["","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"],m=[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],I=[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(p,l){p=p||10,l=l|0||1;var a;if(p===16||p==="hex"){a="";for(var c=0,b=0,A=0;A<this.length;A++){var E=this.words[A],x=((E<<c|b)&16777215).toString(16);b=E>>>24-c&16777215,b!==0||A!==this.length-1?a=g[6-x.length]+x+a:a=x+a,c+=2,c>=26&&(c-=26,A--)}for(b!==0&&(a=b.toString(16)+a);a.length%l!==0;)a="0"+a;return this.negative!==0&&(a="-"+a),a}if(p===(p|0)&&p>=2&&p<=36){var d=m[p],w=I[p];a="";var v=this.clone();for(v.negative=0;!v.isZero();){var O=v.modn(w).toString(p);v=v.idivn(w),v.isZero()?a=O+a:a=g[d-O.length]+O+a}for(this.isZero()&&(a="0"+a);a.length%l!==0;)a="0"+a;return this.negative!==0&&(a="-"+a),a}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(p,l){return i(typeof o<"u"),this.toArrayLike(o,p,l)},s.prototype.toArray=function(p,l){return this.toArrayLike(Array,p,l)},s.prototype.toArrayLike=function(p,l,a){var c=this.byteLength(),b=a||Math.max(1,c);i(c<=b,"byte array longer than desired length"),i(b>0,"Requested array length <= 0"),this.strip();var A=l==="le",E=new p(b),x,d,w=this.clone();if(A){for(d=0;!w.isZero();d++)x=w.andln(255),w.iushrn(8),E[d]=x;for(;d<b;d++)E[d]=0}else{for(d=0;d<b-c;d++)E[d]=0;for(d=0;!w.isZero();d++)x=w.andln(255),w.iushrn(8),E[b-d-1]=x}return E},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var l=p,a=0;return l>=4096&&(a+=13,l>>>=13),l>=64&&(a+=7,l>>>=7),l>=8&&(a+=4,l>>>=4),l>=2&&(a+=2,l>>>=2),a+l},s.prototype._zeroBits=function(p){if(p===0)return 26;var l=p,a=0;return l&8191||(a+=13,l>>>=13),l&127||(a+=7,l>>>=7),l&15||(a+=4,l>>>=4),l&3||(a+=2,l>>>=2),l&1||a++,a},s.prototype.bitLength=function(){var p=this.words[this.length-1],l=this._countBits(p);return(this.length-1)*26+l};function M(R){for(var p=new Array(R.bitLength()),l=0;l<p.length;l++){var a=l/26|0,c=l%26;p[l]=(R.words[a]&1<<c)>>>c}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,l=0;l<this.length;l++){var a=this._zeroBits(this.words[l]);if(p+=a,a!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).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(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var l=0;l<p.length;l++)this.words[l]=this.words[l]|p.words[l];return this.strip()},s.prototype.ior=function(p){return i((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var l;this.length>p.length?l=p:l=this;for(var a=0;a<l.length;a++)this.words[a]=this.words[a]&p.words[a];return this.length=l.length,this.strip()},s.prototype.iand=function(p){return i((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var l,a;this.length>p.length?(l=this,a=p):(l=p,a=this);for(var c=0;c<a.length;c++)this.words[c]=l.words[c]^a.words[c];if(this!==l)for(;c<l.length;c++)this.words[c]=l.words[c];return this.length=l.length,this.strip()},s.prototype.ixor=function(p){return i((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){i(typeof p=="number"&&p>=0);var l=Math.ceil(p/26)|0,a=p%26;this._expand(l),a>0&&l--;for(var c=0;c<l;c++)this.words[c]=~this.words[c]&67108863;return a>0&&(this.words[c]=~this.words[c]&67108863>>26-a),this.strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,l){i(typeof p=="number"&&p>=0);var a=p/26|0,c=p%26;return this._expand(a+1),l?this.words[a]=this.words[a]|1<<c:this.words[a]=this.words[a]&~(1<<c),this.strip()},s.prototype.iadd=function(p){var l;if(this.negative!==0&&p.negative===0)return this.negative=0,l=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,l=this.isub(p),p.negative=1,l._normSign();var a,c;this.length>p.length?(a=this,c=p):(a=p,c=this);for(var b=0,A=0;A<c.length;A++)l=(a.words[A]|0)+(c.words[A]|0)+b,this.words[A]=l&67108863,b=l>>>26;for(;b!==0&&A<a.length;A++)l=(a.words[A]|0)+b,this.words[A]=l&67108863,b=l>>>26;if(this.length=a.length,b!==0)this.words[this.length]=b,this.length++;else if(a!==this)for(;A<a.length;A++)this.words[A]=a.words[A];return this},s.prototype.add=function(p){var l;return p.negative!==0&&this.negative===0?(p.negative=0,l=this.sub(p),p.negative^=1,l):p.negative===0&&this.negative!==0?(this.negative=0,l=p.sub(this),this.negative=1,l):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var l=this.iadd(p);return p.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var a=this.cmp(p);if(a===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,b;a>0?(c=this,b=p):(c=p,b=this);for(var A=0,E=0;E<b.length;E++)l=(c.words[E]|0)-(b.words[E]|0)+A,A=l>>26,this.words[E]=l&67108863;for(;A!==0&&E<c.length;E++)l=(c.words[E]|0)+A,A=l>>26,this.words[E]=l&67108863;if(A===0&&E<c.length&&c!==this)for(;E<c.length;E++)this.words[E]=c.words[E];return this.length=Math.max(this.length,E),c!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function D(R,p,l){l.negative=p.negative^R.negative;var a=R.length+p.length|0;l.length=a,a=a-1|0;var c=R.words[0]|0,b=p.words[0]|0,A=c*b,E=A&67108863,x=A/67108864|0;l.words[0]=E;for(var d=1;d<a;d++){for(var w=x>>>26,v=x&67108863,O=Math.min(d,p.length-1),W=Math.max(0,d-R.length+1);W<=O;W++){var S=d-W|0;c=R.words[S]|0,b=p.words[W]|0,A=c*b+v,w+=A/67108864|0,v=A&67108863}l.words[d]=v|0,x=w|0}return x!==0?l.words[d]=x|0:l.length--,l.strip()}var N=function(p,l,a){var c=p.words,b=l.words,A=a.words,E=0,x,d,w,v=c[0]|0,O=v&8191,W=v>>>13,S=c[1]|0,H=S&8191,C=S>>>13,q=c[2]|0,T=q&8191,y=q>>>13,L=c[3]|0,G=L&8191,Y=L>>>13,X=c[4]|0,ee=X&8191,we=X>>>13,Se=c[5]|0,he=Se&8191,Re=Se>>>13,xe=c[6]|0,se=xe&8191,ve=xe>>>13,le=c[7]|0,ie=le&8191,ue=le>>>13,fe=c[8]|0,te=fe&8191,pe=fe>>>13,_e=c[9]|0,re=_e&8191,Ae=_e>>>13,Ee=b[0]|0,oe=Ee&8191,De=Ee>>>13,Me=b[1]|0,Oe=Me&8191,We=Me>>>13,Qe=b[2]|0,Ie=Qe&8191,et=Qe>>>13,tt=b[3]|0,Ne=tt&8191,Te=tt>>>13,Ce=b[4]|0,de=Ce&8191,Fe=Ce>>>13,Be=b[5]|0,ce=Be&8191,Ue=Be>>>13,$e=b[6]|0,me=$e&8191,ze=$e>>>13,ke=b[7]|0,ge=ke&8191,Le=ke>>>13,Pe=b[8]|0,ye=Pe&8191,Ke=Pe>>>13,it=b[9]|0,qe=it&8191,nt=it>>>13;a.negative=p.negative^l.negative,a.length=19,x=Math.imul(O,oe),d=Math.imul(O,De),d=d+Math.imul(W,oe)|0,w=Math.imul(W,De);var Je=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(Je>>>26)|0,Je&=67108863,x=Math.imul(H,oe),d=Math.imul(H,De),d=d+Math.imul(C,oe)|0,w=Math.imul(C,De),x=x+Math.imul(O,Oe)|0,d=d+Math.imul(O,We)|0,d=d+Math.imul(W,Oe)|0,w=w+Math.imul(W,We)|0;var rt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(rt>>>26)|0,rt&=67108863,x=Math.imul(T,oe),d=Math.imul(T,De),d=d+Math.imul(y,oe)|0,w=Math.imul(y,De),x=x+Math.imul(H,Oe)|0,d=d+Math.imul(H,We)|0,d=d+Math.imul(C,Oe)|0,w=w+Math.imul(C,We)|0,x=x+Math.imul(O,Ie)|0,d=d+Math.imul(O,et)|0,d=d+Math.imul(W,Ie)|0,w=w+Math.imul(W,et)|0;var rr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(rr>>>26)|0,rr&=67108863,x=Math.imul(G,oe),d=Math.imul(G,De),d=d+Math.imul(Y,oe)|0,w=Math.imul(Y,De),x=x+Math.imul(T,Oe)|0,d=d+Math.imul(T,We)|0,d=d+Math.imul(y,Oe)|0,w=w+Math.imul(y,We)|0,x=x+Math.imul(H,Ie)|0,d=d+Math.imul(H,et)|0,d=d+Math.imul(C,Ie)|0,w=w+Math.imul(C,et)|0,x=x+Math.imul(O,Ne)|0,d=d+Math.imul(O,Te)|0,d=d+Math.imul(W,Ne)|0,w=w+Math.imul(W,Te)|0;var ir=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ir>>>26)|0,ir&=67108863,x=Math.imul(ee,oe),d=Math.imul(ee,De),d=d+Math.imul(we,oe)|0,w=Math.imul(we,De),x=x+Math.imul(G,Oe)|0,d=d+Math.imul(G,We)|0,d=d+Math.imul(Y,Oe)|0,w=w+Math.imul(Y,We)|0,x=x+Math.imul(T,Ie)|0,d=d+Math.imul(T,et)|0,d=d+Math.imul(y,Ie)|0,w=w+Math.imul(y,et)|0,x=x+Math.imul(H,Ne)|0,d=d+Math.imul(H,Te)|0,d=d+Math.imul(C,Ne)|0,w=w+Math.imul(C,Te)|0,x=x+Math.imul(O,de)|0,d=d+Math.imul(O,Fe)|0,d=d+Math.imul(W,de)|0,w=w+Math.imul(W,Fe)|0;var nr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(nr>>>26)|0,nr&=67108863,x=Math.imul(he,oe),d=Math.imul(he,De),d=d+Math.imul(Re,oe)|0,w=Math.imul(Re,De),x=x+Math.imul(ee,Oe)|0,d=d+Math.imul(ee,We)|0,d=d+Math.imul(we,Oe)|0,w=w+Math.imul(we,We)|0,x=x+Math.imul(G,Ie)|0,d=d+Math.imul(G,et)|0,d=d+Math.imul(Y,Ie)|0,w=w+Math.imul(Y,et)|0,x=x+Math.imul(T,Ne)|0,d=d+Math.imul(T,Te)|0,d=d+Math.imul(y,Ne)|0,w=w+Math.imul(y,Te)|0,x=x+Math.imul(H,de)|0,d=d+Math.imul(H,Fe)|0,d=d+Math.imul(C,de)|0,w=w+Math.imul(C,Fe)|0,x=x+Math.imul(O,ce)|0,d=d+Math.imul(O,Ue)|0,d=d+Math.imul(W,ce)|0,w=w+Math.imul(W,Ue)|0;var sr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(sr>>>26)|0,sr&=67108863,x=Math.imul(se,oe),d=Math.imul(se,De),d=d+Math.imul(ve,oe)|0,w=Math.imul(ve,De),x=x+Math.imul(he,Oe)|0,d=d+Math.imul(he,We)|0,d=d+Math.imul(Re,Oe)|0,w=w+Math.imul(Re,We)|0,x=x+Math.imul(ee,Ie)|0,d=d+Math.imul(ee,et)|0,d=d+Math.imul(we,Ie)|0,w=w+Math.imul(we,et)|0,x=x+Math.imul(G,Ne)|0,d=d+Math.imul(G,Te)|0,d=d+Math.imul(Y,Ne)|0,w=w+Math.imul(Y,Te)|0,x=x+Math.imul(T,de)|0,d=d+Math.imul(T,Fe)|0,d=d+Math.imul(y,de)|0,w=w+Math.imul(y,Fe)|0,x=x+Math.imul(H,ce)|0,d=d+Math.imul(H,Ue)|0,d=d+Math.imul(C,ce)|0,w=w+Math.imul(C,Ue)|0,x=x+Math.imul(O,me)|0,d=d+Math.imul(O,ze)|0,d=d+Math.imul(W,me)|0,w=w+Math.imul(W,ze)|0;var yt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(yt>>>26)|0,yt&=67108863,x=Math.imul(ie,oe),d=Math.imul(ie,De),d=d+Math.imul(ue,oe)|0,w=Math.imul(ue,De),x=x+Math.imul(se,Oe)|0,d=d+Math.imul(se,We)|0,d=d+Math.imul(ve,Oe)|0,w=w+Math.imul(ve,We)|0,x=x+Math.imul(he,Ie)|0,d=d+Math.imul(he,et)|0,d=d+Math.imul(Re,Ie)|0,w=w+Math.imul(Re,et)|0,x=x+Math.imul(ee,Ne)|0,d=d+Math.imul(ee,Te)|0,d=d+Math.imul(we,Ne)|0,w=w+Math.imul(we,Te)|0,x=x+Math.imul(G,de)|0,d=d+Math.imul(G,Fe)|0,d=d+Math.imul(Y,de)|0,w=w+Math.imul(Y,Fe)|0,x=x+Math.imul(T,ce)|0,d=d+Math.imul(T,Ue)|0,d=d+Math.imul(y,ce)|0,w=w+Math.imul(y,Ue)|0,x=x+Math.imul(H,me)|0,d=d+Math.imul(H,ze)|0,d=d+Math.imul(C,me)|0,w=w+Math.imul(C,ze)|0,x=x+Math.imul(O,ge)|0,d=d+Math.imul(O,Le)|0,d=d+Math.imul(W,ge)|0,w=w+Math.imul(W,Le)|0;var hi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(hi>>>26)|0,hi&=67108863,x=Math.imul(te,oe),d=Math.imul(te,De),d=d+Math.imul(pe,oe)|0,w=Math.imul(pe,De),x=x+Math.imul(ie,Oe)|0,d=d+Math.imul(ie,We)|0,d=d+Math.imul(ue,Oe)|0,w=w+Math.imul(ue,We)|0,x=x+Math.imul(se,Ie)|0,d=d+Math.imul(se,et)|0,d=d+Math.imul(ve,Ie)|0,w=w+Math.imul(ve,et)|0,x=x+Math.imul(he,Ne)|0,d=d+Math.imul(he,Te)|0,d=d+Math.imul(Re,Ne)|0,w=w+Math.imul(Re,Te)|0,x=x+Math.imul(ee,de)|0,d=d+Math.imul(ee,Fe)|0,d=d+Math.imul(we,de)|0,w=w+Math.imul(we,Fe)|0,x=x+Math.imul(G,ce)|0,d=d+Math.imul(G,Ue)|0,d=d+Math.imul(Y,ce)|0,w=w+Math.imul(Y,Ue)|0,x=x+Math.imul(T,me)|0,d=d+Math.imul(T,ze)|0,d=d+Math.imul(y,me)|0,w=w+Math.imul(y,ze)|0,x=x+Math.imul(H,ge)|0,d=d+Math.imul(H,Le)|0,d=d+Math.imul(C,ge)|0,w=w+Math.imul(C,Le)|0,x=x+Math.imul(O,ye)|0,d=d+Math.imul(O,Ke)|0,d=d+Math.imul(W,ye)|0,w=w+Math.imul(W,Ke)|0;var ui=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ui>>>26)|0,ui&=67108863,x=Math.imul(re,oe),d=Math.imul(re,De),d=d+Math.imul(Ae,oe)|0,w=Math.imul(Ae,De),x=x+Math.imul(te,Oe)|0,d=d+Math.imul(te,We)|0,d=d+Math.imul(pe,Oe)|0,w=w+Math.imul(pe,We)|0,x=x+Math.imul(ie,Ie)|0,d=d+Math.imul(ie,et)|0,d=d+Math.imul(ue,Ie)|0,w=w+Math.imul(ue,et)|0,x=x+Math.imul(se,Ne)|0,d=d+Math.imul(se,Te)|0,d=d+Math.imul(ve,Ne)|0,w=w+Math.imul(ve,Te)|0,x=x+Math.imul(he,de)|0,d=d+Math.imul(he,Fe)|0,d=d+Math.imul(Re,de)|0,w=w+Math.imul(Re,Fe)|0,x=x+Math.imul(ee,ce)|0,d=d+Math.imul(ee,Ue)|0,d=d+Math.imul(we,ce)|0,w=w+Math.imul(we,Ue)|0,x=x+Math.imul(G,me)|0,d=d+Math.imul(G,ze)|0,d=d+Math.imul(Y,me)|0,w=w+Math.imul(Y,ze)|0,x=x+Math.imul(T,ge)|0,d=d+Math.imul(T,Le)|0,d=d+Math.imul(y,ge)|0,w=w+Math.imul(y,Le)|0,x=x+Math.imul(H,ye)|0,d=d+Math.imul(H,Ke)|0,d=d+Math.imul(C,ye)|0,w=w+Math.imul(C,Ke)|0,x=x+Math.imul(O,qe)|0,d=d+Math.imul(O,nt)|0,d=d+Math.imul(W,qe)|0,w=w+Math.imul(W,nt)|0;var di=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(di>>>26)|0,di&=67108863,x=Math.imul(re,Oe),d=Math.imul(re,We),d=d+Math.imul(Ae,Oe)|0,w=Math.imul(Ae,We),x=x+Math.imul(te,Ie)|0,d=d+Math.imul(te,et)|0,d=d+Math.imul(pe,Ie)|0,w=w+Math.imul(pe,et)|0,x=x+Math.imul(ie,Ne)|0,d=d+Math.imul(ie,Te)|0,d=d+Math.imul(ue,Ne)|0,w=w+Math.imul(ue,Te)|0,x=x+Math.imul(se,de)|0,d=d+Math.imul(se,Fe)|0,d=d+Math.imul(ve,de)|0,w=w+Math.imul(ve,Fe)|0,x=x+Math.imul(he,ce)|0,d=d+Math.imul(he,Ue)|0,d=d+Math.imul(Re,ce)|0,w=w+Math.imul(Re,Ue)|0,x=x+Math.imul(ee,me)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(we,me)|0,w=w+Math.imul(we,ze)|0,x=x+Math.imul(G,ge)|0,d=d+Math.imul(G,Le)|0,d=d+Math.imul(Y,ge)|0,w=w+Math.imul(Y,Le)|0,x=x+Math.imul(T,ye)|0,d=d+Math.imul(T,Ke)|0,d=d+Math.imul(y,ye)|0,w=w+Math.imul(y,Ke)|0,x=x+Math.imul(H,qe)|0,d=d+Math.imul(H,nt)|0,d=d+Math.imul(C,qe)|0,w=w+Math.imul(C,nt)|0;var li=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(li>>>26)|0,li&=67108863,x=Math.imul(re,Ie),d=Math.imul(re,et),d=d+Math.imul(Ae,Ie)|0,w=Math.imul(Ae,et),x=x+Math.imul(te,Ne)|0,d=d+Math.imul(te,Te)|0,d=d+Math.imul(pe,Ne)|0,w=w+Math.imul(pe,Te)|0,x=x+Math.imul(ie,de)|0,d=d+Math.imul(ie,Fe)|0,d=d+Math.imul(ue,de)|0,w=w+Math.imul(ue,Fe)|0,x=x+Math.imul(se,ce)|0,d=d+Math.imul(se,Ue)|0,d=d+Math.imul(ve,ce)|0,w=w+Math.imul(ve,Ue)|0,x=x+Math.imul(he,me)|0,d=d+Math.imul(he,ze)|0,d=d+Math.imul(Re,me)|0,w=w+Math.imul(Re,ze)|0,x=x+Math.imul(ee,ge)|0,d=d+Math.imul(ee,Le)|0,d=d+Math.imul(we,ge)|0,w=w+Math.imul(we,Le)|0,x=x+Math.imul(G,ye)|0,d=d+Math.imul(G,Ke)|0,d=d+Math.imul(Y,ye)|0,w=w+Math.imul(Y,Ke)|0,x=x+Math.imul(T,qe)|0,d=d+Math.imul(T,nt)|0,d=d+Math.imul(y,qe)|0,w=w+Math.imul(y,nt)|0;var pi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(pi>>>26)|0,pi&=67108863,x=Math.imul(re,Ne),d=Math.imul(re,Te),d=d+Math.imul(Ae,Ne)|0,w=Math.imul(Ae,Te),x=x+Math.imul(te,de)|0,d=d+Math.imul(te,Fe)|0,d=d+Math.imul(pe,de)|0,w=w+Math.imul(pe,Fe)|0,x=x+Math.imul(ie,ce)|0,d=d+Math.imul(ie,Ue)|0,d=d+Math.imul(ue,ce)|0,w=w+Math.imul(ue,Ue)|0,x=x+Math.imul(se,me)|0,d=d+Math.imul(se,ze)|0,d=d+Math.imul(ve,me)|0,w=w+Math.imul(ve,ze)|0,x=x+Math.imul(he,ge)|0,d=d+Math.imul(he,Le)|0,d=d+Math.imul(Re,ge)|0,w=w+Math.imul(Re,Le)|0,x=x+Math.imul(ee,ye)|0,d=d+Math.imul(ee,Ke)|0,d=d+Math.imul(we,ye)|0,w=w+Math.imul(we,Ke)|0,x=x+Math.imul(G,qe)|0,d=d+Math.imul(G,nt)|0,d=d+Math.imul(Y,qe)|0,w=w+Math.imul(Y,nt)|0;var Ar=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(Ar>>>26)|0,Ar&=67108863,x=Math.imul(re,de),d=Math.imul(re,Fe),d=d+Math.imul(Ae,de)|0,w=Math.imul(Ae,Fe),x=x+Math.imul(te,ce)|0,d=d+Math.imul(te,Ue)|0,d=d+Math.imul(pe,ce)|0,w=w+Math.imul(pe,Ue)|0,x=x+Math.imul(ie,me)|0,d=d+Math.imul(ie,ze)|0,d=d+Math.imul(ue,me)|0,w=w+Math.imul(ue,ze)|0,x=x+Math.imul(se,ge)|0,d=d+Math.imul(se,Le)|0,d=d+Math.imul(ve,ge)|0,w=w+Math.imul(ve,Le)|0,x=x+Math.imul(he,ye)|0,d=d+Math.imul(he,Ke)|0,d=d+Math.imul(Re,ye)|0,w=w+Math.imul(Re,Ke)|0,x=x+Math.imul(ee,qe)|0,d=d+Math.imul(ee,nt)|0,d=d+Math.imul(we,qe)|0,w=w+Math.imul(we,nt)|0;var gi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(gi>>>26)|0,gi&=67108863,x=Math.imul(re,ce),d=Math.imul(re,Ue),d=d+Math.imul(Ae,ce)|0,w=Math.imul(Ae,Ue),x=x+Math.imul(te,me)|0,d=d+Math.imul(te,ze)|0,d=d+Math.imul(pe,me)|0,w=w+Math.imul(pe,ze)|0,x=x+Math.imul(ie,ge)|0,d=d+Math.imul(ie,Le)|0,d=d+Math.imul(ue,ge)|0,w=w+Math.imul(ue,Le)|0,x=x+Math.imul(se,ye)|0,d=d+Math.imul(se,Ke)|0,d=d+Math.imul(ve,ye)|0,w=w+Math.imul(ve,Ke)|0,x=x+Math.imul(he,qe)|0,d=d+Math.imul(he,nt)|0,d=d+Math.imul(Re,qe)|0,w=w+Math.imul(Re,nt)|0;var bi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(bi>>>26)|0,bi&=67108863,x=Math.imul(re,me),d=Math.imul(re,ze),d=d+Math.imul(Ae,me)|0,w=Math.imul(Ae,ze),x=x+Math.imul(te,ge)|0,d=d+Math.imul(te,Le)|0,d=d+Math.imul(pe,ge)|0,w=w+Math.imul(pe,Le)|0,x=x+Math.imul(ie,ye)|0,d=d+Math.imul(ie,Ke)|0,d=d+Math.imul(ue,ye)|0,w=w+Math.imul(ue,Ke)|0,x=x+Math.imul(se,qe)|0,d=d+Math.imul(se,nt)|0,d=d+Math.imul(ve,qe)|0,w=w+Math.imul(ve,nt)|0;var kt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(kt>>>26)|0,kt&=67108863,x=Math.imul(re,ge),d=Math.imul(re,Le),d=d+Math.imul(Ae,ge)|0,w=Math.imul(Ae,Le),x=x+Math.imul(te,ye)|0,d=d+Math.imul(te,Ke)|0,d=d+Math.imul(pe,ye)|0,w=w+Math.imul(pe,Ke)|0,x=x+Math.imul(ie,qe)|0,d=d+Math.imul(ie,nt)|0,d=d+Math.imul(ue,qe)|0,w=w+Math.imul(ue,nt)|0;var vi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(vi>>>26)|0,vi&=67108863,x=Math.imul(re,ye),d=Math.imul(re,Ke),d=d+Math.imul(Ae,ye)|0,w=Math.imul(Ae,Ke),x=x+Math.imul(te,qe)|0,d=d+Math.imul(te,nt)|0,d=d+Math.imul(pe,qe)|0,w=w+Math.imul(pe,nt)|0;var mi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(mi>>>26)|0,mi&=67108863,x=Math.imul(re,qe),d=Math.imul(re,nt),d=d+Math.imul(Ae,qe)|0,w=Math.imul(Ae,nt);var yi=(E+x|0)+((d&8191)<<13)|0;return E=(w+(d>>>13)|0)+(yi>>>26)|0,yi&=67108863,A[0]=Je,A[1]=rt,A[2]=rr,A[3]=ir,A[4]=nr,A[5]=sr,A[6]=yt,A[7]=hi,A[8]=ui,A[9]=di,A[10]=li,A[11]=pi,A[12]=Ar,A[13]=gi,A[14]=bi,A[15]=kt,A[16]=vi,A[17]=mi,A[18]=yi,E!==0&&(A[19]=E,a.length++),a};Math.imul||(N=D);function k(R,p,l){l.negative=p.negative^R.negative,l.length=R.length+p.length;for(var a=0,c=0,b=0;b<l.length-1;b++){var A=c;c=0;for(var E=a&67108863,x=Math.min(b,p.length-1),d=Math.max(0,b-R.length+1);d<=x;d++){var w=b-d,v=R.words[w]|0,O=p.words[d]|0,W=v*O,S=W&67108863;A=A+(W/67108864|0)|0,S=S+E|0,E=S&67108863,A=A+(S>>>26)|0,c+=A>>>26,A&=67108863}l.words[b]=E,a=A,A=c}return a!==0?l.words[b]=a:l.length--,l.strip()}function K(R,p,l){var a=new B;return a.mulp(R,p,l)}s.prototype.mulTo=function(p,l){var a,c=this.length+p.length;return this.length===10&&p.length===10?a=N(this,p,l):c<63?a=D(this,p,l):c<1024?a=k(this,p,l):a=K(this,p,l),a};function B(R,p){this.x=R,this.y=p}B.prototype.makeRBT=function(p){for(var l=new Array(p),a=s.prototype._countBits(p)-1,c=0;c<p;c++)l[c]=this.revBin(c,a,p);return l},B.prototype.revBin=function(p,l,a){if(p===0||p===a-1)return p;for(var c=0,b=0;b<l;b++)c|=(p&1)<<l-b-1,p>>=1;return c},B.prototype.permute=function(p,l,a,c,b,A){for(var E=0;E<A;E++)c[E]=l[p[E]],b[E]=a[p[E]]},B.prototype.transform=function(p,l,a,c,b,A){this.permute(A,p,l,a,c,b);for(var E=1;E<b;E<<=1)for(var x=E<<1,d=Math.cos(2*Math.PI/x),w=Math.sin(2*Math.PI/x),v=0;v<b;v+=x)for(var O=d,W=w,S=0;S<E;S++){var H=a[v+S],C=c[v+S],q=a[v+S+E],T=c[v+S+E],y=O*q-W*T;T=O*T+W*q,q=y,a[v+S]=H+q,c[v+S]=C+T,a[v+S+E]=H-q,c[v+S+E]=C-T,S!==x&&(y=d*O-w*W,W=d*W+w*O,O=y)}},B.prototype.guessLen13b=function(p,l){var a=Math.max(l,p)|1,c=a&1,b=0;for(a=a/2|0;a;a=a>>>1)b++;return 1<<b+1+c},B.prototype.conjugate=function(p,l,a){if(!(a<=1))for(var c=0;c<a/2;c++){var b=p[c];p[c]=p[a-c-1],p[a-c-1]=b,b=l[c],l[c]=-l[a-c-1],l[a-c-1]=-b}},B.prototype.normalize13b=function(p,l){for(var a=0,c=0;c<l/2;c++){var b=Math.round(p[2*c+1]/l)*8192+Math.round(p[2*c]/l)+a;p[c]=b&67108863,b<67108864?a=0:a=b/67108864|0}return p},B.prototype.convert13b=function(p,l,a,c){for(var b=0,A=0;A<l;A++)b=b+(p[A]|0),a[2*A]=b&8191,b=b>>>13,a[2*A+1]=b&8191,b=b>>>13;for(A=2*l;A<c;++A)a[A]=0;i(b===0),i((b&-8192)===0)},B.prototype.stub=function(p){for(var l=new Array(p),a=0;a<p;a++)l[a]=0;return l},B.prototype.mulp=function(p,l,a){var c=2*this.guessLen13b(p.length,l.length),b=this.makeRBT(c),A=this.stub(c),E=new Array(c),x=new Array(c),d=new Array(c),w=new Array(c),v=new Array(c),O=new Array(c),W=a.words;W.length=c,this.convert13b(p.words,p.length,E,c),this.convert13b(l.words,l.length,w,c),this.transform(E,A,x,d,c,b),this.transform(w,A,v,O,c,b);for(var S=0;S<c;S++){var H=x[S]*v[S]-d[S]*O[S];d[S]=x[S]*O[S]+d[S]*v[S],x[S]=H}return this.conjugate(x,d,c),this.transform(x,d,W,A,c,b),this.conjugate(W,A,c),this.normalize13b(W,c),a.negative=p.negative^l.negative,a.length=p.length+l.length,a.strip()},s.prototype.mul=function(p){var l=new s(null);return l.words=new Array(this.length+p.length),this.mulTo(p,l)},s.prototype.mulf=function(p){var l=new s(null);return l.words=new Array(this.length+p.length),K(this,p,l)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){i(typeof p=="number"),i(p<67108864);for(var l=0,a=0;a<this.length;a++){var c=(this.words[a]|0)*p,b=(c&67108863)+(l&67108863);l>>=26,l+=c/67108864|0,l+=b>>>26,this.words[a]=b&67108863}return l!==0&&(this.words[a]=l,this.length++),this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var l=M(p);if(l.length===0)return new s(1);for(var a=this,c=0;c<l.length&&l[c]===0;c++,a=a.sqr());if(++c<l.length)for(var b=a.sqr();c<l.length;c++,b=b.sqr())l[c]!==0&&(a=a.mul(b));return a},s.prototype.iushln=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26,c=67108863>>>26-l<<26-l,b;if(l!==0){var A=0;for(b=0;b<this.length;b++){var E=this.words[b]&c,x=(this.words[b]|0)-E<<l;this.words[b]=x|A,A=E>>>26-l}A&&(this.words[b]=A,this.length++)}if(a!==0){for(b=this.length-1;b>=0;b--)this.words[b+a]=this.words[b];for(b=0;b<a;b++)this.words[b]=0;this.length+=a}return this.strip()},s.prototype.ishln=function(p){return i(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,l,a){i(typeof p=="number"&&p>=0);var c;l?c=(l-l%26)/26:c=0;var b=p%26,A=Math.min((p-b)/26,this.length),E=67108863^67108863>>>b<<b,x=a;if(c-=A,c=Math.max(0,c),x){for(var d=0;d<A;d++)x.words[d]=this.words[d];x.length=A}if(A!==0)if(this.length>A)for(this.length-=A,d=0;d<this.length;d++)this.words[d]=this.words[d+A];else this.words[0]=0,this.length=1;var w=0;for(d=this.length-1;d>=0&&(w!==0||d>=c);d--){var v=this.words[d]|0;this.words[d]=w<<26-b|v>>>b,w=v&E}return x&&w!==0&&(x.words[x.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(p,l,a){return i(this.negative===0),this.iushrn(p,l,a)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26,c=1<<l;if(this.length<=a)return!1;var b=this.words[a];return!!(b&c)},s.prototype.imaskn=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=a)return this;if(l!==0&&a++,this.length=Math.min(a,this.length),l!==0){var c=67108863^67108863>>>l<<l;this.words[this.length-1]&=c}return this.strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return i(typeof p=="number"),i(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},s.prototype.isubn=function(p){if(i(typeof p=="number"),i(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+1]-=1;return this.strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,l,a){var c=p.length+a,b;this._expand(c);var A,E=0;for(b=0;b<p.length;b++){A=(this.words[b+a]|0)+E;var x=(p.words[b]|0)*l;A-=x&67108863,E=(A>>26)-(x/67108864|0),this.words[b+a]=A&67108863}for(;b<this.length-a;b++)A=(this.words[b+a]|0)+E,E=A>>26,this.words[b+a]=A&67108863;if(E===0)return this.strip();for(i(E===-1),E=0,b=0;b<this.length;b++)A=-(this.words[b]|0)+E,E=A>>26,this.words[b]=A&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(p,l){var a=this.length-p.length,c=this.clone(),b=p,A=b.words[b.length-1]|0,E=this._countBits(A);a=26-E,a!==0&&(b=b.ushln(a),c.iushln(a),A=b.words[b.length-1]|0);var x=c.length-b.length,d;if(l!=="mod"){d=new s(null),d.length=x+1,d.words=new Array(d.length);for(var w=0;w<d.length;w++)d.words[w]=0}var v=c.clone()._ishlnsubmul(b,1,x);v.negative===0&&(c=v,d&&(d.words[x]=1));for(var O=x-1;O>=0;O--){var W=(c.words[b.length+O]|0)*67108864+(c.words[b.length+O-1]|0);for(W=Math.min(W/A|0,67108863),c._ishlnsubmul(b,W,O);c.negative!==0;)W--,c.negative=0,c._ishlnsubmul(b,1,O),c.isZero()||(c.negative^=1);d&&(d.words[O]=W)}return d&&d.strip(),c.strip(),l!=="div"&&a!==0&&c.iushrn(a),{div:d||null,mod:c}},s.prototype.divmod=function(p,l,a){if(i(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var c,b,A;return this.negative!==0&&p.negative===0?(A=this.neg().divmod(p,l),l!=="mod"&&(c=A.div.neg()),l!=="div"&&(b=A.mod.neg(),a&&b.negative!==0&&b.iadd(p)),{div:c,mod:b}):this.negative===0&&p.negative!==0?(A=this.divmod(p.neg(),l),l!=="mod"&&(c=A.div.neg()),{div:c,mod:A.mod}):this.negative&p.negative?(A=this.neg().divmod(p.neg(),l),l!=="div"&&(b=A.mod.neg(),a&&b.negative!==0&&b.isub(p)),{div:A.div,mod:b}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?l==="div"?{div:this.divn(p.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modn(p.words[0]))}:this._wordDiv(p,l)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var l=this.divmod(p);if(l.mod.isZero())return l.div;var a=l.div.negative!==0?l.mod.isub(p):l.mod,c=p.ushrn(1),b=p.andln(1),A=a.cmp(c);return A<0||b===1&&A===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},s.prototype.modn=function(p){i(p<=67108863);for(var l=(1<<26)%p,a=0,c=this.length-1;c>=0;c--)a=(l*a+(this.words[c]|0))%p;return a},s.prototype.idivn=function(p){i(p<=67108863);for(var l=0,a=this.length-1;a>=0;a--){var c=(this.words[a]|0)+l*67108864;this.words[a]=c/p|0,l=c%p}return this.strip()},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){i(p.negative===0),i(!p.isZero());var l=this,a=p.clone();l.negative!==0?l=l.umod(p):l=l.clone();for(var c=new s(1),b=new s(0),A=new s(0),E=new s(1),x=0;l.isEven()&&a.isEven();)l.iushrn(1),a.iushrn(1),++x;for(var d=a.clone(),w=l.clone();!l.isZero();){for(var v=0,O=1;!(l.words[0]&O)&&v<26;++v,O<<=1);if(v>0)for(l.iushrn(v);v-- >0;)(c.isOdd()||b.isOdd())&&(c.iadd(d),b.isub(w)),c.iushrn(1),b.iushrn(1);for(var W=0,S=1;!(a.words[0]&S)&&W<26;++W,S<<=1);if(W>0)for(a.iushrn(W);W-- >0;)(A.isOdd()||E.isOdd())&&(A.iadd(d),E.isub(w)),A.iushrn(1),E.iushrn(1);l.cmp(a)>=0?(l.isub(a),c.isub(A),b.isub(E)):(a.isub(l),A.isub(c),E.isub(b))}return{a:A,b:E,gcd:a.iushln(x)}},s.prototype._invmp=function(p){i(p.negative===0),i(!p.isZero());var l=this,a=p.clone();l.negative!==0?l=l.umod(p):l=l.clone();for(var c=new s(1),b=new s(0),A=a.clone();l.cmpn(1)>0&&a.cmpn(1)>0;){for(var E=0,x=1;!(l.words[0]&x)&&E<26;++E,x<<=1);if(E>0)for(l.iushrn(E);E-- >0;)c.isOdd()&&c.iadd(A),c.iushrn(1);for(var d=0,w=1;!(a.words[0]&w)&&d<26;++d,w<<=1);if(d>0)for(a.iushrn(d);d-- >0;)b.isOdd()&&b.iadd(A),b.iushrn(1);l.cmp(a)>=0?(l.isub(a),c.isub(b)):(a.isub(l),b.isub(c))}var v;return l.cmpn(1)===0?v=c:v=b,v.cmpn(0)<0&&v.iadd(p),v},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var l=this.clone(),a=p.clone();l.negative=0,a.negative=0;for(var c=0;l.isEven()&&a.isEven();c++)l.iushrn(1),a.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;a.isEven();)a.iushrn(1);var b=l.cmp(a);if(b<0){var A=l;l=a,a=A}else if(b===0||a.cmpn(1)===0)break;l.isub(a)}while(!0);return a.iushln(c)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){i(typeof p=="number");var l=p%26,a=(p-l)/26,c=1<<l;if(this.length<=a)return this._expand(a+1),this.words[a]|=c,this;for(var b=c,A=a;b!==0&&A<this.length;A++){var E=this.words[A]|0;E+=b,b=E>>>26,E&=67108863,this.words[A]=E}return b!==0&&(this.words[A]=b,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var l=p<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this.strip();var a;if(this.length>1)a=1;else{l&&(p=-p),i(p<=67108863,"Number is too big");var c=this.words[0]|0;a=c===p?0:c<p?-1:1}return this.negative!==0?-a|0:a},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var l=this.ucmp(p);return this.negative!==0?-l|0:l},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var l=0,a=this.length-1;a>=0;a--){var c=this.words[a]|0,b=p.words[a]|0;if(c!==b){c<b?l=-1:c>b&&(l=1);break}}return l},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new J(p)},s.prototype.toRed=function(p){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return i(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},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(p){return i(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var j={k256:null,p224:null,p192:null,p25519:null};function F(R,p){this.name=R,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},F.prototype.ireduce=function(p){var l=p,a;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),a=l.bitLength();while(a>this.n);var c=a<this.n?-1:l.ucmp(this.p);return c===0?(l.words[0]=0,l.length=1):c>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},F.prototype.split=function(p,l){p.iushrn(this.n,0,l)},F.prototype.imulK=function(p){return p.imul(this.k)};function U(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(U,F),U.prototype.split=function(p,l){for(var a=4194303,c=Math.min(p.length,9),b=0;b<c;b++)l.words[b]=p.words[b];if(l.length=c,p.length<=9){p.words[0]=0,p.length=1;return}var A=p.words[9];for(l.words[l.length++]=A&a,b=10;b<p.length;b++){var E=p.words[b]|0;p.words[b-10]=(E&a)<<4|A>>>22,A=E}A>>>=22,p.words[b-10]=A,A===0&&p.length>10?p.length-=10:p.length-=9},U.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var l=0,a=0;a<p.length;a++){var c=p.words[a]|0;l+=c*977,p.words[a]=l&67108863,l=c*64+(l/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(z,F);function _(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(_,F);function P(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(P,F),P.prototype.imulK=function(p){for(var l=0,a=0;a<p.length;a++){var c=(p.words[a]|0)*19+l,b=c&67108863;c>>>=26,p.words[a]=b,l=c}return l!==0&&(p.words[p.length++]=l),p},s._prime=function(p){if(j[p])return j[p];var l;if(p==="k256")l=new U;else if(p==="p224")l=new z;else if(p==="p192")l=new _;else if(p==="p25519")l=new P;else throw new Error("Unknown prime "+p);return j[p]=l,l};function J(R){if(typeof R=="string"){var p=s._prime(R);this.m=p.p,this.prime=p}else i(R.gtn(1),"modulus must be greater than 1"),this.m=R,this.prime=null}J.prototype._verify1=function(p){i(p.negative===0,"red works only with positives"),i(p.red,"red works only with red numbers")},J.prototype._verify2=function(p,l){i((p.negative|l.negative)===0,"red works only with positives"),i(p.red&&p.red===l.red,"red works only with red numbers")},J.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):p.umod(this.m)._forceRed(this)},J.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},J.prototype.add=function(p,l){this._verify2(p,l);var a=p.add(l);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},J.prototype.iadd=function(p,l){this._verify2(p,l);var a=p.iadd(l);return a.cmp(this.m)>=0&&a.isub(this.m),a},J.prototype.sub=function(p,l){this._verify2(p,l);var a=p.sub(l);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},J.prototype.isub=function(p,l){this._verify2(p,l);var a=p.isub(l);return a.cmpn(0)<0&&a.iadd(this.m),a},J.prototype.shl=function(p,l){return this._verify1(p),this.imod(p.ushln(l))},J.prototype.imul=function(p,l){return this._verify2(p,l),this.imod(p.imul(l))},J.prototype.mul=function(p,l){return this._verify2(p,l),this.imod(p.mul(l))},J.prototype.isqr=function(p){return this.imul(p,p.clone())},J.prototype.sqr=function(p){return this.mul(p,p)},J.prototype.sqrt=function(p){if(p.isZero())return p.clone();var l=this.m.andln(3);if(i(l%2===1),l===3){var a=this.m.add(new s(1)).iushrn(2);return this.pow(p,a)}for(var c=this.m.subn(1),b=0;!c.isZero()&&c.andln(1)===0;)b++,c.iushrn(1);i(!c.isZero());var A=new s(1).toRed(this),E=A.redNeg(),x=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,x).cmp(E)!==0;)d.redIAdd(E);for(var w=this.pow(d,c),v=this.pow(p,c.addn(1).iushrn(1)),O=this.pow(p,c),W=b;O.cmp(A)!==0;){for(var S=O,H=0;S.cmp(A)!==0;H++)S=S.redSqr();i(H<W);var C=this.pow(w,new s(1).iushln(W-H-1));v=v.redMul(C),w=C.redSqr(),O=O.redMul(w),W=H}return v},J.prototype.invm=function(p){var l=p._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},J.prototype.pow=function(p,l){if(l.isZero())return new s(1).toRed(this);if(l.cmpn(1)===0)return p.clone();var a=4,c=new Array(1<<a);c[0]=new s(1).toRed(this),c[1]=p;for(var b=2;b<c.length;b++)c[b]=this.mul(c[b-1],p);var A=c[0],E=0,x=0,d=l.bitLength()%26;for(d===0&&(d=26),b=l.length-1;b>=0;b--){for(var w=l.words[b],v=d-1;v>=0;v--){var O=w>>v&1;if(A!==c[0]&&(A=this.sqr(A)),O===0&&E===0){x=0;continue}E<<=1,E|=O,x++,!(x!==a&&(b!==0||v!==0))&&(A=this.mul(A,c[E]),x=0,E=0)}d=26}return A},J.prototype.convertTo=function(p){var l=p.umod(this.m);return l===p?l.clone():l},J.prototype.convertFrom=function(p){var l=p.clone();return l.red=null,l},s.mont=function(p){return new Q(p)};function Q(R){J.call(this,R),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(Q,J),Q.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},Q.prototype.convertFrom=function(p){var l=this.imod(p.mul(this.rinv));return l.red=null,l},Q.prototype.imul=function(p,l){if(p.isZero()||l.isZero())return p.words[0]=0,p.length=1,p;var a=p.imul(l),c=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=a.isub(c).iushrn(this.shift),A=b;return b.cmp(this.m)>=0?A=b.isub(this.m):b.cmpn(0)<0&&(A=b.iadd(this.m)),A._forceRed(this)},Q.prototype.mul=function(p,l){if(p.isZero()||l.isZero())return new s(0)._forceRed(this);var a=p.mul(l),c=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=a.isub(c).iushrn(this.shift),A=b;return b.cmp(this.m)>=0?A=b.isub(this.m):b.cmpn(0)<0&&(A=b.iadd(this.m)),A._forceRed(this)},Q.prototype.invm=function(p){var l=this.imod(p._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(r,Pt)})(Hr);var qo={};(function(r){var e=r;function t(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var f=[];if(typeof s!="string"){for(var u=0;u<s.length;u++)f[u]=s[u]|0;return f}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var u=0;u<s.length;u+=2)f.push(parseInt(s[u]+s[u+1],16))}else for(var u=0;u<s.length;u++){var h=s.charCodeAt(u),g=h>>8,m=h&255;g?f.push(g,m):f.push(m)}return f}e.toArray=t;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",f=0;f<s.length;f++)o+=i(s[f].toString(16));return o}e.toHex=n,e.encode=function(o,f){return f==="hex"?n(o):o}})(qo),function(r){var e=r,t=Hr.exports,i=$i,n=qo;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(g,m,I){var M=new Array(Math.max(g.bitLength(),I)+1),D;for(D=0;D<M.length;D+=1)M[D]=0;var N=1<<m+1,k=g.clone();for(D=0;D<M.length;D++){var K,B=k.andln(N-1);k.isOdd()?(B>(N>>1)-1?K=(N>>1)-B:K=B,k.isubn(K)):K=0,M[D]=K,k.iushrn(1)}return M}e.getNAF=s;function o(g,m){var I=[[],[]];g=g.clone(),m=m.clone();for(var M=0,D=0,N;g.cmpn(-M)>0||m.cmpn(-D)>0;){var k=g.andln(3)+M&3,K=m.andln(3)+D&3;k===3&&(k=-1),K===3&&(K=-1);var B;k&1?(N=g.andln(7)+M&7,(N===3||N===5)&&K===2?B=-k:B=k):B=0,I[0].push(B);var j;K&1?(N=m.andln(7)+D&7,(N===3||N===5)&&k===2?j=-K:j=K):j=0,I[1].push(j),2*M===B+1&&(M=1-M),2*D===j+1&&(D=1-D),g.iushrn(1),m.iushrn(1)}return I}e.getJSF=o;function f(g,m,I){var M="_"+m;g.prototype[m]=function(){return this[M]!==void 0?this[M]:this[M]=I.call(this)}}e.cachedProperty=f;function u(g){return typeof g=="string"?e.toArray(g,"hex"):g}e.parseBytes=u;function h(g){return new t(g,"hex","le")}e.intFromLE=h}(hr);var aa={exports:{}},Uo;aa.exports=function(e){return Uo||(Uo=new Mi(null)),Uo.generate(e)};function Mi(r){this.rand=r}if(aa.exports.Rand=Mi,Mi.prototype.generate=function(e){return this._rand(e)},Mi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t},typeof self=="object")self.crypto&&self.crypto.getRandomValues?Mi.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?Mi.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:typeof window=="object"&&(Mi.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var ou=qs;if(typeof ou.randomBytes!="function")throw new Error("Not supported");Mi.prototype._rand=function(e){return ou.randomBytes(e)}}catch{}var $o={},Ki=Hr.exports,Zn=hr,oa=Zn.getNAF,d3=Zn.getJSF,fa=Zn.assert;function Ii(r,e){this.type=r,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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var ca=Ii;Ii.prototype.point=function(){throw new Error("Not implemented")},Ii.prototype.validate=function(){throw new Error("Not implemented")},Ii.prototype._fixedNafMul=function(e,t){fa(e.precomputed);var i=e._getDoubles(),n=oa(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],f,u;for(f=0;f<n.length;f+=i.step){u=0;for(var h=f+i.step-1;h>=f;h--)u=(u<<1)+n[h];o.push(u)}for(var g=this.jpoint(null,null,null),m=this.jpoint(null,null,null),I=s;I>0;I--){for(f=0;f<o.length;f++)u=o[f],u===I?m=m.mixedAdd(i.points[f]):u===-I&&(m=m.mixedAdd(i.points[f].neg()));g=g.add(m)}return g.toP()},Ii.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=oa(t,i,this._bitLength),f=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var h=0;u>=0&&o[u]===0;u--)h++;if(u>=0&&h++,f=f.dblp(h),u<0)break;var g=o[u];fa(g!==0),e.type==="affine"?g>0?f=f.mixedAdd(s[g-1>>1]):f=f.mixedAdd(s[-g-1>>1].neg()):g>0?f=f.add(s[g-1>>1]):f=f.add(s[-g-1>>1].neg())}return e.type==="affine"?f.toP():f},Ii.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,h=0,g,m,I;for(g=0;g<n;g++){I=t[g];var M=I._getNAFPoints(e);o[g]=M.wnd,f[g]=M.points}for(g=n-1;g>=1;g-=2){var D=g-1,N=g;if(o[D]!==1||o[N]!==1){u[D]=oa(i[D],o[D],this._bitLength),u[N]=oa(i[N],o[N],this._bitLength),h=Math.max(u[D].length,h),h=Math.max(u[N].length,h);continue}var k=[t[D],null,null,t[N]];t[D].y.cmp(t[N].y)===0?(k[1]=t[D].add(t[N]),k[2]=t[D].toJ().mixedAdd(t[N].neg())):t[D].y.cmp(t[N].y.redNeg())===0?(k[1]=t[D].toJ().mixedAdd(t[N]),k[2]=t[D].add(t[N].neg())):(k[1]=t[D].toJ().mixedAdd(t[N]),k[2]=t[D].toJ().mixedAdd(t[N].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],B=d3(i[D],i[N]);for(h=Math.max(B[0].length,h),u[D]=new Array(h),u[N]=new Array(h),m=0;m<h;m++){var j=B[0][m]|0,F=B[1][m]|0;u[D][m]=K[(j+1)*3+(F+1)],u[N][m]=0,f[D]=k}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(g=h;g>=0;g--){for(var _=0;g>=0;){var P=!0;for(m=0;m<n;m++)z[m]=u[m][g]|0,z[m]!==0&&(P=!1);if(!P)break;_++,g--}if(g>=0&&_++,U=U.dblp(_),g<0)break;for(m=0;m<n;m++){var J=z[m];J!==0&&(J>0?I=f[m][J-1>>1]:J<0&&(I=f[m][-J-1>>1].neg()),I.type==="affine"?U=U.mixedAdd(I):U=U.add(I))}}for(g=0;g<n;g++)f[g]=null;return s?U:U.toP()};function vr(r,e){this.curve=r,this.type=e,this.precomputed=null}Ii.BasePoint=vr,vr.prototype.eq=function(){throw new Error("Not implemented")},vr.prototype.validate=function(){return this.curve.validate(this)},Ii.prototype.decodePoint=function(e,t){e=Zn.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?fa(e[e.length-1]%2===0):e[0]===7&&fa(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")},vr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},vr.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},vr.prototype.encode=function(e,t){return Zn.encode(this._encode(t),e)},vr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},vr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},vr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},vr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}},vr.prototype._getBeta=function(){return null},vr.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var l3=hr,pt=Hr.exports,zo=bn.exports,En=ca,p3=l3.assert;function mr(r){En.call(this,"short",r),this.a=new pt(r.a,16).toRed(this.red),this.b=new pt(r.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(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}zo(mr,En);var g3=mr;mr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new pt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new pt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],p3(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new pt(f.a,16),b:new pt(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}},mr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:pt.mont(e),i=new pt(2).toRed(t).redInvm(),n=i.redNeg(),s=new pt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]},mr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new pt(1),o=new pt(0),f=new pt(0),u=new pt(1),h,g,m,I,M,D,N,k=0,K,B;i.cmpn(0)!==0;){var j=n.div(i);K=n.sub(j.mul(i)),B=f.sub(j.mul(s));var F=u.sub(j.mul(o));if(!m&&K.cmp(t)<0)h=N.neg(),g=s,m=K.neg(),I=B;else if(m&&++k===2)break;N=K,n=i,i=K,f=s,s=B,u=o,o=F}M=K.neg(),D=B;var U=m.sqr().add(I.sqr()),z=M.sqr().add(D.sqr());return z.cmp(U)>=0&&(M=h,D=g),m.negative&&(m=m.neg(),I=I.neg()),M.negative&&(M=M.neg(),D=D.neg()),[{a:m,b:I},{a:M,b:D}]},mr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),h=s.mul(i.b),g=o.mul(n.b),m=e.sub(f).sub(u),I=h.add(g).neg();return{k1:m,k2:I}},mr.prototype.pointFromX=function(e,t){e=new pt(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(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},mr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},mr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var f=this._endoSplit(t[o]),u=e[o],h=u._getBeta();f.k1.negative&&(f.k1.ineg(),u=u.neg(!0)),f.k2.negative&&(f.k2.ineg(),h=h.neg(!0)),n[o*2]=u,n[o*2+1]=h,s[o*2]=f.k1,s[o*2+1]=f.k2}for(var g=this._wnafMulAdd(1,n,s,o*2,i),m=0;m<o*2;m++)n[m]=null,s[m]=null;return g};function St(r,e,t,i){En.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new pt(e,16),this.y=new pt(t,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)}zo(St,En.BasePoint),mr.prototype.point=function(e,t,i){return new St(this,e,t,i)},mr.prototype.pointFromJSON=function(e,t){return St.fromJSON(this,e,t)},St.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=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=t,t.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 t}},St.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]},St.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(f){return e.point(f[0],f[1],i)}var o=t[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},St.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)+">"},St.prototype.isInfinity=function(){return this.inf},St.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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},St.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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)},St.prototype.getX=function(){return this.x.fromRed()},St.prototype.getY=function(){return this.y.fromRed()},St.prototype.mul=function(e){return e=new pt(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)},St.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},St.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},St.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)},St.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.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 t},St.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 Tt(r,e,t,i){En.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(t,16),this.z=new pt(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}zo(Tt,En.BasePoint),mr.prototype.jpoint=function(e,t,i){return new Tt(this,e,t,i)},Tt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)},Tt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Tt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),h=o.redSub(f);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),m=g.redMul(u),I=n.redMul(g),M=h.redSqr().redIAdd(m).redISub(I).redISub(I),D=h.redMul(I.redISub(M)).redISub(o.redMul(m)),N=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(M,D,N)},Tt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),g=h.redMul(f),m=i.redMul(h),I=u.redSqr().redIAdd(g).redISub(m).redISub(m),M=u.redMul(m.redISub(I)).redISub(s.redMul(g)),D=this.z.redMul(f);return this.curve.jpoint(I,M,D)},Tt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,f=this.y,u=this.z,h=u.redSqr().redSqr(),g=f.redAdd(f);for(t=0;t<e;t++){var m=o.redSqr(),I=g.redSqr(),M=I.redSqr(),D=m.redAdd(m).redIAdd(m).redIAdd(n.redMul(h)),N=o.redMul(I),k=D.redSqr().redISub(N.redAdd(N)),K=N.redISub(k),B=D.redMul(K);B=B.redIAdd(B).redISub(M);var j=g.redMul(u);t+1<e&&(h=h.redMul(M)),o=k,u=j,g=B}return this.curve.jpoint(o,g.redMul(s),u)},Tt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Tt.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n),h=u.redSqr().redISub(f).redISub(f),g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),e=h,t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),I=this.y.redSqr(),M=I.redSqr(),D=this.x.redAdd(I).redSqr().redISub(m).redISub(M);D=D.redIAdd(D);var N=m.redAdd(m).redIAdd(m),k=N.redSqr(),K=M.redIAdd(M);K=K.redIAdd(K),K=K.redIAdd(K),e=k.redISub(D).redISub(D),t=N.redMul(D.redISub(e)).redISub(K),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)},Tt.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=u.redSqr().redISub(f).redISub(f);e=h;var g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),I=this.y.redSqr(),M=this.x.redMul(I),D=this.x.redSub(m).redMul(this.x.redAdd(m));D=D.redAdd(D).redIAdd(D);var N=M.redIAdd(M);N=N.redIAdd(N);var k=N.redAdd(N);e=D.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(I).redISub(m);var K=I.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),t=D.redMul(N.redISub(e)).redISub(K)}return this.curve.jpoint(e,t,i)},Tt.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),f=i.redSqr(),u=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=t.redAdd(t);h=h.redIAdd(h);var g=h.redMul(f),m=u.redSqr().redISub(g.redAdd(g)),I=g.redISub(m),M=f.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=u.redMul(I).redISub(M),N=i.redAdd(i).redMul(n);return this.curve.jpoint(m,D,N)},Tt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(o);var u=f.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var g=s.redIAdd(f).redSqr().redISub(o).redISub(u).redISub(h),m=t.redMul(g);m=m.redIAdd(m),m=m.redIAdd(m);var I=this.x.redMul(u).redISub(m);I=I.redIAdd(I),I=I.redIAdd(I);var M=this.y.redMul(g.redMul(h.redISub(g)).redISub(f.redMul(u)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=this.z.redAdd(f).redSqr().redISub(i).redISub(u);return this.curve.jpoint(I,M,D)},Tt.prototype.mul=function(e,t){return e=new pt(e,t),this.curve._wnafMul(this,e)},Tt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Tt.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){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}},Tt.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)+">"},Tt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Sn=Hr.exports,fu=bn.exports,ha=ca,b3=hr;function Mn(r){ha.call(this,"mont",r),this.a=new Sn(r.a,16).toRed(this.red),this.b=new Sn(r.b,16).toRed(this.red),this.i4=new Sn(4).toRed(this.red).redInvm(),this.two=new Sn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}fu(Mn,ha);var v3=Mn;Mn.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function Mt(r,e,t){ha.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Sn(e,16),this.z=new Sn(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}fu(Mt,ha.BasePoint),Mn.prototype.decodePoint=function(e,t){return this.point(b3.toArray(e,t),1)},Mn.prototype.point=function(e,t){return new Mt(this,e,t)},Mn.prototype.pointFromJSON=function(e){return Mt.fromJSON(this,e)},Mt.prototype.precompute=function(){},Mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Mt.fromJSON=function(e,t){return new Mt(e,t[0],t[1]||e.one)},Mt.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)+">"},Mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Mt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)},Mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.diffAdd=function(e,t){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),f=o.redMul(i),u=s.redMul(n),h=t.z.redMul(f.redAdd(u).redSqr()),g=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(h,g)},Mt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var m3=hr,ii=Hr.exports,cu=bn.exports,ua=ca,y3=m3.assert;function Vr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,ua.call(this,"edwards",r),this.a=new ii(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ii(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ii(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),y3(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}cu(Vr,ua);var w3=Vr;Vr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},Vr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},Vr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)},Vr.prototype.pointFromX=function(e,t){e=new ii(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()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)},Vr.prototype.pointFromY=function(e,t){e=new ii(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(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)},Vr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function ft(r,e,t,i,n){ua.BasePoint.call(this,r,"projective"),e===null&&t===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 ii(e,16),this.y=new ii(t,16),this.z=i?new ii(i,16):this.curve.one,this.t=n&&new ii(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()))))}cu(ft,ua.BasePoint),Vr.prototype.pointFromJSON=function(e){return ft.fromJSON(this,e)},Vr.prototype.point=function(e,t,i,n){return new ft(this,e,t,i,n)},ft.fromJSON=function(e,t){return new ft(e,t[0],t[1],t[2])},ft.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)+">"},ft.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ft.prototype._extDbl=function(){var e=this.x.redSqr(),t=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(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),h=s.redMul(f),g=o.redMul(u),m=s.redMul(u),I=f.redMul(o);return this.curve.point(h,g,I,m)},ft.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,h;if(this.curve.twisted){f=this.curve._mulA(t);var g=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(f.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(u=this.z.redSqr(),h=g.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(h),s=g.redMul(f.redSub(i)),o=g.redMul(h))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),h=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(h),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(h);return this.curve.point(n,s,o)},ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ft.prototype._extAdd=function(e){var t=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(t),f=s.redSub(n),u=s.redAdd(n),h=i.redAdd(t),g=o.redMul(f),m=u.redMul(h),I=o.redMul(h),M=f.redMul(u);return this.curve.point(g,m,M,I)},ft.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(f).redMul(h),m,I;return this.curve.twisted?(m=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),I=f.redMul(u)):(m=t.redMul(u).redMul(s.redSub(n)),I=this.curve._mulC(f).redMul(u)),this.curve.point(g,m,I)},ft.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ft.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ft.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)},ft.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)},ft.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},ft.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ft.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ft.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ft.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ft.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===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(t.redIAdd(n),this.x.cmp(t)===0)return!0}},ft.prototype.toP=ft.prototype.normalize,ft.prototype.mixedAdd=ft.prototype.add,function(r){var e=r;e.base=ca,e.short=g3,e.mont=v3,e.edwards=w3}($o);var da={},ko,hu;function _3(){return hu||(hu=1,ko={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"]]}}),ko}(function(r){var e=r,t=fr,i=$o,n=hr,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 f(h,g){Object.defineProperty(e,h,{configurable:!0,enumerable:!0,get:function(){var m=new o(g);return Object.defineProperty(e,h,{configurable:!0,enumerable:!0,value:m}),m}})}f("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:t.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("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:t.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("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:t.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("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:t.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"]}),f("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:t.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"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["9"]}),f("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:t.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=_3()}catch{u=void 0}f("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:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})})(da);var x3=fr,ji=qo,uu=$i;function Di(r){if(!(this instanceof Di))return new Di(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ji.toArray(r.entropy,r.entropyEnc||"hex"),t=ji.toArray(r.nonce,r.nonceEnc||"hex"),i=ji.toArray(r.pers,r.persEnc||"hex");uu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var A3=Di;Di.prototype._init=function(e,t,i){var n=e.concat(t).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},Di.prototype._hmac=function(){return new x3.hmac(this.hash,this.K)},Di.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.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())},Di.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=ji.toArray(e,t),i=ji.toArray(i,n),uu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Di.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ji.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++,ji.encode(o,t)};var E3=Hr.exports,S3=hr,Ko=S3.assert;function zt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var M3=zt;zt.fromPublic=function(e,t,i){return t instanceof zt?t:new zt(e,{pub:t,pubEnc:i})},zt.fromPrivate=function(e,t,i){return t instanceof zt?t:new zt(e,{priv:t,privEnc:i})},zt.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"}},zt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},zt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},zt.prototype._importPrivate=function(e,t){this.priv=new E3(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},zt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Ko(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Ko(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,t)},zt.prototype.derive=function(e){return e.validate()||Ko(e.validate(),"public point not validated"),e.mul(this.priv).getX()},zt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},zt.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)},zt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var la=Hr.exports,jo=hr,I3=jo.assert;function pa(r,e){if(r instanceof pa)return r;this._importDER(r,e)||(I3(r.r&&r.s,"Signature without r or s"),this.r=new la(r.r,16),this.s=new la(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var D3=pa;function O3(){this.place=0}function Ho(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function du(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}pa.prototype._importDER=function(e,t){e=jo.toArray(e,t);var i=new O3;if(e[i.place++]!==48)return!1;var n=Ho(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Ho(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 f=Ho(e,i);if(f===!1||e.length!==f+i.place||e[i.place]&128)return!1;var u=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;return this.r=new la(o),this.s=new la(u),this.recoveryParam=null,!0};function Vo(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}pa.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=du(t),i=du(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Vo(n,t.length),n=n.concat(t),n.push(2),Vo(n,i.length);var s=n.concat(i),o=[48];return Vo(o,s.length),o=o.concat(s),jo.encode(o,e)};var ni=Hr.exports,lu=A3,P3=hr,Go=da,R3=aa.exports,pu=P3.assert,Wo=M3,ga=D3;function yr(r){if(!(this instanceof yr))return new yr(r);typeof r=="string"&&(pu(Object.prototype.hasOwnProperty.call(Go,r),"Unknown curve "+r),r=Go[r]),r instanceof Go.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var N3=yr;yr.prototype.keyPair=function(e){return new Wo(this,e)},yr.prototype.keyFromPrivate=function(e,t){return Wo.fromPrivate(this,e,t)},yr.prototype.keyFromPublic=function(e,t){return Wo.fromPublic(this,e,t)},yr.prototype.genKeyPair=function(e){e||(e={});for(var t=new lu({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 ni(2));;){var s=new ni(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},yr.prototype._truncateToN=function(e,t,i){var n;if(ni.isBN(e)||typeof e=="number")e=new ni(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new ni(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new ni(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},yr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength);for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new lu({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new ni(1)),g=0;;g++){var m=n.k?n.k(g):new ni(u.generate(this.n.byteLength()));if(m=this._truncateToN(m,!0),!(m.cmpn(1)<=0||m.cmp(h)>=0)){var I=this.g.mul(m);if(!I.isInfinity()){var M=I.getX(),D=M.umod(this.n);if(D.cmpn(0)!==0){var N=m.invm(this.n).mul(D.mul(t.getPrivate()).iadd(e));if(N=N.umod(this.n),N.cmpn(0)!==0){var k=(I.getY().isOdd()?1:0)|(M.cmp(D)!==0?2:0);return n.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),k^=1),new ga({r:D,s:N,recoveryParam:k})}}}}}},yr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new ga(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),h=u.mul(e).umod(this.n),g=u.mul(o).umod(this.n),m;return this.curve._maxwellTrick?(m=this.g.jmulAdd(h,i.getPublic(),g),m.isInfinity()?!1:m.eqXToP(o)):(m=this.g.mulAdd(h,i.getPublic(),g),m.isInfinity()?!1:m.getX().umod(this.n).cmp(o)===0)},yr.prototype.recoverPubKey=function(r,e,t,i){pu((3&t)===t,"The recovery param is more than two bits"),e=new ga(e,i);var n=this.n,s=new ni(r),o=e.r,f=e.s,u=t&1,h=t>>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),u):o=this.curve.pointFromX(o,u);var g=e.r.invm(n),m=n.sub(s).mul(g).umod(n),I=f.mul(g).umod(n);return this.g.mulAdd(m,o,I)},yr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ga(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var es=hr,gu=es.assert,bu=es.parseBytes,In=es.cachedProperty;function It(r,e){this.eddsa=r,this._secret=bu(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=bu(e.pub)}It.fromPublic=function(e,t){return t instanceof It?t:new It(e,{pub:t})},It.fromSecret=function(e,t){return t instanceof It?t:new It(e,{secret:t})},It.prototype.secret=function(){return this._secret},In(It,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),In(It,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),In(It,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),In(It,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),In(It,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),In(It,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),It.prototype.sign=function(e){return gu(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},It.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},It.prototype.getSecret=function(e){return gu(this._secret,"KeyPair is public only"),es.encode(this.secret(),e)},It.prototype.getPublic=function(e){return es.encode(this.pubBytes(),e)};var C3=It,T3=Hr.exports,ba=hr,vu=ba.assert,va=ba.cachedProperty,F3=ba.parseBytes;function Hi(r,e){this.eddsa=r,typeof e!="object"&&(e=F3(e)),Array.isArray(e)&&(vu(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),vu(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof T3&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}va(Hi,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),va(Hi,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),va(Hi,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),va(Hi,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Hi.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Hi.prototype.toHex=function(){return ba.encode(this.toBytes(),"hex").toUpperCase()};var B3=Hi,L3=fr,q3=da,Dn=hr,U3=Dn.assert,mu=Dn.parseBytes,yu=C3,wu=B3;function er(r){if(U3(r==="ed25519","only tested with ed25519 so far"),!(this instanceof er))return new er(r);r=q3[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=L3.sha512}var $3=er;er.prototype.sign=function(e,t){e=mu(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})},er.prototype.verify=function(e,t,i){if(e=mu(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)},er.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return Dn.intFromLE(e.digest()).umod(this.curve.n)},er.prototype.keyFromPublic=function(e){return yu.fromPublic(this,e)},er.prototype.keyFromSecret=function(e){return yu.fromSecret(this,e)},er.prototype.makeSignature=function(e){return e instanceof wu?e:new wu(this,e)},er.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},er.prototype.decodePoint=function(e){e=Dn.parseBytes(e);var t=e.length-1,i=e.slice(0,t).concat(e[t]&-129),n=(e[t]&128)!==0,s=Dn.intFromLE(i);return this.curve.pointFromY(s,n)},er.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},er.prototype.decodeInt=function(e){return Dn.intFromLE(e)},er.prototype.isPoint=function(e){return e instanceof this.pointClass},function(r){var e=r;e.version=u3.version,e.utils=hr,e.rand=aa.exports,e.curve=$o,e.curves=da,e.ec=N3,e.eddsa=$3}(au);const z3={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"}},k3=":";function ma(r){const[e,t]=r.split(k3);return{namespace:e,reference:t}}function _u(r,e){return r.includes(":")?[r]:e.chains||[]}var K3=Object.defineProperty,xu=Object.getOwnPropertySymbols,j3=Object.prototype.hasOwnProperty,H3=Object.prototype.propertyIsEnumerable,Au=(r,e,t)=>e in r?K3(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Eu=(r,e)=>{for(var t in e||(e={}))j3.call(e,t)&&Au(r,t,e[t]);if(xu)for(var t of xu(e))H3.call(e,t)&&Au(r,t,e[t]);return r};const V3="ReactNative",ur={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},G3="js";function ya(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function On(){return!kn()&&!!oo()&&navigator.product===V3}function ts(){return!ya()&&!!oo()&&!!kn()}function rs(){return On()?ur.reactNative:ya()?ur.node:ts()?ur.browser:ur.unknown}function W3(){var r;try{return On()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function J3(r,e){let t=Kn.parse(r);return t=Eu(Eu({},t),e),r=Kn.stringify(t),r}function Su(){return Vc()||{name:"",description:"",url:"",icons:[""]}}function Y3(){if(rs()===ur.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:t,Version:i}=global.Platform;return[t,i].join("-")}const r=Kg();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function Q3(){var r;const e=rs();return e===ur.browser?[e,((r=Hc())==null?void 0:r.host)||"unknown"].join(":"):e}function Mu(r,e,t){const i=Y3(),n=Q3();return[[r,e].join("-"),[G3,t].join("-"),i,n].join("/")}function X3({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){const u=t.split("?"),h=Mu(r,e,i),g={auth:n,ua:h,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},m=J3(u[1]||"",g);return u[0]+"?"+m}function Vi(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Iu(r){return Object.fromEntries(r.entries())}function Du(r){return new Map(Object.entries(r))}function Gi(r=ae.FIVE_MINUTES,e){const t=ae.toMiliseconds(r||ae.FIVE_MINUTES);let i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Pn(r,e,t){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(t)),e);try{const o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Ou(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.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: ${r}`)}function Z3(r){return Ou("topic",r)}function em(r){return Ou("id",r)}function Pu(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function wt(r,e){return ae.fromMiliseconds((e||Date.now())+ae.toMiliseconds(r))}function Oi(r){return Date.now()>=ae.toMiliseconds(r)}function Ye(r,e){return`${r}${e?`:${e}`:""}`}function tm(r=[],e=[]){return[...new Set([...r,...e])]}async function rm({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;const o=im(s,r,e),f=rs();if(f===ur.browser){if(!((i=kn())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,sm()?"_blank":"_self","noreferrer noopener")}else f===ur.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function im(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${am(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function nm(r,e){let t="";try{if(ts()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Ru(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Nu(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Jo(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function sm(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function am(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Cu(r){return Buffer.from(r,"base64").toString("utf-8")}const om="https://rpc.walletconnect.org/v1";async function fm(r,e,t,i,n,s){switch(t.t){case"eip191":return cm(r,e,t.s);case"eip1271":return await hm(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function cm(r,e,t){return L2(xh(e),t).toLowerCase()===r.toLowerCase()}async function hm(r,e,t,i,n,s){const o=ma(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),m=xh(e).substring(2),I=f+m+u+h+g,M=await fetch(`${s||om}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:um(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:I},"latest"]})}),{result:D}=await M.json();return D?D.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function um(){return Date.now()+Math.floor(Math.random()*1e3)}var dm=Object.defineProperty,lm=Object.defineProperties,pm=Object.getOwnPropertyDescriptors,Tu=Object.getOwnPropertySymbols,gm=Object.prototype.hasOwnProperty,bm=Object.prototype.propertyIsEnumerable,Fu=(r,e,t)=>e in r?dm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vm=(r,e)=>{for(var t in e||(e={}))gm.call(e,t)&&Fu(r,t,e[t]);if(Tu)for(var t of Tu(e))bm.call(e,t)&&Fu(r,t,e[t]);return r},mm=(r,e)=>lm(r,pm(e));const ym="did:pkh:",Yo=r=>r?.split(":"),wm=r=>{const e=r&&Yo(r);if(e)return r.includes(ym)?e[3]:e[1]},Qo=r=>{const e=r&&Yo(r);if(e)return e[2]+":"+e[3]},wa=r=>{const e=r&&Yo(r);if(e)return e.pop()};async function Bu(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Lu(n,n.iss),o=wa(n.iss);return await fm(o,s,i,Qo(n.iss),t)}const Lu=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=wa(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${wm(e)}`,u=`Nonce: ${r.nonce}`,h=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,m=r.nbf?`Not Before: ${r.nbf}`:void 0,I=r.requestId?`Request ID: ${r.requestId}`:void 0,M=r.resources?`Resources:${r.resources.map(N=>`
|
23
|
-
- ${
|
24
|
-
`)};function _m(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function xm(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Wi(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);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 Am(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Em(e,t,i)}}}function Em(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function qu(r){return Wi(r),`urn:recap:${_m(r).replace(/=/g,"")}`}function is(r){const e=xm(r.replace("urn:recap:",""));return Wi(e),e}function Sm(r,e,t){const i=Am(r,e,t);return qu(i)}function Mm(r){return r&&r.includes("urn:recap:")}function Im(r,e){const t=is(r),i=is(e),n=Dm(t,i);return qu(n)}function Dm(r,e){Wi(r),Wi(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,u)=>f.localeCompare(u)).forEach(f=>{var u,h;i.att[n]=mm(vm({},i.att[n]),{[f]:((u=r.att[n])==null?void 0:u[f])||((h=e.att[n])==null?void 0:h[f])})})}),i}function Om(r="",e){Wi(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(f=>{const u=Object.keys(e.att[f]).map(m=>({ability:m.split("/")[0],action:m.split("/")[1]}));u.sort((m,I)=>m.action.localeCompare(I.action));const h={};u.forEach(m=>{h[m.ability]||(h[m.ability]=[]),h[m.ability].push(m.action)});const g=Object.keys(h).map(m=>(n++,`(${n}) '${m}': '${h[m].join("', '")}' for '${f}'.`));i.push(g.join(", ").replace(".,","."))});const s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Uu(r){var e;const t=is(r);Wi(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function $u(r){const e=is(r);Wi(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function _a(r){if(!r)return;const e=r?.[r.length-1];return Mm(e)?e:void 0}const zu="base10",Gt="base16",Pi="base64pad",ns="base64url",ss="utf8",ku=0,si=1,as=2,Pm=0,Ku=1,os=12,Xo=32;function Rm(){const r=Lo.generateKeyPair();return{privateKey:xt(r.secretKey,Gt),publicKey:xt(r.publicKey,Gt)}}function Zo(){const r=_i.randomBytes(Xo);return xt(r,Gt)}function Nm(r,e){const t=Lo.sharedKey(At(r,Gt),At(e,Gt),!0),i=new Y2(Xn.SHA256,t).expand(Xo);return xt(i,Gt)}function xa(r){const e=Xn.hash(At(r,Gt));return xt(e,Gt)}function ai(r){const e=Xn.hash(At(r,ss));return xt(e,Gt)}function ju(r){return At(`${r}`,zu)}function Ji(r){return Number(xt(r,zu))}function Cm(r){const e=ju(typeof r.type<"u"?r.type:ku);if(Ji(e)===si&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?At(r.senderPublicKey,Gt):void 0,i=typeof r.iv<"u"?At(r.iv,Gt):_i.randomBytes(os),n=new To.ChaCha20Poly1305(At(r.symKey,Gt)).seal(i,At(r.message,ss));return Hu({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Tm(r,e){const t=ju(as),i=_i.randomBytes(os),n=At(r,ss);return Hu({type:t,sealed:n,iv:i,encoding:e})}function Fm(r){const e=new To.ChaCha20Poly1305(At(r.symKey,Gt)),{sealed:t,iv:i}=fs({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return xt(n,ss)}function Bm(r,e){const{sealed:t}=fs({encoded:r,encoding:e});return xt(t,ss)}function Hu(r){const{encoding:e=Pi}=r;if(Ji(r.type)===as)return xt(Ks([r.type,r.sealed]),e);if(Ji(r.type)===si){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return xt(Ks([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return xt(Ks([r.type,r.iv,r.sealed]),e)}function fs(r){const{encoded:e,encoding:t=Pi}=r,i=At(e,t),n=i.slice(Pm,Ku),s=Ku;if(Ji(n)===si){const h=s+Xo,g=h+os,m=i.slice(s,h),I=i.slice(h,g),M=i.slice(g);return{type:n,sealed:M,iv:I,senderPublicKey:m}}if(Ji(n)===as){const h=i.slice(s),g=_i.randomBytes(os);return{type:n,sealed:h,iv:g}}const o=s+os,f=i.slice(s,o),u=i.slice(o);return{type:n,sealed:u,iv:f}}function Lm(r,e){const t=fs({encoded:r,encoding:e?.encoding});return Vu({type:Ji(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?xt(t.senderPublicKey,Gt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Vu(r){const e=r?.type||ku;if(e===si){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Gu(r){return r.type===si&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Wu(r){return r.type===as}function qm(r){return new au.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function Um(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function $m(r){return Buffer.from(Um(r),"base64")}function zm(r,e){const[t,i,n]=r.split("."),s=$m(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),u=`${t}.${i}`,h=new Xn.SHA256().update(Buffer.from(u)).digest(),g=qm(e),m=Buffer.from(h).toString("hex");if(!g.verify(m,{r:o,s:f}))throw new Error("Invalid signature");return ao(r).payload}const km="irn";function ef(r){return r?.relay||{protocol:km}}function cs(r){const e=z3[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var Km=Object.defineProperty,jm=Object.defineProperties,Hm=Object.getOwnPropertyDescriptors,Ju=Object.getOwnPropertySymbols,Vm=Object.prototype.hasOwnProperty,Gm=Object.prototype.propertyIsEnumerable,Yu=(r,e,t)=>e in r?Km(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Qu=(r,e)=>{for(var t in e||(e={}))Vm.call(e,t)&&Yu(r,t,e[t]);if(Ju)for(var t of Ju(e))Gm.call(e,t)&&Yu(r,t,e[t]);return r},Wm=(r,e)=>jm(r,Hm(e));function Jm(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Xu(r){if(!r.includes("wc:")){const u=Cu(r);u!=null&&u.includes("wc:")&&(r=u)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Kn.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:Ym(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:Jm(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function Ym(r){return r.startsWith("//")?r.substring(2):r}function Qm(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const s=t+e+n;r[n]&&(i[s]=r[n])}),i}function Zu(r){return`${r.protocol}:${r.topic}@${r.version}?`+Kn.stringify(Qu(Wm(Qu({symKey:r.symKey},Qm(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Aa(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Rn(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function Xm(r){const e=[];return Object.values(r).forEach(t=>{e.push(...Rn(t.accounts))}),e}function Zm(r,e){const t=[];return Object.values(r).forEach(i=>{Rn(i.accounts).includes(e)&&t.push(...i.methods)}),t}function ey(r,e){const t=[];return Object.values(r).forEach(i=>{Rn(i.accounts).includes(e)&&t.push(...i.events)}),t}function ty(r){const e={};return r?.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function e0(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=ty(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=tm(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const ry={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}},iy={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 ne(r,e){const{message:t,code:i}=iy[r];return{message:e?`${t} ${e}`:t,code:i}}function ct(r,e){const{message:t,code:i}=ry[r];return{message:e?`${t} ${e}`:t,code:i}}function hs(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ea(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function Wt(r){return typeof r>"u"}function mt(r,e){return e&&Wt(r)?!0:typeof r=="string"&&!!r.trim().length}function tf(r,e){return e&&Wt(r)?!0:typeof r=="number"&&!isNaN(r)}function ny(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let s=!0;return Vi(n,i)?(i.forEach(o=>{const{accounts:f,methods:u,events:h}=r.namespaces[o],g=Rn(f),m=t[o];(!Vi(_u(o,m),g)||!Vi(m.methods,u)||!Vi(m.events,h))&&(s=!1)}),s):!1}function Sa(r){return mt(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function sy(r){if(mt(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Sa(t)}}return!1}function ay(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(mt(r,!1)){if(e(r))return!0;const t=Cu(r);return e(t)}}catch{}return!1}function oy(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function fy(r){return r?.topic}function cy(r,e){let t=null;return mt(r?.publicKey,!1)||(t=ne("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function t0(r){let e=!0;return hs(r)?r.length&&(e=r.every(t=>mt(t,!1))):e=!1,e}function hy(r,e,t){let i=null;return hs(e)&&e.length?e.forEach(n=>{i||Sa(n)||(i=ct("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Sa(r)||(i=ct("UNSUPPORTED_CHAINS",`${t}, 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 uy(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;const o=hy(n,_u(n,s),`${e} ${t}`);o&&(i=o)}),i}function dy(r,e){let t=null;return hs(r)?r.forEach(i=>{t||sy(i)||(t=ct("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ct("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function ly(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=dy(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function py(r,e){let t=null;return t0(r?.methods)?t0(r?.events)||(t=ct("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ct("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function r0(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=py(i,`${e}, namespace`);n&&(t=n)}),t}function gy(r,e,t){let i=null;if(r&&Ea(r)){const n=r0(r,e);n&&(i=n);const s=uy(r,e,t);s&&(i=s)}else i=ne("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function rf(r,e){let t=null;if(r&&Ea(r)){const i=r0(r,e);i&&(t=i);const n=ly(r,e);n&&(t=n)}else t=ne("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function i0(r){return mt(r.protocol,!0)}function by(r,e){let t=!1;return e&&!r?t=!0:r&&hs(r)&&r.length&&r.forEach(i=>{t=i0(i)}),t}function vy(r){return typeof r=="number"}function tr(r){return typeof r<"u"&&typeof r!==null}function my(r){return!(!r||typeof r!="object"||!r.code||!tf(r.code,!1)||!r.message||!mt(r.message,!1))}function yy(r){return!(Wt(r)||!mt(r.method,!1))}function wy(r){return!(Wt(r)||Wt(r.result)&&Wt(r.error)||!tf(r.id,!1)||!mt(r.jsonrpc,!1))}function _y(r){return!(Wt(r)||!mt(r.name,!1))}function n0(r,e){return!(!Sa(e)||!Xm(r).includes(e))}function xy(r,e,t){return mt(t,!1)?Zm(r,e).includes(t):!1}function Ay(r,e,t){return mt(t,!1)?ey(r,e).includes(t):!1}function s0(r,e,t){let i=null;const n=Ey(r),s=Sy(e),o=Object.keys(n),f=Object.keys(s),u=a0(Object.keys(r)),h=a0(Object.keys(e)),g=u.filter(m=>!h.includes(m));return g.length&&(i=ne("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
25
|
-
Required: ${
|
26
|
-
Received: ${Object.keys(e).toString()}`)),
|
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=Nt: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],v=[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],F=[224,256,384,512],T=[128,256],O=["hex","buffer","arrayBuffer","array","digest"],$={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 N=function(x,B,U){return function(k){return new y(x,B,x).update(k)[U]()}},C=function(x,B,U){return function(k,K){return new y(x,B,K).update(k)[U]()}},L=function(x,B,U){return function(k,K,J,X){return f["cshake"+x].update(k,K,J,X)[U]()}},V=function(x,B,U){return function(k,K,J,X){return f["kmac"+x].update(k,K,J,X)[U]()}},z=function(x,B,U,k){for(var K=0;K<O.length;++K){var J=O[K];x[J]=B(U,k,J)}return x},H=function(x,B){var U=N(x,B,"hex");return U.create=function(){return new y(x,B,x)},U.update=function(k){return U.create().update(k)},z(U,N,x,B)},re=function(x,B){var U=C(x,B,"hex");return U.create=function(k){return new y(x,B,k)},U.update=function(k,K){return U.create(K).update(k)},z(U,C,x,B)},P=function(x,B){var U=$[x],k=L(x,B,"hex");return k.create=function(K,J,X){return!J&&!X?f["shake"+x].create(K):new y(x,B,K).bytepad([J,X],U)},k.update=function(K,J,X,G){return k.create(J,X,G).update(K)},z(k,L,x,B)},g=function(x,B){var U=$[x],k=V(x,B,"hex");return k.create=function(K,J,X){return new A(x,B,J).bytepad(["KMAC",X],U).bytepad([K],U)},k.update=function(K,J,X,G){return k.create(K,X,G).update(J)},z(k,V,x,B)},p=[{name:"keccak",padding:M,bits:F,createMethod:H},{name:"sha3",padding:I,bits:F,createMethod:H},{name:"shake",padding:l,bits:T,createMethod:re},{name:"cshake",padding:v,bits:T,createMethod:P},{name:"kmac",padding:v,bits:T,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 y(x,B,U){this.blocks=[],this.s=[],this.padding=B,this.outputBits=U,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=U>>5,this.extraBytes=(U&31)>>3;for(var k=0;k<50;++k)this.s[k]=0}y.prototype.update=function(x){if(this.finalized)throw new Error(r);var B,U=typeof x;if(U!=="string"){if(U==="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);B=!0}for(var k=this.blocks,K=this.byteCount,J=x.length,X=this.blockCount,G=0,ne=this.s,Q,ee;G<J;){if(this.reset)for(this.reset=!1,k[0]=this.block,Q=1;Q<X+1;++Q)k[Q]=0;if(B)for(Q=this.start;G<J&&Q<K;++G)k[Q>>2]|=x[G]<<S[Q++&3];else for(Q=this.start;G<J&&Q<K;++G)ee=x.charCodeAt(G),ee<128?k[Q>>2]|=ee<<S[Q++&3]:ee<2048?(k[Q>>2]|=(192|ee>>6)<<S[Q++&3],k[Q>>2]|=(128|ee&63)<<S[Q++&3]):ee<55296||ee>=57344?(k[Q>>2]|=(224|ee>>12)<<S[Q++&3],k[Q>>2]|=(128|ee>>6&63)<<S[Q++&3],k[Q>>2]|=(128|ee&63)<<S[Q++&3]):(ee=65536+((ee&1023)<<10|x.charCodeAt(++G)&1023),k[Q>>2]|=(240|ee>>18)<<S[Q++&3],k[Q>>2]|=(128|ee>>12&63)<<S[Q++&3],k[Q>>2]|=(128|ee>>6&63)<<S[Q++&3],k[Q>>2]|=(128|ee&63)<<S[Q++&3]);if(this.lastByteIndex=Q,Q>=K){for(this.start=Q-K,this.block=k[X],Q=0;Q<X;++Q)ne[Q]^=k[Q];j(ne),this.reset=!0}else this.start=Q}return this},y.prototype.encode=function(x,B){var U=x&255,k=1,K=[U];for(x=x>>8,U=x&255;U>0;)K.unshift(U),x=x>>8,U=x&255,++k;return B?K.push(k):K.unshift(k),this.update(K),K.length},y.prototype.encodeString=function(x){var B,U=typeof x;if(U!=="string"){if(U==="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);B=!0}var k=0,K=x.length;if(B)k=K;else for(var J=0;J<x.length;++J){var X=x.charCodeAt(J);X<128?k+=1:X<2048?k+=2:X<55296||X>=57344?k+=3:(X=65536+((X&1023)<<10|x.charCodeAt(++J)&1023),k+=4)}return k+=this.encode(k*8),this.update(x),k},y.prototype.bytepad=function(x,B){for(var U=this.encode(B),k=0;k<x.length;++k)U+=this.encodeString(x[k]);var K=B-U%B,J=[];return J.length=K,this.update(J),this},y.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var x=this.blocks,B=this.lastByteIndex,U=this.blockCount,k=this.s;if(x[B>>2]|=this.padding[B&3],this.lastByteIndex===this.byteCount)for(x[0]=x[U],B=1;B<U+1;++B)x[B]=0;for(x[U-1]|=2147483648,B=0;B<U;++B)k[B]^=x[B];j(k)}},y.prototype.toString=y.prototype.hex=function(){this.finalize();for(var x=this.blockCount,B=this.s,U=this.outputBlocks,k=this.extraBytes,K=0,J=0,X="",G;J<U;){for(K=0;K<x&&J<U;++K,++J)G=B[K],X+=h[G>>4&15]+h[G&15]+h[G>>12&15]+h[G>>8&15]+h[G>>20&15]+h[G>>16&15]+h[G>>28&15]+h[G>>24&15];J%x===0&&(j(B),K=0)}return k&&(G=B[K],X+=h[G>>4&15]+h[G&15],k>1&&(X+=h[G>>12&15]+h[G>>8&15]),k>2&&(X+=h[G>>20&15]+h[G>>16&15])),X},y.prototype.arrayBuffer=function(){this.finalize();var x=this.blockCount,B=this.s,U=this.outputBlocks,k=this.extraBytes,K=0,J=0,X=this.outputBits>>3,G;k?G=new ArrayBuffer(U+1<<2):G=new ArrayBuffer(X);for(var ne=new Uint32Array(G);J<U;){for(K=0;K<x&&J<U;++K,++J)ne[J]=B[K];J%x===0&&j(B)}return k&&(ne[K]=B[K],G=G.slice(0,X)),G},y.prototype.buffer=y.prototype.arrayBuffer,y.prototype.digest=y.prototype.array=function(){this.finalize();for(var x=this.blockCount,B=this.s,U=this.outputBlocks,k=this.extraBytes,K=0,J=0,X=[],G,ne;J<U;){for(K=0;K<x&&J<U;++K,++J)G=J<<2,ne=B[K],X[G]=ne&255,X[G+1]=ne>>8&255,X[G+2]=ne>>16&255,X[G+3]=ne>>24&255;J%x===0&&j(B)}return k&&(G=J<<2,ne=B[K],X[G]=ne&255,k>1&&(X[G+1]=ne>>8&255),k>2&&(X[G+2]=ne>>16&255)),X};function A(x,B,U){y.call(this,x,B,U)}A.prototype=new y,A.prototype.finalize=function(){return this.encode(this.outputBits,!0),y.prototype.finalize.call(this)};var j=function(x){var B,U,k,K,J,X,G,ne,Q,ee,qe,Ue,he,Pe,Re,ae,$e,Ne,ce,Fe,Te,oe,De,Ce,ie,Ve,He,pe,We,Be,de,Ge,Xe,se,Je,Ze,ge,ze,Oe,ue,ke,je,fe,Qe,et,be,tt,rt,le,Ke,Ae,ve,it,nt,ye,st,xe,Ye,ar,fr,cr,hr,wt;for(k=0;k<48;k+=2)K=x[0]^x[10]^x[20]^x[30]^x[40],J=x[1]^x[11]^x[21]^x[31]^x[41],X=x[2]^x[12]^x[22]^x[32]^x[42],G=x[3]^x[13]^x[23]^x[33]^x[43],ne=x[4]^x[14]^x[24]^x[34]^x[44],Q=x[5]^x[15]^x[25]^x[35]^x[45],ee=x[6]^x[16]^x[26]^x[36]^x[46],qe=x[7]^x[17]^x[27]^x[37]^x[47],Ue=x[8]^x[18]^x[28]^x[38]^x[48],he=x[9]^x[19]^x[29]^x[39]^x[49],B=Ue^(X<<1|G>>>31),U=he^(G<<1|X>>>31),x[0]^=B,x[1]^=U,x[10]^=B,x[11]^=U,x[20]^=B,x[21]^=U,x[30]^=B,x[31]^=U,x[40]^=B,x[41]^=U,B=K^(ne<<1|Q>>>31),U=J^(Q<<1|ne>>>31),x[2]^=B,x[3]^=U,x[12]^=B,x[13]^=U,x[22]^=B,x[23]^=U,x[32]^=B,x[33]^=U,x[42]^=B,x[43]^=U,B=X^(ee<<1|qe>>>31),U=G^(qe<<1|ee>>>31),x[4]^=B,x[5]^=U,x[14]^=B,x[15]^=U,x[24]^=B,x[25]^=U,x[34]^=B,x[35]^=U,x[44]^=B,x[45]^=U,B=ne^(Ue<<1|he>>>31),U=Q^(he<<1|Ue>>>31),x[6]^=B,x[7]^=U,x[16]^=B,x[17]^=U,x[26]^=B,x[27]^=U,x[36]^=B,x[37]^=U,x[46]^=B,x[47]^=U,B=ee^(K<<1|J>>>31),U=qe^(J<<1|K>>>31),x[8]^=B,x[9]^=U,x[18]^=B,x[19]^=U,x[28]^=B,x[29]^=U,x[38]^=B,x[39]^=U,x[48]^=B,x[49]^=U,Pe=x[0],Re=x[1],be=x[11]<<4|x[10]>>>28,tt=x[10]<<4|x[11]>>>28,pe=x[20]<<3|x[21]>>>29,We=x[21]<<3|x[20]>>>29,fr=x[31]<<9|x[30]>>>23,cr=x[30]<<9|x[31]>>>23,je=x[40]<<18|x[41]>>>14,fe=x[41]<<18|x[40]>>>14,se=x[2]<<1|x[3]>>>31,Je=x[3]<<1|x[2]>>>31,ae=x[13]<<12|x[12]>>>20,$e=x[12]<<12|x[13]>>>20,rt=x[22]<<10|x[23]>>>22,le=x[23]<<10|x[22]>>>22,Be=x[33]<<13|x[32]>>>19,de=x[32]<<13|x[33]>>>19,hr=x[42]<<2|x[43]>>>30,wt=x[43]<<2|x[42]>>>30,nt=x[5]<<30|x[4]>>>2,ye=x[4]<<30|x[5]>>>2,Ze=x[14]<<6|x[15]>>>26,ge=x[15]<<6|x[14]>>>26,Ne=x[25]<<11|x[24]>>>21,ce=x[24]<<11|x[25]>>>21,Ke=x[34]<<15|x[35]>>>17,Ae=x[35]<<15|x[34]>>>17,Ge=x[45]<<29|x[44]>>>3,Xe=x[44]<<29|x[45]>>>3,Ce=x[6]<<28|x[7]>>>4,ie=x[7]<<28|x[6]>>>4,st=x[17]<<23|x[16]>>>9,xe=x[16]<<23|x[17]>>>9,ze=x[26]<<25|x[27]>>>7,Oe=x[27]<<25|x[26]>>>7,Fe=x[36]<<21|x[37]>>>11,Te=x[37]<<21|x[36]>>>11,ve=x[47]<<24|x[46]>>>8,it=x[46]<<24|x[47]>>>8,Qe=x[8]<<27|x[9]>>>5,et=x[9]<<27|x[8]>>>5,Ve=x[18]<<20|x[19]>>>12,He=x[19]<<20|x[18]>>>12,Ye=x[29]<<7|x[28]>>>25,ar=x[28]<<7|x[29]>>>25,ue=x[38]<<8|x[39]>>>24,ke=x[39]<<8|x[38]>>>24,oe=x[48]<<14|x[49]>>>18,De=x[49]<<14|x[48]>>>18,x[0]=Pe^~ae&Ne,x[1]=Re^~$e&ce,x[10]=Ce^~Ve&pe,x[11]=ie^~He&We,x[20]=se^~Ze&ze,x[21]=Je^~ge&Oe,x[30]=Qe^~be&rt,x[31]=et^~tt&le,x[40]=nt^~st&Ye,x[41]=ye^~xe&ar,x[2]=ae^~Ne&Fe,x[3]=$e^~ce&Te,x[12]=Ve^~pe&Be,x[13]=He^~We&de,x[22]=Ze^~ze&ue,x[23]=ge^~Oe&ke,x[32]=be^~rt&Ke,x[33]=tt^~le&Ae,x[42]=st^~Ye&fr,x[43]=xe^~ar&cr,x[4]=Ne^~Fe&oe,x[5]=ce^~Te&De,x[14]=pe^~Be&Ge,x[15]=We^~de&Xe,x[24]=ze^~ue&je,x[25]=Oe^~ke&fe,x[34]=rt^~Ke&ve,x[35]=le^~Ae&it,x[44]=Ye^~fr&hr,x[45]=ar^~cr&wt,x[6]=Fe^~oe&Pe,x[7]=Te^~De&Re,x[16]=Be^~Ge&Ce,x[17]=de^~Xe&ie,x[26]=ue^~je&se,x[27]=ke^~fe&Je,x[36]=Ke^~ve&Qe,x[37]=Ae^~it&et,x[46]=fr^~hr&nt,x[47]=cr^~wt&ye,x[8]=oe^~Pe&ae,x[9]=De^~Re&$e,x[18]=Ge^~Ce&Ve,x[19]=Xe^~ie&He,x[28]=je^~se&Ze,x[29]=fe^~Je&ge,x[38]=ve^~Qe&be,x[39]=it^~et&tt,x[48]=hr^~nt&st,x[49]=wt^~ye&xe,x[0]^=D[k],x[1]^=D[k+1]};if(a)t.exports=f;else for(b=0;b<u.length;++b)n[u[b]]=f[u[b]]})()})(Du);var sm=Du.exports;function Ou(t){return"0x"+sm.keccak_256(xt(t))}const om="rlp/5.7.0";new Ee(om);const am="address/5.7.0",ys=new Ee(am);function Pu(t){ur(t,20)||ys.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=xt(Ou(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 fm=9007199254740991;function cm(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const of={};for(let t=0;t<10;t++)of[String(t)]=String(t);for(let t=0;t<26;t++)of[String.fromCharCode(65+t)]=String(10+t);const Ru=Math.floor(cm(fm));function hm(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>of[i]).join("");for(;e.length>=Ru;){let i=e.substring(0,Ru);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 um(t){let e=null;if(typeof t!="string"&&ys.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=Pu(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ys.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)!==hm(t)&&ys.throwArgumentError("bad icap checksum","address",t),e=im(t.substring(4));e.length<40;)e="0"+e;e=Pu("0x"+e)}else ys.throwArgumentError("invalid address","address",t);return e}const dm="properties/5.7.0";new Ee(dm);function ms(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}var dr={},Ie={},sn=$u;function $u(t,e){if(!t)throw new Error(e||"Assertion failed")}$u.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+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 lm=sn,pm=Tn.exports;Ie.inherits=pm;function gm(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function bm(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):gm(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=bm;function vm(t){for(var e="",r=0;r<t.length;r++)e+=Fu(t[r].toString(16));return e}Ie.toHex=vm;function Nu(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Ie.htonl=Nu;function ym(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=Nu(n)),r+=Tu(n.toString(16))}return r}Ie.toHex32=ym;function Fu(t){return t.length===1?"0"+t:t}Ie.zero2=Fu;function Tu(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=Tu;function mm(t,e,r,i){var n=r-e;lm(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=mm;function wm(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=wm;function _m(t,e){return t>>>e|t<<32-e}Ie.rotr32=_m;function xm(t,e){return t<<e|t>>>32-e}Ie.rotl32=xm;function Em(t,e){return t+e>>>0}Ie.sum32=Em;function Sm(t,e,r){return t+e+r>>>0}Ie.sum32_3=Sm;function Mm(t,e,r,i){return t+e+r+i>>>0}Ie.sum32_4=Mm;function Im(t,e,r,i,n){return t+e+r+i+n>>>0}Ie.sum32_5=Im;function Am(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=Am;function Dm(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}Ie.sum64_hi=Dm;function Om(t,e,r,i){var n=e+i;return n>>>0}Ie.sum64_lo=Om;function Pm(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}Ie.sum64_4_hi=Pm;function Rm(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}Ie.sum64_4_lo=Rm;function $m(t,e,r,i,n,s,o,a,c,h){var l=0,v=e;v=v+i>>>0,l+=v<e?1:0,v=v+s>>>0,l+=v<s?1:0,v=v+a>>>0,l+=v<a?1:0,v=v+h>>>0,l+=v<h?1:0;var M=t+r+n+o+c+l;return M>>>0}Ie.sum64_5_hi=$m;function Nm(t,e,r,i,n,s,o,a,c,h){var l=e+i+s+a+h;return l>>>0}Ie.sum64_5_lo=Nm;function Fm(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}Ie.rotr64_hi=Fm;function Tm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Ie.rotr64_lo=Tm;function Cm(t,e,r){return t>>>r}Ie.shr64_hi=Cm;function Bm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Ie.shr64_lo=Bm;var Cn={},Cu=Ie,Lm=sn;function mo(){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}Cn.BlockHash=mo,mo.prototype.update=function(e,r){if(e=Cu.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=Cu.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},mo.prototype.digest=function(e){return this.update(this._pad()),Lm(this.pending===null),this._digest(e)},mo.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 Bn={},Hr={},qm=Ie,Wr=qm.rotr32;function Um(t,e,r,i){if(t===0)return Bu(e,r,i);if(t===1||t===3)return qu(e,r,i);if(t===2)return Lu(e,r,i)}Hr.ft_1=Um;function Bu(t,e,r){return t&e^~t&r}Hr.ch32=Bu;function Lu(t,e,r){return t&e^t&r^e&r}Hr.maj32=Lu;function qu(t,e,r){return t^e^r}Hr.p32=qu;function zm(t){return Wr(t,2)^Wr(t,13)^Wr(t,22)}Hr.s0_256=zm;function km(t){return Wr(t,6)^Wr(t,11)^Wr(t,25)}Hr.s1_256=km;function jm(t){return Wr(t,7)^Wr(t,18)^t>>>3}Hr.g0_256=jm;function Km(t){return Wr(t,17)^Wr(t,19)^t>>>10}Hr.g1_256=Km;var Ln=Ie,Vm=Cn,Hm=Hr,af=Ln.rotl32,ws=Ln.sum32,Wm=Ln.sum32_5,Gm=Hm.ft_1,Uu=Vm.BlockHash,Jm=[1518500249,1859775393,2400959708,3395469782];function Gr(){if(!(this instanceof Gr))return new Gr;Uu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ln.inherits(Gr,Uu);var Ym=Gr;Gr.blockSize=512,Gr.outSize=160,Gr.hmacStrength=80,Gr.padLength=64,Gr.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]=af(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),v=Wm(af(s,5),Gm(l,o,a,c),h,i[n],Jm[l]);h=c,c=a,a=af(o,30),o=s,s=v}this.h[0]=ws(this.h[0],s),this.h[1]=ws(this.h[1],o),this.h[2]=ws(this.h[2],a),this.h[3]=ws(this.h[3],c),this.h[4]=ws(this.h[4],h)},Gr.prototype._digest=function(e){return e==="hex"?Ln.toHex32(this.h,"big"):Ln.split32(this.h,"big")};var qn=Ie,Xm=Cn,Un=Hr,Zm=sn,Tr=qn.sum32,Qm=qn.sum32_4,e2=qn.sum32_5,t2=Un.ch32,r2=Un.maj32,i2=Un.s0_256,n2=Un.s1_256,s2=Un.g0_256,o2=Un.g1_256,zu=Xm.BlockHash,a2=[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 Jr(){if(!(this instanceof Jr))return new Jr;zu.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=a2,this.W=new Array(64)}qn.inherits(Jr,zu);var ku=Jr;Jr.blockSize=512,Jr.outSize=256,Jr.hmacStrength=192,Jr.padLength=64,Jr.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]=Qm(o2(i[n-2]),i[n-7],s2(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],v=this.h[6],M=this.h[7];for(Zm(this.k.length===i.length),n=0;n<i.length;n++){var I=e2(M,n2(h),t2(h,l,v),this.k[n],i[n]),S=Tr(i2(s),r2(s,o,a));M=v,v=l,l=h,h=Tr(c,I),c=a,a=o,o=s,s=Tr(I,S)}this.h[0]=Tr(this.h[0],s),this.h[1]=Tr(this.h[1],o),this.h[2]=Tr(this.h[2],a),this.h[3]=Tr(this.h[3],c),this.h[4]=Tr(this.h[4],h),this.h[5]=Tr(this.h[5],l),this.h[6]=Tr(this.h[6],v),this.h[7]=Tr(this.h[7],M)},Jr.prototype._digest=function(e){return e==="hex"?qn.toHex32(this.h,"big"):qn.split32(this.h,"big")};var ff=Ie,ju=ku;function di(){if(!(this instanceof di))return new di;ju.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}ff.inherits(di,ju);var f2=di;di.blockSize=512,di.outSize=224,di.hmacStrength=192,di.padLength=64,di.prototype._digest=function(e){return e==="hex"?ff.toHex32(this.h.slice(0,7),"big"):ff.split32(this.h.slice(0,7),"big")};var nr=Ie,c2=Cn,h2=sn,Yr=nr.rotr64_hi,Xr=nr.rotr64_lo,Ku=nr.shr64_hi,Vu=nr.shr64_lo,Ci=nr.sum64,cf=nr.sum64_hi,hf=nr.sum64_lo,u2=nr.sum64_4_hi,d2=nr.sum64_4_lo,l2=nr.sum64_5_hi,p2=nr.sum64_5_lo,Hu=c2.BlockHash,g2=[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 Cr(){if(!(this instanceof Cr))return new Cr;Hu.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=g2,this.W=new Array(160)}nr.inherits(Cr,Hu);var Wu=Cr;Cr.blockSize=1024,Cr.outSize=512,Cr.hmacStrength=192,Cr.padLength=128,Cr.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=I2(i[n-4],i[n-3]),o=A2(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],h=S2(i[n-30],i[n-29]),l=M2(i[n-30],i[n-29]),v=i[n-32],M=i[n-31];i[n]=u2(s,o,a,c,h,l,v,M),i[n+1]=d2(s,o,a,c,h,l,v,M)}},Cr.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],v=this.h[7],M=this.h[8],I=this.h[9],S=this.h[10],D=this.h[11],F=this.h[12],T=this.h[13],O=this.h[14],$=this.h[15];h2(this.k.length===i.length);for(var N=0;N<i.length;N+=2){var C=O,L=$,V=x2(M,I),z=E2(M,I),H=b2(M,I,S,D,F),re=v2(M,I,S,D,F,T),P=this.k[N],g=this.k[N+1],p=i[N],f=i[N+1],u=l2(C,L,V,z,H,re,P,g,p,f),b=p2(C,L,V,z,H,re,P,g,p,f);C=w2(n,s),L=_2(n,s),V=y2(n,s,o,a,c),z=m2(n,s,o,a,c,h);var _=cf(C,L,V,z),E=hf(C,L,V,z);O=F,$=T,F=S,T=D,S=M,D=I,M=cf(l,v,u,b),I=hf(v,v,u,b),l=c,v=h,c=o,h=a,o=n,a=s,n=cf(u,b,_,E),s=hf(u,b,_,E)}Ci(this.h,0,n,s),Ci(this.h,2,o,a),Ci(this.h,4,c,h),Ci(this.h,6,l,v),Ci(this.h,8,M,I),Ci(this.h,10,S,D),Ci(this.h,12,F,T),Ci(this.h,14,O,$)},Cr.prototype._digest=function(e){return e==="hex"?nr.toHex32(this.h,"big"):nr.split32(this.h,"big")};function b2(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function v2(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function y2(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function m2(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function w2(t,e){var r=Yr(t,e,28),i=Yr(e,t,2),n=Yr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function _2(t,e){var r=Xr(t,e,28),i=Xr(e,t,2),n=Xr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function x2(t,e){var r=Yr(t,e,14),i=Yr(t,e,18),n=Yr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function E2(t,e){var r=Xr(t,e,14),i=Xr(t,e,18),n=Xr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function S2(t,e){var r=Yr(t,e,1),i=Yr(t,e,8),n=Ku(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function M2(t,e){var r=Xr(t,e,1),i=Xr(t,e,8),n=Vu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function I2(t,e){var r=Yr(t,e,19),i=Yr(e,t,29),n=Ku(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function A2(t,e){var r=Xr(t,e,19),i=Xr(e,t,29),n=Vu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var uf=Ie,Gu=Wu;function li(){if(!(this instanceof li))return new li;Gu.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}uf.inherits(li,Gu);var D2=li;li.blockSize=1024,li.outSize=384,li.hmacStrength=192,li.padLength=128,li.prototype._digest=function(e){return e==="hex"?uf.toHex32(this.h.slice(0,12),"big"):uf.split32(this.h.slice(0,12),"big")},Bn.sha1=Ym,Bn.sha224=f2,Bn.sha256=ku,Bn.sha384=D2,Bn.sha512=Wu;var Ju={},on=Ie,O2=Cn,wo=on.rotl32,Yu=on.sum32,_s=on.sum32_3,Xu=on.sum32_4,Zu=O2.BlockHash;function Zr(){if(!(this instanceof Zr))return new Zr;Zu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}on.inherits(Zr,Zu),Ju.ripemd160=Zr,Zr.blockSize=512,Zr.outSize=160,Zr.hmacStrength=192,Zr.padLength=64,Zr.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,v=o,M=a,I=0;I<80;I++){var S=Yu(wo(Xu(i,Qu(I,n,s,o),e[$2[I]+r],P2(I)),F2[I]),a);i=a,a=o,o=wo(s,10),s=n,n=S,S=Yu(wo(Xu(c,Qu(79-I,h,l,v),e[N2[I]+r],R2(I)),T2[I]),M),c=M,M=v,v=wo(l,10),l=h,h=S}S=_s(this.h[1],s,v),this.h[1]=_s(this.h[2],o,M),this.h[2]=_s(this.h[3],a,c),this.h[3]=_s(this.h[4],i,h),this.h[4]=_s(this.h[0],n,l),this.h[0]=S},Zr.prototype._digest=function(e){return e==="hex"?on.toHex32(this.h,"little"):on.split32(this.h,"little")};function Qu(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 P2(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function R2(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var $2=[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],N2=[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],F2=[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],T2=[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],C2=Ie,B2=sn;function zn(t,e,r){if(!(this instanceof zn))return new zn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(C2.toArray(e,r))}var L2=zn;zn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),B2(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)},zn.prototype.update=function(e,r){return this.inner.update(e,r),this},zn.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=Cn,e.sha=Bn,e.ripemd=Ju,e.hmac=L2,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}(dr);function kn(t,e,r){return r={path:e,exports:{},require:function(i,n){return q2(i,n??r.path)}},t(r,r.exports),r.exports}function q2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var df=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 Br=kn(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),v=l>>8,M=l&255;v?c.push(v,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}}),lr=kn(function(t,e){var r=e;r.assert=df,r.toArray=Br.toArray,r.zero2=Br.zero2,r.toHex=Br.toHex,r.encode=Br.encode;function i(c,h,l){var v=new Array(Math.max(c.bitLength(),l)+1);v.fill(0);for(var M=1<<h+1,I=c.clone(),S=0;S<v.length;S++){var D,F=I.andln(M-1);I.isOdd()?(F>(M>>1)-1?D=(M>>1)-F:D=F,I.isubn(D)):D=0,v[S]=D,I.iushrn(1)}return v}r.getNAF=i;function n(c,h){var l=[[],[]];c=c.clone(),h=h.clone();for(var v=0,M=0,I;c.cmpn(-v)>0||h.cmpn(-M)>0;){var S=c.andln(3)+v&3,D=h.andln(3)+M&3;S===3&&(S=-1),D===3&&(D=-1);var F;S&1?(I=c.andln(7)+v&7,(I===3||I===5)&&D===2?F=-S:F=S):F=0,l[0].push(F);var T;D&1?(I=h.andln(7)+M&7,(I===3||I===5)&&S===2?T=-D:T=D):T=0,l[1].push(T),2*v===F+1&&(v=1-v),2*M===T+1&&(M=1-M),c.iushrn(1),h.iushrn(1)}return l}r.getJSF=n;function s(c,h,l){var v="_"+h;c.prototype[h]=function(){return this[v]!==void 0?this[v]:this[v]=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 me(c,"hex","le")}r.intFromLE=a}),_o=lr.getNAF,U2=lr.getJSF,xo=lr.assert;function Bi(t,e){this.type=t,this.p=new me(e.p,16),this.red=e.prime?me.red(e.prime):me.mont(this.p),this.zero=new me(0).toRed(this.red),this.one=new me(1).toRed(this.red),this.two=new me(2).toRed(this.red),this.n=e.n&&new me(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 an=Bi;Bi.prototype.point=function(){throw new Error("Not implemented")},Bi.prototype.validate=function(){throw new Error("Not implemented")},Bi.prototype._fixedNafMul=function(e,r){xo(e.precomputed);var i=e._getDoubles(),n=_o(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),v=this.jpoint(null,null,null),M=s;M>0;M--){for(a=0;a<o.length;a++)c=o[a],c===M?v=v.mixedAdd(i.points[a]):c===-M&&(v=v.mixedAdd(i.points[a].neg()));l=l.add(v)}return l.toP()},Bi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=_o(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];xo(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},Bi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,h=0,l,v,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]=_o(i[S],o[S],this._bitLength),c[D]=_o(i[D],o[D],this._bitLength),h=Math.max(c[S].length,h),h=Math.max(c[D].length,h);continue}var F=[r[S],null,null,r[D]];r[S].y.cmp(r[D].y)===0?(F[1]=r[S].add(r[D]),F[2]=r[S].toJ().mixedAdd(r[D].neg())):r[S].y.cmp(r[D].y.redNeg())===0?(F[1]=r[S].toJ().mixedAdd(r[D]),F[2]=r[S].add(r[D].neg())):(F[1]=r[S].toJ().mixedAdd(r[D]),F[2]=r[S].toJ().mixedAdd(r[D].neg()));var T=[-3,-1,-5,-7,0,7,5,1,3],O=U2(i[S],i[D]);for(h=Math.max(O[0].length,h),c[S]=new Array(h),c[D]=new Array(h),v=0;v<h;v++){var $=O[0][v]|0,N=O[1][v]|0;c[S][v]=T[($+1)*3+(N+1)],c[D][v]=0,a[S]=F}}var C=this.jpoint(null,null,null),L=this._wnafT4;for(l=h;l>=0;l--){for(var V=0;l>=0;){var z=!0;for(v=0;v<n;v++)L[v]=c[v][l]|0,L[v]!==0&&(z=!1);if(!z)break;V++,l--}if(l>=0&&V++,C=C.dblp(V),l<0)break;for(v=0;v<n;v++){var H=L[v];H!==0&&(H>0?M=a[v][H-1>>1]:H<0&&(M=a[v][-H-1>>1].neg()),M.type==="affine"?C=C.mixedAdd(M):C=C.add(M))}}for(l=0;l<n;l++)a[l]=null;return s?C:C.toP()};function wr(t,e){this.curve=t,this.type=e,this.precomputed=null}Bi.BasePoint=wr,wr.prototype.eq=function(){throw new Error("Not implemented")},wr.prototype.validate=function(){return this.curve.validate(this)},Bi.prototype.decodePoint=function(e,r){e=lr.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?xo(e[e.length-1]%2===0):e[0]===7&&xo(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")},wr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},wr.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))},wr.prototype.encode=function(e,r){return lr.encode(this._encode(r),e)},wr.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},wr.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},wr.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}},wr.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}},wr.prototype._getBeta=function(){return null},wr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var lf=kn(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}}}),z2=lr.assert;function _r(t){an.call(this,"short",t),this.a=new me(t.a,16).toRed(this.red),this.b=new me(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)}lf(_r,an);var k2=_r;_r.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new me(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 me(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],z2(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 me(a.a,16),b:new me(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},_r.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:me.mont(e),i=new me(2).toRed(r).redInvm(),n=i.redNeg(),s=new me(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},_r.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new me(1),o=new me(0),a=new me(0),c=new me(1),h,l,v,M,I,S,D,F=0,T,O;i.cmpn(0)!==0;){var $=n.div(i);T=n.sub($.mul(i)),O=a.sub($.mul(s));var N=c.sub($.mul(o));if(!v&&T.cmp(r)<0)h=D.neg(),l=s,v=T.neg(),M=O;else if(v&&++F===2)break;D=T,n=i,i=T,a=s,s=O,c=o,o=N}I=T.neg(),S=O;var C=v.sqr().add(M.sqr()),L=I.sqr().add(S.sqr());return L.cmp(C)>=0&&(I=h,S=l),v.negative&&(v=v.neg(),M=M.neg()),I.negative&&(I=I.neg(),S=S.neg()),[{a:v,b:M},{a:I,b:S}]},_r.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),v=e.sub(a).sub(c),M=h.add(l).neg();return{k1:v,k2:M}},_r.prototype.pointFromX=function(e,r){e=new me(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)},_r.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},_r.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),v=0;v<o*2;v++)n[v]=null,s[v]=null;return l};function It(t,e,r,i){an.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new me(e,16),this.y=new me(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)}lf(It,an.BasePoint),_r.prototype.point=function(e,r,i){return new It(this,e,r,i)},_r.prototype.pointFromJSON=function(e,r){return It.fromJSON(this,e,r)},It.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}},It.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]},It.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},It.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)+">"},It.prototype.isInfinity=function(){return this.inf},It.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)},It.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)},It.prototype.getX=function(){return this.x.fromRed()},It.prototype.getY=function(){return this.y.fromRed()},It.prototype.mul=function(e){return e=new me(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)},It.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)},It.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)},It.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)},It.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},It.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 Ct(t,e,r,i){an.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new me(0)):(this.x=new me(e,16),this.y=new me(r,16),this.z=new me(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}lf(Ct,an.BasePoint),_r.prototype.jpoint=function(e,r,i){return new Ct(this,e,r,i)},Ct.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)},Ct.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ct.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(),v=l.redMul(c),M=n.redMul(l),I=h.redSqr().redIAdd(v).redISub(M).redISub(M),S=h.redMul(M.redISub(I)).redISub(o.redMul(v)),D=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,S,D)},Ct.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),v=i.redMul(h),M=c.redSqr().redIAdd(l).redISub(v).redISub(v),I=c.redMul(v.redISub(M)).redISub(s.redMul(l)),S=this.z.redMul(a);return this.curve.jpoint(M,I,S)},Ct.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 v=o.redSqr(),M=l.redSqr(),I=M.redSqr(),S=v.redAdd(v).redIAdd(v).redIAdd(n.redMul(h)),D=o.redMul(M),F=S.redSqr().redISub(D.redAdd(D)),T=D.redISub(F),O=S.redMul(T);O=O.redIAdd(O).redISub(I);var $=l.redMul(c);r+1<e&&(h=h.redMul(I)),o=F,c=$,l=O}return this.curve.jpoint(o,l.redMul(s),c)},Ct.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Ct.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 v=this.x.redSqr(),M=this.y.redSqr(),I=M.redSqr(),S=this.x.redAdd(M).redSqr().redISub(v).redISub(I);S=S.redIAdd(S);var D=v.redAdd(v).redIAdd(v),F=D.redSqr(),T=I.redIAdd(I);T=T.redIAdd(T),T=T.redIAdd(T),e=F.redISub(S).redISub(S),r=D.redMul(S.redISub(e)).redISub(T),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Ct.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 v=this.z.redSqr(),M=this.y.redSqr(),I=this.x.redMul(M),S=this.x.redSub(v).redMul(this.x.redAdd(v));S=S.redAdd(S).redIAdd(S);var D=I.redIAdd(I);D=D.redIAdd(D);var F=D.redAdd(D);e=S.redSqr().redISub(F),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(v);var T=M.redSqr();T=T.redIAdd(T),T=T.redIAdd(T),T=T.redIAdd(T),r=S.redMul(D.redISub(e)).redISub(T)}return this.curve.jpoint(e,r,i)},Ct.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),v=c.redSqr().redISub(l.redAdd(l)),M=l.redISub(v),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(v,S,D)},Ct.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),v=r.redMul(l);v=v.redIAdd(v),v=v.redIAdd(v);var M=this.x.redMul(c).redISub(v);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)},Ct.prototype.mul=function(e,r){return e=new me(e,r),this.curve._wnafMul(this,e)},Ct.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},Ct.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}},Ct.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)+">"},Ct.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Eo=kn(function(t,e){var r=e;r.base=an,r.short=k2,r.mont=null,r.edwards=null}),So=kn(function(t,e){var r=e,i=lr.assert;function n(a){a.type==="short"?this.curve=new Eo.short(a):a.type==="edwards"?this.curve=new Eo.edwards(a):this.curve=new Eo.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:dr.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:dr.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:dr.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:dr.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:dr.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:dr.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:dr.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:dr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Li(t){if(!(this instanceof Li))return new Li(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=Br.toArray(t.entropy,t.entropyEnc||"hex"),r=Br.toArray(t.nonce,t.nonceEnc||"hex"),i=Br.toArray(t.pers,t.persEnc||"hex");df(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var td=Li;Li.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},Li.prototype._hmac=function(){return new dr.hmac(this.hash,this.K)},Li.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())},Li.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=Br.toArray(e,r),i=Br.toArray(i,n),df(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Li.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=Br.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++,Br.encode(o,r)};var pf=lr.assert;function Kt(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 gf=Kt;Kt.fromPublic=function(e,r,i){return r instanceof Kt?r:new Kt(e,{pub:r,pubEnc:i})},Kt.fromPrivate=function(e,r,i){return r instanceof Kt?r:new Kt(e,{priv:r,privEnc:i})},Kt.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"}},Kt.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},Kt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Kt.prototype._importPrivate=function(e,r){this.priv=new me(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Kt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?pf(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&pf(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)},Kt.prototype.derive=function(e){return e.validate()||pf(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Kt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Kt.prototype.verify=function(e,r){return this.ec.verify(e,r,this)},Kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var j2=lr.assert;function Mo(t,e){if(t instanceof Mo)return t;this._importDER(t,e)||(j2(t.r&&t.s,"Signature without r or s"),this.r=new me(t.r,16),this.s=new me(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Io=Mo;function K2(){this.place=0}function bf(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 rd(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)}Mo.prototype._importDER=function(e,r){e=lr.toArray(e,r);var i=new K2;if(e[i.place++]!==48)return!1;var n=bf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=bf(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=bf(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 me(o),this.s=new me(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)}Mo.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=rd(r),i=rd(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),lr.encode(o,e)};var V2=function(){throw new Error("unsupported")},id=lr.assert;function xr(t){if(!(this instanceof xr))return new xr(t);typeof t=="string"&&(id(Object.prototype.hasOwnProperty.call(So,t),"Unknown curve "+t),t=So[t]),t instanceof So.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 H2=xr;xr.prototype.keyPair=function(e){return new gf(this,e)},xr.prototype.keyFromPrivate=function(e,r){return gf.fromPrivate(this,e,r)},xr.prototype.keyFromPublic=function(e,r){return gf.fromPublic(this,e,r)},xr.prototype.genKeyPair=function(e){e||(e={});for(var r=new td({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||V2(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new me(2));;){var s=new me(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},xr.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},xr.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 me(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),c=new td({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new me(1)),l=0;;l++){var v=n.k?n.k(l):new me(c.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(h)>=0)){var M=this.g.mul(v);if(!M.isInfinity()){var I=M.getX(),S=I.umod(this.n);if(S.cmpn(0)!==0){var D=v.invm(this.n).mul(S.mul(r.getPrivate()).iadd(e));if(D=D.umod(this.n),D.cmpn(0)!==0){var F=(M.getY().isOdd()?1:0)|(I.cmp(S)!==0?2:0);return n.canonical&&D.cmp(this.nh)>0&&(D=this.n.sub(D),F^=1),new Io({r:S,s:D,recoveryParam:F})}}}}}},xr.prototype.verify=function(e,r,i,n){e=this._truncateToN(new me(e,16)),i=this.keyFromPublic(i,n),r=new Io(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)},xr.prototype.recoverPubKey=function(t,e,r,i){id((3&r)===r,"The recovery param is more than two bits"),e=new Io(e,i);var n=this.n,s=new me(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),v=n.sub(s).mul(l).umod(n),M=a.mul(l).umod(n);return this.g.mulAdd(v,o,M)},xr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Io(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 W2=kn(function(t,e){var r=e;r.version="6.5.4",r.utils=lr,r.rand=function(){throw new Error("unsupported")},r.curve=Eo,r.curves=So,r.ec=H2,r.eddsa=null}),G2=W2.ec;const J2="signing-key/5.7.0",yf=new Ee(J2);let mf=null;function Qr(){return mf||(mf=new G2("secp256k1")),mf}class Y2{constructor(e){ms(this,"curve","secp256k1"),ms(this,"privateKey",Yt(e)),Qy(this.privateKey)!==32&&yf.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=Qr().keyFromPrivate(xt(this.privateKey));ms(this,"publicKey","0x"+r.getPublic(!1,"hex")),ms(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),ms(this,"_isSigningKey",!0)}_addPoint(e){const r=Qr().keyFromPublic(xt(this.publicKey)),i=Qr().keyFromPublic(xt(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=Qr().keyFromPrivate(xt(this.privateKey)),i=xt(e);i.length!==32&&yf.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return mu({recoveryParam:n.recoveryParam,r:Ti("0x"+n.r.toString(16),32),s:Ti("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=Qr().keyFromPrivate(xt(this.privateKey)),i=Qr().keyFromPublic(xt(nd(e)));return Ti("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function X2(t,e){const r=mu(e),i={r:xt(r.r),s:xt(r.s)};return"0x"+Qr().recoverPubKey(xt(t),i,r.recoveryParam).encode("hex",!1)}function nd(t,e){const r=xt(t);if(r.length===32){const i=new Y2(r);return e?"0x"+Qr().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?Yt(r):"0x"+Qr().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+Qr().keyFromPublic(r).getPublic(!0,"hex"):Yt(r)}return yf.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Z2="transactions/5.7.0";new Ee(Z2);var sd;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(sd||(sd={}));function Q2(t){const e=nd(t);return um(yu(Ou(yu(e,1)),12))}function e3(t,e){return Q2(X2(xt(t),e))}function od(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function wf(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 t3(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 v(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,F=0,T=0,O=S.length;T!==O&&S[T]===0;)T++,D++;for(var $=(O-T)*l+1>>>0,N=new Uint8Array($);T!==O;){for(var C=S[T],L=0,V=$-1;(C!==0||L<F)&&V!==-1;V--,L++)C+=256*N[V]>>>0,N[V]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");F=L,T++}for(var z=$-F;z!==$&&N[z]===0;)z++;for(var H=c.repeat(D);z<$;++z)H+=t.charAt(N[z]);return H}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 F=0,T=0;S[D]===c;)F++,D++;for(var O=(S.length-D)*h+1>>>0,$=new Uint8Array(O);S[D];){var N=r[S.charCodeAt(D)];if(N===255)return;for(var C=0,L=O-1;(N!==0||C<T)&&L!==-1;L--,C++)N+=a*$[L]>>>0,$[L]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");T=C,D++}if(S[D]!==" "){for(var V=O-T;V!==O&&$[V]===0;)V++;for(var z=new Uint8Array(F+(O-V)),H=F;V!==O;)z[H++]=$[V++];return z}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:M,decode:I}}var r3=t3,i3=r3;const ad=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")},n3=t=>new TextEncoder().encode(t),s3=t=>new TextDecoder().decode(t);class o3{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 a3{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 fd(this,e)}}class f3{constructor(e){this.decoders=e}or(e){return fd(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 fd=(t,e)=>new f3({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class c3{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new o3(e,r,i),this.decoder=new a3(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ao=({name:t,prefix:e,encode:r,decode:i})=>new c3(t,e,r,i),xs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=i3(r,e);return Ao({prefix:t,name:e,encode:i,decode:s=>ad(n(s))})},h3=(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 v=n[t[l]];if(v===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|v,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},u3=(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},Bt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ao({prefix:e,name:t,encode(n){return u3(n,i,r)},decode(n){return h3(n,i,r,t)}}),d3=Ao({prefix:"\0",name:"identity",encode:t=>s3(t),decode:t=>n3(t)});var l3=Object.freeze({__proto__:null,identity:d3});const p3=Bt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var g3=Object.freeze({__proto__:null,base2:p3});const b3=Bt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var v3=Object.freeze({__proto__:null,base8:b3});const y3=xs({prefix:"9",name:"base10",alphabet:"0123456789"});var m3=Object.freeze({__proto__:null,base10:y3});const w3=Bt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_3=Bt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var x3=Object.freeze({__proto__:null,base16:w3,base16upper:_3});const E3=Bt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),S3=Bt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),M3=Bt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),I3=Bt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),A3=Bt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),D3=Bt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),O3=Bt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),P3=Bt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),R3=Bt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $3=Object.freeze({__proto__:null,base32:E3,base32upper:S3,base32pad:M3,base32padupper:I3,base32hex:A3,base32hexupper:D3,base32hexpad:O3,base32hexpadupper:P3,base32z:R3});const N3=xs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),F3=xs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var T3=Object.freeze({__proto__:null,base36:N3,base36upper:F3});const C3=xs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B3=xs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var L3=Object.freeze({__proto__:null,base58btc:C3,base58flickr:B3});const q3=Bt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),U3=Bt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),z3=Bt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),k3=Bt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var j3=Object.freeze({__proto__:null,base64:q3,base64pad:U3,base64url:z3,base64urlpad:k3});const cd=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}"),K3=cd.reduce((t,e,r)=>(t[r]=e,t),[]),V3=cd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function H3(t){return t.reduce((e,r)=>(e+=K3[r],e),"")}function W3(t){const e=[];for(const r of t){const i=V3[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const G3=Ao({prefix:"\u{1F680}",name:"base256emoji",encode:H3,decode:W3});var J3=Object.freeze({__proto__:null,base256emoji:G3}),Y3=ud,hd=128,X3=127,Z3=~X3,Q3=Math.pow(2,31);function ud(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Q3;)e[r++]=t&255|hd,t/=128;for(;t&Z3;)e[r++]=t&255|hd,t>>>=7;return e[r]=t|0,ud.bytes=r-i+1,e}var ew=_f,tw=128,dd=127;function _f(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw _f.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&dd)<<n:(o&dd)*Math.pow(2,n),n+=7}while(o>=tw);return _f.bytes=s-i,r}var rw=Math.pow(2,7),iw=Math.pow(2,14),nw=Math.pow(2,21),sw=Math.pow(2,28),ow=Math.pow(2,35),aw=Math.pow(2,42),fw=Math.pow(2,49),cw=Math.pow(2,56),hw=Math.pow(2,63),uw=function(t){return t<rw?1:t<iw?2:t<nw?3:t<sw?4:t<ow?5:t<aw?6:t<fw?7:t<cw?8:t<hw?9:10},dw={encode:Y3,decode:ew,encodingLength:uw},ld=dw;const pd=(t,e,r=0)=>(ld.encode(t,e,r),e),gd=t=>ld.encodingLength(t),xf=(t,e)=>{const r=e.byteLength,i=gd(t),n=i+gd(r),s=new Uint8Array(n+r);return pd(t,s,0),pd(r,s,i),s.set(e,n),new lw(t,r,e,s)};class lw{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const bd=({name:t,code:e,encode:r})=>new pw(t,e,r);class pw{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?xf(this.code,r):r.then(i=>xf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const vd=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),gw=bd({name:"sha2-256",code:18,encode:vd("SHA-256")}),bw=bd({name:"sha2-512",code:19,encode:vd("SHA-512")});var vw=Object.freeze({__proto__:null,sha256:gw,sha512:bw});const yd=0,yw="identity",md=ad;var mw=Object.freeze({__proto__:null,identity:{code:yd,name:yw,encode:md,digest:t=>xf(yd,md(t))}});new TextEncoder,new TextDecoder;const wd={...l3,...g3,...v3,...m3,...x3,...$3,...T3,...L3,...j3,...J3};({...vw,...mw});function _d(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const xd=_d("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ef=_d("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}),Ed={utf8:xd,"utf-8":xd,hex:wd.base16,latin1:Ef,ascii:Ef,binary:Ef,...wd};function Er(t,e="utf8"){const r=Ed[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 Zt(t,e="utf8"){const r=Ed[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 Sd={},ww="elliptic",_w="6.6.1",xw="EC cryptography",Ew="lib/elliptic.js",Sw=["lib"],Mw={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/"},Iw={type:"git",url:"git@github.com:indutny/elliptic"},Aw=["EC","Elliptic","curve","Cryptography"],Dw="Fedor Indutny <fedor@indutny.com>",Ow="MIT",Pw={url:"https://github.com/indutny/elliptic/issues"},Rw="https://github.com/indutny/elliptic",$w={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"},Nw={"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"},Fw={name:ww,version:_w,description:xw,main:Ew,files:Sw,scripts:Mw,repository:Iw,keywords:Aw,author:Dw,license:Ow,bugs:Pw,homepage:Rw,devDependencies:$w,dependencies:Nw},pr={},ei={exports:{}};(function(t){(function(e,r){function i(P,g){if(!P)throw new Error(g||"Assertion failed")}function n(P,g){P.super_=g;var p=function(){};p.prototype=g.prototype,P.prototype=new p,P.prototype.constructor=P}function s(P,g,p){if(s.isBN(P))return P;this.negative=0,this.words=null,this.length=0,this.red=null,P!==null&&((g==="le"||g==="be")&&(p=g,g=10),this._init(P||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=tf.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(P,g){var p=P.charCodeAt(g);return p>=65&&p<=70?p-55:p>=97&&p<=102?p-87:p-48&15}function c(P,g,p){var f=a(P,p);return p-1>=g&&(f|=a(P,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(P,g,p,f){for(var u=0,b=Math.min(P.length,p),_=g;_<b;_++){var E=P.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 y=1;for(d=h(g,m,g.length,p),m=0;m<E;m++)y*=p;this.imuln(y),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"],v=[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=v[g],m=M[g];f="";var y=this.clone();for(y.negative=0;!y.isZero();){var A=y.modn(m).toString(g);y=y.idivn(m),y.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(P){for(var g=new Array(P.bitLength()),p=0;p<g.length;p++){var f=p/26|0,u=p%26;g[p]=(P.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(P,g,p){p.negative=g.negative^P.negative;var f=P.length+g.length|0;p.length=f,f=f-1|0;var u=P.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,y=w&67108863,A=Math.min(d,g.length-1),j=Math.max(0,d-P.length+1);j<=A;j++){var x=d-j|0;u=P.words[x]|0,b=g.words[j]|0,_=u*b+y,m+=_/67108864|0,y=_&67108863}p.words[d]=y|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,y=u[0]|0,A=y&8191,j=y>>>13,x=u[1]|0,B=x&8191,U=x>>>13,k=u[2]|0,K=k&8191,J=k>>>13,X=u[3]|0,G=X&8191,ne=X>>>13,Q=u[4]|0,ee=Q&8191,qe=Q>>>13,Ue=u[5]|0,he=Ue&8191,Pe=Ue>>>13,Re=u[6]|0,ae=Re&8191,$e=Re>>>13,Ne=u[7]|0,ce=Ne&8191,Fe=Ne>>>13,Te=u[8]|0,oe=Te&8191,De=Te>>>13,Ce=u[9]|0,ie=Ce&8191,Ve=Ce>>>13,He=b[0]|0,pe=He&8191,We=He>>>13,Be=b[1]|0,de=Be&8191,Ge=Be>>>13,Xe=b[2]|0,se=Xe&8191,Je=Xe>>>13,Ze=b[3]|0,ge=Ze&8191,ze=Ze>>>13,Oe=b[4]|0,ue=Oe&8191,ke=Oe>>>13,je=b[5]|0,fe=je&8191,Qe=je>>>13,et=b[6]|0,be=et&8191,tt=et>>>13,rt=b[7]|0,le=rt&8191,Ke=rt>>>13,Ae=b[8]|0,ve=Ae&8191,it=Ae>>>13,nt=b[9]|0,ye=nt&8191,st=nt>>>13;f.negative=g.negative^p.negative,f.length=19,w=Math.imul(A,pe),d=Math.imul(A,We),d=d+Math.imul(j,pe)|0,m=Math.imul(j,We);var xe=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(xe>>>26)|0,xe&=67108863,w=Math.imul(B,pe),d=Math.imul(B,We),d=d+Math.imul(U,pe)|0,m=Math.imul(U,We),w=w+Math.imul(A,de)|0,d=d+Math.imul(A,Ge)|0,d=d+Math.imul(j,de)|0,m=m+Math.imul(j,Ge)|0;var Ye=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,w=Math.imul(K,pe),d=Math.imul(K,We),d=d+Math.imul(J,pe)|0,m=Math.imul(J,We),w=w+Math.imul(B,de)|0,d=d+Math.imul(B,Ge)|0,d=d+Math.imul(U,de)|0,m=m+Math.imul(U,Ge)|0,w=w+Math.imul(A,se)|0,d=d+Math.imul(A,Je)|0,d=d+Math.imul(j,se)|0,m=m+Math.imul(j,Je)|0;var ar=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(ar>>>26)|0,ar&=67108863,w=Math.imul(G,pe),d=Math.imul(G,We),d=d+Math.imul(ne,pe)|0,m=Math.imul(ne,We),w=w+Math.imul(K,de)|0,d=d+Math.imul(K,Ge)|0,d=d+Math.imul(J,de)|0,m=m+Math.imul(J,Ge)|0,w=w+Math.imul(B,se)|0,d=d+Math.imul(B,Je)|0,d=d+Math.imul(U,se)|0,m=m+Math.imul(U,Je)|0,w=w+Math.imul(A,ge)|0,d=d+Math.imul(A,ze)|0,d=d+Math.imul(j,ge)|0,m=m+Math.imul(j,ze)|0;var fr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(fr>>>26)|0,fr&=67108863,w=Math.imul(ee,pe),d=Math.imul(ee,We),d=d+Math.imul(qe,pe)|0,m=Math.imul(qe,We),w=w+Math.imul(G,de)|0,d=d+Math.imul(G,Ge)|0,d=d+Math.imul(ne,de)|0,m=m+Math.imul(ne,Ge)|0,w=w+Math.imul(K,se)|0,d=d+Math.imul(K,Je)|0,d=d+Math.imul(J,se)|0,m=m+Math.imul(J,Je)|0,w=w+Math.imul(B,ge)|0,d=d+Math.imul(B,ze)|0,d=d+Math.imul(U,ge)|0,m=m+Math.imul(U,ze)|0,w=w+Math.imul(A,ue)|0,d=d+Math.imul(A,ke)|0,d=d+Math.imul(j,ue)|0,m=m+Math.imul(j,ke)|0;var cr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(cr>>>26)|0,cr&=67108863,w=Math.imul(he,pe),d=Math.imul(he,We),d=d+Math.imul(Pe,pe)|0,m=Math.imul(Pe,We),w=w+Math.imul(ee,de)|0,d=d+Math.imul(ee,Ge)|0,d=d+Math.imul(qe,de)|0,m=m+Math.imul(qe,Ge)|0,w=w+Math.imul(G,se)|0,d=d+Math.imul(G,Je)|0,d=d+Math.imul(ne,se)|0,m=m+Math.imul(ne,Je)|0,w=w+Math.imul(K,ge)|0,d=d+Math.imul(K,ze)|0,d=d+Math.imul(J,ge)|0,m=m+Math.imul(J,ze)|0,w=w+Math.imul(B,ue)|0,d=d+Math.imul(B,ke)|0,d=d+Math.imul(U,ue)|0,m=m+Math.imul(U,ke)|0,w=w+Math.imul(A,fe)|0,d=d+Math.imul(A,Qe)|0,d=d+Math.imul(j,fe)|0,m=m+Math.imul(j,Qe)|0;var hr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(hr>>>26)|0,hr&=67108863,w=Math.imul(ae,pe),d=Math.imul(ae,We),d=d+Math.imul($e,pe)|0,m=Math.imul($e,We),w=w+Math.imul(he,de)|0,d=d+Math.imul(he,Ge)|0,d=d+Math.imul(Pe,de)|0,m=m+Math.imul(Pe,Ge)|0,w=w+Math.imul(ee,se)|0,d=d+Math.imul(ee,Je)|0,d=d+Math.imul(qe,se)|0,m=m+Math.imul(qe,Je)|0,w=w+Math.imul(G,ge)|0,d=d+Math.imul(G,ze)|0,d=d+Math.imul(ne,ge)|0,m=m+Math.imul(ne,ze)|0,w=w+Math.imul(K,ue)|0,d=d+Math.imul(K,ke)|0,d=d+Math.imul(J,ue)|0,m=m+Math.imul(J,ke)|0,w=w+Math.imul(B,fe)|0,d=d+Math.imul(B,Qe)|0,d=d+Math.imul(U,fe)|0,m=m+Math.imul(U,Qe)|0,w=w+Math.imul(A,be)|0,d=d+Math.imul(A,tt)|0,d=d+Math.imul(j,be)|0,m=m+Math.imul(j,tt)|0;var wt=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(wt>>>26)|0,wt&=67108863,w=Math.imul(ce,pe),d=Math.imul(ce,We),d=d+Math.imul(Fe,pe)|0,m=Math.imul(Fe,We),w=w+Math.imul(ae,de)|0,d=d+Math.imul(ae,Ge)|0,d=d+Math.imul($e,de)|0,m=m+Math.imul($e,Ge)|0,w=w+Math.imul(he,se)|0,d=d+Math.imul(he,Je)|0,d=d+Math.imul(Pe,se)|0,m=m+Math.imul(Pe,Je)|0,w=w+Math.imul(ee,ge)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(qe,ge)|0,m=m+Math.imul(qe,ze)|0,w=w+Math.imul(G,ue)|0,d=d+Math.imul(G,ke)|0,d=d+Math.imul(ne,ue)|0,m=m+Math.imul(ne,ke)|0,w=w+Math.imul(K,fe)|0,d=d+Math.imul(K,Qe)|0,d=d+Math.imul(J,fe)|0,m=m+Math.imul(J,Qe)|0,w=w+Math.imul(B,be)|0,d=d+Math.imul(B,tt)|0,d=d+Math.imul(U,be)|0,m=m+Math.imul(U,tt)|0,w=w+Math.imul(A,le)|0,d=d+Math.imul(A,Ke)|0,d=d+Math.imul(j,le)|0,m=m+Math.imul(j,Ke)|0;var xi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(xi>>>26)|0,xi&=67108863,w=Math.imul(oe,pe),d=Math.imul(oe,We),d=d+Math.imul(De,pe)|0,m=Math.imul(De,We),w=w+Math.imul(ce,de)|0,d=d+Math.imul(ce,Ge)|0,d=d+Math.imul(Fe,de)|0,m=m+Math.imul(Fe,Ge)|0,w=w+Math.imul(ae,se)|0,d=d+Math.imul(ae,Je)|0,d=d+Math.imul($e,se)|0,m=m+Math.imul($e,Je)|0,w=w+Math.imul(he,ge)|0,d=d+Math.imul(he,ze)|0,d=d+Math.imul(Pe,ge)|0,m=m+Math.imul(Pe,ze)|0,w=w+Math.imul(ee,ue)|0,d=d+Math.imul(ee,ke)|0,d=d+Math.imul(qe,ue)|0,m=m+Math.imul(qe,ke)|0,w=w+Math.imul(G,fe)|0,d=d+Math.imul(G,Qe)|0,d=d+Math.imul(ne,fe)|0,m=m+Math.imul(ne,Qe)|0,w=w+Math.imul(K,be)|0,d=d+Math.imul(K,tt)|0,d=d+Math.imul(J,be)|0,m=m+Math.imul(J,tt)|0,w=w+Math.imul(B,le)|0,d=d+Math.imul(B,Ke)|0,d=d+Math.imul(U,le)|0,m=m+Math.imul(U,Ke)|0,w=w+Math.imul(A,ve)|0,d=d+Math.imul(A,it)|0,d=d+Math.imul(j,ve)|0,m=m+Math.imul(j,it)|0;var Ei=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,w=Math.imul(ie,pe),d=Math.imul(ie,We),d=d+Math.imul(Ve,pe)|0,m=Math.imul(Ve,We),w=w+Math.imul(oe,de)|0,d=d+Math.imul(oe,Ge)|0,d=d+Math.imul(De,de)|0,m=m+Math.imul(De,Ge)|0,w=w+Math.imul(ce,se)|0,d=d+Math.imul(ce,Je)|0,d=d+Math.imul(Fe,se)|0,m=m+Math.imul(Fe,Je)|0,w=w+Math.imul(ae,ge)|0,d=d+Math.imul(ae,ze)|0,d=d+Math.imul($e,ge)|0,m=m+Math.imul($e,ze)|0,w=w+Math.imul(he,ue)|0,d=d+Math.imul(he,ke)|0,d=d+Math.imul(Pe,ue)|0,m=m+Math.imul(Pe,ke)|0,w=w+Math.imul(ee,fe)|0,d=d+Math.imul(ee,Qe)|0,d=d+Math.imul(qe,fe)|0,m=m+Math.imul(qe,Qe)|0,w=w+Math.imul(G,be)|0,d=d+Math.imul(G,tt)|0,d=d+Math.imul(ne,be)|0,m=m+Math.imul(ne,tt)|0,w=w+Math.imul(K,le)|0,d=d+Math.imul(K,Ke)|0,d=d+Math.imul(J,le)|0,m=m+Math.imul(J,Ke)|0,w=w+Math.imul(B,ve)|0,d=d+Math.imul(B,it)|0,d=d+Math.imul(U,ve)|0,m=m+Math.imul(U,it)|0,w=w+Math.imul(A,ye)|0,d=d+Math.imul(A,st)|0,d=d+Math.imul(j,ye)|0,m=m+Math.imul(j,st)|0;var Si=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Si>>>26)|0,Si&=67108863,w=Math.imul(ie,de),d=Math.imul(ie,Ge),d=d+Math.imul(Ve,de)|0,m=Math.imul(Ve,Ge),w=w+Math.imul(oe,se)|0,d=d+Math.imul(oe,Je)|0,d=d+Math.imul(De,se)|0,m=m+Math.imul(De,Je)|0,w=w+Math.imul(ce,ge)|0,d=d+Math.imul(ce,ze)|0,d=d+Math.imul(Fe,ge)|0,m=m+Math.imul(Fe,ze)|0,w=w+Math.imul(ae,ue)|0,d=d+Math.imul(ae,ke)|0,d=d+Math.imul($e,ue)|0,m=m+Math.imul($e,ke)|0,w=w+Math.imul(he,fe)|0,d=d+Math.imul(he,Qe)|0,d=d+Math.imul(Pe,fe)|0,m=m+Math.imul(Pe,Qe)|0,w=w+Math.imul(ee,be)|0,d=d+Math.imul(ee,tt)|0,d=d+Math.imul(qe,be)|0,m=m+Math.imul(qe,tt)|0,w=w+Math.imul(G,le)|0,d=d+Math.imul(G,Ke)|0,d=d+Math.imul(ne,le)|0,m=m+Math.imul(ne,Ke)|0,w=w+Math.imul(K,ve)|0,d=d+Math.imul(K,it)|0,d=d+Math.imul(J,ve)|0,m=m+Math.imul(J,it)|0,w=w+Math.imul(B,ye)|0,d=d+Math.imul(B,st)|0,d=d+Math.imul(U,ye)|0,m=m+Math.imul(U,st)|0;var Mi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,w=Math.imul(ie,se),d=Math.imul(ie,Je),d=d+Math.imul(Ve,se)|0,m=Math.imul(Ve,Je),w=w+Math.imul(oe,ge)|0,d=d+Math.imul(oe,ze)|0,d=d+Math.imul(De,ge)|0,m=m+Math.imul(De,ze)|0,w=w+Math.imul(ce,ue)|0,d=d+Math.imul(ce,ke)|0,d=d+Math.imul(Fe,ue)|0,m=m+Math.imul(Fe,ke)|0,w=w+Math.imul(ae,fe)|0,d=d+Math.imul(ae,Qe)|0,d=d+Math.imul($e,fe)|0,m=m+Math.imul($e,Qe)|0,w=w+Math.imul(he,be)|0,d=d+Math.imul(he,tt)|0,d=d+Math.imul(Pe,be)|0,m=m+Math.imul(Pe,tt)|0,w=w+Math.imul(ee,le)|0,d=d+Math.imul(ee,Ke)|0,d=d+Math.imul(qe,le)|0,m=m+Math.imul(qe,Ke)|0,w=w+Math.imul(G,ve)|0,d=d+Math.imul(G,it)|0,d=d+Math.imul(ne,ve)|0,m=m+Math.imul(ne,it)|0,w=w+Math.imul(K,ye)|0,d=d+Math.imul(K,st)|0,d=d+Math.imul(J,ye)|0,m=m+Math.imul(J,st)|0;var Ii=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,w=Math.imul(ie,ge),d=Math.imul(ie,ze),d=d+Math.imul(Ve,ge)|0,m=Math.imul(Ve,ze),w=w+Math.imul(oe,ue)|0,d=d+Math.imul(oe,ke)|0,d=d+Math.imul(De,ue)|0,m=m+Math.imul(De,ke)|0,w=w+Math.imul(ce,fe)|0,d=d+Math.imul(ce,Qe)|0,d=d+Math.imul(Fe,fe)|0,m=m+Math.imul(Fe,Qe)|0,w=w+Math.imul(ae,be)|0,d=d+Math.imul(ae,tt)|0,d=d+Math.imul($e,be)|0,m=m+Math.imul($e,tt)|0,w=w+Math.imul(he,le)|0,d=d+Math.imul(he,Ke)|0,d=d+Math.imul(Pe,le)|0,m=m+Math.imul(Pe,Ke)|0,w=w+Math.imul(ee,ve)|0,d=d+Math.imul(ee,it)|0,d=d+Math.imul(qe,ve)|0,m=m+Math.imul(qe,it)|0,w=w+Math.imul(G,ye)|0,d=d+Math.imul(G,st)|0,d=d+Math.imul(ne,ye)|0,m=m+Math.imul(ne,st)|0;var Pr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,w=Math.imul(ie,ue),d=Math.imul(ie,ke),d=d+Math.imul(Ve,ue)|0,m=Math.imul(Ve,ke),w=w+Math.imul(oe,fe)|0,d=d+Math.imul(oe,Qe)|0,d=d+Math.imul(De,fe)|0,m=m+Math.imul(De,Qe)|0,w=w+Math.imul(ce,be)|0,d=d+Math.imul(ce,tt)|0,d=d+Math.imul(Fe,be)|0,m=m+Math.imul(Fe,tt)|0,w=w+Math.imul(ae,le)|0,d=d+Math.imul(ae,Ke)|0,d=d+Math.imul($e,le)|0,m=m+Math.imul($e,Ke)|0,w=w+Math.imul(he,ve)|0,d=d+Math.imul(he,it)|0,d=d+Math.imul(Pe,ve)|0,m=m+Math.imul(Pe,it)|0,w=w+Math.imul(ee,ye)|0,d=d+Math.imul(ee,st)|0,d=d+Math.imul(qe,ye)|0,m=m+Math.imul(qe,st)|0;var Ai=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,w=Math.imul(ie,fe),d=Math.imul(ie,Qe),d=d+Math.imul(Ve,fe)|0,m=Math.imul(Ve,Qe),w=w+Math.imul(oe,be)|0,d=d+Math.imul(oe,tt)|0,d=d+Math.imul(De,be)|0,m=m+Math.imul(De,tt)|0,w=w+Math.imul(ce,le)|0,d=d+Math.imul(ce,Ke)|0,d=d+Math.imul(Fe,le)|0,m=m+Math.imul(Fe,Ke)|0,w=w+Math.imul(ae,ve)|0,d=d+Math.imul(ae,it)|0,d=d+Math.imul($e,ve)|0,m=m+Math.imul($e,it)|0,w=w+Math.imul(he,ye)|0,d=d+Math.imul(he,st)|0,d=d+Math.imul(Pe,ye)|0,m=m+Math.imul(Pe,st)|0;var Di=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Di>>>26)|0,Di&=67108863,w=Math.imul(ie,be),d=Math.imul(ie,tt),d=d+Math.imul(Ve,be)|0,m=Math.imul(Ve,tt),w=w+Math.imul(oe,le)|0,d=d+Math.imul(oe,Ke)|0,d=d+Math.imul(De,le)|0,m=m+Math.imul(De,Ke)|0,w=w+Math.imul(ce,ve)|0,d=d+Math.imul(ce,it)|0,d=d+Math.imul(Fe,ve)|0,m=m+Math.imul(Fe,it)|0,w=w+Math.imul(ae,ye)|0,d=d+Math.imul(ae,st)|0,d=d+Math.imul($e,ye)|0,m=m+Math.imul($e,st)|0;var Wt=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,w=Math.imul(ie,le),d=Math.imul(ie,Ke),d=d+Math.imul(Ve,le)|0,m=Math.imul(Ve,Ke),w=w+Math.imul(oe,ve)|0,d=d+Math.imul(oe,it)|0,d=d+Math.imul(De,ve)|0,m=m+Math.imul(De,it)|0,w=w+Math.imul(ce,ye)|0,d=d+Math.imul(ce,st)|0,d=d+Math.imul(Fe,ye)|0,m=m+Math.imul(Fe,st)|0;var Oi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,w=Math.imul(ie,ve),d=Math.imul(ie,it),d=d+Math.imul(Ve,ve)|0,m=Math.imul(Ve,it),w=w+Math.imul(oe,ye)|0,d=d+Math.imul(oe,st)|0,d=d+Math.imul(De,ye)|0,m=m+Math.imul(De,st)|0;var Pi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,w=Math.imul(ie,ye),d=Math.imul(ie,st),d=d+Math.imul(Ve,ye)|0,m=Math.imul(Ve,st);var Ri=(E+w|0)+((d&8191)<<13)|0;return E=(m+(d>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,_[0]=xe,_[1]=Ye,_[2]=ar,_[3]=fr,_[4]=cr,_[5]=hr,_[6]=wt,_[7]=xi,_[8]=Ei,_[9]=Si,_[10]=Mi,_[11]=Ii,_[12]=Pr,_[13]=Ai,_[14]=Di,_[15]=Wt,_[16]=Oi,_[17]=Pi,_[18]=Ri,E!==0&&(_[19]=E,f.length++),f};Math.imul||(D=S);function F(P,g,p){p.negative=g.negative^P.negative,p.length=P.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-P.length+1);d<=w;d++){var m=b-d,y=P.words[m]|0,A=g.words[d]|0,j=y*A,x=j&67108863;_=_+(j/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 T(P,g,p){var f=new O;return f.mulp(P,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=F(this,g,p):f=T(this,g,p),f};function O(P,g){this.x=P,this.y=g}O.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},O.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},O.prototype.permute=function(g,p,f,u,b,_){for(var E=0;E<_;E++)u[E]=p[g[E]],b[E]=f[g[E]]},O.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),y=0;y<b;y+=w)for(var A=d,j=m,x=0;x<E;x++){var B=f[y+x],U=u[y+x],k=f[y+x+E],K=u[y+x+E],J=A*k-j*K;K=A*K+j*k,k=J,f[y+x]=B+k,u[y+x]=U+K,f[y+x+E]=B-k,u[y+x+E]=U-K,x!==w&&(J=d*A-m*j,j=d*j+m*A,A=J)}},O.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},O.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}},O.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},O.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)},O.prototype.stub=function(g){for(var p=new Array(g),f=0;f<g;f++)p[f]=0;return p},O.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),y=new Array(u),A=new Array(u),j=f.words;j.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,_,y,A,u,b);for(var x=0;x<u;x++){var B=w[x]*y[x]-d[x]*A[x];d[x]=w[x]*A[x]+d[x]*y[x],w[x]=B}return this.conjugate(w,d,u),this.transform(w,d,j,_,u,b),this.conjugate(j,_,u),this.normalize13b(j,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),T(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 y=this.words[d]|0;this.words[d]=m<<26-b|y>>>b,m=y&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 y=u.clone()._ishlnsubmul(b,1,w);y.negative===0&&(u=y,d&&(d.words[w]=1));for(var A=w-1;A>=0;A--){var j=(u.words[b.length+A]|0)*67108864+(u.words[b.length+A-1]|0);for(j=Math.min(j/_|0,67108863),u._ishlnsubmul(b,j,A);u.negative!==0;)j--,u.negative=0,u._ishlnsubmul(b,1,A),u.isZero()||(u.negative^=1);d&&(d.words[A]=j)}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 y=0,A=1;!(p.words[0]&A)&&y<26;++y,A<<=1);if(y>0)for(p.iushrn(y);y-- >0;)(u.isOdd()||b.isOdd())&&(u.iadd(d),b.isub(m)),u.iushrn(1),b.iushrn(1);for(var j=0,x=1;!(f.words[0]&x)&&j<26;++j,x<<=1);if(j>0)for(f.iushrn(j);j-- >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 y;return p.cmpn(1)===0?y=u:y=b,y.cmpn(0)<0&&y.iadd(g),y},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 H(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 $={k256:null,p224:null,p192:null,p25519:null};function N(P,g){this.name=P,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()}N.prototype._tmp=function(){var g=new s(null);return g.words=new Array(Math.ceil(this.n/13)),g},N.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},N.prototype.split=function(g,p){g.iushrn(this.n,0,p)},N.prototype.imulK=function(g){return g.imul(this.k)};function C(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(C,N),C.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},C.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 L(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(L,N);function V(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(V,N);function z(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(z,N),z.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($[g])return $[g];var p;if(g==="k256")p=new C;else if(g==="p224")p=new L;else if(g==="p192")p=new V;else if(g==="p25519")p=new z;else throw new Error("Unknown prime "+g);return $[g]=p,p};function H(P){if(typeof P=="string"){var g=s._prime(P);this.m=g.p,this.prime=g}else i(P.gtn(1),"modulus must be greater than 1"),this.m=P,this.prime=null}H.prototype._verify1=function(g){i(g.negative===0,"red works only with positives"),i(g.red,"red works only with red numbers")},H.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")},H.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},H.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},H.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)},H.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},H.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)},H.prototype.isub=function(g,p){this._verify2(g,p);var f=g.isub(p);return f.cmpn(0)<0&&f.iadd(this.m),f},H.prototype.shl=function(g,p){return this._verify1(g),this.imod(g.ushln(p))},H.prototype.imul=function(g,p){return this._verify2(g,p),this.imod(g.imul(p))},H.prototype.mul=function(g,p){return this._verify2(g,p),this.imod(g.mul(p))},H.prototype.isqr=function(g){return this.imul(g,g.clone())},H.prototype.sqr=function(g){return this.mul(g,g)},H.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),y=this.pow(g,u.addn(1).iushrn(1)),A=this.pow(g,u),j=b;A.cmp(_)!==0;){for(var x=A,B=0;x.cmp(_)!==0;B++)x=x.redSqr();i(B<j);var U=this.pow(m,new s(1).iushln(j-B-1));y=y.redMul(U),m=U.redSqr(),A=A.redMul(m),j=B}return y},H.prototype.invm=function(g){var p=g._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},H.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],y=d-1;y>=0;y--){var A=m>>y&1;if(_!==u[0]&&(_=this.sqr(_)),A===0&&E===0){w=0;continue}E<<=1,E|=A,w++,!(w!==f&&(b!==0||y!==0))&&(_=this.mul(_,u[E]),w=0,E=0)}d=26}return _},H.prototype.convertTo=function(g){var p=g.umod(this.m);return p===g?p.clone():p},H.prototype.convertFrom=function(g){var p=g.clone();return p.red=null,p},s.mont=function(g){return new re(g)};function re(P){H.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(re,H),re.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},re.prototype.convertFrom=function(g){var p=this.imod(g.mul(this.rinv));return p.red=null,p},re.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)},re.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)},re.prototype.invm=function(g){var p=this.imod(g._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,Nt)})(ei);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 h=s.charCodeAt(c),l=h>>8,v=h&255;l?a.push(l,v):a.push(v)}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=ei.exports,i=sn,n=Sf;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(l,v,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<<v+1,F=l.clone();for(S=0;S<I.length;S++){var T,O=F.andln(D-1);F.isOdd()?(O>(D>>1)-1?T=(D>>1)-O:T=O,F.isubn(T)):T=0,I[S]=T,F.iushrn(1)}return I}e.getNAF=s;function o(l,v){var M=[[],[]];l=l.clone(),v=v.clone();for(var I=0,S=0,D;l.cmpn(-I)>0||v.cmpn(-S)>0;){var F=l.andln(3)+I&3,T=v.andln(3)+S&3;F===3&&(F=-1),T===3&&(T=-1);var O;F&1?(D=l.andln(7)+I&7,(D===3||D===5)&&T===2?O=-F:O=F):O=0,M[0].push(O);var $;T&1?(D=v.andln(7)+S&7,(D===3||D===5)&&F===2?$=-T:$=T):$=0,M[1].push($),2*I===O+1&&(I=1-I),2*S===$+1&&(S=1-S),l.iushrn(1),v.iushrn(1)}return M}e.getJSF=o;function a(l,v,M){var I="_"+v;l.prototype[v]=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}(pr);var Do={exports:{}},Mf;Do.exports=function(e){return Mf||(Mf=new qi(null)),Mf.generate(e)};function qi(t){this.rand=t}if(Do.exports.Rand=qi,qi.prototype.generate=function(e){return this._rand(e)},qi.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?qi.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?qi.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(qi.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var Md=tf;if(typeof Md.randomBytes!="function")throw new Error("Not supported");qi.prototype._rand=function(e){return Md.randomBytes(e)}}catch{}var If={},fn=ei.exports,Es=pr,Oo=Es.getNAF,Tw=Es.getJSF,Po=Es.assert;function Ui(t,e){this.type=t,this.p=new fn(e.p,16),this.red=e.prime?fn.red(e.prime):fn.mont(this.p),this.zero=new fn(0).toRed(this.red),this.one=new fn(1).toRed(this.red),this.two=new fn(2).toRed(this.red),this.n=e.n&&new fn(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 Ro=Ui;Ui.prototype.point=function(){throw new Error("Not implemented")},Ui.prototype.validate=function(){throw new Error("Not implemented")},Ui.prototype._fixedNafMul=function(e,r){Po(e.precomputed);var i=e._getDoubles(),n=Oo(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),v=this.jpoint(null,null,null),M=s;M>0;M--){for(a=0;a<o.length;a++)c=o[a],c===M?v=v.mixedAdd(i.points[a]):c===-M&&(v=v.mixedAdd(i.points[a].neg()));l=l.add(v)}return l.toP()},Ui.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Oo(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];Po(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},Ui.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,h=0,l,v,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]=Oo(i[S],o[S],this._bitLength),c[D]=Oo(i[D],o[D],this._bitLength),h=Math.max(c[S].length,h),h=Math.max(c[D].length,h);continue}var F=[r[S],null,null,r[D]];r[S].y.cmp(r[D].y)===0?(F[1]=r[S].add(r[D]),F[2]=r[S].toJ().mixedAdd(r[D].neg())):r[S].y.cmp(r[D].y.redNeg())===0?(F[1]=r[S].toJ().mixedAdd(r[D]),F[2]=r[S].add(r[D].neg())):(F[1]=r[S].toJ().mixedAdd(r[D]),F[2]=r[S].toJ().mixedAdd(r[D].neg()));var T=[-3,-1,-5,-7,0,7,5,1,3],O=Tw(i[S],i[D]);for(h=Math.max(O[0].length,h),c[S]=new Array(h),c[D]=new Array(h),v=0;v<h;v++){var $=O[0][v]|0,N=O[1][v]|0;c[S][v]=T[($+1)*3+(N+1)],c[D][v]=0,a[S]=F}}var C=this.jpoint(null,null,null),L=this._wnafT4;for(l=h;l>=0;l--){for(var V=0;l>=0;){var z=!0;for(v=0;v<n;v++)L[v]=c[v][l]|0,L[v]!==0&&(z=!1);if(!z)break;V++,l--}if(l>=0&&V++,C=C.dblp(V),l<0)break;for(v=0;v<n;v++){var H=L[v];H!==0&&(H>0?M=a[v][H-1>>1]:H<0&&(M=a[v][-H-1>>1].neg()),M.type==="affine"?C=C.mixedAdd(M):C=C.add(M))}}for(l=0;l<n;l++)a[l]=null;return s?C:C.toP()};function Sr(t,e){this.curve=t,this.type=e,this.precomputed=null}Ui.BasePoint=Sr,Sr.prototype.eq=function(){throw new Error("Not implemented")},Sr.prototype.validate=function(){return this.curve.validate(this)},Ui.prototype.decodePoint=function(e,r){e=Es.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?Po(e[e.length-1]%2===0):e[0]===7&&Po(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")},Sr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},Sr.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))},Sr.prototype.encode=function(e,r){return Es.encode(this._encode(r),e)},Sr.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},Sr.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},Sr.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}},Sr.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}},Sr.prototype._getBeta=function(){return null},Sr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var Cw=pr,pt=ei.exports,Af=Tn.exports,jn=Ro,Bw=Cw.assert;function Mr(t){jn.call(this,"short",t),this.a=new pt(t.a,16).toRed(this.red),this.b=new pt(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)}Af(Mr,jn);var Lw=Mr;Mr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new pt(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 pt(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],Bw(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 pt(a.a,16),b:new pt(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},Mr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:pt.mont(e),i=new pt(2).toRed(r).redInvm(),n=i.redNeg(),s=new pt(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},Mr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new pt(1),o=new pt(0),a=new pt(0),c=new pt(1),h,l,v,M,I,S,D,F=0,T,O;i.cmpn(0)!==0;){var $=n.div(i);T=n.sub($.mul(i)),O=a.sub($.mul(s));var N=c.sub($.mul(o));if(!v&&T.cmp(r)<0)h=D.neg(),l=s,v=T.neg(),M=O;else if(v&&++F===2)break;D=T,n=i,i=T,a=s,s=O,c=o,o=N}I=T.neg(),S=O;var C=v.sqr().add(M.sqr()),L=I.sqr().add(S.sqr());return L.cmp(C)>=0&&(I=h,S=l),v.negative&&(v=v.neg(),M=M.neg()),I.negative&&(I=I.neg(),S=S.neg()),[{a:v,b:M},{a:I,b:S}]},Mr.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),v=e.sub(a).sub(c),M=h.add(l).neg();return{k1:v,k2:M}},Mr.prototype.pointFromX=function(e,r){e=new pt(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)},Mr.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},Mr.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),v=0;v<o*2;v++)n[v]=null,s[v]=null;return l};function At(t,e,r,i){jn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new pt(e,16),this.y=new pt(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)}Af(At,jn.BasePoint),Mr.prototype.point=function(e,r,i){return new At(this,e,r,i)},Mr.prototype.pointFromJSON=function(e,r){return At.fromJSON(this,e,r)},At.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}},At.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]},At.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},At.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)+">"},At.prototype.isInfinity=function(){return this.inf},At.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)},At.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)},At.prototype.getX=function(){return this.x.fromRed()},At.prototype.getY=function(){return this.y.fromRed()},At.prototype.mul=function(e){return e=new pt(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)},At.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)},At.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)},At.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)},At.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},At.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 Lt(t,e,r,i){jn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(r,16),this.z=new pt(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}Af(Lt,jn.BasePoint),Mr.prototype.jpoint=function(e,r,i){return new Lt(this,e,r,i)},Lt.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)},Lt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Lt.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(),v=l.redMul(c),M=n.redMul(l),I=h.redSqr().redIAdd(v).redISub(M).redISub(M),S=h.redMul(M.redISub(I)).redISub(o.redMul(v)),D=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,S,D)},Lt.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),v=i.redMul(h),M=c.redSqr().redIAdd(l).redISub(v).redISub(v),I=c.redMul(v.redISub(M)).redISub(s.redMul(l)),S=this.z.redMul(a);return this.curve.jpoint(M,I,S)},Lt.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 v=o.redSqr(),M=l.redSqr(),I=M.redSqr(),S=v.redAdd(v).redIAdd(v).redIAdd(n.redMul(h)),D=o.redMul(M),F=S.redSqr().redISub(D.redAdd(D)),T=D.redISub(F),O=S.redMul(T);O=O.redIAdd(O).redISub(I);var $=l.redMul(c);r+1<e&&(h=h.redMul(I)),o=F,c=$,l=O}return this.curve.jpoint(o,l.redMul(s),c)},Lt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Lt.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 v=this.x.redSqr(),M=this.y.redSqr(),I=M.redSqr(),S=this.x.redAdd(M).redSqr().redISub(v).redISub(I);S=S.redIAdd(S);var D=v.redAdd(v).redIAdd(v),F=D.redSqr(),T=I.redIAdd(I);T=T.redIAdd(T),T=T.redIAdd(T),e=F.redISub(S).redISub(S),r=D.redMul(S.redISub(e)).redISub(T),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Lt.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 v=this.z.redSqr(),M=this.y.redSqr(),I=this.x.redMul(M),S=this.x.redSub(v).redMul(this.x.redAdd(v));S=S.redAdd(S).redIAdd(S);var D=I.redIAdd(I);D=D.redIAdd(D);var F=D.redAdd(D);e=S.redSqr().redISub(F),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(v);var T=M.redSqr();T=T.redIAdd(T),T=T.redIAdd(T),T=T.redIAdd(T),r=S.redMul(D.redISub(e)).redISub(T)}return this.curve.jpoint(e,r,i)},Lt.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),v=c.redSqr().redISub(l.redAdd(l)),M=l.redISub(v),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(v,S,D)},Lt.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),v=r.redMul(l);v=v.redIAdd(v),v=v.redIAdd(v);var M=this.x.redMul(c).redISub(v);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)},Lt.prototype.mul=function(e,r){return e=new pt(e,r),this.curve._wnafMul(this,e)},Lt.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},Lt.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}},Lt.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)+">"},Lt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Kn=ei.exports,Id=Tn.exports,$o=Ro,qw=pr;function Vn(t){$o.call(this,"mont",t),this.a=new Kn(t.a,16).toRed(this.red),this.b=new Kn(t.b,16).toRed(this.red),this.i4=new Kn(4).toRed(this.red).redInvm(),this.two=new Kn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Id(Vn,$o);var Uw=Vn;Vn.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 Dt(t,e,r){$o.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Kn(e,16),this.z=new Kn(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Id(Dt,$o.BasePoint),Vn.prototype.decodePoint=function(e,r){return this.point(qw.toArray(e,r),1)},Vn.prototype.point=function(e,r){return new Dt(this,e,r)},Vn.prototype.pointFromJSON=function(e){return Dt.fromJSON(this,e)},Dt.prototype.precompute=function(){},Dt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Dt.fromJSON=function(e,r){return new Dt(e,r[0],r[1]||e.one)},Dt.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)+">"},Dt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Dt.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)},Dt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Dt.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)},Dt.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},Dt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Dt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Dt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Dt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Dt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var zw=pr,pi=ei.exports,Ad=Tn.exports,No=Ro,kw=zw.assert;function ti(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,No.call(this,"edwards",t),this.a=new pi(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new pi(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new pi(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),kw(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}Ad(ti,No);var jw=ti;ti.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},ti.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},ti.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},ti.prototype.pointFromX=function(e,r){e=new pi(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)},ti.prototype.pointFromY=function(e,r){e=new pi(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)},ti.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 ft(t,e,r,i,n){No.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 pi(e,16),this.y=new pi(r,16),this.z=i?new pi(i,16):this.curve.one,this.t=n&&new pi(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()))))}Ad(ft,No.BasePoint),ti.prototype.pointFromJSON=function(e){return ft.fromJSON(this,e)},ti.prototype.point=function(e,r,i,n){return new ft(this,e,r,i,n)},ft.fromJSON=function(e,r){return new ft(e,r[0],r[1],r[2])},ft.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)+">"},ft.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ft.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),v=s.redMul(c),M=a.redMul(o);return this.curve.point(h,l,M,v)},ft.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)},ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ft.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),v=c.redMul(h),M=o.redMul(h),I=a.redMul(c);return this.curve.point(l,v,I,M)},ft.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),v,M;return this.curve.twisted?(v=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),M=a.redMul(c)):(v=r.redMul(c).redMul(s.redSub(n)),M=this.curve._mulC(a).redMul(c)),this.curve.point(l,v,M)},ft.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ft.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ft.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},ft.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},ft.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},ft.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ft.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ft.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ft.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ft.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}},ft.prototype.toP=ft.prototype.normalize,ft.prototype.mixedAdd=ft.prototype.add,function(t){var e=t;e.base=Ro,e.short=Lw,e.mont=Uw,e.edwards=jw}(If);var Fo={},Df,Dd;function Kw(){return Dd||(Dd=1,Df={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"]]}}),Df}(function(t){var e=t,r=dr,i=If,n=pr,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 v=new o(l);return Object.defineProperty(e,h,{configurable:!0,enumerable:!0,value:v}),v}})}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=Kw()}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]})})(Fo);var Vw=dr,cn=Sf,Od=sn;function zi(t){if(!(this instanceof zi))return new zi(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=cn.toArray(t.entropy,t.entropyEnc||"hex"),r=cn.toArray(t.nonce,t.nonceEnc||"hex"),i=cn.toArray(t.pers,t.persEnc||"hex");Od(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Hw=zi;zi.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},zi.prototype._hmac=function(){return new Vw.hmac(this.hash,this.K)},zi.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())},zi.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=cn.toArray(e,r),i=cn.toArray(i,n),Od(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},zi.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=cn.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++,cn.encode(o,r)};var Ww=ei.exports,Gw=pr,Of=Gw.assert;function Vt(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 Jw=Vt;Vt.fromPublic=function(e,r,i){return r instanceof Vt?r:new Vt(e,{pub:r,pubEnc:i})},Vt.fromPrivate=function(e,r,i){return r instanceof Vt?r:new Vt(e,{priv:r,privEnc:i})},Vt.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"}},Vt.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},Vt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Vt.prototype._importPrivate=function(e,r){this.priv=new Ww(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Vt.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)},Vt.prototype.derive=function(e){return e.validate()||Of(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Vt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Vt.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},Vt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var To=ei.exports,Pf=pr,Yw=Pf.assert;function Co(t,e){if(t instanceof Co)return t;this._importDER(t,e)||(Yw(t.r&&t.s,"Signature without r or s"),this.r=new To(t.r,16),this.s=new To(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Xw=Co;function Zw(){this.place=0}function Rf(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 Pd(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)}Co.prototype._importDER=function(e,r){e=Pf.toArray(e,r);var i=new Zw;if(e[i.place++]!==48)return!1;var n=Rf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Rf(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=Rf(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 To(o),this.s=new To(c),this.recoveryParam=null,!0};function $f(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)}Co.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=Pd(r),i=Pd(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];$f(n,r.length),n=n.concat(r),n.push(2),$f(n,i.length);var s=n.concat(i),o=[48];return $f(o,s.length),o=o.concat(s),Pf.encode(o,e)};var Lr=ei.exports,Rd=Hw,Qw=pr,Nf=Fo,e6=Do.exports,hn=Qw.assert,Ff=Jw,Bo=Xw;function Ir(t){if(!(this instanceof Ir))return new Ir(t);typeof t=="string"&&(hn(Object.prototype.hasOwnProperty.call(Nf,t),"Unknown curve "+t),t=Nf[t]),t instanceof Nf.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 t6=Ir;Ir.prototype.keyPair=function(e){return new Ff(this,e)},Ir.prototype.keyFromPrivate=function(e,r){return Ff.fromPrivate(this,e,r)},Ir.prototype.keyFromPublic=function(e,r){return Ff.fromPublic(this,e,r)},Ir.prototype.genKeyPair=function(e){e||(e={});for(var r=new Rd({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||e6(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Lr(2));;){var s=new Lr(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Ir.prototype._truncateToN=function(e,r,i){var n;if(Lr.isBN(e)||typeof e=="number")e=new Lr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Lr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Lr(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},Ir.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Lr.isBN(e)){hn(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),hn(e.length>>>0===e.length);for(var s=0;s<e.length;s++)hn((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),hn(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);hn(new Lr(c).eq(e),"Can not sign message");for(var h=new Rd({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new Lr(1)),v=0;;v++){var M=n.k?n.k(v):new Lr(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 F=M.invm(this.n).mul(D.mul(r.getPrivate()).iadd(e));if(F=F.umod(this.n),F.cmpn(0)!==0){var T=(I.getY().isOdd()?1:0)|(S.cmp(D)!==0?2:0);return n.canonical&&F.cmp(this.nh)>0&&(F=this.n.sub(F),T^=1),new Bo({r:D,s:F,recoveryParam:T})}}}}}},Ir.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new Bo(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),v;return this.curve._maxwellTrick?(v=this.g.jmulAdd(h,i.getPublic(),l),v.isInfinity()?!1:v.eqXToP(o)):(v=this.g.mulAdd(h,i.getPublic(),l),v.isInfinity()?!1:v.getX().umod(this.n).cmp(o)===0)},Ir.prototype.recoverPubKey=function(t,e,r,i){hn((3&r)===r,"The recovery param is more than two bits"),e=new Bo(e,i);var n=this.n,s=new Lr(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),v=n.sub(s).mul(l).umod(n),M=a.mul(l).umod(n);return this.g.mulAdd(v,o,M)},Ir.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Bo(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 Ss=pr,$d=Ss.assert,Nd=Ss.parseBytes,Hn=Ss.cachedProperty;function Ot(t,e){this.eddsa=t,this._secret=Nd(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Nd(e.pub)}Ot.fromPublic=function(e,r){return r instanceof Ot?r:new Ot(e,{pub:r})},Ot.fromSecret=function(e,r){return r instanceof Ot?r:new Ot(e,{secret:r})},Ot.prototype.secret=function(){return this._secret},Hn(Ot,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),Hn(Ot,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),Hn(Ot,"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}),Hn(Ot,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),Hn(Ot,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),Hn(Ot,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Ot.prototype.sign=function(e){return $d(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Ot.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},Ot.prototype.getSecret=function(e){return $d(this._secret,"KeyPair is public only"),Ss.encode(this.secret(),e)},Ot.prototype.getPublic=function(e){return Ss.encode(this.pubBytes(),e)};var r6=Ot,i6=ei.exports,Lo=pr,Fd=Lo.assert,qo=Lo.cachedProperty,n6=Lo.parseBytes;function un(t,e){this.eddsa=t,typeof e!="object"&&(e=n6(e)),Array.isArray(e)&&(Fd(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),Fd(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof i6&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}qo(un,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),qo(un,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),qo(un,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),qo(un,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),un.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},un.prototype.toHex=function(){return Lo.encode(this.toBytes(),"hex").toUpperCase()};var s6=un,o6=dr,a6=Fo,Wn=pr,f6=Wn.assert,Td=Wn.parseBytes,Cd=r6,Bd=s6;function sr(t){if(f6(t==="ed25519","only tested with ed25519 so far"),!(this instanceof sr))return new sr(t);t=a6[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=o6.sha512}var c6=sr;sr.prototype.sign=function(e,r){e=Td(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})},sr.prototype.verify=function(e,r,i){if(e=Td(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)},sr.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return Wn.intFromLE(e.digest()).umod(this.curve.n)},sr.prototype.keyFromPublic=function(e){return Cd.fromPublic(this,e)},sr.prototype.keyFromSecret=function(e){return Cd.fromSecret(this,e)},sr.prototype.makeSignature=function(e){return e instanceof Bd?e:new Bd(this,e)},sr.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},sr.prototype.decodePoint=function(e){e=Wn.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=Wn.intFromLE(i);return this.curve.pointFromY(s,n)},sr.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},sr.prototype.decodeInt=function(e){return Wn.intFromLE(e)},sr.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=Fw.version,e.utils=pr,e.rand=Do.exports,e.curve=If,e.curves=Fo,e.ec=t6,e.eddsa=c6}(Sd);const h6={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"}},u6=":";function Uo(t){const[e,r]=t.split(u6);return{namespace:e,reference:r}}function Ld(t,e){return t.includes(":")?[t]:e.chains||[]}var d6=Object.defineProperty,qd=Object.getOwnPropertySymbols,l6=Object.prototype.hasOwnProperty,p6=Object.prototype.propertyIsEnumerable,Ud=(t,e,r)=>e in t?d6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zd=(t,e)=>{for(var r in e||(e={}))l6.call(e,r)&&Ud(t,r,e[r]);if(qd)for(var r of qd(e))p6.call(e,r)&&Ud(t,r,e[r]);return t};const g6="ReactNative",gr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},b6="js";function zo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ki(){return!ds()&&!!Ja()&&navigator.product===g6}function v6(){return ki()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function y6(){return ki()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Ms(){return!zo()&&!!Ja()&&!!ds()}function Is(){return ki()?gr.reactNative:zo()?gr.node:Ms()?gr.browser:gr.unknown}function kd(){var t;try{return ki()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function m6(t,e){let r=ls.parse(t);return r=zd(zd({},r),e),t=ls.stringify(r),t}function jd(){return ou()||{name:"",description:"",url:"",icons:[""]}}function w6(){if(Is()===gr.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=Iy();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 _6(){var t;const e=Is();return e===gr.browser?[e,((t=su())==null?void 0:t.host)||"unknown"].join(":"):e}function Kd(t,e,r){const i=w6(),n=_6();return[[t,e].join("-"),[b6,r].join("-"),i,n].join("/")}function x6({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=r.split("?"),l=Kd(t,e,i),v={auth:n,ua:l,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},M=m6(h[1]||"",v);return h[0]+"?"+M}function dn(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Vd(t){return Object.fromEntries(t.entries())}function Hd(t){return new Map(Object.entries(t))}function ln(t=Y.FIVE_MINUTES,e){const r=Y.toMiliseconds(t||Y.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 ji(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 Wd(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 E6(t){return Wd("topic",t)}function S6(t){return Wd("id",t)}function Gd(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 Et(t,e){return Y.fromMiliseconds((e||Date.now())+Y.toMiliseconds(t))}function Ki(t){return Date.now()>=Y.toMiliseconds(t)}function Se(t,e){return`${t}${e?`:${e}`:""}`}function M6(t=[],e=[]){return[...new Set([...t,...e])]}async function I6({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=A6(s,t,e),a=Is();if(a===gr.browser){if(!((i=ds())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,O6()?"_blank":"_self","noreferrer noopener")}else a===gr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function A6(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}${P6(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function D6(t,e){let r="";try{if(Ms()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function Jd(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function Yd(){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 Tf(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function O6(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function P6(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Xd(t){return Buffer.from(t,"base64").toString("utf-8")}function R6(t){return new Promise(e=>setTimeout(e,t))}function As(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function $6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ko(t,...e){if(!$6(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 Cf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");As(t.outputLen),As(t.blockLen)}function Gn(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 Zd(t,e){ko(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const jo=BigInt(2**32-1),Qd=BigInt(32);function N6(t,e=!1){return e?{h:Number(t&jo),l:Number(t>>Qd&jo)}:{h:Number(t>>Qd&jo)|0,l:Number(t&jo)|0}}function F6(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}=N6(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const T6=(t,e,r)=>t<<r|e>>>32-r,C6=(t,e,r)=>e<<r|t>>>32-r,B6=(t,e,r)=>e<<r-32|t>>>64-r,L6=(t,e,r)=>t<<r-32|e>>>64-r,Jn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const q6=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Bf=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ri=(t,e)=>t<<32-e|t>>>e,el=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),U6=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function tl(t){for(let e=0;e<t.length;e++)t[e]=U6(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 Yn(t){return typeof t=="string"&&(t=z6(t)),ko(t),t}class Lf{clone(){return this._cloneInto()}}function rl(t){const e=i=>t().update(Yn(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ds(t=32){if(Jn&&typeof Jn.getRandomValues=="function")return Jn.getRandomValues(new Uint8Array(t));if(Jn&&typeof Jn.randomBytes=="function")return Jn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const il=[],nl=[],sl=[],k6=BigInt(0),Os=BigInt(1),j6=BigInt(2),K6=BigInt(7),V6=BigInt(256),H6=BigInt(113);for(let t=0,e=Os,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],il.push(2*(5*i+r)),nl.push((t+1)*(t+2)/2%64);let n=k6;for(let s=0;s<7;s++)e=(e<<Os^(e>>K6)*H6)%V6,e&j6&&(n^=Os<<(Os<<BigInt(s))-Os);sl.push(n)}const[W6,G6]=F6(sl,!0),ol=(t,e,r)=>r>32?B6(t,e,r):T6(t,e,r),al=(t,e,r)=>r>32?L6(t,e,r):C6(t,e,r);function J6(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],v=ol(h,l,1)^r[a],M=al(h,l,1)^r[a+1];for(let I=0;I<50;I+=10)t[o+I]^=v,t[o+I+1]^=M}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=nl[o],c=ol(n,s,a),h=al(n,s,a),l=il[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]^=W6[i],t[1]^=G6[i]}r.fill(0)}class qf extends Lf{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,As(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=q6(this.state)}keccak(){el||tl(this.state32),J6(this.state32,this.rounds),el||tl(this.state32),this.posOut=0,this.pos=0}update(e){Gn(this);const{blockLen:r,state:i}=this;e=Yn(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){Gn(this,!1),ko(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 As(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zd(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 qf(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 Y6=(t,e,r)=>rl(()=>new qf(e,t,r)),X6=Y6(1,136,256/8),Z6="https://rpc.walletconnect.org/v1";function fl(t){const e=`Ethereum Signed Message:
|
22
|
+
${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(X6(r)).toString("hex")}async function Q6(t,e,r,i,n,s){switch(r.t){case"eip191":return e4(t,e,r.s);case"eip1271":return await t4(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function e4(t,e,r){return e3(fl(e),r).toLowerCase()===t.toLowerCase()}async function t4(t,e,r,i,n,s){const o=Uo(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",h="0000000000000000000000000000000000000000000000000000000000000041",l=r.substring(2),v=fl(e).substring(2),M=a+v+c+h+l,I=await fetch(`${s||Z6}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:r4(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:M},"latest"]})}),{result:S}=await I.json();return S?S.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function r4(){return Date.now()+Math.floor(Math.random()*1e3)}var i4=Object.defineProperty,n4=Object.defineProperties,s4=Object.getOwnPropertyDescriptors,cl=Object.getOwnPropertySymbols,o4=Object.prototype.hasOwnProperty,a4=Object.prototype.propertyIsEnumerable,hl=(t,e,r)=>e in t?i4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,f4=(t,e)=>{for(var r in e||(e={}))o4.call(e,r)&&hl(t,r,e[r]);if(cl)for(var r of cl(e))a4.call(e,r)&&hl(t,r,e[r]);return t},c4=(t,e)=>n4(t,s4(e));const h4="did:pkh:",Uf=t=>t?.split(":"),u4=t=>{const e=t&&Uf(t);if(e)return t.includes(h4)?e[3]:e[1]},zf=t=>{const e=t&&Uf(t);if(e)return e[2]+":"+e[3]},Ko=t=>{const e=t&&Uf(t);if(e)return e.pop()};async function ul(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=dl(n,n.iss),o=Ko(n.iss);return await Q6(o,s,i,zf(n.iss),r)}const dl=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=Ko(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: ${u4(e)}`,c=`Nonce: ${t.nonce}`,h=`Issued At: ${t.iat}`,l=t.exp?`Expiration Time: ${t.exp}`:void 0,v=t.nbf?`Not Before: ${t.nbf}`:void 0,M=t.requestId?`Request ID: ${t.requestId}`:void 0,I=t.resources?`Resources:${t.resources.map(D=>`
|
23
|
+
- ${D}`).join("")}`:void 0,S=Vo(t.resources);if(S){const D=Ps(S);n=w4(n,D)}return[r,i,"",n,"",s,o,a,c,h,l,v,M,I].filter(D=>D!=null).join(`
|
24
|
+
`)};function d4(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function l4(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function pn(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 p4(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:g4(e,r,i)}}}function g4(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function ll(t){return pn(t),`urn:recap:${d4(t).replace(/=/g,"")}`}function Ps(t){const e=l4(t.replace("urn:recap:",""));return pn(e),e}function b4(t,e,r){const i=p4(t,e,r);return ll(i)}function v4(t){return t&&t.includes("urn:recap:")}function y4(t,e){const r=Ps(t),i=Ps(e),n=m4(r,i);return ll(n)}function m4(t,e){pn(t),pn(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]=c4(f4({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((h=e.att[n])==null?void 0:h[a])})})}),i}function w4(t="",e){pn(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(v=>({ability:v.split("/")[0],action:v.split("/")[1]}));c.sort((v,M)=>v.action.localeCompare(M.action));const h={};c.forEach(v=>{h[v.ability]||(h[v.ability]=[]),h[v.ability].push(v.action)});const l=Object.keys(h).map(v=>(n++,`(${n}) '${v}': '${h[v].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function pl(t){var e;const r=Ps(t);pn(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function gl(t){const e=Ps(t);pn(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 Vo(t){if(!t)return;const e=t?.[t.length-1];return v4(e)?e:void 0}function kf(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function br(t,...e){if(!bl(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 vl(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){br(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function yl(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Vi=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),x4=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 E4(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function jf(t){if(typeof t=="string")t=E4(t);else if(bl(t))t=Kf(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function S4(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function M4(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 I4=(t,e)=>{function r(i,...n){if(br(i),t.nonceLength!==void 0){const h=n[0];if(!h)throw new Error("nonce / iv required");t.varSizeNonce?br(h):br(h,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&br(n[1]);const o=e(i,...n),a=(h,l)=>{if(l!==void 0){if(h!==2)throw new Error("cipher output not supported");br(l)}};let c=!1;return{encrypt(h,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,br(h),a(o.encrypt.length,l),o.encrypt(h,l)},decrypt(h,l){if(br(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 ml(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&&!A4(e))throw new Error("invalid output, must be aligned");return e}function wl(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 A4(t){return t.byteOffset%4===0}function Kf(t){return Uint8Array.from(t)}function Xn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const _l=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),D4=_l("expand 16-byte k"),O4=_l("expand 32-byte k"),P4=Vi(D4),R4=Vi(O4);function Le(t,e){return t<<e|t>>>32-e}function Vf(t){return t.byteOffset%4===0}const Ho=64,$4=16,xl=2**32-1,El=new Uint32Array;function N4(t,e,r,i,n,s,o,a){const c=n.length,h=new Uint8Array(Ho),l=Vi(h),v=Vf(n)&&Vf(s),M=v?Vi(n):El,I=v?Vi(s):El;for(let S=0;S<c;o++){if(t(e,r,i,l,o,a),o>=xl)throw new Error("arx: counter overflow");const D=Math.min(Ho,c-S);if(v&&D===Ho){const F=S/4;if(S%4!==0)throw new Error("arx: invalid block position");for(let T=0,O;T<$4;T++)O=F+T,I[O]=M[O]^l[T];S+=Ho;continue}for(let F=0,T;F<D;F++)T=S+F,s[T]=n[T]^h[F];S+=D}}function F4(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=S4({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return kf(n),kf(o),yl(s),yl(r),(a,c,h,l,v=0)=>{br(a),br(c),br(h);const M=h.length;if(l===void 0&&(l=new Uint8Array(M)),br(l),kf(v),v<0||v>=xl)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,F;if(S===32)I.push(D=Kf(a)),F=R4;else if(S===16&&r)D=new Uint8Array(32),D.set(a),D.set(a,16),F=P4,I.push(D);else throw new Error(`arx: invalid 32-byte key, got length=${S}`);Vf(c)||I.push(c=Kf(c));const T=Vi(D);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(F,T,Vi(c.subarray(0,16)),T),c=c.subarray(16)}const O=16-n;if(O!==c.length)throw new Error(`arx: nonce must be ${O} or 16 bytes`);if(O!==12){const N=new Uint8Array(12);N.set(c,s?0:12-c.length),c=N,I.push(c)}const $=Vi(c);return N4(t,F,T,$,h,l,v,o),Xn(...I),l}}const qt=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class T4{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=jf(e),br(e,32);const r=qt(e,0),i=qt(e,2),n=qt(e,4),s=qt(e,6),o=qt(e,8),a=qt(e,10),c=qt(e,12),h=qt(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]=qt(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],v=o[4],M=o[5],I=o[6],S=o[7],D=o[8],F=o[9],T=qt(e,r+0),O=qt(e,r+2),$=qt(e,r+4),N=qt(e,r+6),C=qt(e,r+8),L=qt(e,r+10),V=qt(e,r+12),z=qt(e,r+14);let H=s[0]+(T&8191),re=s[1]+((T>>>13|O<<3)&8191),P=s[2]+((O>>>10|$<<6)&8191),g=s[3]+(($>>>7|N<<9)&8191),p=s[4]+((N>>>4|C<<12)&8191),f=s[5]+(C>>>1&8191),u=s[6]+((C>>>14|L<<2)&8191),b=s[7]+((L>>>11|V<<5)&8191),_=s[8]+((V>>>8|z<<8)&8191),E=s[9]+(z>>>5|n),w=0,d=w+H*a+re*(5*F)+P*(5*D)+g*(5*S)+p*(5*I);w=d>>>13,d&=8191,d+=f*(5*M)+u*(5*v)+b*(5*l)+_*(5*h)+E*(5*c),w+=d>>>13,d&=8191;let m=w+H*c+re*a+P*(5*F)+g*(5*D)+p*(5*S);w=m>>>13,m&=8191,m+=f*(5*I)+u*(5*M)+b*(5*v)+_*(5*l)+E*(5*h),w+=m>>>13,m&=8191;let y=w+H*h+re*c+P*a+g*(5*F)+p*(5*D);w=y>>>13,y&=8191,y+=f*(5*S)+u*(5*I)+b*(5*M)+_*(5*v)+E*(5*l),w+=y>>>13,y&=8191;let A=w+H*l+re*h+P*c+g*a+p*(5*F);w=A>>>13,A&=8191,A+=f*(5*D)+u*(5*S)+b*(5*I)+_*(5*M)+E*(5*v),w+=A>>>13,A&=8191;let j=w+H*v+re*l+P*h+g*c+p*a;w=j>>>13,j&=8191,j+=f*(5*F)+u*(5*D)+b*(5*S)+_*(5*I)+E*(5*M),w+=j>>>13,j&=8191;let x=w+H*M+re*v+P*l+g*h+p*c;w=x>>>13,x&=8191,x+=f*a+u*(5*F)+b*(5*D)+_*(5*S)+E*(5*I),w+=x>>>13,x&=8191;let B=w+H*I+re*M+P*v+g*l+p*h;w=B>>>13,B&=8191,B+=f*c+u*a+b*(5*F)+_*(5*D)+E*(5*S),w+=B>>>13,B&=8191;let U=w+H*S+re*I+P*M+g*v+p*l;w=U>>>13,U&=8191,U+=f*h+u*c+b*a+_*(5*F)+E*(5*D),w+=U>>>13,U&=8191;let k=w+H*D+re*S+P*I+g*M+p*v;w=k>>>13,k&=8191,k+=f*l+u*h+b*c+_*a+E*(5*F),w+=k>>>13,k&=8191;let K=w+H*F+re*D+P*S+g*I+p*M;w=K>>>13,K&=8191,K+=f*v+u*l+b*h+_*c+E*a,w+=K>>>13,K&=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]=y,s[3]=A,s[4]=j,s[5]=x,s[6]=B,s[7]=U,s[8]=k,s[9]=K}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;Xn(i)}update(e){vl(this);const{buffer:r,blockLen:i}=this;e=jf(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(){Xn(this.h,this.r,this.buffer,this.pad)}digestInto(e){vl(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 C4(t){const e=(i,n)=>t(n).update(jf(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const B4=C4(t=>new T4(t));function L4(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],h=t[3],l=e[0],v=e[1],M=e[2],I=e[3],S=e[4],D=e[5],F=e[6],T=e[7],O=n,$=r[0],N=r[1],C=r[2],L=o,V=a,z=c,H=h,re=l,P=v,g=M,p=I,f=S,u=D,b=F,_=T,E=O,w=$,d=N,m=C;for(let A=0;A<s;A+=2)L=L+re|0,E=Le(E^L,16),f=f+E|0,re=Le(re^f,12),L=L+re|0,E=Le(E^L,8),f=f+E|0,re=Le(re^f,7),V=V+P|0,w=Le(w^V,16),u=u+w|0,P=Le(P^u,12),V=V+P|0,w=Le(w^V,8),u=u+w|0,P=Le(P^u,7),z=z+g|0,d=Le(d^z,16),b=b+d|0,g=Le(g^b,12),z=z+g|0,d=Le(d^z,8),b=b+d|0,g=Le(g^b,7),H=H+p|0,m=Le(m^H,16),_=_+m|0,p=Le(p^_,12),H=H+p|0,m=Le(m^H,8),_=_+m|0,p=Le(p^_,7),L=L+P|0,m=Le(m^L,16),b=b+m|0,P=Le(P^b,12),L=L+P|0,m=Le(m^L,8),b=b+m|0,P=Le(P^b,7),V=V+g|0,E=Le(E^V,16),_=_+E|0,g=Le(g^_,12),V=V+g|0,E=Le(E^V,8),_=_+E|0,g=Le(g^_,7),z=z+p|0,w=Le(w^z,16),f=f+w|0,p=Le(p^f,12),z=z+p|0,w=Le(w^z,8),f=f+w|0,p=Le(p^f,7),H=H+re|0,d=Le(d^H,16),u=u+d|0,re=Le(re^u,12),H=H+re|0,d=Le(d^H,8),u=u+d|0,re=Le(re^u,7);let y=0;i[y++]=o+L|0,i[y++]=a+V|0,i[y++]=c+z|0,i[y++]=h+H|0,i[y++]=l+re|0,i[y++]=v+P|0,i[y++]=M+g|0,i[y++]=I+p|0,i[y++]=S+f|0,i[y++]=D+u|0,i[y++]=F+b|0,i[y++]=T+_|0,i[y++]=O+E|0,i[y++]=$+w|0,i[y++]=N+d|0,i[y++]=C+m|0}const q4=F4(L4,{counterRight:!1,counterLength:4,allowShortKeys:!1}),U4=new Uint8Array(16),Sl=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(U4.subarray(r))},z4=new Uint8Array(32);function Ml(t,e,r,i,n){const s=t(e,r,z4),o=B4.create(s);n&&Sl(o,n),Sl(o,i);const a=new Uint8Array(16),c=x4(a);wl(c,0,BigInt(n?n.length:0),!0),wl(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return Xn(s,a),h}const k4=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=ml(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=Ml(t,e,r,a,i);return s.set(c,o),Xn(c),s},decrypt(n,s){s=ml(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Ml(t,e,r,o,i);if(!M4(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),Xn(c),s}}),Il=I4({blockSize:64,nonceLength:12,tagLength:16},k4(q4));class Al extends Lf{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Cf(e);const i=Yn(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 Gn(this),this.iHash.update(e),this}digestInto(e){Gn(this),ko(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 Hf=(t,e,r)=>new Al(t,e).update(r).digest();Hf.create=(t,e)=>new Al(t,e);function j4(t,e,r){return Cf(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Hf(t,Yn(r),Yn(e))}const Wf=new Uint8Array([0]),Dl=new Uint8Array;function K4(t,e,r,i=32){if(Cf(t),As(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=Dl);const s=new Uint8Array(n*t.outputLen),o=Hf.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let h=0;h<n;h++)Wf[0]=h+1,a.update(h===0?Dl:c).update(r).update(Wf).digestInto(c),s.set(c,t.outputLen*h),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Wf.fill(0),s.slice(0,i)}const V4=(t,e,r,i,n)=>K4(t,j4(t,e,r),i,n);function H4(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)}const W4=(t,e,r)=>t&e^~t&r,G4=(t,e,r)=>t&e^t&r^e&r;class J4 extends Lf{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=Bf(this.buffer)}update(e){Gn(this);const{view:r,buffer:i,blockLen:n}=this;e=Yn(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=Bf(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){Gn(this),Zd(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 v=o;v<n;v++)r[v]=0;H4(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Bf(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 v=0;v<h;v++)a.setUint32(4*v,l[v],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 Y4=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]),Wi=new Uint32Array(64);class X4 extends J4{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 v=0;v<16;v++,r+=4)Wi[v]=e.getUint32(r,!1);for(let v=16;v<64;v++){const M=Wi[v-15],I=Wi[v-2],S=ri(M,7)^ri(M,18)^M>>>3,D=ri(I,17)^ri(I,19)^I>>>10;Wi[v]=D+Wi[v-7]+S+Wi[v-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:h,H:l}=this;for(let v=0;v<64;v++){const M=ri(a,6)^ri(a,11)^ri(a,25),I=l+M+W4(a,c,h)+Y4[v]+Wi[v]|0,S=(ri(i,2)^ri(i,13)^ri(i,22))+G4(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(){Wi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Wo=rl(()=>new X4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ol=BigInt(0);function Gf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pl(t){if(!Gf(t))throw new Error("Uint8Array expected")}const Z4=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Q4(t){Pl(t);let e="";for(let r=0;r<t.length;r++)e+=Z4[t[r]];return e}function e8(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ol:BigInt("0x"+t)}const gi={_0:48,_9:57,A:65,F:70,a:97,f:102};function Rl(t){if(t>=gi._0&&t<=gi._9)return t-gi._0;if(t>=gi.A&&t<=gi.F)return t-(gi.A-10);if(t>=gi.a&&t<=gi.f)return t-(gi.a-10)}function $l(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=Rl(t.charCodeAt(s)),a=Rl(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 Nl(t){return Pl(t),e8(Q4(Uint8Array.from(t).reverse()))}function t8(t,e){return $l(t.toString(16).padStart(e*2,"0"))}function r8(t,e){return t8(t,e).reverse()}function Fl(t,e,r){let i;if(typeof e=="string")try{i=$l(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Gf(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 Jf=t=>typeof t=="bigint"&&Ol<=t;function i8(t,e,r){return Jf(t)&&Jf(e)&&Jf(r)&&e<=t&&t<r}function Tl(t,e,r,i){if(!i8(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const n8={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"||Gf(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 s8(t,e,r={}){const i=(n,s,o)=>{const a=n8[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 Zn=BigInt(0),Go=BigInt(1);function Cl(t,e){const r=t%e;return r>=Zn?r:e+r}function o8(t,e,r){if(e<Zn)throw new Error("invalid exponent, negatives unsupported");if(r<=Zn)throw new Error("invalid modulus");if(r===Go)return Zn;let i=Go;for(;e>Zn;)e&Go&&(i=i*t%r),t=t*t%r,e>>=Go;return i}function qr(t,e,r){let i=t;for(;e-- >Zn;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Qn=BigInt(0),Yf=BigInt(1);function a8(t){return s8(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function f8(t){const e=a8(t),{P:r}=e,i=O=>Cl(O,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(O=>O),c=e.powPminus2||(O=>o8(O,r-BigInt(2),r));function h(O,$,N){const C=i(O*($-N));return $=i($-C),N=i(N+C),[$,N]}const l=(e.a-BigInt(2))/BigInt(4);function v(O,$){Tl("u",O,Qn,r),Tl("scalar",$,Qn,r);const N=$,C=O;let L=Yf,V=Qn,z=O,H=Yf,re=Qn,P;for(let p=BigInt(n-1);p>=Qn;p--){const f=N>>p&Yf;re^=f,P=h(re,L,z),L=P[0],z=P[1],P=h(re,V,H),V=P[0],H=P[1],re=f;const u=L+V,b=i(u*u),_=L-V,E=i(_*_),w=b-E,d=z+H,m=z-H,y=i(m*u),A=i(d*_),j=y+A,x=y-A;z=i(j*j),H=i(C*i(x*x)),L=i(b*E),V=i(w*(b+i(l*w)))}P=h(re,L,z),L=P[0],z=P[1],P=h(re,V,H),V=P[0],H=P[1];const g=c(V);return i(L*g)}function M(O){return r8(i(O),s)}function I(O){const $=Fl("u coordinate",O,s);return o===32&&($[31]&=127),Nl($)}function S(O){const $=Fl("scalar",O),N=$.length;if(N!==s&&N!==o){let C=""+s+" or "+o;throw new Error("invalid scalar, expected "+C+" bytes, got "+N)}return Nl(a($))}function D(O,$){const N=I($),C=S(O),L=v(N,C);if(L===Qn)throw new Error("invalid private or public key received");return M(L)}const F=M(e.Gu);function T(O){return D(O,F)}return{scalarMult:D,scalarMultBase:T,getSharedSecret:(O,$)=>D(O,$),getPublicKey:O=>T(O),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:F}}const Xf=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const c8=BigInt(1),Bl=BigInt(2),h8=BigInt(3),u8=BigInt(5);BigInt(8);function d8(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=Xf,o=t*t%s*t%s,a=qr(o,Bl,s)*o%s,c=qr(a,c8,s)*t%s,h=qr(c,u8,s)*c%s,l=qr(h,e,s)*h%s,v=qr(l,r,s)*l%s,M=qr(v,i,s)*v%s,I=qr(M,n,s)*M%s,S=qr(I,n,s)*M%s,D=qr(S,e,s)*h%s;return{pow_p_5_8:qr(D,Bl,s)*t%s,b2:o}}function l8(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Zf=(()=>f8({P:Xf,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Xf,{pow_p_5_8:r,b2:i}=d8(t);return Cl(qr(r,h8,e)*i,e)},adjustScalarBytes:l8,randomBytes:Ds}))(),Ll="base10",Ht="base16",Gi="base64pad",Rs="base64url",$s="utf8",ql=0,bi=1,Ns=2,p8=0,Ul=1,Fs=12,Qf=32;function g8(){const t=Zf.utils.randomPrivateKey(),e=Zf.getPublicKey(t);return{privateKey:Zt(t,Ht),publicKey:Zt(e,Ht)}}function ec(){const t=Ds(Qf);return Zt(t,Ht)}function b8(t,e){const r=Zf.getSharedSecret(Er(t,Ht),Er(e,Ht)),i=V4(Wo,r,void 0,void 0,Qf);return Zt(i,Ht)}function Jo(t){const e=Wo(Er(t,Ht));return Zt(e,Ht)}function vi(t){const e=Wo(Er(t,$s));return Zt(e,Ht)}function zl(t){return Er(`${t}`,Ll)}function gn(t){return Number(Zt(t,Ll))}function v8(t){const e=zl(typeof t.type<"u"?t.type:ql);if(gn(e)===bi&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Er(t.senderPublicKey,Ht):void 0,i=typeof t.iv<"u"?Er(t.iv,Ht):Ds(Fs),n=Er(t.symKey,Ht),s=Il(n,i).encrypt(Er(t.message,$s));return kl({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function y8(t){const e=Er(t.symKey,Ht),{sealed:r,iv:i}=Ts(t),n=Il(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return Zt(n,$s)}function m8(t,e){const r=zl(Ns),i=Ds(Fs),n=Er(t,$s);return kl({type:r,sealed:n,iv:i,encoding:e})}function w8(t,e){const{sealed:r}=Ts({encoded:t,encoding:e});return Zt(r,$s)}function kl(t){const{encoding:e=Gi}=t;if(gn(t.type)===Ns)return Zt(wf([t.type,t.sealed]),e);if(gn(t.type)===bi){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Zt(wf([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Zt(wf([t.type,t.iv,t.sealed]),e)}function Ts(t){const{encoded:e,encoding:r=Gi}=t,i=Er(e,r),n=i.slice(p8,Ul),s=Ul;if(gn(n)===bi){const h=s+Qf,l=h+Fs,v=i.slice(s,h),M=i.slice(h,l),I=i.slice(l);return{type:n,sealed:I,iv:M,senderPublicKey:v}}if(gn(n)===Ns){const h=i.slice(s),l=Ds(Fs);return{type:n,sealed:h,iv:l}}const o=s+Fs,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function _8(t,e){const r=Ts({encoded:t,encoding:e?.encoding});return jl({type:gn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Zt(r.senderPublicKey,Ht):void 0,receiverPublicKey:e?.receiverPublicKey})}function jl(t){const e=t?.type||ql;if(e===bi){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 Kl(t){return t.type===bi&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Vl(t){return t.type===Ns}function x8(t){return new Sd.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function E8(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function S8(t){return Buffer.from(E8(t),"base64")}function M8(t,e){const[r,i,n]=t.split("."),s=S8(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=Wo(c),l=x8(e),v=Zt(h,Ht);if(!l.verify(v,{r:o,s:a}))throw new Error("Invalid signature");return Ga(t).payload}const I8="irn";function Yo(t){return t?.relay||{protocol:I8}}function Cs(t){const e=h6[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var A8=Object.defineProperty,D8=Object.defineProperties,O8=Object.getOwnPropertyDescriptors,Hl=Object.getOwnPropertySymbols,P8=Object.prototype.hasOwnProperty,R8=Object.prototype.propertyIsEnumerable,Wl=(t,e,r)=>e in t?A8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gl=(t,e)=>{for(var r in e||(e={}))P8.call(e,r)&&Wl(t,r,e[r]);if(Hl)for(var r of Hl(e))R8.call(e,r)&&Wl(t,r,e[r]);return t},$8=(t,e)=>D8(t,O8(e));function N8(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 Jl(t){if(!t.includes("wc:")){const c=Xd(t);c!=null&&c.includes("wc:")&&(t=c)}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=ls.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:F8(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:N8(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function F8(t){return t.startsWith("//")?t.substring(2):t}function T8(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 Yl(t){return`${t.protocol}:${t.topic}@${t.version}?`+ls.stringify(Gl($8(Gl({symKey:t.symKey},T8(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function Xo(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function es(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function C8(t){const e=[];return Object.values(t).forEach(r=>{e.push(...es(r.accounts))}),e}function B8(t,e){const r=[];return Object.values(t).forEach(i=>{es(i.accounts).includes(e)&&r.push(...i.methods)}),r}function L8(t,e){const r=[];return Object.values(t).forEach(i=>{es(i.accounts).includes(e)&&r.push(...i.events)}),r}function q8(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 Xl(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=q8(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=M6(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const U8={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}},z8={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 Z(t,e){const{message:r,code:i}=z8[t];return{message:e?`${r} ${e}`:r,code:i}}function ct(t,e){const{message:r,code:i}=U8[t];return{message:e?`${r} ${e}`:r,code:i}}function Zo(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function Qo(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Qt(t){return typeof t>"u"}function mt(t,e){return e&&Qt(t)?!0:typeof t=="string"&&!!t.trim().length}function tc(t,e){return e&&Qt(t)?!0:typeof t=="number"&&!isNaN(t)}function k8(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return dn(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:h}=t.namespaces[o],l=es(a),v=r[o];(!dn(Ld(o,v),l)||!dn(v.methods,c)||!dn(v.events,h))&&(s=!1)}),s):!1}function ea(t){return mt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function j8(t){if(mt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ea(r)}}return!1}function K8(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=Xd(t);return e(r)}}catch{}return!1}function V8(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function H8(t){return t?.topic}function W8(t,e){let r=null;return mt(t?.publicKey,!1)||(r=Z("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Zl(t){let e=!0;return Zo(t)?t.length&&(e=t.every(r=>mt(r,!1))):e=!1,e}function G8(t,e,r){let i=null;return Zo(e)&&e.length?e.forEach(n=>{i||ea(n)||(i=ct("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):ea(t)||(i=ct("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 J8(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=G8(n,Ld(n,s),`${e} ${r}`);o&&(i=o)}),i}function Y8(t,e){let r=null;return Zo(t)?t.forEach(i=>{r||j8(i)||(r=ct("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=ct("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function X8(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=Y8(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function Z8(t,e){let r=null;return Zl(t?.methods)?Zl(t?.events)||(r=ct("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ct("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Ql(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=Z8(i,`${e}, namespace`);n&&(r=n)}),r}function Q8(t,e,r){let i=null;if(t&&Qo(t)){const n=Ql(t,e);n&&(i=n);const s=J8(t,e,r);s&&(i=s)}else i=Z("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function rc(t,e){let r=null;if(t&&Qo(t)){const i=Ql(t,e);i&&(r=i);const n=X8(t,e);n&&(r=n)}else r=Z("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function e0(t){return mt(t.protocol,!0)}function e5(t,e){let r=!1;return e&&!t?r=!0:t&&Zo(t)&&t.length&&t.forEach(i=>{r=e0(i)}),r}function t5(t){return typeof t=="number"}function or(t){return typeof t<"u"&&typeof t!==null}function r5(t){return!(!t||typeof t!="object"||!t.code||!tc(t.code,!1)||!t.message||!mt(t.message,!1))}function i5(t){return!(Qt(t)||!mt(t.method,!1))}function n5(t){return!(Qt(t)||Qt(t.result)&&Qt(t.error)||!tc(t.id,!1)||!mt(t.jsonrpc,!1))}function s5(t){return!(Qt(t)||!mt(t.name,!1))}function t0(t,e){return!(!ea(e)||!C8(t).includes(e))}function o5(t,e,r){return mt(r,!1)?B8(t,e).includes(r):!1}function a5(t,e,r){return mt(r,!1)?L8(t,e).includes(r):!1}function r0(t,e,r){let i=null;const n=f5(t),s=c5(e),o=Object.keys(n),a=Object.keys(s),c=i0(Object.keys(t)),h=i0(Object.keys(e)),l=c.filter(v=>!h.includes(v));return l.length&&(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
25
|
+
Required: ${l.toString()}
|
26
|
+
Received: ${Object.keys(e).toString()}`)),dn(o,a)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
27
27
|
Required: ${o.toString()}
|
28
|
-
Approved: ${
|
29
|
-
Required: ${
|
30
|
-
Approved: ${
|
28
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(v=>{if(!v.includes(":")||i)return;const M=es(e[v].accounts);M.includes(v)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${v}
|
29
|
+
Required: ${v}
|
30
|
+
Approved: ${M.toString()}`))}),o.forEach(v=>{i||(dn(n[v].methods,s[v].methods)?dn(n[v].events,s[v].events)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${v}`)):i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${v}`))}),i}function f5(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 i0(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function c5(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:es(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 h5(t,e){return tc(t,!1)&&t<=e.max&&t>=e.min}function n0(){const t=Is();return new Promise(e=>{switch(t){case gr.browser:e(u5());break;case gr.reactNative:e(d5());break;case gr.node:e(l5());break;default:e(!0)}})}function u5(){return Ms()&&navigator?.onLine}async function d5(){return ki()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function l5(){return!0}function p5(t){switch(Is()){case gr.browser:g5(t);break;case gr.reactNative:b5(t);break}}function g5(t){!ki()&&Ms()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function b5(t){ki()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const ic={};class Bs{static get(e){return ic[e]}static set(e,r){ic[e]=r}static delete(e){delete ic[e]}}const v5="PARSE_ERROR",y5="INVALID_REQUEST",m5="METHOD_NOT_FOUND",w5="INVALID_PARAMS",s0="INTERNAL_ERROR",nc="SERVER_ERROR",_5=[-32700,-32600,-32601,-32602,-32603],Ls={[v5]:{code:-32700,message:"Parse error"},[y5]:{code:-32600,message:"Invalid Request"},[m5]:{code:-32601,message:"Method not found"},[w5]:{code:-32602,message:"Invalid params"},[s0]:{code:-32603,message:"Internal error"},[nc]:{code:-32e3,message:"Server error"}},o0=nc;function x5(t){return _5.includes(t)}function a0(t){return Object.keys(Ls).includes(t)?Ls[t]:Ls[o0]}function E5(t){const e=Object.values(Ls).find(r=>r.code===t);return e||Ls[o0]}function S5(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var f0={};/*! *****************************************************************************
|
31
31
|
Copyright (c) Microsoft Corporation.
|
32
32
|
|
33
33
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -40,5 +40,5 @@
|
|
40
40
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
41
41
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
42
42
|
PERFORMANCE OF THIS SOFTWARE.
|
43
|
-
***************************************************************************** */var af=function(r,e){return af=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},af(r,e)};function zy(r,e){af(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var of=function(){return of=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},of.apply(this,arguments)};function ky(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function Ky(r,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function jy(r,e){return function(t,i){e(t,i,r)}}function Hy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Vy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(g){try{h(i.next(g))}catch(m){o(m)}}function u(g){try{h(i.throw(g))}catch(m){o(m)}}function h(g){g.done?s(g.value):n(g.value).then(f,u)}h((i=i.apply(r,e||[])).next())})}function Gy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(g){return u([h,g])}}function u(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)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 t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(g){h=[6,g],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Wy(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function Jy(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function ff(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function d0(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Yy(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(d0(arguments[e]));return r}function Qy(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,f=s.length;o<f;o++,n++)i[n]=s[o];return i}function ls(r){return this instanceof ls?(this.v=r,this):new ls(r)}function Xy(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(I){i[I]&&(n[I]=function(M){return new Promise(function(D,N){s.push([I,M,D,N])>1||f(I,M)})})}function f(I,M){try{u(i[I](M))}catch(D){m(s[0][3],D)}}function u(I){I.value instanceof ls?Promise.resolve(I.value.v).then(h,g):m(s[0][2],I)}function h(I){f("next",I)}function g(I){f("throw",I)}function m(I,M){I(M),s.shift(),s.length&&f(s[0][0],s[0][1])}}function Zy(r){var e,t;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]=r[n]?function(o){return(t=!t)?{value:ls(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function e6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof ff=="function"?ff(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(h){s({value:h,done:f})},o)}}function t6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function r6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function i6(r){return r&&r.__esModule?r:{default:r}}function n6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function s6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var a6=Object.freeze({__proto__:null,__extends:zy,get __assign(){return of},__rest:ky,__decorate:Ky,__param:jy,__metadata:Hy,__awaiter:Vy,__generator:Gy,__createBinding:Wy,__exportStar:Jy,__values:ff,__read:d0,__spread:Yy,__spreadArrays:Qy,__await:ls,__asyncGenerator:Xy,__asyncDelegator:Zy,__asyncValues:e6,__makeTemplateObject:t6,__importStar:r6,__importDefault:i6,__classPrivateFieldGet:n6,__classPrivateFieldSet:s6}),o6=Fa(a6),oi={},l0;function f6(){if(l0)return oi;l0=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.isBrowserCryptoAvailable=oi.getSubtleCrypto=oi.getBrowerCrypto=void 0;function r(){return Pt?.crypto||Pt?.msCrypto||{}}oi.getBrowerCrypto=r;function e(){const i=r();return i.subtle||i.webkitSubtle}oi.getSubtleCrypto=e;function t(){return!!r()&&!!e()}return oi.isBrowserCryptoAvailable=t,oi}var fi={},p0;function c6(){if(p0)return fi;p0=1,Object.defineProperty(fi,"__esModule",{value:!0}),fi.isBrowser=fi.isNode=fi.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}fi.isReactNative=r;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}fi.isNode=e;function t(){return!r()&&!e()}return fi.isBrowser=t,fi}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=o6;e.__exportStar(f6(),r),e.__exportStar(c6(),r)})(u0);function Ri(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function Yi(r=6){return BigInt(Ri(r))}function Qi(r,e,t){return{id:t||Ri(),jsonrpc:"2.0",method:r,params:e}}function cf(r,e){return{id:r,jsonrpc:"2.0",result:e}}function hf(r,e,t){return{id:r,jsonrpc:"2.0",error:h6(e,t)}}function h6(r,e){return typeof r>"u"?h0(f0):(typeof r=="string"&&(r=Object.assign(Object.assign({},h0(sf)),{message:r})),typeof e<"u"&&(r.data=e),qy(r.code)&&(r=Uy(r.code)),r)}class u6{}class d6 extends u6{constructor(){super()}}class l6 extends d6{constructor(e){super()}}const p6="^wss?:";function g6(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function b6(r,e){const t=g6(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function g0(r){return b6(r,p6)}function v6(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function b0(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function uf(r){return b0(r)&&"method"in r}function Ma(r){return b0(r)&&(Gr(r)||wr(r))}function Gr(r){return"result"in r}function wr(r){return"error"in r}class m6 extends l6{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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Qi(e.method,e.params||[],e.id||Yi().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{wr(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Ma(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 y6=()=>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"),w6=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",v0=r=>r.split("?")[0],m0=10,_6=y6();class x6{constructor(e){if(this.url=e,this.events=new qt.exports.EventEmitter,this.registering=!1,!g0(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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(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(qi(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!g0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+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((t,i)=>{const n=new URLSearchParams(e).get("origin"),s=u0.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!v6(e)},o=new _6(e,[],s);w6()?o.onerror=f=>{const u=f;i(this.emitError(u.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),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 t=typeof e.data=="string"?fn(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),s=hf(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return $y(e,v0(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>m0&&this.events.setMaxListeners(m0)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${v0(this.url)}`));return this.events.emit("register_error",t),t}}var df={exports:{}};(function(r,e){var t=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,f="[object Arguments]",u="[object Array]",h="[object AsyncFunction]",g="[object Boolean]",m="[object Date]",I="[object Error]",M="[object Function]",D="[object GeneratorFunction]",N="[object Map]",k="[object Number]",K="[object Null]",B="[object Object]",j="[object Promise]",F="[object Proxy]",U="[object RegExp]",z="[object Set]",_="[object String]",P="[object Symbol]",J="[object Undefined]",Q="[object WeakMap]",R="[object ArrayBuffer]",p="[object DataView]",l="[object Float32Array]",a="[object Float64Array]",c="[object Int8Array]",b="[object Int16Array]",A="[object Int32Array]",E="[object Uint8Array]",x="[object Uint8ClampedArray]",d="[object Uint16Array]",w="[object Uint32Array]",v=/[\\^$.*+?()[\]{}|]/g,O=/^\[object .+?Constructor\]$/,W=/^(?:0|[1-9]\d*)$/,S={};S[l]=S[a]=S[c]=S[b]=S[A]=S[E]=S[x]=S[d]=S[w]=!0,S[f]=S[u]=S[R]=S[g]=S[p]=S[m]=S[I]=S[M]=S[N]=S[k]=S[B]=S[U]=S[z]=S[_]=S[Q]=!1;var H=typeof Pt=="object"&&Pt&&Pt.Object===Object&&Pt,C=typeof self=="object"&&self&&self.Object===Object&&self,q=H||C||Function("return this")(),T=e&&!e.nodeType&&e,y=T&&!0&&r&&!r.nodeType&&r,L=y&&y.exports===T,G=L&&H.process,Y=function(){try{return G&&G.binding&&G.binding("util")}catch{}}(),X=Y&&Y.isTypedArray;function ee($,V){for(var Z=-1,be=$==null?0:$.length,ut=0,Ge=[];++Z<be;){var bt=$[Z];V(bt,Z,$)&&(Ge[ut++]=bt)}return Ge}function we($,V){for(var Z=-1,be=V.length,ut=$.length;++Z<be;)$[ut+Z]=V[Z];return $}function Se($,V){for(var Z=-1,be=$==null?0:$.length;++Z<be;)if(V($[Z],Z,$))return!0;return!1}function he($,V){for(var Z=-1,be=Array($);++Z<$;)be[Z]=V(Z);return be}function Re($){return function(V){return $(V)}}function xe($,V){return $.has(V)}function se($,V){return $?.[V]}function ve($){var V=-1,Z=Array($.size);return $.forEach(function(be,ut){Z[++V]=[ut,be]}),Z}function le($,V){return function(Z){return $(V(Z))}}function ie($){var V=-1,Z=Array($.size);return $.forEach(function(be){Z[++V]=be}),Z}var ue=Array.prototype,fe=Function.prototype,te=Object.prototype,pe=q["__core-js_shared__"],_e=fe.toString,re=te.hasOwnProperty,Ae=function(){var $=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""}(),Ee=te.toString,oe=RegExp("^"+_e.call(re).replace(v,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=L?q.Buffer:void 0,Me=q.Symbol,Oe=q.Uint8Array,We=te.propertyIsEnumerable,Qe=ue.splice,Ie=Me?Me.toStringTag:void 0,et=Object.getOwnPropertySymbols,tt=De?De.isBuffer:void 0,Ne=le(Object.keys,Object),Te=Cn(q,"DataView"),Ce=Cn(q,"Map"),de=Cn(q,"Promise"),Fe=Cn(q,"Set"),Be=Cn(q,"WeakMap"),ce=Cn(Object,"create"),Ue=rn(Te),$e=rn(Ce),me=rn(de),ze=rn(Fe),ke=rn(Be),ge=Me?Me.prototype:void 0,Le=ge?ge.valueOf:void 0;function Pe($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function ye(){this.__data__=ce?ce(null):{},this.size=0}function Ke($){var V=this.has($)&&delete this.__data__[$];return this.size-=V?1:0,V}function it($){var V=this.__data__;if(ce){var Z=V[$];return Z===i?void 0:Z}return re.call(V,$)?V[$]:void 0}function qe($){var V=this.__data__;return ce?V[$]!==void 0:re.call(V,$)}function nt($,V){var Z=this.__data__;return this.size+=this.has($)?0:1,Z[$]=ce&&V===void 0?i:V,this}Pe.prototype.clear=ye,Pe.prototype.delete=Ke,Pe.prototype.get=it,Pe.prototype.has=qe,Pe.prototype.set=nt;function Je($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function rt(){this.__data__=[],this.size=0}function rr($){var V=this.__data__,Z=Pa(V,$);if(Z<0)return!1;var be=V.length-1;return Z==be?V.pop():Qe.call(V,Z,1),--this.size,!0}function ir($){var V=this.__data__,Z=Pa(V,$);return Z<0?void 0:V[Z][1]}function nr($){return Pa(this.__data__,$)>-1}function sr($,V){var Z=this.__data__,be=Pa(Z,$);return be<0?(++this.size,Z.push([$,V])):Z[be][1]=V,this}Je.prototype.clear=rt,Je.prototype.delete=rr,Je.prototype.get=ir,Je.prototype.has=nr,Je.prototype.set=sr;function yt($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function hi(){this.size=0,this.__data__={hash:new Pe,map:new(Ce||Je),string:new Pe}}function ui($){var V=Ra(this,$).delete($);return this.size-=V?1:0,V}function di($){return Ra(this,$).get($)}function li($){return Ra(this,$).has($)}function pi($,V){var Z=Ra(this,$),be=Z.size;return Z.set($,V),this.size+=Z.size==be?0:1,this}yt.prototype.clear=hi,yt.prototype.delete=ui,yt.prototype.get=di,yt.prototype.has=li,yt.prototype.set=pi;function Ar($){var V=-1,Z=$==null?0:$.length;for(this.__data__=new yt;++V<Z;)this.add($[V])}function gi($){return this.__data__.set($,i),this}function bi($){return this.__data__.has($)}Ar.prototype.add=Ar.prototype.push=gi,Ar.prototype.has=bi;function kt($){var V=this.__data__=new Je($);this.size=V.size}function vi(){this.__data__=new Je,this.size=0}function mi($){var V=this.__data__,Z=V.delete($);return this.size=V.size,Z}function yi($){return this.__data__.get($)}function ws($){return this.__data__.has($)}function _s($,V){var Z=this.__data__;if(Z instanceof Je){var be=Z.__data__;if(!Ce||be.length<t-1)return be.push([$,V]),this.size=++Z.size,this;Z=this.__data__=new yt(be)}return Z.set($,V),this.size=Z.size,this}kt.prototype.clear=vi,kt.prototype.delete=mi,kt.prototype.get=yi,kt.prototype.has=ws,kt.prototype.set=_s;function U8($,V){var Z=Na($),be=!Z&&e4($),ut=!Z&&!be&&Mf($),Ge=!Z&&!be&&!ut&&_d($),bt=Z||be||ut||Ge,Ot=bt?he($.length,String):[],Bt=Ot.length;for(var dt in $)(V||re.call($,dt))&&!(bt&&(dt=="length"||ut&&(dt=="offset"||dt=="parent")||Ge&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||J8(dt,Bt)))&&Ot.push(dt);return Ot}function Pa($,V){for(var Z=$.length;Z--;)if(vd($[Z][0],V))return Z;return-1}function $8($,V,Z){var be=V($);return Na($)?be:we(be,Z($))}function xs($){return $==null?$===void 0?J:K:Ie&&Ie in Object($)?G8($):Z8($)}function ld($){return As($)&&xs($)==f}function pd($,V,Z,be,ut){return $===V?!0:$==null||V==null||!As($)&&!As(V)?$!==$&&V!==V:z8($,V,Z,be,pd,ut)}function z8($,V,Z,be,ut,Ge){var bt=Na($),Ot=Na(V),Bt=bt?u:Ni($),dt=Ot?u:Ni(V);Bt=Bt==f?B:Bt,dt=dt==f?B:dt;var dr=Bt==B,Cr=dt==B,Kt=Bt==dt;if(Kt&&Mf($)){if(!Mf(V))return!1;bt=!0,dr=!1}if(Kt&&!dr)return Ge||(Ge=new kt),bt||_d($)?gd($,V,Z,be,ut,Ge):H8($,V,Bt,Z,be,ut,Ge);if(!(Z&n)){var Er=dr&&re.call($,"__wrapped__"),Sr=Cr&&re.call(V,"__wrapped__");if(Er||Sr){var Ci=Er?$.value():$,wi=Sr?V.value():V;return Ge||(Ge=new kt),ut(Ci,wi,Z,be,Ge)}}return Kt?(Ge||(Ge=new kt),V8($,V,Z,be,ut,Ge)):!1}function k8($){if(!wd($)||Q8($))return!1;var V=md($)?oe:O;return V.test(rn($))}function K8($){return As($)&&yd($.length)&&!!S[xs($)]}function j8($){if(!X8($))return Ne($);var V=[];for(var Z in Object($))re.call($,Z)&&Z!="constructor"&&V.push(Z);return V}function gd($,V,Z,be,ut,Ge){var bt=Z&n,Ot=$.length,Bt=V.length;if(Ot!=Bt&&!(bt&&Bt>Ot))return!1;var dt=Ge.get($);if(dt&&Ge.get(V))return dt==V;var dr=-1,Cr=!0,Kt=Z&s?new Ar:void 0;for(Ge.set($,V),Ge.set(V,$);++dr<Ot;){var Er=$[dr],Sr=V[dr];if(be)var Ci=bt?be(Sr,Er,dr,V,$,Ge):be(Er,Sr,dr,$,V,Ge);if(Ci!==void 0){if(Ci)continue;Cr=!1;break}if(Kt){if(!Se(V,function(wi,nn){if(!xe(Kt,nn)&&(Er===wi||ut(Er,wi,Z,be,Ge)))return Kt.push(nn)})){Cr=!1;break}}else if(!(Er===Sr||ut(Er,Sr,Z,be,Ge))){Cr=!1;break}}return Ge.delete($),Ge.delete(V),Cr}function H8($,V,Z,be,ut,Ge,bt){switch(Z){case p:if($.byteLength!=V.byteLength||$.byteOffset!=V.byteOffset)return!1;$=$.buffer,V=V.buffer;case R:return!($.byteLength!=V.byteLength||!Ge(new Oe($),new Oe(V)));case g:case m:case k:return vd(+$,+V);case I:return $.name==V.name&&$.message==V.message;case U:case _:return $==V+"";case N:var Ot=ve;case z:var Bt=be&n;if(Ot||(Ot=ie),$.size!=V.size&&!Bt)return!1;var dt=bt.get($);if(dt)return dt==V;be|=s,bt.set($,V);var dr=gd(Ot($),Ot(V),be,ut,Ge,bt);return bt.delete($),dr;case P:if(Le)return Le.call($)==Le.call(V)}return!1}function V8($,V,Z,be,ut,Ge){var bt=Z&n,Ot=bd($),Bt=Ot.length,dt=bd(V),dr=dt.length;if(Bt!=dr&&!bt)return!1;for(var Cr=Bt;Cr--;){var Kt=Ot[Cr];if(!(bt?Kt in V:re.call(V,Kt)))return!1}var Er=Ge.get($);if(Er&&Ge.get(V))return Er==V;var Sr=!0;Ge.set($,V),Ge.set(V,$);for(var Ci=bt;++Cr<Bt;){Kt=Ot[Cr];var wi=$[Kt],nn=V[Kt];if(be)var xd=bt?be(nn,wi,Kt,V,$,Ge):be(wi,nn,Kt,$,V,Ge);if(!(xd===void 0?wi===nn||ut(wi,nn,Z,be,Ge):xd)){Sr=!1;break}Ci||(Ci=Kt=="constructor")}if(Sr&&!Ci){var Ca=$.constructor,Ta=V.constructor;Ca!=Ta&&"constructor"in $&&"constructor"in V&&!(typeof Ca=="function"&&Ca instanceof Ca&&typeof Ta=="function"&&Ta instanceof Ta)&&(Sr=!1)}return Ge.delete($),Ge.delete(V),Sr}function bd($){return $8($,i4,W8)}function Ra($,V){var Z=$.__data__;return Y8(V)?Z[typeof V=="string"?"string":"hash"]:Z.map}function Cn($,V){var Z=se($,V);return k8(Z)?Z:void 0}function G8($){var V=re.call($,Ie),Z=$[Ie];try{$[Ie]=void 0;var be=!0}catch{}var ut=Ee.call($);return be&&(V?$[Ie]=Z:delete $[Ie]),ut}var W8=et?function($){return $==null?[]:($=Object($),ee(et($),function(V){return We.call($,V)}))}:n4,Ni=xs;(Te&&Ni(new Te(new ArrayBuffer(1)))!=p||Ce&&Ni(new Ce)!=N||de&&Ni(de.resolve())!=j||Fe&&Ni(new Fe)!=z||Be&&Ni(new Be)!=Q)&&(Ni=function($){var V=xs($),Z=V==B?$.constructor:void 0,be=Z?rn(Z):"";if(be)switch(be){case Ue:return p;case $e:return N;case me:return j;case ze:return z;case ke:return Q}return V});function J8($,V){return V=V??o,!!V&&(typeof $=="number"||W.test($))&&$>-1&&$%1==0&&$<V}function Y8($){var V=typeof $;return V=="string"||V=="number"||V=="symbol"||V=="boolean"?$!=="__proto__":$===null}function Q8($){return!!Ae&&Ae in $}function X8($){var V=$&&$.constructor,Z=typeof V=="function"&&V.prototype||te;return $===Z}function Z8($){return Ee.call($)}function rn($){if($!=null){try{return _e.call($)}catch{}try{return $+""}catch{}}return""}function vd($,V){return $===V||$!==$&&V!==V}var e4=ld(function(){return arguments}())?ld:function($){return As($)&&re.call($,"callee")&&!We.call($,"callee")},Na=Array.isArray;function t4($){return $!=null&&yd($.length)&&!md($)}var Mf=tt||s4;function r4($,V){return pd($,V)}function md($){if(!wd($))return!1;var V=xs($);return V==M||V==D||V==h||V==F}function yd($){return typeof $=="number"&&$>-1&&$%1==0&&$<=o}function wd($){var V=typeof $;return $!=null&&(V=="object"||V=="function")}function As($){return $!=null&&typeof $=="object"}var _d=X?Re(X):K8;function i4($){return t4($)?U8($):j8($)}function n4(){return[]}function s4(){return!1}r.exports=r4})(df,df.exports);var A6=df.exports;const y0="wc",w0=2,lf="core",Wr=`${y0}@2:${lf}:`,E6={name:lf,logger:"error"},S6={database:":memory:"},M6="crypto",_0="client_ed25519_seed",I6=ae.ONE_DAY,D6="keychain",O6="0.3",P6="messages",R6="0.3",N6=ae.SIX_HOURS,C6="publisher",x0="irn",T6="error",A0="wss://relay.walletconnect.org",F6="relayer",Jt={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"},B6="_subscription",_r={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},L6=.1,pf="2.17.2-rc-0",ht={link_mode:"link_mode",relay:"relay"},q6="0.3",U6="WALLETCONNECT_CLIENT_ID",E0="WALLETCONNECT_LINK_MODE_APPS",Jr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},$6="subscription",z6="0.3",k6=ae.FIVE_SECONDS*1e3,K6="pairing",j6="0.3",ps={wc_pairingDelete:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ae.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ae.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:0},res:{ttl:ae.ONE_DAY,prompt:!1,tag:0}}},Xi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Pr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},H6="history",V6="0.3",G6="expirer",xr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},W6="0.3",J6="verify-api",Y6="https://verify.walletconnect.com",S0="https://verify.walletconnect.org",gs=S0,Q6=`${gs}/v3`,X6=[Y6,S0],Z6="echo",ew="https://echo.walletconnect.com",Yr={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"},Rr={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"},Zi={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"},en={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"},bs={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"},tw=.1,rw="event-client",iw=86400,nw="https://pulse.walletconnect.org/batch";function sw(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var f=r.length,u=r.charAt(0),h=Math.log(f)/Math.log(256),g=Math.log(256)/Math.log(f);function m(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var N=0,k=0,K=0,B=D.length;K!==B&&D[K]===0;)K++,N++;for(var j=(B-K)*g+1>>>0,F=new Uint8Array(j);K!==B;){for(var U=D[K],z=0,_=j-1;(U!==0||z<k)&&_!==-1;_--,z++)U+=256*F[_]>>>0,F[_]=U%f>>>0,U=U/f>>>0;if(U!==0)throw new Error("Non-zero carry");k=z,K++}for(var P=j-k;P!==j&&F[P]===0;)P++;for(var J=u.repeat(N);P<j;++P)J+=r.charAt(F[P]);return J}function I(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var N=0;if(D[N]!==" "){for(var k=0,K=0;D[N]===u;)k++,N++;for(var B=(D.length-N)*h+1>>>0,j=new Uint8Array(B);D[N];){var F=t[D.charCodeAt(N)];if(F===255)return;for(var U=0,z=B-1;(F!==0||U<K)&&z!==-1;z--,U++)F+=f*j[z]>>>0,j[z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");K=U,N++}if(D[N]!==" "){for(var _=B-K;_!==B&&j[_]===0;)_++;for(var P=new Uint8Array(k+(B-_)),J=k;_!==B;)P[J++]=j[_++];return P}}}function M(D){var N=I(D);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:I,decode:M}}var aw=sw,ow=aw;const M0=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},fw=r=>new TextEncoder().encode(r),cw=r=>new TextDecoder().decode(r);class hw{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class uw{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 I0(this,e)}}class dw{constructor(e){this.decoders=e}or(e){return I0(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 I0=(r,e)=>new dw({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class lw{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new hw(e,t,i),this.decoder=new uw(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ia=({name:r,prefix:e,encode:t,decode:i})=>new lw(r,e,t,i),vs=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=ow(t,e);return Ia({prefix:r,name:e,encode:i,decode:s=>M0(n(s))})},pw=(r,e,t,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let f=0,u=0,h=0;for(let g=0;g<s;++g){const m=n[r[g]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<t|m,f+=t,f>=8&&(f-=8,o[h++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},gw=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,f=0;for(let u=0;u<r.length;++u)for(f=f<<8|r[u],o+=8;o>t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<<t-o]),i)for(;s.length*t&7;)s+="=";return s},Ft=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Ia({prefix:e,name:r,encode(n){return gw(n,i,t)},decode(n){return pw(n,i,t,r)}}),bw=Ia({prefix:"\0",name:"identity",encode:r=>cw(r),decode:r=>fw(r)});var vw=Object.freeze({__proto__:null,identity:bw});const mw=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yw=Object.freeze({__proto__:null,base2:mw});const ww=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _w=Object.freeze({__proto__:null,base8:ww});const xw=vs({prefix:"9",name:"base10",alphabet:"0123456789"});var Aw=Object.freeze({__proto__:null,base10:xw});const Ew=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sw=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mw=Object.freeze({__proto__:null,base16:Ew,base16upper:Sw});const Iw=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dw=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ow=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Pw=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Rw=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Nw=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cw=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tw=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Fw=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bw=Object.freeze({__proto__:null,base32:Iw,base32upper:Dw,base32pad:Ow,base32padupper:Pw,base32hex:Rw,base32hexupper:Nw,base32hexpad:Cw,base32hexpadupper:Tw,base32z:Fw});const Lw=vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qw=vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Uw=Object.freeze({__proto__:null,base36:Lw,base36upper:qw});const $w=vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),zw=vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kw=Object.freeze({__proto__:null,base58btc:$w,base58flickr:zw});const Kw=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jw=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hw=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vw=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gw=Object.freeze({__proto__:null,base64:Kw,base64pad:jw,base64url:Hw,base64urlpad:Vw});const D0=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}"),Ww=D0.reduce((r,e,t)=>(r[t]=e,r),[]),Jw=D0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Yw(r){return r.reduce((e,t)=>(e+=Ww[t],e),"")}function Qw(r){const e=[];for(const t of r){const i=Jw[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const Xw=Ia({prefix:"\u{1F680}",name:"base256emoji",encode:Yw,decode:Qw});var Zw=Object.freeze({__proto__:null,base256emoji:Xw}),e5=P0,O0=128,t5=127,r5=~t5,i5=Math.pow(2,31);function P0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=i5;)e[t++]=r&255|O0,r/=128;for(;r&r5;)e[t++]=r&255|O0,r>>>=7;return e[t]=r|0,P0.bytes=t-i+1,e}var n5=gf,s5=128,R0=127;function gf(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw gf.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&R0)<<n:(o&R0)*Math.pow(2,n),n+=7}while(o>=s5);return gf.bytes=s-i,t}var a5=Math.pow(2,7),o5=Math.pow(2,14),f5=Math.pow(2,21),c5=Math.pow(2,28),h5=Math.pow(2,35),u5=Math.pow(2,42),d5=Math.pow(2,49),l5=Math.pow(2,56),p5=Math.pow(2,63),g5=function(r){return r<a5?1:r<o5?2:r<f5?3:r<c5?4:r<h5?5:r<u5?6:r<d5?7:r<l5?8:r<p5?9:10},b5={encode:e5,decode:n5,encodingLength:g5},N0=b5;const C0=(r,e,t=0)=>(N0.encode(r,e,t),e),T0=r=>N0.encodingLength(r),bf=(r,e)=>{const t=e.byteLength,i=T0(r),n=i+T0(t),s=new Uint8Array(n+t);return C0(r,s,0),C0(t,s,i),s.set(e,n),new v5(r,t,e,s)};class v5{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const F0=({name:r,code:e,encode:t})=>new m5(r,e,t);class m5{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?bf(this.code,t):t.then(i=>bf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const B0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),y5=F0({name:"sha2-256",code:18,encode:B0("SHA-256")}),w5=F0({name:"sha2-512",code:19,encode:B0("SHA-512")});var _5=Object.freeze({__proto__:null,sha256:y5,sha512:w5});const L0=0,x5="identity",q0=M0;var A5=Object.freeze({__proto__:null,identity:{code:L0,name:x5,encode:q0,digest:r=>bf(L0,q0(r))}});new TextEncoder,new TextDecoder;const U0={...vw,...yw,..._w,...Aw,...Mw,...Bw,...Uw,...kw,...Gw,...Zw};({..._5,...A5});function E5(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function $0(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const z0=$0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vf=$0("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=E5(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),S5={utf8:z0,"utf-8":z0,hex:U0.base16,latin1:vf,ascii:vf,binary:vf,...U0};function M5(r,e="utf8"){const t=S5[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class I5{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=D6,this.version=O6,this.initialized=!1,this.storagePrefix=Wr,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=ne("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=jt(t,this.name)}get context(){return Qt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Du(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}}class D5{constructor(e,t,i){this.core=e,this.logger=t,this.name=M6,this.randomSessionIdentifier=Zo(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=$c(n);return Uc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=Rm();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=$c(s),f=this.randomSessionIdentifier;return await Tg(f,n,I6,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const f=this.getPrivateKey(n),u=Nm(f,s);return this.setSymKey(u,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||xa(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const f=Vu(o),u=qi(s);if(Wu(f))return Tm(u,o?.encoding);if(Gu(f)){const I=f.senderPublicKey,M=f.receiverPublicKey;n=await this.generateSharedKey(I,M)}const h=this.getSymKey(n),{type:g,senderPublicKey:m}=f;return Cm({type:g,symKey:h,message:u,senderPublicKey:m,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const f=Lm(s,o);if(Wu(f)){const u=Bm(s,o?.encoding);return fn(u)}if(Gu(f)){const u=f.receiverPublicKey,h=f.senderPublicKey;n=await this.generateSharedKey(u,h)}try{const u=this.getSymKey(n),h=Fm({symKey:u,encoded:s,encoding:o?.encoding});return fn(h)}catch(u){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=(n,s=Pi)=>{const o=fs({encoded:n,encoding:s});return Ji(o.type)},this.getPayloadSenderPublicKey=(n,s=Pi)=>{const o=fs({encoded:n,encoding:s});return o.senderPublicKey?xt(o.senderPublicKey,Gt):void 0},this.core=e,this.logger=jt(t,this.name),this.keychain=i||new I5(this.core,this.logger)}get context(){return Qt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(_0)}catch{e=Zo(),await this.keychain.set(_0,e)}return M5(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}}class O5 extends bp{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=P6,this.version=R6,this.initialized=!1,this.storagePrefix=Wr,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}}},this.set=async(i,n)=>{this.isInitialized();const s=ai(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},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=ai(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=jt(e,this.name),this.core=t}get context(){return Qt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Du(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}}class P5 extends vp{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new qt.exports.EventEmitter,this.name=C6,this.queue=new Map,this.publishTimeout=ae.toMiliseconds(ae.ONE_MINUTE),this.failedPublishTimeout=ae.toMiliseconds(ae.ONE_SECOND),this.needsTransportRestart=!1,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 f=s?.ttl||N6,u=ef(s),h=s?.prompt||!1,g=s?.tag||0,m=s?.id||Yi().toString(),I={topic:i,message:n,opts:{ttl:f,relay:u,prompt:h,tag:g,id:m,attestation:s?.attestation}},M=`Failed to publish payload, please try again. id:${m} tag:${g}`,D=Date.now();let N,k=1;try{for(;N===void 0;){if(Date.now()-D>this.publishTimeout)throw new Error(M);this.logger.trace({id:m,attempts:k},`publisher.publish - attempt ${k}`),N=await await Pn(this.rpcPublish(i,n,f,u,h,g,m,s?.attestation).catch(K=>this.logger.warn(K)),this.publishTimeout,M),k++,N||await new Promise(K=>setTimeout(K,this.failedPublishTimeout))}this.relayer.events.emit(Jt.publish,I),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:m,topic:i,message:n,opts:s}})}catch(K){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(K),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw K;this.queue.set(m,I)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=jt(t,this.name),this.registerEventListeners()}get context(){return Qt(this.logger)}rpcPublish(e,t,i,n,s,o,f,u){var h,g,m,I;const M={method:cs(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:u},id:f};return Wt((h=M.params)==null?void 0:h.prompt)&&((g=M.params)==null||delete g.prompt),Wt((m=M.params)==null?void 0:m.tag)&&((I=M.params)==null||delete I.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:M}),this.relayer.request(M)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(on.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Jt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Jt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class R5{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var N5=Object.defineProperty,C5=Object.defineProperties,T5=Object.getOwnPropertyDescriptors,k0=Object.getOwnPropertySymbols,F5=Object.prototype.hasOwnProperty,B5=Object.prototype.propertyIsEnumerable,K0=(r,e,t)=>e in r?N5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ms=(r,e)=>{for(var t in e||(e={}))F5.call(e,t)&&K0(r,t,e[t]);if(k0)for(var t of k0(e))B5.call(e,t)&&K0(r,t,e[t]);return r},mf=(r,e)=>C5(r,T5(e));class L5 extends wp{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new R5,this.events=new qt.exports.EventEmitter,this.name=$6,this.version=z6,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Wr,this.subscribeTimeout=ae.toMiliseconds(ae.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},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=ef(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},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)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const f=new ae.Watch;f.start(n);const u=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(u),f.stop(n),s(!0)),f.elapsed(n)>=k6&&(clearInterval(u),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=jt(t,this.name),this.clientId=""}get context(){return Qt(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,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=ef(i);await this.rpcUnsubscribe(e,t,n);const s=ct("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===ht.relay&&await this.restartToComplete();const s={method:cs(t.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 f=ai(e+this.clientId);if(i?.transportType===ht.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(h=>this.logger.warn(h))},ae.toMiliseconds(ae.ONE_SECOND)),f;const u=await Pn(this.relayer.request(s).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return u?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Jt.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:cs(t.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{return await await Pn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:cs(t.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 Pn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jt.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:cs(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,mf(ms({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,ms({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,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,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ms({},t)),this.topicMap.set(t.topic,e),this.events.emit(Jr.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=ne("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Jr.deleted,mf(ms({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Jr.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(Jr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=ne("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}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){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);hs(t)&&this.onBatchSubscribe(t.map((i,n)=>mf(ms({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(on.pulse,async()=>{await this.checkPending()}),this.events.on(Jr.created,async e=>{const t=Jr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(Jr.deleted,async e=>{const t=Jr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}}var q5=Object.defineProperty,j0=Object.getOwnPropertySymbols,U5=Object.prototype.hasOwnProperty,$5=Object.prototype.propertyIsEnumerable,H0=(r,e,t)=>e in r?q5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,V0=(r,e)=>{for(var t in e||(e={}))U5.call(e,t)&&H0(r,t,e[t]);if(j0)for(var t of j0(e))$5.call(e,t)&&H0(r,t,e[t]);return r};class z5 extends mp{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new qt.exports.EventEmitter,this.name=F6,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=ae.toMiliseconds(ae.THIRTY_SECONDS+ae.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const s=t.id||Yi().toString();await this.toEstablishConnection();try{const o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const f=await new Promise(async(u,h)=>{const g=()=>{h(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(_r.disconnect,g);const m=await o;this.provider.off(_r.disconnect,g),u(m)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(ya())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Jt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Jt.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(_r.payload,this.onPayloadHandler),this.provider.on(_r.connect,this.onConnectHandler),this.provider.on(_r.disconnect,this.onDisconnectHandler),this.provider.on(_r.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?jt(e.logger,this.name):Xr(Qa({level:e.logger||T6})),this.messages=new O5(this.logger,e.core),this.subscriber=new L5(this,this.logger),this.publisher=new P5(this,this.logger),this.relayUrl=e?.relayUrl||A0,this.projectId=e.projectId,this.bundleId=W3(),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)}}get context(){return Qt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:ht.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();const o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish;let f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",u;const h=g=>{g.topic===e&&(this.subscriber.off(Jr.created,h),u())};return await Promise.all([new Promise(g=>{u=g,this.subscriber.on(Jr.created,h)}),new Promise(async(g,m)=>{f=await this.subscriber.subscribe(e,V0({internal:{throwOnFailedPublish:o}},t)).catch(I=>{o&&m(I)})||f,g()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Pn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{const n=()=>{this.provider.off(_r.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(_r.disconnect,n),await Pn(this.provider.connect(),ae.toMiliseconds(ae.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);const i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await o0())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 t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=wt(ae.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Jt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(ya())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new m6(new x6(X3({sdkVersion:pf,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),uf(e)){if(!e.method.endsWith(B6))return;const t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:ht.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(V0({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Ma(e)&&this.events.emit(Jt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Jt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=cf(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(_r.payload,this.onPayloadHandler),this.provider.off(_r.connect,this.onConnectHandler),this.provider.off(_r.disconnect,this.onDisconnectHandler),this.provider.off(_r.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await o0();Py(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Jt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},ae.toMiliseconds(L6))))}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var k5=Object.defineProperty,G0=Object.getOwnPropertySymbols,K5=Object.prototype.hasOwnProperty,j5=Object.prototype.propertyIsEnumerable,W0=(r,e,t)=>e in r?k5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,J0=(r,e)=>{for(var t in e||(e={}))K5.call(e,t)&&W0(r,t,e[t]);if(G0)for(var t of G0(e))j5.call(e,t)&&W0(r,t,e[t]);return r};class tn extends yp{constructor(e,t,i,n=Wr,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=q6,this.cached=[],this.initialized=!1,this.storagePrefix=Wr,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Wt(o)?this.map.set(this.getKey(o),o):oy(o)?this.map.set(o.id,o):fy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(u=>A6(f[u],o[u]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});const u=J0(J0({},this.getData(o)),f);this.map.set(o,u),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=jt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Qt(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 t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=ne("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=ne("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}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:t}=ne("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}}class H5{constructor(e,t){this.core=e,this.logger=t,this.name=K6,this.version=j6,this.events=new qt.exports,this.initialized=!1,this.storagePrefix=Wr,this.ignoredPayloadTypes=[si],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=Zo(),s=await this.core.crypto.setSymKey(n),o=wt(ae.FIVE_MINUTES),f={protocol:x0},u={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},h=Zu({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Xi.create,u),this.core.expirer.set(s,o),await this.pairings.set(s,u),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Yr.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:f,expiryTimestamp:u,methods:h}=Xu(i.uri);n.props.properties.topic=s,n.addTrace(Yr.pairing_uri_validation_success),n.addTrace(Yr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Yr.existing_pairing),g.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(Yr.pairing_not_expired)}const m=u||wt(ae.FIVE_MINUTES),I={topic:s,relay:f,expiry:m,active:!1,methods:h};this.core.expirer.set(s,m),await this.pairings.set(s,I),n.addTrace(Yr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Xi.create,I),n.addTrace(Yr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Yr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ci.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(M){throw n.setError(ci.subscribe_pairing_topic_failure),M}return n.addTrace(Yr.subscribe_pairing_topic_success),I},this.activate=async({topic:i})=>{this.isInitialized();const n=wt(ae.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:u}=Gi();this.events.once(Ye("pairing_ping",s),({error:h})=>{h?u(h):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),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",ct("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:f}=i,u=this.core.crypto.keychain.get(n);return Zu({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:u,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{const o=Qi(n,s),f=await this.core.crypto.encode(i,o),u=ps[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,u),o.id},this.sendResult=async(i,n,s)=>{const o=cf(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),h=ps[u.request.method].res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=hf(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),h=ps[u.request.method]?ps[u.request.method].res:ps.unregistered_method.res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ct("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Oi(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},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)}},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)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Xi.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Gr(n)?this.events.emit(Ye("pairing_ping",s),{}):wr(n)&&this.events.emit(Ye("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Xi.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const f=ct("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ct("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!tr(i)){const{message:f}=ne("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(!ay(i.uri)){const{message:f}=ne("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ci.malformed_pairing_uri),new Error(f)}const o=Xu(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:f}=ne("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){const{message:f}=ne("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&ae.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(ci.pairing_expired);const{message:f}=ne("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(f)}},this.isValidPing=async i=>{if(!tr(i)){const{message:s}=ne("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!tr(i)){const{message:s}=ne("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!mt(i,!1)){const{message:n}=ne("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=ne("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Oi(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=ne("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=jt(t,this.name),this.pairings=new tn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Qt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Jt.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===ht.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{uf(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Ma(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(xr.expired,async e=>{const{topic:t}=Pu(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Xi.expire,{topic:t}))})}}class V5 extends gp{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new qt.exports.EventEmitter,this.name=H6,this.version=V6,this.cached=[],this.initialized=!1,this.storagePrefix=Wr,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)},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:wt(ae.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Pr.created,o)},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=wr(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Pr.updated,n))},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)),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(Pr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=jt(t,this.name)}get context(){return Qt(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(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:Qi(t.request.method,t.request.params,t.id),chainId:t.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 t=this.records.get(e);if(!t){const{message:i}=ne("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Pr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=ne("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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(Pr.created,e=>{const t=Pr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Pr.updated,e=>{const t=Pr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Pr.deleted,e=>{const t=Pr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(on.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{ae.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Pr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}}class G5 extends _p{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new qt.exports.EventEmitter,this.name=G6,this.version=W6,this.cached=[],this.initialized=!1,this.storagePrefix=Wr,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)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},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(xr.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},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(xr.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=jt(t,this.name)}get context(){return Qt(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 Z3(e);if(typeof e=="number")return em(e);const{message:t}=ne("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}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(xr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=ne("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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 t=this.expirations.get(e);if(!t){const{message:i}=ne("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;ae.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(xr.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(on.pulse,()=>this.checkExpirations()),this.events.on(xr.created,e=>{const t=xr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(xr.expired,e=>{const t=xr.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(xr.deleted,e=>{const t=xr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}}class W5 extends xp{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=J6,this.verifyUrlV3=Q6,this.storagePrefix=Wr,this.version=w0,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&ae.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!ts()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:f}=n,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{const h=kn(),g=this.startAbortTimer(ae.ONE_SECOND*5),m=await new Promise((I,M)=>{const D=()=>{window.removeEventListener("message",k),h.body.removeChild(N),M("attestation aborted")};this.abortController.signal.addEventListener("abort",D);const N=h.createElement("iframe");N.src=u,N.style.display="none",N.addEventListener("error",D,{signal:this.abortController.signal});const k=K=>{if(K.data&&typeof K.data=="string")try{const B=JSON.parse(K.data);if(B.type==="verify_attestation"){if(ao(B.attestation).payload.id!==o)return;clearInterval(g),h.body.removeChild(N),this.abortController.signal.removeEventListener("abort",D),window.removeEventListener("message",k),I(B.attestation===null?"":B.attestation)}}catch(B){this.logger.warn(B)}};h.body.appendChild(N),window.addEventListener("message",k,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",m),m}catch(h){this.logger.warn(h)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ao(s).payload.id!==f)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 u=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,u)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(ae.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||gs;return X6.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${gs}`),s=gs),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(ae.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)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),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},this.validateAttestation=(n,s)=>{const o=zm(n,s.publicKey),f={hasExpired:ae.toMiliseconds(o.exp)<Date.now(),payload:o};if(f.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:f.payload.origin,isScam:f.payload.isScam,isVerified:f.payload.isVerified}},this.logger=jt(t,this.name),this.abortController=new AbortController,this.isDevEnv=Jo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Qt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),ae.toMiliseconds(e))}}class J5 extends Ap{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=Z6,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,u=`${ew}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=jt(t,this.context)}}var Y5=Object.defineProperty,Y0=Object.getOwnPropertySymbols,Q5=Object.prototype.hasOwnProperty,X5=Object.prototype.propertyIsEnumerable,Q0=(r,e,t)=>e in r?Y5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ys=(r,e)=>{for(var t in e||(e={}))Q5.call(e,t)&&Q0(r,t,e[t]);if(Y0)for(var t of Y0(e))X5.call(e,t)&&Q0(r,t,e[t]);return r};class Z5 extends Ep{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=rw,this.storagePrefix=Wr,this.storageVersion=tw,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Jo())try{const n={eventId:Nu(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Mu(this.core.relayer.protocol,this.core.relayer.version,pf)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:f,trace:u}}=n,h=Nu(),g=this.core.projectId||"",m=Date.now(),I=ys({eventId:h,timestamp:m,props:{event:s,type:o,properties:{topic:f,trace:u}},bundleId:g,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,I),this.shouldPersist=!0),I},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const f=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(f)return ys(ys({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(on.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{ae.fromMiliseconds(Date.now())-ae.fromMiliseconds(n.timestamp)>iw&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),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)},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)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},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,ys(ys({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},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)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${nw}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${pf}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Su().url,this.logger=jt(t,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 e8=Object.defineProperty,X0=Object.getOwnPropertySymbols,t8=Object.prototype.hasOwnProperty,r8=Object.prototype.propertyIsEnumerable,Z0=(r,e,t)=>e in r?e8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ed=(r,e)=>{for(var t in e||(e={}))t8.call(e,t)&&Z0(r,t,e[t]);if(X0)for(var t of X0(e))r8.call(e,t)&&Z0(r,t,e[t]);return r};class yf extends pp{constructor(e){var t;super(e),this.protocol=y0,this.version=w0,this.name=lf,this.events=new qt.exports.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:u})=>{if(!o||!f)return;const h={topic:o,message:f,publishedAt:Date.now(),transportType:ht.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:u})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||A0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Qa({level:typeof e?.logger=="string"&&e.logger?e.logger:E6.logger}),{logger:n,chunkLoggerController:s}=lp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=jt(n,this.name),this.heartbeat=new ja,this.crypto=new D5(this,this.logger,e?.keychain),this.history=new V5(this,this.logger),this.expirer=new G5(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Ul(ed(ed({},S6),e?.storageOptions)),this.relayer=new z5({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new H5(this,this.logger),this.verify=new W5(this,this.logger,this.storage),this.echoClient=new J5(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Z5(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new yf(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(U6,i),t}get context(){return Qt(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(E0,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.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(E0)||[],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 wf=yf,td="wc",rd=2,id="client",_f=`${td}@${rd}:${id}:`,xf={name:id,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},nd="WALLETCONNECT_DEEPLINK_CHOICE",i8="proposal",n8="Proposal expired",s8="session",Nn=ae.SEVEN_DAYS,a8="engine",Dt={wc_sessionPropose:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1114},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:ae.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:ae.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1119}}},Af={min:ae.FIVE_MINUTES,max:ae.SEVEN_DAYS},Qr={idle:"IDLE",active:"ACTIVE"},o8="request",f8=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],c8="wc",h8="auth",u8="authKeys",d8="pairingTopics",l8="requests",Da=`${c8}@${1.5}:${h8}:`,Oa=`${Da}:PUB_KEY`;var p8=Object.defineProperty,g8=Object.defineProperties,b8=Object.getOwnPropertyDescriptors,sd=Object.getOwnPropertySymbols,v8=Object.prototype.hasOwnProperty,m8=Object.prototype.propertyIsEnumerable,ad=(r,e,t)=>e in r?p8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gt=(r,e)=>{for(var t in e||(e={}))v8.call(e,t)&&ad(r,t,e[t]);if(sd)for(var t of sd(e))m8.call(e,t)&&ad(r,t,e[t]);return r},Nr=(r,e)=>g8(r,b8(e));class y8 extends Mp{constructor(e){super(e),this.name=a8,this.events=new qt.exports,this.initialized=!1,this.requestQueue={state:Qr.idle,queue:[]},this.sessionRequestQueue={state:Qr.idle,queue:[]},this.requestQueueDelay=ae.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],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(Dt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},ae.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Nr(gt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:u}=i;let h=n,g,m=!1;try{h&&(m=this.client.core.pairing.pairings.get(h).active)}catch(F){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),F}if(!h||!m){const{topic:F,uri:U}=await this.client.core.pairing.create();h=F,g=U}if(!h){const{message:F}=ne("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(F)}const I=await this.client.core.crypto.generateKeyPair(),M=Dt.wc_sessionPropose.req.ttl||ae.FIVE_MINUTES,D=wt(M),N=gt({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:x0}],proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:D,pairingTopic:h},f&&{sessionProperties:f}),{reject:k,resolve:K,done:B}=Gi(M,n8);this.events.once(Ye("session_connect"),async({error:F,session:U})=>{if(F)k(F);else if(U){U.self.publicKey=I;const z=Nr(gt({},U),{pairingTopic:N.pairingTopic,requiredNamespaces:N.requiredNamespaces,optionalNamespaces:N.optionalNamespaces,transportType:ht.relay});await this.client.session.set(U.topic,z),await this.setExpiry(U.topic,U.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:U.peer.metadata}),this.cleanupDuplicatePairings(z),K(z)}});const j=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:N,throwOnFailedPublish:!0});return await this.setProposal(j,gt({id:j},N)),{uri:g,approval:B}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[Rr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(P){throw o.setError(Zi.no_internet_connection),P}try{await this.isValidProposalId(t?.id)}catch(P){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(Zi.proposal_not_found),P}try{await this.isValidApprove(t)}catch(P){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Zi.session_approve_namespace_validation_failure),P}const{id:f,relayProtocol:u,namespaces:h,sessionProperties:g,sessionConfig:m}=t,I=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:M,proposer:D,requiredNamespaces:N,optionalNamespaces:k}=I;let K=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:M});K||(K=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Rr.session_approve_started,properties:{topic:M,trace:[Rr.session_approve_started,Rr.session_namespaces_validation_success]}}));const B=await this.client.core.crypto.generateKeyPair(),j=D.publicKey,F=await this.client.core.crypto.generateSharedKey(B,j),U=gt(gt({relay:{protocol:u??"irn"},namespaces:h,controller:{publicKey:B,metadata:this.client.metadata},expiry:wt(Nn)},g&&{sessionProperties:g}),m&&{sessionConfig:m}),z=ht.relay;K.addTrace(Rr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(F,{transportType:z})}catch(P){throw K.setError(Zi.subscribe_session_topic_failure),P}K.addTrace(Rr.subscribe_session_topic_success);const _=Nr(gt({},U),{topic:F,requiredNamespaces:N,optionalNamespaces:k,pairingTopic:M,acknowledged:!1,self:U.controller,peer:{publicKey:D.publicKey,metadata:D.metadata},controller:B,transportType:ht.relay});await this.client.session.set(F,_),K.addTrace(Rr.store_session);try{K.addTrace(Rr.publishing_session_settle),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:U,throwOnFailedPublish:!0}).catch(P=>{throw K?.setError(Zi.session_settle_publish_failure),P}),K.addTrace(Rr.session_settle_publish_success),K.addTrace(Rr.publishing_session_approve),await this.sendResult({id:f,topic:M,result:{relay:{protocol:u??"irn"},responderPublicKey:B},throwOnFailedPublish:!0}).catch(P=>{throw K?.setError(Zi.session_approve_publish_failure),P}),K.addTrace(Rr.session_approve_publish_success)}catch(P){throw this.client.logger.error(P),this.client.session.delete(F,ct("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(F),P}return this.client.core.eventClient.deleteEvent({eventId:K.eventId}),await this.client.core.pairing.updateMetadata({topic:M,metadata:D.metadata}),await this.client.proposal.delete(f,ct("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:M}),await this.setExpiry(F,wt(Nn)),{topic:F,acknowledged:()=>Promise.resolve(this.client.session.get(F))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=t;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:Dt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(m){throw this.client.logger.error("update() -> isValidUpdate() failed"),m}const{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=Gi(),u=Ri(),h=Yi().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Ye("session_update",u),({error:m})=>{m?f(m):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:h}).catch(m=>{this.client.logger.error(m),this.client.session.update(i,{namespaces:g}),f(m)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}const{topic:i}=t,n=Ri(),{done:s,resolve:o,reject:f}=Gi();return this.events.once(Ye("session_extend",n),({error:u})=>{u?f(u):o()}),await this.setExpiry(i,wt(Nn)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(u=>{f(u)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(D){throw this.client.logger.error("request() -> isValidRequest() failed"),D}const{chainId:i,request:n,topic:s,expiry:o=Dt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const u=Ri(),h=Yi().toString(),{done:g,resolve:m,reject:I}=Gi(o,"Request expired. Please try again.");this.events.once(Ye("session_request",u),({error:D,result:N})=>{D?I(D):m(N)});const M=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return M?(await this.sendRequest({clientRpcId:u,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:Nr(gt({},n),{expiryTimestamp:wt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:M}).catch(D=>I(D)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),await g()):await Promise.all([new Promise(async D=>{await this.sendRequest({clientRpcId:u,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:Nr(gt({},n),{expiryTimestamp:wt(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(N=>I(N)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),D()}),new Promise(async D=>{var N;if(!((N=f.sessionConfig)!=null&&N.disableDeepLink)){const k=await nm(this.client.core.storage,nd);await rm({id:u,topic:s,wcDeepLink:k})}D()}),g()]).then(D=>D[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Gr(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):wr(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=Ri(),s=Yi().toString(),{done:o,resolve:f,reject:u}=Gi();this.events.once(Ye("session_ping",n),({error:h})=>{h?u(h):f()}),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)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:s}=t,o=Yi().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ct("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}=ne("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>ny(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?ht.link_mode:ht.relay;o===ht.relay&&await this.confirmOnlineStateOrThrow();const{chains:f,statement:u="",uri:h,domain:g,nonce:m,type:I,exp:M,nbf:D,methods:N=[],expiry:k}=t,K=[...t.resources||[]],{topic:B,uri:j}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:B,uri:j}});const F=await this.client.core.crypto.generateKeyPair(),U=xa(F);if(await Promise.all([this.client.auth.authKeys.set(Oa,{responseTopic:U,publicKey:F}),this.client.auth.pairingTopics.set(U,{topic:U,pairingTopic:B})]),await this.client.core.relayer.subscribe(U,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${B}`),N.length>0){const{namespace:E}=ma(f[0]);let x=Sm(E,"request",N);_a(K)&&(x=Im(x,K.pop())),K.push(x)}const z=k&&k>Dt.wc_sessionAuthenticate.req.ttl?k:Dt.wc_sessionAuthenticate.req.ttl,_={authPayload:{type:I??"caip122",chains:f,statement:u,aud:h,domain:g,version:"1",nonce:m,iat:new Date().toISOString(),exp:M,nbf:D,resources:K},requester:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:wt(z)},P={eip155:{chains:f,methods:[...new Set(["personal_sign",...N])],events:["chainChanged","accountsChanged"]}},J={requiredNamespaces:{},optionalNamespaces:P,relays:[{protocol:"irn"}],pairingTopic:B,proposer:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:wt(Dt.wc_sessionPropose.req.ttl)},{done:Q,resolve:R,reject:p}=Gi(z,"Request expired"),l=async({error:E,session:x})=>{if(this.events.off(Ye("session_request",c),a),E)p(E);else if(x){x.self.publicKey=F,await this.client.session.set(x.topic,x),await this.setExpiry(x.topic,x.expiry),B&&await this.client.core.pairing.updateMetadata({topic:B,metadata:x.peer.metadata});const d=this.client.session.get(x.topic);await this.deleteProposal(b),R({session:d})}},a=async E=>{var x,d,w;if(await this.deletePendingAuthRequest(c,{message:"fulfilled",code:0}),E.error){const q=ct("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===q.code?void 0:(this.events.off(Ye("session_connect"),l),p(E.error.message))}await this.deleteProposal(b),this.events.off(Ye("session_connect"),l);const{cacaos:v,responder:O}=E.result,W=[],S=[];for(const q of v){await Bu({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),p(ct("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:T}=q,y=_a(T.resources),L=[Qo(T.iss)],G=wa(T.iss);if(y){const Y=Uu(y),X=$u(y);W.push(...Y),L.push(...X)}for(const Y of L)S.push(`${Y}:${G}`)}const H=await this.client.core.crypto.generateSharedKey(F,O.publicKey);let C;W.length>0&&(C={topic:H,acknowledged:!0,self:{publicKey:F,metadata:this.client.metadata},peer:O,controller:O.publicKey,expiry:wt(Nn),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:B,namespaces:e0([...new Set(W)],[...new Set(S)]),transportType:o},await this.client.core.relayer.subscribe(H,{transportType:o}),await this.client.session.set(H,C),B&&await this.client.core.pairing.updateMetadata({topic:B,metadata:O.metadata}),C=this.client.session.get(H)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(d=O.metadata.redirect)!=null&&d.linkMode&&(w=O.metadata.redirect)!=null&&w.universal&&i&&(this.client.core.addLinkModeSupportedApp(O.metadata.redirect.universal),this.client.session.update(H,{transportType:ht.link_mode})),R({auths:v,session:C})},c=Ri(),b=Ri();this.events.once(Ye("session_connect"),l),this.events.once(Ye("session_request",c),a);let A;try{if(s){const E=Qi("wc_sessionAuthenticate",_,c);this.client.core.history.set(B,E);const x=await this.client.core.crypto.encode("",E,{type:as,encoding:ns});A=Aa(i,B,x)}else await Promise.all([this.sendRequest({topic:B,method:"wc_sessionAuthenticate",params:_,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:c}),this.sendRequest({topic:B,method:"wc_sessionPropose",params:J,expiry:Dt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(E){throw this.events.off(Ye("session_connect"),l),this.events.off(Ye("session_request",c),a),E}return await this.setProposal(b,gt({id:b},J)),await this.setAuthRequest(c,{request:Nr(gt({},_),{verifyContext:{}}),pairingTopic:B,transportType:o}),{uri:A??j,response:Q}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[en.authenticated_session_approve_started]}});try{this.isInitialized()}catch(k){throw s.setError(bs.no_internet_connection),k}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(bs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const f=o.transportType||ht.relay;f===ht.relay&&await this.confirmOnlineStateOrThrow();const u=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),g=xa(u),m={type:si,receiverPublicKey:u,senderPublicKey:h},I=[],M=[];for(const k of n){if(!await Bu({cacao:k,projectId:this.client.core.projectId})){s.setError(bs.invalid_cacao);const U=ct("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:U,encodeOpts:m}),new Error(U.message)}s.addTrace(en.cacaos_verified);const{p:K}=k,B=_a(K.resources),j=[Qo(K.iss)],F=wa(K.iss);if(B){const U=Uu(B),z=$u(B);I.push(...U),j.push(...z)}for(const U of j)M.push(`${U}:${F}`)}const D=await this.client.core.crypto.generateSharedKey(h,u);s.addTrace(en.create_authenticated_session_topic);let N;if(I?.length>0){N={topic:D,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:wt(Nn),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:e0([...new Set(I)],[...new Set(M)]),transportType:f},s.addTrace(en.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(D,{transportType:f})}catch(k){throw s.setError(bs.subscribe_authenticated_session_topic_failure),k}s.addTrace(en.subscribe_authenticated_session_topic_success),await this.client.session.set(D,N),s.addTrace(en.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(en.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:m,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(k){throw s.setError(bs.authenticated_session_approve_publish_failure),k}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:N}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),u=xa(o),h={type:si,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:u,error:n,encodeOpts:h,rpcOpts:Dt.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,ct("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return Lu(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.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)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:u}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ct("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.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(nd).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,ct("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Qr.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Zi.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ct("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=Qr.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,wt(Dt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:s,transportType:o=ht.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||wt(Dt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:u,throwOnFailedPublish:h,appLink:g}=t,m=Qi(n,s,u);let I;const M=!!g;try{const k=M?ns:Pi;I=await this.client.core.crypto.encode(i,m,{encoding:k})}catch(k){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),k}let D;if(f8.includes(n)){const k=ai(JSON.stringify(m)),K=ai(I);D=await this.client.core.verify.register({id:K,decryptedId:k})}const N=Dt[n].req;if(N.attestation=D,o&&(N.ttl=o),f&&(N.id=f),this.client.core.history.set(i,m),M){const k=Aa(g,i,I);await global.Linking.openURL(k,this.client.name)}else{const k=Dt[n].req;o&&(k.ttl=o),f&&(k.id=f),h?(k.internal=Nr(gt({},k.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,I,k)):this.client.core.relayer.publish(i,I,k).catch(K=>this.client.logger.error(K))}return m.id},this.sendResult=async t=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:u}=t,h=cf(i,s);let g;const m=u&&typeof(global==null?void 0:global.Linking)<"u";try{const M=m?ns:Pi;g=await this.client.core.crypto.encode(n,h,Nr(gt({},f||{}),{encoding:M}))}catch(M){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),M}let I;try{I=await this.client.core.history.get(n,i)}catch(M){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),M}if(m){const M=Aa(u,n,g);await global.Linking.openURL(M,this.client.name)}else{const M=Dt[I.request.method].res;o?(M.internal=Nr(gt({},M.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,M)):this.client.core.relayer.publish(n,g,M).catch(D=>this.client.logger.error(D))}await this.client.core.history.resolve(h)},this.sendError=async t=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:u}=t,h=hf(i,s);let g;const m=u&&typeof(global==null?void 0:global.Linking)<"u";try{const M=m?ns:Pi;g=await this.client.core.crypto.encode(n,h,Nr(gt({},o||{}),{encoding:M}))}catch(M){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),M}let I;try{I=await this.client.core.history.get(n,i)}catch(M){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),M}if(m){const M=Aa(u,n,g);await global.Linking.openURL(M,this.client.name)}else{const M=f||Dt[I.request.method].res;this.client.core.relayer.publish(n,g,M)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Oi(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Oi(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Qr.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=Qr.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Qr.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,u=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});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:f,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:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:s}=t,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}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=ne("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:u}=n;try{const h=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(gt({},n.params));const g=f.expiryTimestamp||wt(Dt.wc_sessionPropose.req.ttl),m=gt({id:u,pairingTopic:i,expiryTimestamp:g},f);await this.setProposal(u,m);const I=await this.getVerifyContext({attestationId:s,hash:ai(JSON.stringify(n)),encryptedId:o,metadata:m.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(ci.proposal_listener_not_found)),h?.addTrace(Yr.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:m,verifyContext:I})}catch(h){await this.sendError({id:u,topic:i,error:h,rpcOpts:Dt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:s}=i;if(Gr(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});const u=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const g=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});const m=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:m}),await this.client.core.pairing.activate({topic:t})}else if(wr(i)){await this.client.proposal.delete(s,ct("USER_DISCONNECTED"));const o=Ye("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Ye("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:f,expiry:u,namespaces:h,sessionProperties:g,sessionConfig:m}=i.params,I=Nr(gt(gt({topic:t,relay:o,expiry:u,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},g&&{sessionProperties:g}),m&&{sessionConfig:m}),{transportType:ht.relay}),M=Ye("session_connect");if(this.events.listenerCount(M)===0)throw new Error(`emitting ${M} without any listeners 997`);this.events.emit(Ye("session_connect"),{session:I}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Gr(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Ye("session_approve",n),{})):wr(i)&&(await this.client.session.delete(t,ct("USER_DISCONNECTED")),this.events.emit(Ye("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:s}=i;try{const o=`${t}_session_update`,f=us.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ct("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(gt({topic:t},n));try{us.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(u){throw us.delete(o),u}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,s=Ye("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Gr(i)?this.events.emit(Ye("session_update",n),{}):wr(i)&&this.events.emit(Ye("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,wt(Nn)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,s=Ye("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Gr(i)?this.events.emit(Ye("session_extend",n),{}):wr(i)&&this.events.emit(Ye("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,s=Ye("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Gr(i)?this.events.emit(Ye("session_ping",n),{}):wr(i)&&this.events.emit(Ye("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Jt.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ct("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;const{topic:o,payload:f,attestation:u,encryptedId:h,transportType:g}=t,{id:m,params:I}=f;try{await this.isValidRequest(gt({topic:o},I));const M=this.client.session.get(o),D=await this.getVerifyContext({attestationId:u,hash:ai(JSON.stringify(Qi("wc_sessionRequest",I,m))),encryptedId:h,metadata:M.peer.metadata,transportType:g}),N={id:m,topic:o,params:I,verifyContext:D};await this.setPendingSessionRequest(N),g===ht.link_mode&&(i=M.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=M.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(N):(this.addSessionRequestToSessionRequestQueue(N),this.processSessionRequestQueue())}catch(M){await this.sendError({id:m,topic:o,error:M}),this.client.logger.error(M)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,s=Ye("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Gr(i)?this.events.emit(Ye("session_request",n),{result:i.result}):wr(i)&&this.events.emit(Ye("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:s}=i;try{const o=`${t}_session_event_${s.event.name}`,f=us.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(gt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),us.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Gr(i)?this.events.emit(Ye("session_request",n),{result:i.result}):wr(i)&&this.events.emit(Ye("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:f,transportType:u}=t;try{const{requester:h,authPayload:g,expiryTimestamp:m}=s.params,I=await this.getVerifyContext({attestationId:o,hash:ai(JSON.stringify(s)),encryptedId:f,metadata:h.metadata,transportType:u}),M={requester:h,pairingTopic:n,id:s.id,authPayload:g,verifyContext:I,expiryTimestamp:m};await this.setAuthRequest(s.id,{request:M,pairingTopic:n,transportType:u}),u===ht.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:I})}catch(h){this.client.logger.error(h);const g=s.params.requester.publicKey,m=await this.client.core.crypto.generateKeyPair(),I=this.getAppLinkIfEnabled(s.params.requester.metadata,u),M={type:si,receiverPublicKey:g,senderPublicKey:m};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:M,rpcOpts:Dt.wc_sessionAuthenticate.autoReject,appLink:I})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Qr.idle,this.processSessionRequestQueue()},ae.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,f=Ye("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Ye("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Qr.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Qr.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Qi("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!tr(t)){const{message:u}=ne("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(Wt(i)||await this.isValidPairingTopic(i),!by(f,!0)){const{message:u}=ne("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(u)}!Wt(n)&&Ea(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Wt(s)&&Ea(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Wt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=gy(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!tr(t))throw new Error(ne("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const f=this.client.proposal.get(i),u=rf(n,"approve()");if(u)throw new Error(u.message);const h=s0(f.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!mt(s,!0)){const{message:g}=ne("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}Wt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!tr(t)){const{message:s}=ne("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!my(n)){const{message:s}=ne("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!tr(t)){const{message:h}=ne("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(h)}const{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!i0(i)){const{message:h}=ne("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const f=cy(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);const u=rf(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Oi(o)){const{message:h}=ne("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async t=>{if(!tr(t)){const{message:u}=ne("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(u)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=rf(n,"update()");if(o)throw new Error(o.message);const f=s0(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!tr(t)){const{message:n}=ne("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!tr(t)){const{message:u}=ne("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(u)}const{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!n0(f,s)){const{message:u}=ne("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!yy(n)){const{message:u}=ne("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(u)}if(!xy(f,s,n.method)){const{message:u}=ne("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(u)}if(o&&!My(o,Af)){const{message:u}=ne("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Af.min} and ${Af.max}`);throw new Error(u)}},this.isValidRespond=async t=>{var i;if(!tr(t)){const{message:o}=ne("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!wy(s)){const{message:o}=ne("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!tr(t)){const{message:n}=ne("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!tr(t)){const{message:f}=ne("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}const{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!n0(o,s)){const{message:f}=ne("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!_y(n)){const{message:f}=ne("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!Ay(o,s,n.name)){const{message:f}=ne("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!tr(t)){const{message:n}=ne("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:s,nonce:o}=t;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(u=>ma(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:f}=ma(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,u={verified:{verifyUrl:o.verifyUrl||gs,validation:"UNKNOWN",origin:o.url||""}};try{if(f===ht.link_mode){const g=this.getAppLinkIfEnabled(o,f);return u.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",u}const h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(u.verified.origin=h.origin,u.verified.isScam=h.isScam,u.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(u)}`),u},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!mt(n,!1)){const{message:s}=ne("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,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)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=ne("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,u,h,g,m,I;return!t||i!==ht.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((h=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:h.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((m=t?.redirect)==null?void 0:m.universal)!==""&&((I=t?.redirect)==null?void 0:I.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=Ru(t,"topic")||"",n=decodeURIComponent(Ru(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:ht.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Jo()||On()&&(t=this.client.metadata.redirect)!=null&&t.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)}}}}isInitialized(){if(!this.initialized){const{message:e}=ne("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Jt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Oa)?this.client.auth.authKeys.get(Oa):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===ht.link_mode?ns:Pi});try{uf(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:ai(i)})):Ma(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(xr.expired,async e=>{const{topic:t,id:i}=Pu(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,ne("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,ne("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Xi.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Xi.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!mt(e,!1)){const{message:t}=ne("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=ne("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Oi(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=ne("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!mt(e,!1)){const{message:t}=ne("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=ne("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Oi(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=ne("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=ne("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}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:t}=ne("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=ne("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!vy(e)){const{message:t}=ne("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=ne("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Oi(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=ne("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class w8 extends tn{constructor(e,t){super(e,t,i8,_f),this.core=e,this.logger=t}}class od extends tn{constructor(e,t){super(e,t,s8,_f),this.core=e,this.logger=t}}class _8 extends tn{constructor(e,t){super(e,t,o8,_f,i=>i.id),this.core=e,this.logger=t}}class x8 extends tn{constructor(e,t){super(e,t,u8,Da,()=>Oa),this.core=e,this.logger=t}}class A8 extends tn{constructor(e,t){super(e,t,d8,Da),this.core=e,this.logger=t}}class E8 extends tn{constructor(e,t){super(e,t,l8,Da,i=>i.id),this.core=e,this.logger=t}}class S8{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new x8(this.core,this.logger),this.pairingTopics=new A8(this.core,this.logger),this.requests=new E8(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Ef extends Sp{constructor(e){super(e),this.protocol=td,this.version=rd,this.name=xf.name,this.events=new qt.exports.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||xf.name,this.metadata=e?.metadata||Su(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Xr(Qa({level:e?.logger||xf.logger}));this.core=e?.core||new wf(e),this.logger=jt(t,this.name),this.session=new od(this.core,this.logger),this.proposal=new w8(this.core,this.logger),this.pendingRequest=new _8(this.core,this.logger),this.engine=new y8(this),this.auth=new S8(this.core,this.logger)}static async init(e){const t=new Ef(e);return await t.initialize(),t}get context(){return Qt(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"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const M8=od,I8=Ef;class D8 extends qt.exports{constructor(){super()}}class fd{constructor(e){this.opts=e}}class cd{constructor(e){this.client=e}}var O8=Object.defineProperty,P8=Object.defineProperties,R8=Object.getOwnPropertyDescriptors,hd=Object.getOwnPropertySymbols,N8=Object.prototype.hasOwnProperty,C8=Object.prototype.propertyIsEnumerable,ud=(r,e,t)=>e in r?O8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,T8=(r,e)=>{for(var t in e||(e={}))N8.call(e,t)&&ud(r,t,e[t]);if(hd)for(var t of hd(e))C8.call(e,t)&&ud(r,t,e[t]);return r},F8=(r,e)=>P8(r,R8(e));class B8 extends cd{constructor(e){super(e),this.init=async()=>{this.signClient=await I8.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig})},this.pair=async t=>{await this.client.core.pairing.pair(t)},this.approveSession=async t=>{const{topic:i,acknowledged:n}=await this.signClient.approve(F8(T8({},t),{id:t.id,namespaces:t.namespaces,sessionProperties:t.sessionProperties,sessionConfig:t.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async t=>await this.signClient.reject(t),this.updateSession=async t=>await this.signClient.update(t),this.extendSession=async t=>await this.signClient.extend(t),this.respondSessionRequest=async t=>await this.signClient.respond(t),this.disconnectSession=async t=>await this.signClient.disconnect(t),this.emitSessionEvent=async t=>await this.signClient.emit(t),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((t,i)=>(t[i.topic]=i,t),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async t=>await this.signClient.approveSessionAuthenticate(t),this.rejectSessionAuthenticate=async t=>await this.signClient.rejectSessionAuthenticate(t),this.formatAuthMessage=t=>this.signClient.formatAuthMessage(t),this.registerDeviceToken=t=>this.client.core.echoClient.registerDeviceToken(t),this.on=(t,i)=>(this.setEvent(t,"off"),this.setEvent(t,"on"),this.client.events.on(t,i)),this.once=(t,i)=>(this.setEvent(t,"off"),this.setEvent(t,"once"),this.client.events.once(t,i)),this.off=(t,i)=>(this.setEvent(t,"off"),this.client.events.off(t,i)),this.removeListener=(t,i)=>(this.setEvent(t,"removeListener"),this.client.events.removeListener(t,i)),this.onSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onSessionProposal=t=>{this.client.events.emit("session_proposal",t)},this.onSessionDelete=t=>{this.client.events.emit("session_delete",t)},this.onProposalExpire=t=>{this.client.events.emit("proposal_expire",t)},this.onSessionRequestExpire=t=>{this.client.events.emit("session_request_expire",t)},this.onSessionRequestAuthenticate=t=>{this.client.events.emit("session_authenticate",t)},this.setEvent=(t,i)=>{switch(t){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 L8={decryptMessage:async r=>{const e={core:new wf({storageOptions:r.storageOptions,storage:r.storage})};await e.core.crypto.init();const t=e.core.crypto.decode(r.topic,r.encryptedMessage);return e.core=null,t},getMetadata:async r=>{const e={core:new wf({storageOptions:r.storageOptions,storage:r.storage}),sessionStore:null};e.sessionStore=new M8(e.core,e.core.logger),await e.sessionStore.init();const t=e.sessionStore.get(r.topic),i=t?.peer.metadata;return e.core=null,e.sessionStore=null,i}},dd=class extends fd{constructor(r){super(r),this.events=new qt.exports,this.on=(e,t)=>this.engine.on(e,t),this.once=(e,t)=>this.engine.once(e,t),this.off=(e,t)=>this.engine.off(e,t),this.removeListener=(e,t)=>this.engine.removeListener(e,t),this.pair=async e=>{try{return await this.engine.pair(e)}catch(t){throw this.logger.error(t.message),t}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(t){throw this.logger.error(t.message),t}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(t){throw this.logger.error(t.message),t}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(t){throw this.logger.error(t.message),t}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(t){throw this.logger.error(t.message),t}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(t){throw this.logger.error(t.message),t}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(t){throw this.logger.error(t.message),t}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(t){throw this.logger.error(t.message),t}},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(t){throw this.logger.error(t.message),t}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(t){throw this.logger.error(t.message),t}},this.metadata=r.metadata,this.name=r.name||Ba,this.signConfig=r.signConfig,this.core=r.core,this.logger=this.core.logger,this.engine=new B8(this)}static async init(r){const e=new dd(r);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(r){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(r.message),r}}};let Sf=dd;Sf.notifications=L8;const q8=Sf;Lt.CLIENT_CONTEXT=Ba,Lt.CLIENT_STORAGE_OPTIONS=Rd,Lt.CLIENT_STORAGE_PREFIX=Pd,Lt.IWalletKit=fd,Lt.IWalletKitEngine=cd,Lt.IWalletKitEvents=D8,Lt.PROTOCOL=Lf,Lt.PROTOCOL_VERSION=Od,Lt.REQUEST_CONTEXT=Nd,Lt.WalletKit=q8,Lt.default=Sf,Object.defineProperty(Lt,"__esModule",{value:!0})});
|
43
|
+
***************************************************************************** */var sc=function(t,e){return sc=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])},sc(t,e)};function M5(t,e){sc(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var oc=function(){return oc=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},oc.apply(this,arguments)};function I5(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 A5(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 D5(t,e){return function(r,i){e(r,i,t)}}function O5(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function P5(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(v){o(v)}}function c(l){try{h(i.throw(l))}catch(v){o(v)}}function h(l){l.done?s(l.value):n(l.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function R5(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 $5(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function N5(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function ac(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 c0(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 F5(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(c0(arguments[e]));return t}function T5(){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 qs(t){return this instanceof qs?(this.v=t,this):new qs(t)}function C5(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){v(s[0][3],S)}}function c(M){M.value instanceof qs?Promise.resolve(M.value.v).then(h,l):v(s[0][2],M)}function h(M){a("next",M)}function l(M){a("throw",M)}function v(M,I){M(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function B5(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:qs(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function L5(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 ac=="function"?ac(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 q5(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function U5(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 z5(t){return t&&t.__esModule?t:{default:t}}function k5(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function j5(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 K5=Object.freeze({__proto__:null,__extends:M5,get __assign(){return oc},__rest:I5,__decorate:A5,__param:D5,__metadata:O5,__awaiter:P5,__generator:R5,__createBinding:$5,__exportStar:N5,__values:ac,__read:c0,__spread:F5,__spreadArrays:T5,__await:qs,__asyncGenerator:C5,__asyncDelegator:B5,__asyncValues:L5,__makeTemplateObject:q5,__importStar:U5,__importDefault:z5,__classPrivateFieldGet:k5,__classPrivateFieldSet:j5}),V5=ua(K5),yi={},h0;function H5(){if(h0)return yi;h0=1,Object.defineProperty(yi,"__esModule",{value:!0}),yi.isBrowserCryptoAvailable=yi.getSubtleCrypto=yi.getBrowerCrypto=void 0;function t(){return Nt?.crypto||Nt?.msCrypto||{}}yi.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}yi.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return yi.isBrowserCryptoAvailable=r,yi}var mi={},u0;function W5(){if(u0)return mi;u0=1,Object.defineProperty(mi,"__esModule",{value:!0}),mi.isBrowser=mi.isNode=mi.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}mi.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}mi.isNode=e;function r(){return!t()&&!e()}return mi.isBrowser=r,mi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=V5;e.__exportStar(H5(),t),e.__exportStar(W5(),t)})(f0);function wi(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function bn(t=6){return BigInt(wi(t))}function vn(t,e,r){return{id:r||wi(),jsonrpc:"2.0",method:t,params:e}}function fc(t,e){return{id:t,jsonrpc:"2.0",result:e}}function cc(t,e,r){return{id:t,jsonrpc:"2.0",error:G5(e,r)}}function G5(t,e){return typeof t>"u"?a0(s0):(typeof t=="string"&&(t=Object.assign(Object.assign({},a0(nc)),{message:t})),typeof e<"u"&&(t.data=e),x5(t.code)&&(t=E5(t.code)),t)}class J5{}class Y5 extends J5{constructor(){super()}}class X5 extends Y5{constructor(e){super()}}const Z5="^wss?:";function Q5(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function e9(t,e){const r=Q5(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function d0(t){return e9(t,Z5)}function t9(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function l0(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function hc(t){return l0(t)&&"method"in t}function ta(t){return l0(t)&&(ii(t)||Ar(t))}function ii(t){return"result"in t}function Ar(t){return"error"in t}class r9 extends X5{constructor(e){super(e),this.events=new jt.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(vn(e.method,e.params||[],e.id||bn().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=>{Ar(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),ta(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 i9=()=>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"),n9=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",p0=t=>t.split("?")[0],g0=10,s9=i9();class o9{constructor(e){if(this.url=e,this.events=new jt.exports.EventEmitter,this.registering=!1,!d0(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(tn(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!d0(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=f0.isReactNative()?void 0:{rejectUnauthorized:!t9(e)},s=new s9(e,[],n);n9()?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"?An(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=cc(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return S5(e,p0(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>g0&&this.events.setMaxListeners(g0)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${p0(this.url)}`));return this.events.emit("register_error",r),r}}var uc={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]",v="[object Date]",M="[object Error]",I="[object Function]",S="[object GeneratorFunction]",D="[object Map]",F="[object Number]",T="[object Null]",O="[object Object]",$="[object Promise]",N="[object Proxy]",C="[object RegExp]",L="[object Set]",V="[object String]",z="[object Symbol]",H="[object Undefined]",re="[object WeakMap]",P="[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]",y=/[\\^$.*+?()[\]{}|]/g,A=/^\[object .+?Constructor\]$/,j=/^(?: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[P]=x[l]=x[g]=x[v]=x[M]=x[I]=x[D]=x[F]=x[O]=x[C]=x[L]=x[V]=x[re]=!1;var B=typeof Nt=="object"&&Nt&&Nt.Object===Object&&Nt,U=typeof self=="object"&&self&&self.Object===Object&&self,k=B||U||Function("return this")(),K=e&&!e.nodeType&&e,J=K&&!0&&t&&!t.nodeType&&t,X=J&&J.exports===K,G=X&&B.process,ne=function(){try{return G&&G.binding&&G.binding("util")}catch{}}(),Q=ne&&ne.isTypedArray;function ee(R,q){for(var W=-1,te=R==null?0:R.length,ut=0,we=[];++W<te;){var bt=R[W];q(bt,W,R)&&(we[ut++]=bt)}return we}function qe(R,q){for(var W=-1,te=q.length,ut=R.length;++W<te;)R[ut+W]=q[W];return R}function Ue(R,q){for(var W=-1,te=R==null?0:R.length;++W<te;)if(q(R[W],W,R))return!0;return!1}function he(R,q){for(var W=-1,te=Array(R);++W<R;)te[W]=q(W);return te}function Pe(R){return function(q){return R(q)}}function Re(R,q){return R.has(q)}function ae(R,q){return R?.[q]}function $e(R){var q=-1,W=Array(R.size);return R.forEach(function(te,ut){W[++q]=[ut,te]}),W}function Ne(R,q){return function(W){return R(q(W))}}function ce(R){var q=-1,W=Array(R.size);return R.forEach(function(te){W[++q]=te}),W}var Fe=Array.prototype,Te=Function.prototype,oe=Object.prototype,De=k["__core-js_shared__"],Ce=Te.toString,ie=oe.hasOwnProperty,Ve=function(){var R=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||"");return R?"Symbol(src)_1."+R:""}(),He=oe.toString,pe=RegExp("^"+Ce.call(ie).replace(y,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),We=X?k.Buffer:void 0,Be=k.Symbol,de=k.Uint8Array,Ge=oe.propertyIsEnumerable,Xe=Fe.splice,se=Be?Be.toStringTag:void 0,Je=Object.getOwnPropertySymbols,Ze=We?We.isBuffer:void 0,ge=Ne(Object.keys,Object),ze=rs(k,"DataView"),Oe=rs(k,"Map"),ue=rs(k,"Promise"),ke=rs(k,"Set"),je=rs(k,"WeakMap"),fe=rs(Object,"create"),Qe=xn(ze),et=xn(Oe),be=xn(ue),tt=xn(ke),rt=xn(je),le=Be?Be.prototype:void 0,Ke=le?le.valueOf:void 0;function Ae(R){var q=-1,W=R==null?0:R.length;for(this.clear();++q<W;){var te=R[q];this.set(te[0],te[1])}}function ve(){this.__data__=fe?fe(null):{},this.size=0}function it(R){var q=this.has(R)&&delete this.__data__[R];return this.size-=q?1:0,q}function nt(R){var q=this.__data__;if(fe){var W=q[R];return W===i?void 0:W}return ie.call(q,R)?q[R]:void 0}function ye(R){var q=this.__data__;return fe?q[R]!==void 0:ie.call(q,R)}function st(R,q){var W=this.__data__;return this.size+=this.has(R)?0:1,W[R]=fe&&q===void 0?i:q,this}Ae.prototype.clear=ve,Ae.prototype.delete=it,Ae.prototype.get=nt,Ae.prototype.has=ye,Ae.prototype.set=st;function xe(R){var q=-1,W=R==null?0:R.length;for(this.clear();++q<W;){var te=R[q];this.set(te[0],te[1])}}function Ye(){this.__data__=[],this.size=0}function ar(R){var q=this.__data__,W=oa(q,R);if(W<0)return!1;var te=q.length-1;return W==te?q.pop():Xe.call(q,W,1),--this.size,!0}function fr(R){var q=this.__data__,W=oa(q,R);return W<0?void 0:q[W][1]}function cr(R){return oa(this.__data__,R)>-1}function hr(R,q){var W=this.__data__,te=oa(W,R);return te<0?(++this.size,W.push([R,q])):W[te][1]=q,this}xe.prototype.clear=Ye,xe.prototype.delete=ar,xe.prototype.get=fr,xe.prototype.has=cr,xe.prototype.set=hr;function wt(R){var q=-1,W=R==null?0:R.length;for(this.clear();++q<W;){var te=R[q];this.set(te[0],te[1])}}function xi(){this.size=0,this.__data__={hash:new Ae,map:new(Oe||xe),string:new Ae}}function Ei(R){var q=aa(this,R).delete(R);return this.size-=q?1:0,q}function Si(R){return aa(this,R).get(R)}function Mi(R){return aa(this,R).has(R)}function Ii(R,q){var W=aa(this,R),te=W.size;return W.set(R,q),this.size+=W.size==te?0:1,this}wt.prototype.clear=xi,wt.prototype.delete=Ei,wt.prototype.get=Si,wt.prototype.has=Mi,wt.prototype.set=Ii;function Pr(R){var q=-1,W=R==null?0:R.length;for(this.__data__=new wt;++q<W;)this.add(R[q])}function Ai(R){return this.__data__.set(R,i),this}function Di(R){return this.__data__.has(R)}Pr.prototype.add=Pr.prototype.push=Ai,Pr.prototype.has=Di;function Wt(R){var q=this.__data__=new xe(R);this.size=q.size}function Oi(){this.__data__=new xe,this.size=0}function Pi(R){var q=this.__data__,W=q.delete(R);return this.size=q.size,W}function Ri(R){return this.__data__.get(R)}function Hs(R){return this.__data__.has(R)}function Ws(R,q){var W=this.__data__;if(W instanceof xe){var te=W.__data__;if(!Oe||te.length<r-1)return te.push([R,q]),this.size=++W.size,this;W=this.__data__=new wt(te)}return W.set(R,q),this.size=W.size,this}Wt.prototype.clear=Oi,Wt.prototype.delete=Pi,Wt.prototype.get=Ri,Wt.prototype.has=Hs,Wt.prototype.set=Ws;function Ax(R,q){var W=fa(R),te=!W&&kx(R),ut=!W&&!te&&Sc(R),we=!W&&!te&&!ut&&Ep(R),bt=W||te||ut||we,$t=bt?he(R.length,String):[],zt=$t.length;for(var dt in R)(q||ie.call(R,dt))&&!(bt&&(dt=="length"||ut&&(dt=="offset"||dt=="parent")||we&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||Bx(dt,zt)))&&$t.push(dt);return $t}function oa(R,q){for(var W=R.length;W--;)if(mp(R[W][0],q))return W;return-1}function Dx(R,q,W){var te=q(R);return fa(R)?te:qe(te,W(R))}function Gs(R){return R==null?R===void 0?H:T:se&&se in Object(R)?Tx(R):zx(R)}function gp(R){return Js(R)&&Gs(R)==a}function bp(R,q,W,te,ut){return R===q?!0:R==null||q==null||!Js(R)&&!Js(q)?R!==R&&q!==q:Ox(R,q,W,te,bp,ut)}function Ox(R,q,W,te,ut,we){var bt=fa(R),$t=fa(q),zt=bt?c:Ji(R),dt=$t?c:Ji(q);zt=zt==a?O:zt,dt=dt==a?O:dt;var yr=zt==O,jr=dt==O,Gt=zt==dt;if(Gt&&Sc(R)){if(!Sc(q))return!1;bt=!0,yr=!1}if(Gt&&!yr)return we||(we=new Wt),bt||Ep(R)?vp(R,q,W,te,ut,we):Nx(R,q,zt,W,te,ut,we);if(!(W&n)){var Rr=yr&&ie.call(R,"__wrapped__"),$r=jr&&ie.call(q,"__wrapped__");if(Rr||$r){var Yi=Rr?R.value():R,$i=$r?q.value():q;return we||(we=new Wt),ut(Yi,$i,W,te,we)}}return Gt?(we||(we=new Wt),Fx(R,q,W,te,ut,we)):!1}function Px(R){if(!xp(R)||qx(R))return!1;var q=wp(R)?pe:A;return q.test(xn(R))}function Rx(R){return Js(R)&&_p(R.length)&&!!x[Gs(R)]}function $x(R){if(!Ux(R))return ge(R);var q=[];for(var W in Object(R))ie.call(R,W)&&W!="constructor"&&q.push(W);return q}function vp(R,q,W,te,ut,we){var bt=W&n,$t=R.length,zt=q.length;if($t!=zt&&!(bt&&zt>$t))return!1;var dt=we.get(R);if(dt&&we.get(q))return dt==q;var yr=-1,jr=!0,Gt=W&s?new Pr:void 0;for(we.set(R,q),we.set(q,R);++yr<$t;){var Rr=R[yr],$r=q[yr];if(te)var Yi=bt?te($r,Rr,yr,q,R,we):te(Rr,$r,yr,R,q,we);if(Yi!==void 0){if(Yi)continue;jr=!1;break}if(Gt){if(!Ue(q,function($i,En){if(!Re(Gt,En)&&(Rr===$i||ut(Rr,$i,W,te,we)))return Gt.push(En)})){jr=!1;break}}else if(!(Rr===$r||ut(Rr,$r,W,te,we))){jr=!1;break}}return we.delete(R),we.delete(q),jr}function Nx(R,q,W,te,ut,we,bt){switch(W){case g:if(R.byteLength!=q.byteLength||R.byteOffset!=q.byteOffset)return!1;R=R.buffer,q=q.buffer;case P:return!(R.byteLength!=q.byteLength||!we(new de(R),new de(q)));case l:case v:case F:return mp(+R,+q);case M:return R.name==q.name&&R.message==q.message;case C:case V:return R==q+"";case D:var $t=$e;case L:var zt=te&n;if($t||($t=ce),R.size!=q.size&&!zt)return!1;var dt=bt.get(R);if(dt)return dt==q;te|=s,bt.set(R,q);var yr=vp($t(R),$t(q),te,ut,we,bt);return bt.delete(R),yr;case z:if(Ke)return Ke.call(R)==Ke.call(q)}return!1}function Fx(R,q,W,te,ut,we){var bt=W&n,$t=yp(R),zt=$t.length,dt=yp(q),yr=dt.length;if(zt!=yr&&!bt)return!1;for(var jr=zt;jr--;){var Gt=$t[jr];if(!(bt?Gt in q:ie.call(q,Gt)))return!1}var Rr=we.get(R);if(Rr&&we.get(q))return Rr==q;var $r=!0;we.set(R,q),we.set(q,R);for(var Yi=bt;++jr<zt;){Gt=$t[jr];var $i=R[Gt],En=q[Gt];if(te)var Sp=bt?te(En,$i,Gt,q,R,we):te($i,En,Gt,R,q,we);if(!(Sp===void 0?$i===En||ut($i,En,W,te,we):Sp)){$r=!1;break}Yi||(Yi=Gt=="constructor")}if($r&&!Yi){var ca=R.constructor,ha=q.constructor;ca!=ha&&"constructor"in R&&"constructor"in q&&!(typeof ca=="function"&&ca instanceof ca&&typeof ha=="function"&&ha instanceof ha)&&($r=!1)}return we.delete(R),we.delete(q),$r}function yp(R){return Dx(R,Vx,Cx)}function aa(R,q){var W=R.__data__;return Lx(q)?W[typeof q=="string"?"string":"hash"]:W.map}function rs(R,q){var W=ae(R,q);return Px(W)?W:void 0}function Tx(R){var q=ie.call(R,se),W=R[se];try{R[se]=void 0;var te=!0}catch{}var ut=He.call(R);return te&&(q?R[se]=W:delete R[se]),ut}var Cx=Je?function(R){return R==null?[]:(R=Object(R),ee(Je(R),function(q){return Ge.call(R,q)}))}:Hx,Ji=Gs;(ze&&Ji(new ze(new ArrayBuffer(1)))!=g||Oe&&Ji(new Oe)!=D||ue&&Ji(ue.resolve())!=$||ke&&Ji(new ke)!=L||je&&Ji(new je)!=re)&&(Ji=function(R){var q=Gs(R),W=q==O?R.constructor:void 0,te=W?xn(W):"";if(te)switch(te){case Qe:return g;case et:return D;case be:return $;case tt:return L;case rt:return re}return q});function Bx(R,q){return q=q??o,!!q&&(typeof R=="number"||j.test(R))&&R>-1&&R%1==0&&R<q}function Lx(R){var q=typeof R;return q=="string"||q=="number"||q=="symbol"||q=="boolean"?R!=="__proto__":R===null}function qx(R){return!!Ve&&Ve in R}function Ux(R){var q=R&&R.constructor,W=typeof q=="function"&&q.prototype||oe;return R===W}function zx(R){return He.call(R)}function xn(R){if(R!=null){try{return Ce.call(R)}catch{}try{return R+""}catch{}}return""}function mp(R,q){return R===q||R!==R&&q!==q}var kx=gp(function(){return arguments}())?gp:function(R){return Js(R)&&ie.call(R,"callee")&&!Ge.call(R,"callee")},fa=Array.isArray;function jx(R){return R!=null&&_p(R.length)&&!wp(R)}var Sc=Ze||Wx;function Kx(R,q){return bp(R,q)}function wp(R){if(!xp(R))return!1;var q=Gs(R);return q==I||q==S||q==h||q==N}function _p(R){return typeof R=="number"&&R>-1&&R%1==0&&R<=o}function xp(R){var q=typeof R;return R!=null&&(q=="object"||q=="function")}function Js(R){return R!=null&&typeof R=="object"}var Ep=Q?Pe(Q):Rx;function Vx(R){return jx(R)?Ax(R):$x(R)}function Hx(){return[]}function Wx(){return!1}t.exports=Kx})(uc,uc.exports);var a9=uc.exports;const b0="wc",v0=2,ra="core",ni=`${b0}@2:${ra}:`,f9={name:ra,logger:"error"},c9={database:":memory:"},h9="crypto",y0="client_ed25519_seed",u9=Y.ONE_DAY,d9="keychain",l9="0.3",p9="messages",g9="0.3",m0=Y.SIX_HOURS,b9="publisher",w0="irn",v9="error",_0="wss://relay.walletconnect.org",y9="relayer",Pt={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"},m9="_subscription",Dr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},w9=.1,dc="2.17.3-canary-nbl-1",ht={link_mode:"link_mode",relay:"relay"},_9="0.3",x9="WALLETCONNECT_CLIENT_ID",x0="WALLETCONNECT_LINK_MODE_APPS",vr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},E9="subscription",S9="0.3",M9=Y.FIVE_SECONDS*1e3,I9="pairing",A9="0.3",Us={wc_pairingDelete:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Y.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Y.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:0},res:{ttl:Y.ONE_DAY,prompt:!1,tag:0}}},yn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ur={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},D9="history",O9="0.3",P9="expirer",Or={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},R9="0.3",$9="verify-api",N9="https://verify.walletconnect.com",E0="https://verify.walletconnect.org",zs=E0,F9=`${zs}/v3`,T9=[N9,E0],C9="echo",B9="https://echo.walletconnect.com",si={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"},_i={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"},zr={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"},mn={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"},wn={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"},L9=.1,q9="event-client",U9=86400,z9="https://pulse.walletconnect.org/batch";function k9(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 v(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,F=0,T=0,O=S.length;T!==O&&S[T]===0;)T++,D++;for(var $=(O-T)*l+1>>>0,N=new Uint8Array($);T!==O;){for(var C=S[T],L=0,V=$-1;(C!==0||L<F)&&V!==-1;V--,L++)C+=256*N[V]>>>0,N[V]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");F=L,T++}for(var z=$-F;z!==$&&N[z]===0;)z++;for(var H=c.repeat(D);z<$;++z)H+=t.charAt(N[z]);return H}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 F=0,T=0;S[D]===c;)F++,D++;for(var O=(S.length-D)*h+1>>>0,$=new Uint8Array(O);S[D];){var N=r[S.charCodeAt(D)];if(N===255)return;for(var C=0,L=O-1;(N!==0||C<T)&&L!==-1;L--,C++)N+=a*$[L]>>>0,$[L]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");T=C,D++}if(S[D]!==" "){for(var V=O-T;V!==O&&$[V]===0;)V++;for(var z=new Uint8Array(F+(O-V)),H=F;V!==O;)z[H++]=$[V++];return z}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:M,decode:I}}var j9=k9,K9=j9;const S0=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")},V9=t=>new TextEncoder().encode(t),H9=t=>new TextDecoder().decode(t);class W9{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 G9{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 M0(this,e)}}class J9{constructor(e){this.decoders=e}or(e){return M0(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 M0=(t,e)=>new J9({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Y9{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new W9(e,r,i),this.decoder=new G9(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ia=({name:t,prefix:e,encode:r,decode:i})=>new Y9(t,e,r,i),js=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=K9(r,e);return ia({prefix:t,name:e,encode:i,decode:s=>S0(n(s))})},X9=(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 v=n[t[l]];if(v===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|v,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},Z9=(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},Ut=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>ia({prefix:e,name:t,encode(n){return Z9(n,i,r)},decode(n){return X9(n,i,r,t)}}),Q9=ia({prefix:"\0",name:"identity",encode:t=>H9(t),decode:t=>V9(t)});var e7=Object.freeze({__proto__:null,identity:Q9});const t7=Ut({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var r7=Object.freeze({__proto__:null,base2:t7});const i7=Ut({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var n7=Object.freeze({__proto__:null,base8:i7});const s7=js({prefix:"9",name:"base10",alphabet:"0123456789"});var o7=Object.freeze({__proto__:null,base10:s7});const a7=Ut({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),f7=Ut({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var c7=Object.freeze({__proto__:null,base16:a7,base16upper:f7});const h7=Ut({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),u7=Ut({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),d7=Ut({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),l7=Ut({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),p7=Ut({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),g7=Ut({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),b7=Ut({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),v7=Ut({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),y7=Ut({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var m7=Object.freeze({__proto__:null,base32:h7,base32upper:u7,base32pad:d7,base32padupper:l7,base32hex:p7,base32hexupper:g7,base32hexpad:b7,base32hexpadupper:v7,base32z:y7});const w7=js({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),_7=js({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var x7=Object.freeze({__proto__:null,base36:w7,base36upper:_7});const E7=js({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),S7=js({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var M7=Object.freeze({__proto__:null,base58btc:E7,base58flickr:S7});const I7=Ut({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),A7=Ut({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),D7=Ut({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),O7=Ut({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var P7=Object.freeze({__proto__:null,base64:I7,base64pad:A7,base64url:D7,base64urlpad:O7});const I0=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}"),R7=I0.reduce((t,e,r)=>(t[r]=e,t),[]),$7=I0.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function N7(t){return t.reduce((e,r)=>(e+=R7[r],e),"")}function F7(t){const e=[];for(const r of t){const i=$7[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const T7=ia({prefix:"\u{1F680}",name:"base256emoji",encode:N7,decode:F7});var C7=Object.freeze({__proto__:null,base256emoji:T7}),B7=D0,A0=128,L7=127,q7=~L7,U7=Math.pow(2,31);function D0(t,e,r){e=e||[],r=r||0;for(var i=r;t>=U7;)e[r++]=t&255|A0,t/=128;for(;t&q7;)e[r++]=t&255|A0,t>>>=7;return e[r]=t|0,D0.bytes=r-i+1,e}var z7=lc,k7=128,O0=127;function lc(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw lc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&O0)<<n:(o&O0)*Math.pow(2,n),n+=7}while(o>=k7);return lc.bytes=s-i,r}var j7=Math.pow(2,7),K7=Math.pow(2,14),V7=Math.pow(2,21),H7=Math.pow(2,28),W7=Math.pow(2,35),G7=Math.pow(2,42),J7=Math.pow(2,49),Y7=Math.pow(2,56),X7=Math.pow(2,63),Z7=function(t){return t<j7?1:t<K7?2:t<V7?3:t<H7?4:t<W7?5:t<G7?6:t<J7?7:t<Y7?8:t<X7?9:10},Q7={encode:B7,decode:z7,encodingLength:Z7},P0=Q7;const R0=(t,e,r=0)=>(P0.encode(t,e,r),e),$0=t=>P0.encodingLength(t),pc=(t,e)=>{const r=e.byteLength,i=$0(t),n=i+$0(r),s=new Uint8Array(n+r);return R0(t,s,0),R0(r,s,i),s.set(e,n),new e_(t,r,e,s)};class e_{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const N0=({name:t,code:e,encode:r})=>new t_(t,e,r);class t_{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?pc(this.code,r):r.then(i=>pc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const F0=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),r_=N0({name:"sha2-256",code:18,encode:F0("SHA-256")}),i_=N0({name:"sha2-512",code:19,encode:F0("SHA-512")});var n_=Object.freeze({__proto__:null,sha256:r_,sha512:i_});const T0=0,s_="identity",C0=S0;var o_=Object.freeze({__proto__:null,identity:{code:T0,name:s_,encode:C0,digest:t=>pc(T0,C0(t))}});new TextEncoder,new TextDecoder;const B0={...e7,...r7,...n7,...o7,...c7,...m7,...x7,...M7,...P7,...C7};({...n_,...o_});function a_(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function L0(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const q0=L0("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),gc=L0("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=a_(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),f_={utf8:q0,"utf-8":q0,hex:B0.base16,latin1:gc,ascii:gc,binary:gc,...B0};function c_(t,e="utf8"){const r=f_[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}`)}class h_{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=d9,this.version=l9,this.initialized=!1,this.storagePrefix=ni,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=Z("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Jt(r,this.name)}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Vd(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Hd(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class u_{constructor(e,r,i){this.core=e,this.logger=r,this.name=h9,this.randomSessionIdentifier=ec(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=eu(n);return Qh(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=g8();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=eu(s),a=this.randomSessionIdentifier;return await vy(a,n,u9,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=b8(a,s);return this.setSymKey(c,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Jo(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const a=jl(o),c=tn(s);if(Vl(a))return m8(c,o?.encoding);if(Kl(a)){const M=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(M,I)}const h=this.getSymKey(n),{type:l,senderPublicKey:v}=a;return v8({type:l,symKey:h,message:c,senderPublicKey:v,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const a=_8(s,o);if(Vl(a)){const c=w8(s,o?.encoding);return An(c)}if(Kl(a)){const c=a.receiverPublicKey,h=a.senderPublicKey;n=await this.generateSharedKey(c,h)}try{const c=this.getSymKey(n),h=y8({symKey:c,encoded:s,encoding:o?.encoding});return An(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(n,s=Gi)=>{const o=Ts({encoded:n,encoding:s});return gn(o.type)},this.getPayloadSenderPublicKey=(n,s=Gi)=>{const o=Ts({encoded:n,encoding:s});return o.senderPublicKey?Zt(o.senderPublicKey,Ht):void 0},this.core=e,this.logger=Jt(r,this.name),this.keychain=i||new h_(this.core,this.logger)}get context(){return tr(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(y0)}catch{e=ec(),await this.keychain.set(y0,e)}return c_(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class d_ extends yg{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=p9,this.version=g9,this.initialized=!1,this.storagePrefix=ni,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}}},this.set=async(i,n)=>{this.isInitialized();const s=vi(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},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=vi(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Jt(e,this.name),this.core=r}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Vd(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Hd(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var l_=Object.defineProperty,p_=Object.defineProperties,g_=Object.getOwnPropertyDescriptors,U0=Object.getOwnPropertySymbols,b_=Object.prototype.hasOwnProperty,v_=Object.prototype.propertyIsEnumerable,z0=(t,e,r)=>e in t?l_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,k0=(t,e)=>{for(var r in e||(e={}))b_.call(e,r)&&z0(t,r,e[r]);if(U0)for(var r of U0(e))v_.call(e,r)&&z0(t,r,e[r]);return t},j0=(t,e)=>p_(t,g_(e));class y_ extends mg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new jt.exports.EventEmitter,this.name=b9,this.queue=new Map,this.publishTimeout=Y.toMiliseconds(Y.ONE_MINUTE),this.initialPublishTimeout=Y.toMiliseconds(Y.ONE_SECOND*15),this.needsTransportRestart=!1,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||m0,c=Yo(s),h=s?.prompt||!1,l=s?.tag||0,v=s?.id||bn().toString(),M={topic:i,message:n,opts:{ttl:a,relay:c,prompt:h,tag:l,id:v,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${v} tag:${l}`;try{const S=new Promise(async D=>{const F=({id:O})=>{M.opts.id===O&&(this.removeRequestFromQueue(O),this.relayer.events.removeListener(Pt.publish,F),D(M))};this.relayer.events.on(Pt.publish,F);const T=ji(new Promise((O,$)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:h,tag:l,id:v,attestation:s?.attestation}).then(O).catch(N=>{this.logger.warn(N,N?.message),$(N)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${v} tag:${l}`);try{await T,this.events.removeListener(Pt.publish,F)}catch(O){this.queue.set(v,j0(k0({},M),{attempt:1})),this.logger.warn(O,O?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:v,topic:i,message:n,opts:s}}),await ji(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(v)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Jt(r,this.name),this.registerEventListeners()}get context(){return tr(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=m0,prompt:h,tag:l,id:v,attestation:M}=e,I={method:Cs(Yo().protocol).publish,params:{topic:o,message:a,ttl:c,prompt:h,tag:l,attestation:M},id:v};Qt((r=I.params)==null?void 0:r.prompt)&&((i=I.params)==null||delete i.prompt),Qt((n=I.params)==null?void 0:n.tag)&&((s=I.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I});const S=await this.relayer.request(I);return this.relayer.events.emit(Pt.publish,e),this.logger.debug("Successfully Published Payload"),S}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,j0(k0({},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({topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a}),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(In.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Pt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Pt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class m_{constructor(){this.map=new Map,this.set=(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),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)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var w_=Object.defineProperty,__=Object.defineProperties,x_=Object.getOwnPropertyDescriptors,K0=Object.getOwnPropertySymbols,E_=Object.prototype.hasOwnProperty,S_=Object.prototype.propertyIsEnumerable,V0=(t,e,r)=>e in t?w_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ks=(t,e)=>{for(var r in e||(e={}))E_.call(e,r)&&V0(t,r,e[r]);if(K0)for(var r of K0(e))S_.call(e,r)&&V0(t,r,e[r]);return t},bc=(t,e)=>__(t,x_(e));class M_ extends xg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new m_,this.events=new jt.exports.EventEmitter,this.name=E9,this.version=S9,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ni,this.subscribeTimeout=Y.toMiliseconds(Y.ONE_MINUTE),this.initialSubscribeTimeout=Y.toMiliseconds(Y.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},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=Yo(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}},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)},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 Y.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)>=M9&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},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)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(In.pulse,async()=>{await this.checkPending()}),this.events.on(vr.created,async i=>{const n=vr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(vr.deleted,async i=>{const n=vr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=Jt(r,this.name),this.clientId=""}get context(){return tr(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=Yo(i);await this.rpcUnsubscribe(e,r,n);const s=ct("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===ht.relay&&await this.restartToComplete();const s={method:Cs(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=this.getSubscriptionId(e);if(i?.transportType===ht.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(l=>this.logger.warn(l))},Y.toMiliseconds(Y.ONE_SECOND)),a;const c=new Promise(async l=>{const v=M=>{M.topic===e&&(this.events.removeListener(vr.created,v),l(M.id))};this.events.on(vr.created,v);try{const M=await ji(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(vr.created,v),l(M)}catch{}}),h=await ji(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(Pt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Cs(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 ji(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(Pt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Cs(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 ji(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(Pt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Cs(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,bc(Ks({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Ks({},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,Ks({},r)),this.topicMap.set(r.topic,e),this.events.emit(vr.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}=Z("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(vr.deleted,bc(Ks({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(vr.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(vr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=Z("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(e.map(r=>bc(Ks({},r),{id: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 R6(Y.toMiliseconds(Y.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}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return vi(e+this.clientId)}}var I_=Object.defineProperty,H0=Object.getOwnPropertySymbols,A_=Object.prototype.hasOwnProperty,D_=Object.prototype.propertyIsEnumerable,W0=(t,e,r)=>e in t?I_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,G0=(t,e)=>{for(var r in e||(e={}))A_.call(e,r)&&W0(t,r,e[r]);if(H0)for(var r of H0(e))D_.call(e,r)&&W0(t,r,e[r]);return t};class O_ extends wg{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new jt.exports.EventEmitter,this.name=y9,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=Y.toMiliseconds(Y.THIRTY_SECONDS+Y.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=Y.toMiliseconds(Y.ONE_SECOND*15),this.request=async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||bn().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}},this.resetPingTimeout=()=>{if(zo())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)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Pt.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.fatal(r,`Fatal socket error: ${r?.message}`),this.events.emit(Pt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Dr.payload,this.onPayloadHandler),this.provider.on(Dr.connect,this.onConnectHandler),this.provider.on(Dr.disconnect,this.onDisconnectHandler),this.provider.on(Dr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Jt(e.logger,this.name):ai(Aa({level:e.logger||v9})),this.messages=new d_(this.logger,e.core),this.subscriber=new M_(this,this.logger),this.publisher=new y_(this,this.logger),this.relayUrl=e?.relayUrl||_0,this.projectId=e.projectId,v6()?this.packageName=kd():y6()&&(this.bundleId=kd()),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 tr(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:ht.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(vr.created,h),c())};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(vr.created,h)}),new Promise(async(l,v)=>{a=await this.subscriber.subscribe(e,G0({internal:{throwOnFailedPublish:o}},r)).catch(M=>{o&&v(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 ji(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 n0())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=Et(Y.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Pt.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(Dr.disconnect,s),await ji(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(Dr.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(Dr.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Dr.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,Y.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(zo())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 r9(new o9(x6({sdkVersion:dc,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}),hc(e)){if(!e.method.endsWith(m9))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:ht.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(G0({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else ta(e)&&this.events.emit(Pt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Pt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=fc(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Dr.payload,this.onPayloadHandler),this.provider.off(Dr.connect,this.onConnectHandler),this.provider.off(Dr.disconnect,this.onDisconnectHandler),this.provider.off(Dr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await n0();p5(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(Pt.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))},Y.toMiliseconds(w9))))}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var P_=Object.defineProperty,J0=Object.getOwnPropertySymbols,R_=Object.prototype.hasOwnProperty,$_=Object.prototype.propertyIsEnumerable,Y0=(t,e,r)=>e in t?P_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,X0=(t,e)=>{for(var r in e||(e={}))R_.call(e,r)&&Y0(t,r,e[r]);if(J0)for(var r of J0(e))$_.call(e,r)&&Y0(t,r,e[r]);return t};class _n extends _g{constructor(e,r,i,n=ni,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=_9,this.cached=[],this.initialized=!1,this.storagePrefix=ni,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,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):V8(o)?this.map.set(o.id,o):H8(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},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())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>a9(a[c],o[c]))):this.values),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=X0(X0({},this.getData(o)),a);this.map.set(o,c),await this.persist()},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=Jt(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return tr(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}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=Z("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}=Z("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}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class N_{constructor(e,r){this.core=e,this.logger=r,this.name=I9,this.version=A9,this.events=new jt.exports,this.initialized=!1,this.storagePrefix=ni,this.ignoredPayloadTypes=[bi],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=ec(),s=await this.core.crypto.setSymKey(n),o=Et(Y.FIVE_MINUTES),a={protocol:w0},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},h=Yl({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(yn.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}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[si.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:h}=Jl(i.uri);n.props.properties.topic=s,n.addTrace(si.pairing_uri_validation_success),n.addTrace(si.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),n.addTrace(si.existing_pairing),l.active)throw n.setError(_i.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(si.pairing_not_expired)}const v=c||Et(Y.FIVE_MINUTES),M={topic:s,relay:a,expiry:v,active:!1,methods:h};this.core.expirer.set(s,v),await this.pairings.set(s,M),n.addTrace(si.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(yn.create,M),n.addTrace(si.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(si.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(_i.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(_i.subscribe_pairing_topic_failure),I}return n.addTrace(si.subscribe_pairing_topic_success),M},this.activate=async({topic:i})=>{this.isInitialized();const n=Et(Y.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=ln();this.events.once(Se("pairing_ping",s),({error:h})=>{h?c(h):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),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",ct("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return Yl({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{const o=vn(n,s),a=await this.core.crypto.encode(i,o),c=Us[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id},this.sendResult=async(i,n,s)=>{const o=fc(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),h=Us[c.request.method].res;await this.core.relayer.publish(n,a,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=cc(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),h=Us[c.request.method]?Us[c.request.method].res:Us.unregistered_method.res;await this.core.relayer.publish(n,a,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ct("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Ki(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},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)}},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)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(yn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{ii(n)?this.events.emit(Se("pairing_ping",s),{}):Ar(n)&&this.events.emit(Se("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(yn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=ct("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)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ct("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!or(i)){const{message:a}=Z("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(_i.malformed_pairing_uri),new Error(a)}if(!K8(i.uri)){const{message:a}=Z("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(_i.malformed_pairing_uri),new Error(a)}const o=Jl(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=Z("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(_i.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=Z("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(_i.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&Y.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(_i.pairing_expired);const{message:a}=Z("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=async i=>{if(!or(i)){const{message:s}=Z("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!or(i)){const{message:s}=Z("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!mt(i,!1)){const{message:n}=Z("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Ki(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=Z("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Jt(r,this.name),this.pairings=new _n(this.core,this.logger,this.name,this.storagePrefix)}get context(){return tr(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Pt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===ht.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{hc(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):ta(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(Or.expired,async e=>{const{topic:r}=Gd(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(yn.expire,{topic:r}))})}}class F_ extends vg{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new jt.exports.EventEmitter,this.name=D9,this.version=O9,this.cached=[],this.initialized=!1,this.storagePrefix=ni,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)},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:Et(Y.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Ur.created,o)},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=Ar(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Ur.updated,n))},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)),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(Ur.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Jt(r,this.name)}get context(){return tr(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:vn(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}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ur.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=Z("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(Ur.created,e=>{const r=Ur.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ur.updated,e=>{const r=Ur.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ur.deleted,e=>{const r=Ur.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(In.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{Y.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Ur.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class T_ extends Eg{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new jt.exports.EventEmitter,this.name=P9,this.version=R9,this.cached=[],this.initialized=!1,this.storagePrefix=ni,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)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},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(Or.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},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(Or.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Jt(r,this.name)}get context(){return tr(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 E6(e);if(typeof e=="number")return S6(e);const{message:r}=Z("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(Or.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=Z("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}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;Y.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Or.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(In.pulse,()=>this.checkExpirations()),this.events.on(Or.created,e=>{const r=Or.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Or.expired,e=>{const r=Or.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Or.deleted,e=>{const r=Or.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class C_ extends Sg{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,this.name=$9,this.verifyUrlV3=F9,this.storagePrefix=ni,this.version=v0,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&Y.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!Ms()||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(Y.ONE_SECOND*5),v=await new Promise((M,I)=>{const S=()=>{window.removeEventListener("message",F),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 F=T=>{if(T.data&&typeof T.data=="string")try{const O=JSON.parse(T.data);if(O.type==="verify_attestation"){if(Ga(O.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(D),this.abortController.signal.removeEventListener("abort",S),window.removeEventListener("message",F),M(O.attestation===null?"":O.attestation)}}catch(O){this.logger.warn(O)}};h.body.appendChild(D),window.addEventListener("message",F,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",v),v}catch(h){this.logger.warn(h)}return""},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(Ga(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)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(Y.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},this.getVerifyUrl=n=>{let s=n||zs;return T9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${zs}`),s=zs),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(Y.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)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},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")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),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},this.validateAttestation=(n,s)=>{const o=M8(n,s.publicKey),a={hasExpired:Y.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=Jt(r,this.name),this.abortController=new AbortController,this.isDevEnv=Tf(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return tr(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),Y.toMiliseconds(e))}}class B_ extends Mg{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=C9,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${B9}/${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=Jt(r,this.context)}}var L_=Object.defineProperty,Z0=Object.getOwnPropertySymbols,q_=Object.prototype.hasOwnProperty,U_=Object.prototype.propertyIsEnumerable,Q0=(t,e,r)=>e in t?L_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vs=(t,e)=>{for(var r in e||(e={}))q_.call(e,r)&&Q0(t,r,e[r]);if(Z0)for(var r of Z0(e))U_.call(e,r)&&Q0(t,r,e[r]);return t};class z_ extends Ig{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,this.context=q9,this.storagePrefix=ni,this.storageVersion=L9,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Tf())try{const n={eventId:Yd(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Kd(this.core.relayer.protocol,this.core.relayer.version,dc)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,h=Yd(),l=this.core.projectId||"",v=Date.now(),M=Vs({eventId:h,timestamp:v,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},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 Vs(Vs({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(In.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{Y.fromMiliseconds(Date.now())-Y.fromMiliseconds(n.timestamp)>U9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),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)},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)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},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,Vs(Vs({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},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)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${z9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${dc}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>jd().url,this.logger=Jt(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 k_=Object.defineProperty,ep=Object.getOwnPropertySymbols,j_=Object.prototype.hasOwnProperty,K_=Object.prototype.propertyIsEnumerable,tp=(t,e,r)=>e in t?k_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rp=(t,e)=>{for(var r in e||(e={}))j_.call(e,r)&&tp(t,r,e[r]);if(ep)for(var r of ep(e))K_.call(e,r)&&tp(t,r,e[r]);return t};class vc extends bg{constructor(e){var r;super(e),this.protocol=b0,this.version=v0,this.name=ra,this.events=new jt.exports.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const h={topic:o,message:a,publishedAt:Date.now(),transportType:ht.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||_0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Aa({level:typeof e?.logger=="string"&&e.logger?e.logger:f9.logger,name:ra}),{logger:n,chunkLoggerController:s}=gg({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=Jt(n,this.name),this.heartbeat=new wa,this.crypto=new u_(this,this.logger,e?.keychain),this.history=new F_(this,this.logger),this.expirer=new T_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new z1(rp(rp({},c9),e?.storageOptions)),this.relayer=new O_({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new N_(this,this.logger),this.verify=new C_(this,this.logger,this.storage),this.echoClient=new B_(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new z_(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new vc(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(x9,i),r}get context(){return tr(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(x0,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.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(x0)||[],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 yc=vc,ip="wc",np=2,sp="client",mc=`${ip}@${np}:${sp}:`,wc={name:sp,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},op="WALLETCONNECT_DEEPLINK_CHOICE",V_="proposal",H_="Proposal expired",W_="session",ts=Y.SEVEN_DAYS,G_="engine",Rt={wc_sessionPropose:{req:{ttl:Y.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Y.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Y.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Y.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Y.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1119}}},_c={min:Y.FIVE_MINUTES,max:Y.SEVEN_DAYS},oi={idle:"IDLE",active:"ACTIVE"},J_="request",Y_=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],X_="wc",Z_="auth",Q_="authKeys",ex="pairingTopics",tx="requests",na=`${X_}@${1.5}:${Z_}:`,sa=`${na}:PUB_KEY`;var rx=Object.defineProperty,ix=Object.defineProperties,nx=Object.getOwnPropertyDescriptors,ap=Object.getOwnPropertySymbols,sx=Object.prototype.hasOwnProperty,ox=Object.prototype.propertyIsEnumerable,fp=(t,e,r)=>e in t?rx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gt=(t,e)=>{for(var r in e||(e={}))sx.call(e,r)&&fp(t,r,e[r]);if(ap)for(var r of ap(e))ox.call(e,r)&&fp(t,r,e[r]);return t},kr=(t,e)=>ix(t,nx(e));class ax extends Dg{constructor(e){super(e),this.name=G_,this.events=new jt.exports,this.initialized=!1,this.requestQueue={state:oi.idle,queue:[]},this.sessionRequestQueue={state:oi.idle,queue:[]},this.requestQueueDelay=Y.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],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(Rt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},Y.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=kr(gt({},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,v=!1;try{h&&(v=this.client.core.pairing.pairings.get(h).active)}catch(N){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),N}if(!h||!v){const{topic:N,uri:C}=await this.client.core.pairing.create();h=N,l=C}if(!h){const{message:N}=Z("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(N)}const M=await this.client.core.crypto.generateKeyPair(),I=Rt.wc_sessionPropose.req.ttl||Y.FIVE_MINUTES,S=Et(I),D=gt({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:w0}],proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:S,pairingTopic:h},a&&{sessionProperties:a}),{reject:F,resolve:T,done:O}=ln(I,H_);this.events.once(Se("session_connect"),async({error:N,session:C})=>{if(N)F(N);else if(C){C.self.publicKey=M;const L=kr(gt({},C),{pairingTopic:D.pairingTopic,requiredNamespaces:D.requiredNamespaces,optionalNamespaces:D.optionalNamespaces,transportType:ht.relay});await this.client.session.set(C.topic,L),await this.setExpiry(C.topic,C.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:C.peer.metadata}),this.cleanupDuplicatePairings(L),T(L)}});const $=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:D,throwOnFailedPublish:!0});return await this.setProposal($,gt({id:$},D)),{uri:l,approval:O}},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}},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:[zr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(z){throw o.setError(mn.no_internet_connection),z}try{await this.isValidProposalId(r?.id)}catch(z){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(mn.proposal_not_found),z}try{await this.isValidApprove(r)}catch(z){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(mn.session_approve_namespace_validation_failure),z}const{id:a,relayProtocol:c,namespaces:h,sessionProperties:l,sessionConfig:v}=r,M=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:I,proposer:S,requiredNamespaces:D,optionalNamespaces:F}=M;let T=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});T||(T=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:zr.session_approve_started,properties:{topic:I,trace:[zr.session_approve_started,zr.session_namespaces_validation_success]}}));const O=await this.client.core.crypto.generateKeyPair(),$=S.publicKey,N=await this.client.core.crypto.generateSharedKey(O,$),C=gt(gt({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:O,metadata:this.client.metadata},expiry:Et(ts)},l&&{sessionProperties:l}),v&&{sessionConfig:v}),L=ht.relay;T.addTrace(zr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(N,{transportType:L})}catch(z){throw T.setError(mn.subscribe_session_topic_failure),z}T.addTrace(zr.subscribe_session_topic_success);const V=kr(gt({},C),{topic:N,requiredNamespaces:D,optionalNamespaces:F,pairingTopic:I,acknowledged:!1,self:C.controller,peer:{publicKey:S.publicKey,metadata:S.metadata},controller:O,transportType:ht.relay});await this.client.session.set(N,V),T.addTrace(zr.store_session);try{T.addTrace(zr.publishing_session_settle),await this.sendRequest({topic:N,method:"wc_sessionSettle",params:C,throwOnFailedPublish:!0}).catch(z=>{throw T?.setError(mn.session_settle_publish_failure),z}),T.addTrace(zr.session_settle_publish_success),T.addTrace(zr.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:c??"irn"},responderPublicKey:O},throwOnFailedPublish:!0}).catch(z=>{throw T?.setError(mn.session_approve_publish_failure),z}),T.addTrace(zr.session_approve_publish_success)}catch(z){throw this.client.logger.error(z),this.client.session.delete(N,ct("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(N),z}return this.client.core.eventClient.deleteEvent({eventId:T.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:S.metadata}),await this.client.proposal.delete(a,ct("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(N,Et(ts)),{topic:N,acknowledged:()=>Promise.resolve(this.client.session.get(N))}},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:Rt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(v){throw this.client.logger.error("update() -> isValidUpdate() failed"),v}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=ln(),c=wi(),h=bn().toString(),l=this.client.session.get(i).namespaces;return this.events.once(Se("session_update",c),({error:v})=>{v?a(v):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(v=>{this.client.logger.error(v),this.client.session.update(i,{namespaces:l}),a(v)}),{acknowledged:s}},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=wi(),{done:s,resolve:o,reject:a}=ln();return this.events.once(Se("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,Et(ts)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(S){throw this.client.logger.error("request() -> isValidRequest() failed"),S}const{chainId:i,request:n,topic:s,expiry:o=Rt.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const c=wi(),h=bn().toString(),{done:l,resolve:v,reject:M}=ln(o,"Request expired. Please try again.");this.events.once(Se("session_request",c),({error:S,result:D})=>{S?M(S):v(D)});const I=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return I?(await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:kr(gt({},n),{expiryTimestamp:Et(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(S=>M(S)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await l()):await Promise.all([new Promise(async S=>{await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:kr(gt({},n),{expiryTimestamp:Et(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(D=>M(D)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),S()}),new Promise(async S=>{var D;if(!((D=a.sessionConfig)!=null&&D.disableDeepLink)){const F=await D6(this.client.core.storage,op);await I6({id:c,topic:s,wcDeepLink:F})}S()}),l()]).then(S=>S[2])},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===ht.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);ii(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Ar(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)},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=wi(),s=bn().toString(),{done:o,resolve:a,reject:c}=ln();this.events.once(Se("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)&&await this.client.core.pairing.ping({topic:i})},this.emit=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=bn().toString(),a=wi();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})},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:ct("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}=Z("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>k8(i,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),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?ht.link_mode:ht.relay;o===ht.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:h,domain:l,nonce:v,type:M,exp:I,nbf:S,methods:D=[],expiry:F}=r,T=[...r.resources||[]],{topic:O,uri:$}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:O,uri:$}});const N=await this.client.core.crypto.generateKeyPair(),C=Jo(N);if(await Promise.all([this.client.auth.authKeys.set(sa,{responseTopic:C,publicKey:N}),this.client.auth.pairingTopics.set(C,{topic:C,pairingTopic:O})]),await this.client.core.relayer.subscribe(C,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${O}`),D.length>0){const{namespace:E}=Uo(a[0]);let w=b4(E,"request",D);Vo(T)&&(w=y4(w,T.pop())),T.push(w)}const L=F&&F>Rt.wc_sessionAuthenticate.req.ttl?F:Rt.wc_sessionAuthenticate.req.ttl,V={authPayload:{type:M??"caip122",chains:a,statement:c,aud:h,domain:l,version:"1",nonce:v,iat:new Date().toISOString(),exp:I,nbf:S,resources:T},requester:{publicKey:N,metadata:this.client.metadata},expiryTimestamp:Et(L)},z={eip155:{chains:a,methods:[...new Set(["personal_sign",...D])],events:["chainChanged","accountsChanged"]}},H={requiredNamespaces:{},optionalNamespaces:z,relays:[{protocol:"irn"}],pairingTopic:O,proposer:{publicKey:N,metadata:this.client.metadata},expiryTimestamp:Et(Rt.wc_sessionPropose.req.ttl)},{done:re,resolve:P,reject:g}=ln(L,"Request expired"),p=async({error:E,session:w})=>{if(this.events.off(Se("session_request",u),f),E)g(E);else if(w){w.self.publicKey=N,await this.client.session.set(w.topic,w),await this.setExpiry(w.topic,w.expiry),O&&await this.client.core.pairing.updateMetadata({topic:O,metadata:w.peer.metadata});const d=this.client.session.get(w.topic);await this.deleteProposal(b),P({session:d})}},f=async E=>{var w,d,m;if(await this.deletePendingAuthRequest(u,{message:"fulfilled",code:0}),E.error){const k=ct("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===k.code?void 0:(this.events.off(Se("session_connect"),p),g(E.error.message))}await this.deleteProposal(b),this.events.off(Se("session_connect"),p);const{cacaos:y,responder:A}=E.result,j=[],x=[];for(const k of y){await ul({cacao:k,projectId:this.client.core.projectId})||(this.client.logger.error(k,"Signature verification failed"),g(ct("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:K}=k,J=Vo(K.resources),X=[zf(K.iss)],G=Ko(K.iss);if(J){const ne=pl(J),Q=gl(J);j.push(...ne),X.push(...Q)}for(const ne of X)x.push(`${ne}:${G}`)}const B=await this.client.core.crypto.generateSharedKey(N,A.publicKey);let U;j.length>0&&(U={topic:B,acknowledged:!0,self:{publicKey:N,metadata:this.client.metadata},peer:A,controller:A.publicKey,expiry:Et(ts),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:O,namespaces:Xl([...new Set(j)],[...new Set(x)]),transportType:o},await this.client.core.relayer.subscribe(B,{transportType:o}),await this.client.session.set(B,U),O&&await this.client.core.pairing.updateMetadata({topic:O,metadata:A.metadata}),U=this.client.session.get(B)),(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(B,{transportType:ht.link_mode})),P({auths:y,session:U})},u=wi(),b=wi();this.events.once(Se("session_connect"),p),this.events.once(Se("session_request",u),f);let _;try{if(s){const E=vn("wc_sessionAuthenticate",V,u);this.client.core.history.set(O,E);const w=await this.client.core.crypto.encode("",E,{type:Ns,encoding:Rs});_=Xo(i,O,w)}else await Promise.all([this.sendRequest({topic:O,method:"wc_sessionAuthenticate",params:V,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:u}),this.sendRequest({topic:O,method:"wc_sessionPropose",params:H,expiry:Rt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(E){throw this.events.off(Se("session_connect"),p),this.events.off(Se("session_request",u),f),E}return await this.setProposal(b,gt({id:b},H)),await this.setAuthRequest(u,{request:kr(gt({},V),{verifyContext:{}}),pairingTopic:O,transportType:o}),{uri:_??$,response:re}},this.approveSessionAuthenticate=async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[wn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(F){throw s.setError(ks.no_internet_connection),F}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||ht.relay;a===ht.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=Jo(c),v={type:bi,receiverPublicKey:c,senderPublicKey:h},M=[],I=[];for(const F of n){if(!await ul({cacao:F,projectId:this.client.core.projectId})){s.setError(ks.invalid_cacao);const C=ct("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:C,encodeOpts:v}),new Error(C.message)}s.addTrace(wn.cacaos_verified);const{p:T}=F,O=Vo(T.resources),$=[zf(T.iss)],N=Ko(T.iss);if(O){const C=pl(O),L=gl(O);M.push(...C),$.push(...L)}for(const C of $)I.push(`${C}:${N}`)}const S=await this.client.core.crypto.generateSharedKey(h,c);s.addTrace(wn.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:Et(ts),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Xl([...new Set(M)],[...new Set(I)]),transportType:a},s.addTrace(wn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:a})}catch(F){throw s.setError(ks.subscribe_authenticated_session_topic_failure),F}s.addTrace(wn.subscribe_authenticated_session_topic_success),await this.client.session.set(S,D),s.addTrace(wn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(wn.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:v,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(F){throw s.setError(ks.authenticated_session_approve_publish_failure),F}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}},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===ht.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Jo(o),h={type:bi,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:h,rpcOpts:Rt.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,ct("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:i,iss:n}=r;return dl(i,n)},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)},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)}},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,ct("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(op).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,ct("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=oi.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(mn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,ct("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},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=oi.idle,this.client.events.emit("session_request_expire",{id:r}))},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)])},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}))},this.setProposal=async(r,i)=>{this.client.core.expirer.set(r,Et(Rt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)},this.setAuthRequest=async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=ht.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})},this.setPendingSessionRequest=async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||Et(Rt.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})},this.sendRequest=async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:h,appLink:l}=r,v=vn(n,s,c);let M;const I=!!l;try{const F=I?Rs:Gi;M=await this.client.core.crypto.encode(i,v,{encoding:F})}catch(F){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),F}let S;if(Y_.includes(n)){const F=vi(JSON.stringify(v)),T=vi(M);S=await this.client.core.verify.register({id:T,decryptedId:F})}const D=Rt[n].req;if(D.attestation=S,o&&(D.ttl=o),a&&(D.id=a),this.client.core.history.set(i,v),I){const F=Xo(l,i,M);await global.Linking.openURL(F,this.client.name)}else{const F=Rt[n].req;o&&(F.ttl=o),a&&(F.id=a),h?(F.internal=kr(gt({},F.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,M,F)):this.client.core.relayer.publish(i,M,F).catch(T=>this.client.logger.error(T))}return v.id},this.sendResult=async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,h=fc(i,s);let l;const v=c&&typeof(global==null?void 0:global.Linking)<"u";try{const I=v?Rs:Gi;l=await this.client.core.crypto.encode(n,h,kr(gt({},a||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> 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(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(v){const I=Xo(c,n,l);await global.Linking.openURL(I,this.client.name)}else{const I=Rt[M.request.method].res;o?(I.internal=kr(gt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,l,I)):this.client.core.relayer.publish(n,l,I).catch(S=>this.client.logger.error(S))}await this.client.core.history.resolve(h)},this.sendError=async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,h=cc(i,s);let l;const v=c&&typeof(global==null?void 0:global.Linking)<"u";try{const I=v?Rs:Gi;l=await this.client.core.crypto.encode(n,h,kr(gt({},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(v){const I=Xo(c,n,l);await global.Linking.openURL(I,this.client.name)}else{const I=a||Rt[M.request.method].res;this.client.core.relayer.publish(n,l,I)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Ki(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=>{Ki(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===oi.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=oi.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=oi.idle},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}`)}},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}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:i}=r,{message:n}=Z("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},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)},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(_i.proposal_listener_not_found)),this.isValidConnect(gt({},n.params));const l=a.expiryTimestamp||Et(Rt.wc_sessionPropose.req.ttl),v=gt({id:c,pairingTopic:i,expiryTimestamp:l},a);await this.setProposal(c,v);const M=await this.getVerifyContext({attestationId:s,hash:vi(JSON.stringify(n)),encryptedId:o,metadata:v.proposer.metadata});h?.addTrace(si.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:v,verifyContext:M})}catch(h){await this.sendError({id:c,topic:i,error:h,rpcOpts:Rt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(r,i,n)=>{const{id:s}=i;if(ii(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 v=await this.client.core.relayer.subscribe(l,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:v}),await this.client.core.pairing.activate({topic:r})}else if(Ar(i)){await this.client.proposal.delete(s,ct("USER_DISCONNECTED"));const o=Se("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Se("session_connect"),{error:i.error})}},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:v}=i.params,M=kr(gt(gt({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}),v&&{sessionConfig:v}),{transportType:ht.relay}),I=Se("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Se("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)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;ii(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Se("session_approve",n),{})):Ar(i)&&(await this.client.session.delete(r,ct("USER_DISCONNECTED")),this.events.emit(Se("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=Bs.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:ct("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(gt({topic:r},n));try{Bs.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 Bs.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)}},this.isRequestOutOfSync=(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3),this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i,s=Se("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);ii(i)?this.events.emit(Se("session_update",n),{}):Ar(i)&&this.events.emit(Se("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Et(ts)),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)}},this.onSessionExtendResponse=(r,i)=>{const{id:n}=i,s=Se("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);ii(i)?this.events.emit(Se("session_extend",n),{}):Ar(i)&&this.events.emit(Se("session_extend",n),{error:i.error})},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)}},this.onSessionPingResponse=(r,i)=>{const{id:n}=i,s=Se("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{ii(i)?this.events.emit(Se("session_ping",n),{}):Ar(i)&&this.events.emit(Se("session_ping",n),{error:i.error})},500)},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(Pt.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:ct("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:h,transportType:l}=r,{id:v,params:M}=a;try{await this.isValidRequest(gt({topic:o},M));const I=this.client.session.get(o),S=await this.getVerifyContext({attestationId:c,hash:vi(JSON.stringify(vn("wc_sessionRequest",M,v))),encryptedId:h,metadata:I.peer.metadata,transportType:l}),D={id:v,topic:o,params:M,verifyContext:S};await this.setPendingSessionRequest(D),l===ht.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:v,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i,s=Se("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);ii(i)?this.events.emit(Se("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Se("session_request",n),{error:i.error})},this.onSessionEventRequest=async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=Bs.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(gt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Bs.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),ii(i)?this.events.emit(Se("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Se("session_request",n),{error:i.error})},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:v}=s.params,M=await this.getVerifyContext({attestationId:o,hash:vi(JSON.stringify(s)),encryptedId:a,metadata:h.metadata,transportType:c}),I={requester:h,pairingTopic:n,id:s.id,authPayload:l,verifyContext:M,expiryTimestamp:v};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:c}),c===ht.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,v=await this.client.core.crypto.generateKeyPair(),M=this.getAppLinkIfEnabled(s.params.requester.metadata,c),I={type:bi,receiverPublicKey:l,senderPublicKey:v};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:I,rpcOpts:Rt.wc_sessionAuthenticate.autoReject,appLink:M})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=oi.idle,this.processSessionRequestQueue()},Y.toMiliseconds(this.requestQueueDelay))},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=Se("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Se("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===oi.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=oi.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=r=>{this.client.events.emit("session_request",r)},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:vn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async r=>{if(!or(r)){const{message:c}=Z("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),!e5(a,!0)){const{message:c}=Z("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!Qt(n)&&Qo(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Qt(s)&&Qo(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Qt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,i)=>{const n=Q8(r,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async r=>{if(!or(r))throw new Error(Z("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=rc(n,"approve()");if(c)throw new Error(c.message);const h=r0(a.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!mt(s,!0)){const{message:l}=Z("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(l)}Qt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!or(r)){const{message:s}=Z("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!r5(n)){const{message:s}=Z("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!or(r)){const{message:h}=Z("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!e0(i)){const{message:h}=Z("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const a=W8(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=rc(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Ki(o)){const{message:h}=Z("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!or(r)){const{message:c}=Z("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=rc(n,"update()");if(o)throw new Error(o.message);const a=r0(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!or(r)){const{message:n}=Z("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async r=>{if(!or(r)){const{message:c}=Z("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(!t0(a,s)){const{message:c}=Z("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!i5(n)){const{message:c}=Z("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!o5(a,s,n.method)){const{message:c}=Z("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!h5(o,_c)){const{message:c}=Z("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${_c.min} and ${_c.max}`);throw new Error(c)}},this.isValidRespond=async r=>{var i;if(!or(r)){const{message:o}=Z("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(!n5(s)){const{message:o}=Z("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!or(r)){const{message:n}=Z("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!or(r)){const{message:a}=Z("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(!t0(o,s)){const{message:a}=Z("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!s5(n)){const{message:a}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!a5(o,s,n.name)){const{message:a}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!or(r)){const{message:n}=Z("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},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=>Uo(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Uo(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||zs,validation:"UNKNOWN",origin:o.url||""}};try{if(a===ht.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},this.validateSessionProps=(r,i)=>{Object.values(r).forEach(n=>{if(!mt(n,!1)){const{message:s}=Z("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0},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)}}},this.checkRecentlyDeleted=r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}},this.isLinkModeEnabled=(r,i)=>{var n,s,o,a,c,h,l,v,M;return!r||i!==ht.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&&((v=r?.redirect)==null?void 0:v.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"},this.getAppLinkIfEnabled=(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=Jd(r,"topic")||"",n=decodeURIComponent(Jd(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:ht.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var r;if(Tf()||ki()&&(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)}}}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Pt.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(sa)?this.client.auth.authKeys.get(sa):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===ht.link_mode?Rs:Gi});try{hc(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:vi(i)})):ta(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(Or.expired,async e=>{const{topic:r,id:i}=Gd(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Z("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Z("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(yn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(yn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!mt(e,!1)){const{message:r}=Z("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}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Ki(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=Z("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!mt(e,!1)){const{message:r}=Z("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}=Z("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Ki(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=Z("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=Z("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}=Z("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=Z("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!t5(e)){const{message:r}=Z("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=Z("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Ki(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=Z("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class fx extends _n{constructor(e,r){super(e,r,V_,mc),this.core=e,this.logger=r}}class cp extends _n{constructor(e,r){super(e,r,W_,mc),this.core=e,this.logger=r}}class cx extends _n{constructor(e,r){super(e,r,J_,mc,i=>i.id),this.core=e,this.logger=r}}class hx extends _n{constructor(e,r){super(e,r,Q_,na,()=>sa),this.core=e,this.logger=r}}class ux extends _n{constructor(e,r){super(e,r,ex,na),this.core=e,this.logger=r}}class dx extends _n{constructor(e,r){super(e,r,tx,na,i=>i.id),this.core=e,this.logger=r}}class lx{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new hx(this.core,this.logger),this.pairingTopics=new ux(this.core,this.logger),this.requests=new dx(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class xc extends Ag{constructor(e){super(e),this.protocol=ip,this.version=np,this.name=wc.name,this.events=new jt.exports.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||wc.name,this.metadata=e?.metadata||jd(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ai(Aa({level:e?.logger||wc.logger}));this.core=e?.core||new yc(e),this.logger=Jt(r,this.name),this.session=new cp(this.core,this.logger),this.proposal=new fx(this.core,this.logger),this.pendingRequest=new cx(this.core,this.logger),this.engine=new ax(this),this.auth=new lx(this.core,this.logger)}static async init(e){const r=new xc(e);return await r.initialize(),r}get context(){return tr(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()},Y.toMiliseconds(Y.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const px=cp,gx=xc;class bx extends jt.exports{constructor(){super()}}class hp{constructor(e){this.opts=e}}class up{constructor(e){this.client=e}}var vx=Object.defineProperty,yx=Object.defineProperties,mx=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,wx=Object.prototype.hasOwnProperty,_x=Object.prototype.propertyIsEnumerable,lp=(t,e,r)=>e in t?vx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xx=(t,e)=>{for(var r in e||(e={}))wx.call(e,r)&&lp(t,r,e[r]);if(dp)for(var r of dp(e))_x.call(e,r)&&lp(t,r,e[r]);return t},Ex=(t,e)=>yx(t,mx(e));class Sx extends up{constructor(e){super(e),this.init=async()=>{this.signClient=await gx.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(Ex(xx({},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 Mx={decryptMessage:async t=>{const e={core:new yc({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 yc({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new px(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}},pp=class extends hp{constructor(t){super(t),this.events=new jt.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 Sx(this)}static async init(t){const e=new pp(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 Ec=pp;Ec.notifications=Mx;const Ix=Ec;kt.CLIENT_CONTEXT=da,kt.CLIENT_STORAGE_OPTIONS=Np,kt.CLIENT_STORAGE_PREFIX=$p,kt.IWalletKit=hp,kt.IWalletKitEngine=up,kt.IWalletKitEvents=bx,kt.PROTOCOL=Tc,kt.PROTOCOL_VERSION=Rp,kt.REQUEST_CONTEXT=Fp,kt.WalletKit=Ix,kt.default=Ec,Object.defineProperty(kt,"__esModule",{value:!0})});
|
44
44
|
//# sourceMappingURL=index.umd.js.map
|