@dcl/vesting-dashboard 3.0.5 → 3.0.6-9213391407.commit-101c1e4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +0,0 @@
1
- import{p as ei,g as Ll,c as e6,r as r6,a as Ie,B as fa,e as Di,b as ql,s as i6,d as Xi,W as jl,f as dd,_ as n6}from"./index-92525cc1.js";import{t as s6}from"./tslib.es6-c2094241.js";var pd=globalThis&&globalThis.__spreadArray||function(r,t,e){if(e||arguments.length===2)for(var n=0,s=t.length,a;n<s;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return r.concat(a||Array.prototype.slice.call(t))},o6=function(){function r(t,e,n){this.name=t,this.version=e,this.os=n,this.type="browser"}return r}(),a6=function(){function r(t){this.version=t,this.type="node",this.name="node",this.os=ei.platform}return r}(),u6=function(){function r(t,e,n,s){this.name=t,this.version=e,this.os=n,this.bot=s,this.type="bot-device"}return r}(),c6=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),h6=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),l6=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,f6=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,gd=3,d6=[["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",l6]],md=[["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 p6(r){return r?vd(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new h6:typeof navigator<"u"?vd(navigator.userAgent):v6()}function g6(r){return r!==""&&d6.reduce(function(t,e){var n=e[0],s=e[1];if(t)return t;var a=s.exec(r);return!!a&&[n,a]},!1)}function vd(r){var t=g6(r);if(!t)return null;var e=t[0],n=t[1];if(e==="searchbot")return new c6;var s=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);s?s.length<gd&&(s=pd(pd([],s,!0),y6(gd-s.length),!0)):s=[];var a=s.join("."),c=m6(r),l=f6.exec(r);return l&&l[1]?new u6(e,a,c,l[1]):new o6(e,a,c)}function m6(r){for(var t=0,e=md.length;t<e;t++){var n=md[t],s=n[0],a=n[1],c=a.exec(r);if(c)return s}return null}function v6(){var r=typeof ei<"u"&&ei.version;return r?new a6(ei.version.slice(1)):null}function y6(r){for(var t=[],e=0;e<r;e++)t.push("0");return t}var bt={};const Mn=Ll(s6);var Ph={},zo={},yd;function w6(){if(yd)return zo;yd=1,Object.defineProperty(zo,"__esModule",{value:!0}),zo.delay=void 0;function r(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}return zo.delay=r,zo}var ws={},Oh={},bs={},wd;function b6(){return wd||(wd=1,Object.defineProperty(bs,"__esModule",{value:!0}),bs.ONE_THOUSAND=bs.ONE_HUNDRED=void 0,bs.ONE_HUNDRED=100,bs.ONE_THOUSAND=1e3),bs}var Nh={},bd;function _6(){return bd||(bd=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}(Nh)),Nh}var _d;function x1(){return _d||(_d=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;t.__exportStar(b6(),r),t.__exportStar(_6(),r)}(Oh)),Oh}var Ed;function E6(){if(Ed)return ws;Ed=1,Object.defineProperty(ws,"__esModule",{value:!0}),ws.fromMiliseconds=ws.toMiliseconds=void 0;const r=x1();function t(n){return n*r.ONE_THOUSAND}ws.toMiliseconds=t;function e(n){return Math.floor(n/r.ONE_THOUSAND)}return ws.fromMiliseconds=e,ws}var Ad;function A6(){return Ad||(Ad=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;t.__exportStar(w6(),r),t.__exportStar(E6(),r)}(Ph)),Ph}var Js={},Sd;function S6(){if(Sd)return Js;Sd=1,Object.defineProperty(Js,"__esModule",{value:!0}),Js.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const n=this.get(e);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const s=Date.now()-n.started;this.timestamps.set(e,{started:n.started,elapsed:s})}get(e){const n=this.timestamps.get(e);if(typeof n>"u")throw new Error(`No timestamp found for label: ${e}`);return n}elapsed(e){const n=this.get(e);return n.elapsed||Date.now()-n.started}}return Js.Watch=r,Js.default=r,Js}var Rh={},ko={},Id;function I6(){if(Id)return ko;Id=1,Object.defineProperty(ko,"__esModule",{value:!0}),ko.IWatch=void 0;class r{}return ko.IWatch=r,ko}var Dd;function D6(){return Dd||(Dd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Mn.__exportStar(I6(),r)}(Rh)),Rh}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;t.__exportStar(A6(),r),t.__exportStar(S6(),r),t.__exportStar(D6(),r),t.__exportStar(x1(),r)})(bt);var je={};Object.defineProperty(je,"__esModule",{value:!0});je.getLocalStorage=je.getLocalStorageOrThrow=je.getCrypto=je.getCryptoOrThrow=M1=je.getLocation=je.getLocationOrThrow=zl=je.getNavigator=je.getNavigatorOrThrow=$l=je.getDocument=je.getDocumentOrThrow=je.getFromWindowOrThrow=je.getFromWindow=void 0;function Ms(r){let t;return typeof window<"u"&&typeof window[r]<"u"&&(t=window[r]),t}je.getFromWindow=Ms;function fo(r){const t=Ms(r);if(!t)throw new Error(`${r} is not defined in Window`);return t}je.getFromWindowOrThrow=fo;function x6(){return fo("document")}je.getDocumentOrThrow=x6;function M6(){return Ms("document")}var $l=je.getDocument=M6;function C6(){return fo("navigator")}je.getNavigatorOrThrow=C6;function P6(){return Ms("navigator")}var zl=je.getNavigator=P6;function O6(){return fo("location")}je.getLocationOrThrow=O6;function N6(){return Ms("location")}var M1=je.getLocation=N6;function R6(){return fo("crypto")}je.getCryptoOrThrow=R6;function T6(){return Ms("crypto")}je.getCrypto=T6;function F6(){return fo("localStorage")}je.getLocalStorageOrThrow=F6;function U6(){return Ms("localStorage")}je.getLocalStorage=U6;var kl={};Object.defineProperty(kl,"__esModule",{value:!0});var C1=kl.getWindowMetadata=void 0;const xd=je;function B6(){let r,t;try{r=xd.getDocumentOrThrow(),t=xd.getLocationOrThrow()}catch{return null}function e(){const E=r.getElementsByTagName("link"),x=[];for(let I=0;I<E.length;I++){const R=E[I],Y=R.getAttribute("rel");if(Y&&Y.toLowerCase().indexOf("icon")>-1){const W=R.getAttribute("href");if(W)if(W.toLowerCase().indexOf("https:")===-1&&W.toLowerCase().indexOf("http:")===-1&&W.indexOf("//")!==0){let tt=t.protocol+"//"+t.host;if(W.indexOf("/")===0)tt+=W;else{const K=t.pathname.split("/");K.pop();const V=K.join("/");tt+=V+"/"+W}x.push(tt)}else if(W.indexOf("//")===0){const tt=t.protocol+W;x.push(tt)}else x.push(W)}}return x}function n(...E){const x=r.getElementsByTagName("meta");for(let I=0;I<x.length;I++){const R=x[I],Y=["itemprop","property","name"].map(W=>R.getAttribute(W)).filter(W=>W?E.includes(W):!1);if(Y.length&&Y){const W=R.getAttribute("content");if(W)return W}}return""}function s(){let E=n("name","og:site_name","og:title","twitter:title");return E||(E=r.title),E}function a(){return n("description","og:description","twitter:description","keywords")}const c=s(),l=a(),d=t.origin,f=e();return{description:l,url:d,icons:f,name:c}}C1=kl.getWindowMetadata=B6;var na={},L6=r=>encodeURIComponent(r).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),P1="%[a-f0-9]{2}",Md=new RegExp("("+P1+")|([^%]+?)","gi"),Cd=new RegExp("("+P1+")+","gi");function dl(r,t){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;t=t||1;var e=r.slice(0,t),n=r.slice(t);return Array.prototype.concat.call([],dl(e),dl(n))}function q6(r){try{return decodeURIComponent(r)}catch{for(var t=r.match(Md)||[],e=1;e<t.length;e++)r=dl(t,e).join(""),t=r.match(Md)||[];return r}}function j6(r){for(var t={"%FE%FF":"��","%FF%FE":"��"},e=Cd.exec(r);e;){try{t[e[0]]=decodeURIComponent(e[0])}catch{var n=q6(e[0]);n!==e[0]&&(t[e[0]]=n)}e=Cd.exec(r)}t["%C2"]="�";for(var s=Object.keys(t),a=0;a<s.length;a++){var c=s[a];r=r.replace(new RegExp(c,"g"),t[c])}return r}var $6=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 j6(r)}},z6=(r,t)=>{if(!(typeof r=="string"&&typeof t=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(t==="")return[r];const e=r.indexOf(t);return e===-1?[r]:[r.slice(0,e),r.slice(e+t.length)]},k6=function(r,t){for(var e={},n=Object.keys(r),s=Array.isArray(t),a=0;a<n.length;a++){var c=n[a],l=r[c];(s?t.indexOf(c)!==-1:t(c,l,r))&&(e[c]=l)}return e};(function(r){const t=L6,e=$6,n=z6,s=k6,a=K=>K==null,c=Symbol("encodeFragmentIdentifier");function l(K){switch(K.arrayFormat){case"index":return V=>(B,z)=>{const $=B.length;return z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,[w(V,K),"[",$,"]"].join("")]:[...B,[w(V,K),"[",w($,K),"]=",w(z,K)].join("")]};case"bracket":return V=>(B,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,[w(V,K),"[]"].join("")]:[...B,[w(V,K),"[]=",w(z,K)].join("")];case"colon-list-separator":return V=>(B,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,[w(V,K),":list="].join("")]:[...B,[w(V,K),":list=",w(z,K)].join("")];case"comma":case"separator":case"bracket-separator":{const V=K.arrayFormat==="bracket-separator"?"[]=":"=";return B=>(z,$)=>$===void 0||K.skipNull&&$===null||K.skipEmptyString&&$===""?z:($=$===null?"":$,z.length===0?[[w(B,K),V,w($,K)].join("")]:[[z,w($,K)].join(K.arrayFormatSeparator)])}default:return V=>(B,z)=>z===void 0||K.skipNull&&z===null||K.skipEmptyString&&z===""?B:z===null?[...B,w(V,K)]:[...B,[w(V,K),"=",w(z,K)].join("")]}}function d(K){let V;switch(K.arrayFormat){case"index":return(B,z,$)=>{if(V=/\[(\d*)\]$/.exec(B),B=B.replace(/\[\d*\]$/,""),!V){$[B]=z;return}$[B]===void 0&&($[B]={}),$[B][V[1]]=z};case"bracket":return(B,z,$)=>{if(V=/(\[\])$/.exec(B),B=B.replace(/\[\]$/,""),!V){$[B]=z;return}if($[B]===void 0){$[B]=[z];return}$[B]=[].concat($[B],z)};case"colon-list-separator":return(B,z,$)=>{if(V=/(:list)$/.exec(B),B=B.replace(/:list$/,""),!V){$[B]=z;return}if($[B]===void 0){$[B]=[z];return}$[B]=[].concat($[B],z)};case"comma":case"separator":return(B,z,$)=>{const v=typeof z=="string"&&z.includes(K.arrayFormatSeparator),T=typeof z=="string"&&!v&&E(z,K).includes(K.arrayFormatSeparator);z=T?E(z,K):z;const st=v||T?z.split(K.arrayFormatSeparator).map(ft=>E(ft,K)):z===null?z:E(z,K);$[B]=st};case"bracket-separator":return(B,z,$)=>{const v=/(\[\])$/.test(B);if(B=B.replace(/\[\]$/,""),!v){$[B]=z&&E(z,K);return}const T=z===null?[]:z.split(K.arrayFormatSeparator).map(st=>E(st,K));if($[B]===void 0){$[B]=T;return}$[B]=[].concat($[B],T)};default:return(B,z,$)=>{if($[B]===void 0){$[B]=z;return}$[B]=[].concat($[B],z)}}}function f(K){if(typeof K!="string"||K.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function w(K,V){return V.encode?V.strict?t(K):encodeURIComponent(K):K}function E(K,V){return V.decode?e(K):K}function x(K){return Array.isArray(K)?K.sort():typeof K=="object"?x(Object.keys(K)).sort((V,B)=>Number(V)-Number(B)).map(V=>K[V]):K}function I(K){const V=K.indexOf("#");return V!==-1&&(K=K.slice(0,V)),K}function R(K){let V="";const B=K.indexOf("#");return B!==-1&&(V=K.slice(B)),V}function Y(K){K=I(K);const V=K.indexOf("?");return V===-1?"":K.slice(V+1)}function W(K,V){return V.parseNumbers&&!Number.isNaN(Number(K))&&typeof K=="string"&&K.trim()!==""?K=Number(K):V.parseBooleans&&K!==null&&(K.toLowerCase()==="true"||K.toLowerCase()==="false")&&(K=K.toLowerCase()==="true"),K}function tt(K,V){V=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},V),f(V.arrayFormatSeparator);const B=d(V),z=Object.create(null);if(typeof K!="string"||(K=K.trim().replace(/^[?#&]/,""),!K))return z;for(const $ of K.split("&")){if($==="")continue;let[v,T]=n(V.decode?$.replace(/\+/g," "):$,"=");T=T===void 0?null:["comma","separator","bracket-separator"].includes(V.arrayFormat)?T:E(T,V),B(E(v,V),T,z)}for(const $ of Object.keys(z)){const v=z[$];if(typeof v=="object"&&v!==null)for(const T of Object.keys(v))v[T]=W(v[T],V);else z[$]=W(v,V)}return V.sort===!1?z:(V.sort===!0?Object.keys(z).sort():Object.keys(z).sort(V.sort)).reduce(($,v)=>{const T=z[v];return T&&typeof T=="object"&&!Array.isArray(T)?$[v]=x(T):$[v]=T,$},Object.create(null))}r.extract=Y,r.parse=tt,r.stringify=(K,V)=>{if(!K)return"";V=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},V),f(V.arrayFormatSeparator);const B=T=>V.skipNull&&a(K[T])||V.skipEmptyString&&K[T]==="",z=l(V),$={};for(const T of Object.keys(K))B(T)||($[T]=K[T]);const v=Object.keys($);return V.sort!==!1&&v.sort(V.sort),v.map(T=>{const st=K[T];return st===void 0?"":st===null?w(T,V):Array.isArray(st)?st.length===0&&V.arrayFormat==="bracket-separator"?w(T,V)+"[]":st.reduce(z(T),[]).join("&"):w(T,V)+"="+w(st,V)}).filter(T=>T.length>0).join("&")},r.parseUrl=(K,V)=>{V=Object.assign({decode:!0},V);const[B,z]=n(K,"#");return Object.assign({url:B.split("?")[0]||"",query:tt(Y(K),V)},V&&V.parseFragmentIdentifier&&z?{fragmentIdentifier:E(z,V)}:{})},r.stringifyUrl=(K,V)=>{V=Object.assign({encode:!0,strict:!0,[c]:!0},V);const B=I(K.url).split("?")[0]||"",z=r.extract(K.url),$=r.parse(z,{sort:!1}),v=Object.assign($,K.query);let T=r.stringify(v,V);T&&(T=`?${T}`);let st=R(K.url);return K.fragmentIdentifier&&(st=`#${V[c]?w(K.fragmentIdentifier,V):K.fragmentIdentifier}`),`${B}${T}${st}`},r.pick=(K,V,B)=>{B=Object.assign({parseFragmentIdentifier:!0,[c]:!1},B);const{url:z,query:$,fragmentIdentifier:v}=r.parseUrl(K,B);return r.stringifyUrl({url:z,query:s($,V),fragmentIdentifier:v},B)},r.exclude=(K,V,B)=>{const z=Array.isArray(V)?$=>!V.includes($):($,v)=>!V($,v);return r.pick(K,z,B)}})(na);var Hl={},ac={},oe={},O1={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function t(l,d){var f=l>>>16&65535,w=l&65535,E=d>>>16&65535,x=d&65535;return w*x+(f*x+w*E<<16>>>0)|0}r.mul=Math.imul||t;function e(l,d){return l+d|0}r.add=e;function n(l,d){return l-d|0}r.sub=n;function s(l,d){return l<<d|l>>>32-d}r.rotl=s;function a(l,d){return l<<32-d|l>>>d}r.rotr=a;function c(l){return typeof l=="number"&&isFinite(l)&&Math.floor(l)===l}r.isInteger=Number.isInteger||c,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(l){return r.isInteger(l)&&l>=-r.MAX_SAFE_INTEGER&&l<=r.MAX_SAFE_INTEGER}})(O1);Object.defineProperty(oe,"__esModule",{value:!0});var N1=O1;function H6(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])<<16>>16}oe.readInt16BE=H6;function K6(r,t){return t===void 0&&(t=0),(r[t+0]<<8|r[t+1])>>>0}oe.readUint16BE=K6;function V6(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])<<16>>16}oe.readInt16LE=V6;function G6(r,t){return t===void 0&&(t=0),(r[t+1]<<8|r[t])>>>0}oe.readUint16LE=G6;function R1(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>8,t[e+1]=r>>>0,t}oe.writeUint16BE=R1;oe.writeInt16BE=R1;function T1(r,t,e){return t===void 0&&(t=new Uint8Array(2)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t}oe.writeUint16LE=T1;oe.writeInt16LE=T1;function pl(r,t){return t===void 0&&(t=0),r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]}oe.readInt32BE=pl;function gl(r,t){return t===void 0&&(t=0),(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}oe.readUint32BE=gl;function ml(r,t){return t===void 0&&(t=0),r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t]}oe.readInt32LE=ml;function vl(r,t){return t===void 0&&(t=0),(r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t])>>>0}oe.readUint32LE=vl;function Gu(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r>>>0,t}oe.writeUint32BE=Gu;oe.writeInt32BE=Gu;function Wu(r,t,e){return t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0),t[e+0]=r>>>0,t[e+1]=r>>>8,t[e+2]=r>>>16,t[e+3]=r>>>24,t}oe.writeUint32LE=Wu;oe.writeInt32LE=Wu;function W6(r,t){t===void 0&&(t=0);var e=pl(r,t),n=pl(r,t+4);return e*4294967296+n-(n>>31)*4294967296}oe.readInt64BE=W6;function Y6(r,t){t===void 0&&(t=0);var e=gl(r,t),n=gl(r,t+4);return e*4294967296+n}oe.readUint64BE=Y6;function Q6(r,t){t===void 0&&(t=0);var e=ml(r,t),n=ml(r,t+4);return n*4294967296+e-(e>>31)*4294967296}oe.readInt64LE=Q6;function J6(r,t){t===void 0&&(t=0);var e=vl(r,t),n=vl(r,t+4);return n*4294967296+e}oe.readUint64LE=J6;function F1(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),Gu(r/4294967296>>>0,t,e),Gu(r>>>0,t,e+4),t}oe.writeUint64BE=F1;oe.writeInt64BE=F1;function U1(r,t,e){return t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0),Wu(r>>>0,t,e),Wu(r/4294967296>>>0,t,e+4),t}oe.writeUint64LE=U1;oe.writeInt64LE=U1;function X6(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,s=1,a=r/8+e-1;a>=e;a--)n+=t[a]*s,s*=256;return n}oe.readUintBE=X6;function Z6(r,t,e){if(e===void 0&&(e=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>t.length-e)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,s=1,a=e;a<e+r/8;a++)n+=t[a]*s,s*=256;return n}oe.readUintLE=Z6;function t_(r,t,e,n){if(e===void 0&&(e=new Uint8Array(r/8)),n===void 0&&(n=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!N1.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var s=1,a=r/8+n-1;a>=n;a--)e[a]=t/s&255,s*=256;return e}oe.writeUintBE=t_;function e_(r,t,e,n){if(e===void 0&&(e=new Uint8Array(r/8)),n===void 0&&(n=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!N1.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var s=1,a=n;a<n+r/8;a++)e[a]=t/s&255,s*=256;return e}oe.writeUintLE=e_;function r_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat32(t)}oe.readFloat32BE=r_;function i_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat32(t,!0)}oe.readFloat32LE=i_;function n_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat64(t)}oe.readFloat64BE=n_;function s_(r,t){t===void 0&&(t=0);var e=new DataView(r.buffer,r.byteOffset,r.byteLength);return e.getFloat64(t,!0)}oe.readFloat64LE=s_;function o_(r,t,e){t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat32(e,r),t}oe.writeFloat32BE=o_;function a_(r,t,e){t===void 0&&(t=new Uint8Array(4)),e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat32(e,r,!0),t}oe.writeFloat32LE=a_;function u_(r,t,e){t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat64(e,r),t}oe.writeFloat64BE=u_;function c_(r,t,e){t===void 0&&(t=new Uint8Array(8)),e===void 0&&(e=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat64(e,r,!0),t}oe.writeFloat64LE=c_;var ni={};Object.defineProperty(ni,"__esModule",{value:!0});function h_(r){for(var t=0;t<r.length;t++)r[t]=0;return r}ni.wipe=h_;Object.defineProperty(ac,"__esModule",{value:!0});var wr=oe,yl=ni,l_=20;function f_(r,t,e){for(var n=1634760805,s=857760878,a=2036477234,c=1797285236,l=e[3]<<24|e[2]<<16|e[1]<<8|e[0],d=e[7]<<24|e[6]<<16|e[5]<<8|e[4],f=e[11]<<24|e[10]<<16|e[9]<<8|e[8],w=e[15]<<24|e[14]<<16|e[13]<<8|e[12],E=e[19]<<24|e[18]<<16|e[17]<<8|e[16],x=e[23]<<24|e[22]<<16|e[21]<<8|e[20],I=e[27]<<24|e[26]<<16|e[25]<<8|e[24],R=e[31]<<24|e[30]<<16|e[29]<<8|e[28],Y=t[3]<<24|t[2]<<16|t[1]<<8|t[0],W=t[7]<<24|t[6]<<16|t[5]<<8|t[4],tt=t[11]<<24|t[10]<<16|t[9]<<8|t[8],K=t[15]<<24|t[14]<<16|t[13]<<8|t[12],V=n,B=s,z=a,$=c,v=l,T=d,st=f,ft=w,pt=E,gt=x,h=I,y=R,b=Y,C=W,M=tt,N=K,q=0;q<l_;q+=2)V=V+v|0,b^=V,b=b>>>32-16|b<<16,pt=pt+b|0,v^=pt,v=v>>>32-12|v<<12,B=B+T|0,C^=B,C=C>>>32-16|C<<16,gt=gt+C|0,T^=gt,T=T>>>32-12|T<<12,z=z+st|0,M^=z,M=M>>>32-16|M<<16,h=h+M|0,st^=h,st=st>>>32-12|st<<12,$=$+ft|0,N^=$,N=N>>>32-16|N<<16,y=y+N|0,ft^=y,ft=ft>>>32-12|ft<<12,z=z+st|0,M^=z,M=M>>>32-8|M<<8,h=h+M|0,st^=h,st=st>>>32-7|st<<7,$=$+ft|0,N^=$,N=N>>>32-8|N<<8,y=y+N|0,ft^=y,ft=ft>>>32-7|ft<<7,B=B+T|0,C^=B,C=C>>>32-8|C<<8,gt=gt+C|0,T^=gt,T=T>>>32-7|T<<7,V=V+v|0,b^=V,b=b>>>32-8|b<<8,pt=pt+b|0,v^=pt,v=v>>>32-7|v<<7,V=V+T|0,N^=V,N=N>>>32-16|N<<16,h=h+N|0,T^=h,T=T>>>32-12|T<<12,B=B+st|0,b^=B,b=b>>>32-16|b<<16,y=y+b|0,st^=y,st=st>>>32-12|st<<12,z=z+ft|0,C^=z,C=C>>>32-16|C<<16,pt=pt+C|0,ft^=pt,ft=ft>>>32-12|ft<<12,$=$+v|0,M^=$,M=M>>>32-16|M<<16,gt=gt+M|0,v^=gt,v=v>>>32-12|v<<12,z=z+ft|0,C^=z,C=C>>>32-8|C<<8,pt=pt+C|0,ft^=pt,ft=ft>>>32-7|ft<<7,$=$+v|0,M^=$,M=M>>>32-8|M<<8,gt=gt+M|0,v^=gt,v=v>>>32-7|v<<7,B=B+st|0,b^=B,b=b>>>32-8|b<<8,y=y+b|0,st^=y,st=st>>>32-7|st<<7,V=V+T|0,N^=V,N=N>>>32-8|N<<8,h=h+N|0,T^=h,T=T>>>32-7|T<<7;wr.writeUint32LE(V+n|0,r,0),wr.writeUint32LE(B+s|0,r,4),wr.writeUint32LE(z+a|0,r,8),wr.writeUint32LE($+c|0,r,12),wr.writeUint32LE(v+l|0,r,16),wr.writeUint32LE(T+d|0,r,20),wr.writeUint32LE(st+f|0,r,24),wr.writeUint32LE(ft+w|0,r,28),wr.writeUint32LE(pt+E|0,r,32),wr.writeUint32LE(gt+x|0,r,36),wr.writeUint32LE(h+I|0,r,40),wr.writeUint32LE(y+R|0,r,44),wr.writeUint32LE(b+Y|0,r,48),wr.writeUint32LE(C+W|0,r,52),wr.writeUint32LE(M+tt|0,r,56),wr.writeUint32LE(N+K|0,r,60)}function B1(r,t,e,n,s){if(s===void 0&&(s=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<e.length)throw new Error("ChaCha: destination is shorter than source");var a,c;if(s===0){if(t.length!==8&&t.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");a=new Uint8Array(16),c=a.length-t.length,a.set(t,c)}else{if(t.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");a=t,c=s}for(var l=new Uint8Array(64),d=0;d<e.length;d+=64){f_(l,a,r);for(var f=d;f<d+64&&f<e.length;f++)n[f]=e[f]^l[f-d];p_(a,0,c)}return yl.wipe(l),s===0&&yl.wipe(a),n}ac.streamXOR=B1;function d_(r,t,e,n){return n===void 0&&(n=0),yl.wipe(e),B1(r,t,e,e,n)}ac.stream=d_;function p_(r,t,e){for(var n=1;e--;)n=n+(r[t]&255)|0,r[t]=n&255,n>>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}var L1={},Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});function g_(r,t,e){return~(r-1)&t|r-1&e}Jn.select=g_;function m_(r,t){return(r|0)-(t|0)-1>>>31&1}Jn.lessOrEqual=m_;function q1(r,t){if(r.length!==t.length)return 0;for(var e=0,n=0;n<r.length;n++)e|=r[n]^t[n];return 1&e-1>>>8}Jn.compare=q1;function v_(r,t){return r.length===0||t.length===0?!1:q1(r,t)!==0}Jn.equal=v_;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=Jn,e=ni;r.DIGEST_LENGTH=16;var n=function(){function c(l){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 d=l[0]|l[1]<<8;this._r[0]=d&8191;var f=l[2]|l[3]<<8;this._r[1]=(d>>>13|f<<3)&8191;var w=l[4]|l[5]<<8;this._r[2]=(f>>>10|w<<6)&7939;var E=l[6]|l[7]<<8;this._r[3]=(w>>>7|E<<9)&8191;var x=l[8]|l[9]<<8;this._r[4]=(E>>>4|x<<12)&255,this._r[5]=x>>>1&8190;var I=l[10]|l[11]<<8;this._r[6]=(x>>>14|I<<2)&8191;var R=l[12]|l[13]<<8;this._r[7]=(I>>>11|R<<5)&8065;var Y=l[14]|l[15]<<8;this._r[8]=(R>>>8|Y<<8)&8191,this._r[9]=Y>>>5&127,this._pad[0]=l[16]|l[17]<<8,this._pad[1]=l[18]|l[19]<<8,this._pad[2]=l[20]|l[21]<<8,this._pad[3]=l[22]|l[23]<<8,this._pad[4]=l[24]|l[25]<<8,this._pad[5]=l[26]|l[27]<<8,this._pad[6]=l[28]|l[29]<<8,this._pad[7]=l[30]|l[31]<<8}return c.prototype._blocks=function(l,d,f){for(var w=this._fin?0:2048,E=this._h[0],x=this._h[1],I=this._h[2],R=this._h[3],Y=this._h[4],W=this._h[5],tt=this._h[6],K=this._h[7],V=this._h[8],B=this._h[9],z=this._r[0],$=this._r[1],v=this._r[2],T=this._r[3],st=this._r[4],ft=this._r[5],pt=this._r[6],gt=this._r[7],h=this._r[8],y=this._r[9];f>=16;){var b=l[d+0]|l[d+1]<<8;E+=b&8191;var C=l[d+2]|l[d+3]<<8;x+=(b>>>13|C<<3)&8191;var M=l[d+4]|l[d+5]<<8;I+=(C>>>10|M<<6)&8191;var N=l[d+6]|l[d+7]<<8;R+=(M>>>7|N<<9)&8191;var q=l[d+8]|l[d+9]<<8;Y+=(N>>>4|q<<12)&8191,W+=q>>>1&8191;var S=l[d+10]|l[d+11]<<8;tt+=(q>>>14|S<<2)&8191;var g=l[d+12]|l[d+13]<<8;K+=(S>>>11|g<<5)&8191;var O=l[d+14]|l[d+15]<<8;V+=(g>>>8|O<<8)&8191,B+=O>>>5|w;var it=0,lt=it;lt+=E*z,lt+=x*(5*y),lt+=I*(5*h),lt+=R*(5*gt),lt+=Y*(5*pt),it=lt>>>13,lt&=8191,lt+=W*(5*ft),lt+=tt*(5*st),lt+=K*(5*T),lt+=V*(5*v),lt+=B*(5*$),it+=lt>>>13,lt&=8191;var _=it;_+=E*$,_+=x*z,_+=I*(5*y),_+=R*(5*h),_+=Y*(5*gt),it=_>>>13,_&=8191,_+=W*(5*pt),_+=tt*(5*ft),_+=K*(5*st),_+=V*(5*T),_+=B*(5*v),it+=_>>>13,_&=8191;var Z=it;Z+=E*v,Z+=x*$,Z+=I*z,Z+=R*(5*y),Z+=Y*(5*h),it=Z>>>13,Z&=8191,Z+=W*(5*gt),Z+=tt*(5*pt),Z+=K*(5*ft),Z+=V*(5*st),Z+=B*(5*T),it+=Z>>>13,Z&=8191;var U=it;U+=E*T,U+=x*v,U+=I*$,U+=R*z,U+=Y*(5*y),it=U>>>13,U&=8191,U+=W*(5*h),U+=tt*(5*gt),U+=K*(5*pt),U+=V*(5*ft),U+=B*(5*st),it+=U>>>13,U&=8191;var L=it;L+=E*st,L+=x*T,L+=I*v,L+=R*$,L+=Y*z,it=L>>>13,L&=8191,L+=W*(5*y),L+=tt*(5*h),L+=K*(5*gt),L+=V*(5*pt),L+=B*(5*ft),it+=L>>>13,L&=8191;var k=it;k+=E*ft,k+=x*st,k+=I*T,k+=R*v,k+=Y*$,it=k>>>13,k&=8191,k+=W*z,k+=tt*(5*y),k+=K*(5*h),k+=V*(5*gt),k+=B*(5*pt),it+=k>>>13,k&=8191;var p=it;p+=E*pt,p+=x*ft,p+=I*st,p+=R*T,p+=Y*v,it=p>>>13,p&=8191,p+=W*$,p+=tt*z,p+=K*(5*y),p+=V*(5*h),p+=B*(5*gt),it+=p>>>13,p&=8191;var F=it;F+=E*gt,F+=x*pt,F+=I*ft,F+=R*st,F+=Y*T,it=F>>>13,F&=8191,F+=W*v,F+=tt*$,F+=K*z,F+=V*(5*y),F+=B*(5*h),it+=F>>>13,F&=8191;var et=it;et+=E*h,et+=x*gt,et+=I*pt,et+=R*ft,et+=Y*st,it=et>>>13,et&=8191,et+=W*T,et+=tt*v,et+=K*$,et+=V*z,et+=B*(5*y),it+=et>>>13,et&=8191;var ct=it;ct+=E*y,ct+=x*h,ct+=I*gt,ct+=R*pt,ct+=Y*ft,it=ct>>>13,ct&=8191,ct+=W*st,ct+=tt*T,ct+=K*v,ct+=V*$,ct+=B*z,it+=ct>>>13,ct&=8191,it=(it<<2)+it|0,it=it+lt|0,lt=it&8191,it=it>>>13,_+=it,E=lt,x=_,I=Z,R=U,Y=L,W=k,tt=p,K=F,V=et,B=ct,d+=16,f-=16}this._h[0]=E,this._h[1]=x,this._h[2]=I,this._h[3]=R,this._h[4]=Y,this._h[5]=W,this._h[6]=tt,this._h[7]=K,this._h[8]=V,this._h[9]=B},c.prototype.finish=function(l,d){d===void 0&&(d=0);var f=new Uint16Array(10),w,E,x,I;if(this._leftover){for(I=this._leftover,this._buffer[I++]=1;I<16;I++)this._buffer[I]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(w=this._h[1]>>>13,this._h[1]&=8191,I=2;I<10;I++)this._h[I]+=w,w=this._h[I]>>>13,this._h[I]&=8191;for(this._h[0]+=w*5,w=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=w,w=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=w,f[0]=this._h[0]+5,w=f[0]>>>13,f[0]&=8191,I=1;I<10;I++)f[I]=this._h[I]+w,w=f[I]>>>13,f[I]&=8191;for(f[9]-=8192,E=(w^1)-1,I=0;I<10;I++)f[I]&=E;for(E=~E,I=0;I<10;I++)this._h[I]=this._h[I]&E|f[I];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,x=this._h[0]+this._pad[0],this._h[0]=x&65535,I=1;I<8;I++)x=(this._h[I]+this._pad[I]|0)+(x>>>16)|0,this._h[I]=x&65535;return l[d+0]=this._h[0]>>>0,l[d+1]=this._h[0]>>>8,l[d+2]=this._h[1]>>>0,l[d+3]=this._h[1]>>>8,l[d+4]=this._h[2]>>>0,l[d+5]=this._h[2]>>>8,l[d+6]=this._h[3]>>>0,l[d+7]=this._h[3]>>>8,l[d+8]=this._h[4]>>>0,l[d+9]=this._h[4]>>>8,l[d+10]=this._h[5]>>>0,l[d+11]=this._h[5]>>>8,l[d+12]=this._h[6]>>>0,l[d+13]=this._h[6]>>>8,l[d+14]=this._h[7]>>>0,l[d+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(l){var d=0,f=l.length,w;if(this._leftover){w=16-this._leftover,w>f&&(w=f);for(var E=0;E<w;E++)this._buffer[this._leftover+E]=l[d+E];if(f-=w,d+=w,this._leftover+=w,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(f>=16&&(w=f-f%16,this._blocks(l,d,w),d+=w,f-=w),f){for(var E=0;E<f;E++)this._buffer[this._leftover+E]=l[d+E];this._leftover+=f}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var l=new Uint8Array(16);return this.finish(l),l},c.prototype.clean=function(){return e.wipe(this._buffer),e.wipe(this._r),e.wipe(this._h),e.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},c}();r.Poly1305=n;function s(c,l){var d=new n(c);d.update(l);var f=d.digest();return d.clean(),f}r.oneTimeAuth=s;function a(c,l){return c.length!==r.DIGEST_LENGTH||l.length!==r.DIGEST_LENGTH?!1:t.equal(c,l)}r.equal=a})(L1);(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=ac,e=L1,n=ni,s=oe,a=Jn;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var c=new Uint8Array(16),l=function(){function d(f){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,f.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(f)}return d.prototype.seal=function(f,w,E,x){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var I=new Uint8Array(16);I.set(f,I.length-f.length);var R=new Uint8Array(32);t.stream(this._key,I,R,4);var Y=w.length+this.tagLength,W;if(x){if(x.length!==Y)throw new Error("ChaCha20Poly1305: incorrect destination length");W=x}else W=new Uint8Array(Y);return t.streamXOR(this._key,I,w,W,4),this._authenticate(W.subarray(W.length-this.tagLength,W.length),R,W.subarray(0,W.length-this.tagLength),E),n.wipe(I),W},d.prototype.open=function(f,w,E,x){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(w.length<this.tagLength)return null;var I=new Uint8Array(16);I.set(f,I.length-f.length);var R=new Uint8Array(32);t.stream(this._key,I,R,4);var Y=new Uint8Array(this.tagLength);if(this._authenticate(Y,R,w.subarray(0,w.length-this.tagLength),E),!a.equal(Y,w.subarray(w.length-this.tagLength,w.length)))return null;var W=w.length-this.tagLength,tt;if(x){if(x.length!==W)throw new Error("ChaCha20Poly1305: incorrect destination length");tt=x}else tt=new Uint8Array(W);return t.streamXOR(this._key,I,w.subarray(0,w.length-this.tagLength),tt,4),n.wipe(I),tt},d.prototype.clean=function(){return n.wipe(this._key),this},d.prototype._authenticate=function(f,w,E,x){var I=new e.Poly1305(w);x&&(I.update(x),x.length%16>0&&I.update(c.subarray(x.length%16))),I.update(E),E.length%16>0&&I.update(c.subarray(E.length%16));var R=new Uint8Array(8);x&&s.writeUint64LE(x.length,R),I.update(R),s.writeUint64LE(E.length,R),I.update(R);for(var Y=I.digest(),W=0;W<Y.length;W++)f[W]=Y[W];I.clean(),n.wipe(Y),n.wipe(R)},d}();r.ChaCha20Poly1305=l})(Hl);var j1={},da={},Kl={};Object.defineProperty(Kl,"__esModule",{value:!0});function y_(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}Kl.isSerializableHash=y_;Object.defineProperty(da,"__esModule",{value:!0});var Gi=Kl,w_=Jn,b_=ni,$1=function(){function r(t,e){this._finished=!1,this._inner=new t,this._outer=new t,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);e.length>this.blockSize?this._inner.update(e).finish(n).clean():n.set(e);for(var s=0;s<n.length;s++)n[s]^=54;this._inner.update(n);for(var s=0;s<n.length;s++)n[s]^=106;this._outer.update(n),Gi.isSerializableHash(this._inner)&&Gi.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),b_.wipe(n)}return r.prototype.reset=function(){if(!Gi.isSerializableHash(this._inner)||!Gi.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(){Gi.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Gi.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(t){return this._inner.update(t),this},r.prototype.finish=function(t){return this._finished?(this._outer.finish(t),this):(this._inner.finish(t),this._outer.update(t.subarray(0,this.digestLength)).finish(t),this._finished=!0,this)},r.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},r.prototype.saveState=function(){if(!Gi.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(t){if(!Gi.isSerializableHash(this._inner)||!Gi.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(t),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(t){if(!Gi.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(t)},r}();da.HMAC=$1;function __(r,t,e){var n=new $1(r,t);n.update(e);var s=n.digest();return n.clean(),s}da.hmac=__;da.equal=w_.equal;Object.defineProperty(j1,"__esModule",{value:!0});var Pd=da,Od=ni,E_=function(){function r(t,e,n,s){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=t,this._info=s;var a=Pd.hmac(this._hash,n,e);this._hmac=new Pd.HMAC(t,a),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var t=this._counter[0];if(t===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),t>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(t){for(var e=new Uint8Array(t),n=0;n<e.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),e[n]=this._buffer[this._bufpos++];return e},r.prototype.clean=function(){this._hmac.clean(),Od.wipe(this._buffer),Od.wipe(this._counter),this._bufpos=0},r}(),A_=j1.HKDF=E_,po={},uc={},cc={};Object.defineProperty(cc,"__esModule",{value:!0});cc.BrowserRandomSource=void 0;const Nd=65536;class S_{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t=typeof self<"u"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const e=new Uint8Array(t);for(let n=0;n<e.length;n+=Nd)this._crypto.getRandomValues(e.subarray(n,n+Math.min(e.length-n,Nd)));return e}}cc.BrowserRandomSource=S_;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});hc.NodeRandomSource=void 0;const I_=ni;class D_{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof e6<"u"){const t=r6();t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(t);if(e.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const n=new Uint8Array(t);for(let s=0;s<n.length;s++)n[s]=e[s];return(0,I_.wipe)(e),n}}hc.NodeRandomSource=D_;Object.defineProperty(uc,"__esModule",{value:!0});uc.SystemRandomSource=void 0;const x_=cc,M_=hc;class C_{constructor(){if(this.isAvailable=!1,this.name="",this._source=new x_.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new M_.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}uc.SystemRandomSource=C_;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const t=uc,e=oe,n=ni;r.defaultRandomSource=new t.SystemRandomSource;function s(f,w=r.defaultRandomSource){return w.randomBytes(f)}r.randomBytes=s;function a(f=r.defaultRandomSource){const w=s(4,f),E=(0,e.readUint32LE)(w);return(0,n.wipe)(w),E}r.randomUint32=a;const c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function l(f,w=c,E=r.defaultRandomSource){if(w.length<2)throw new Error("randomString charset is too short");if(w.length>256)throw new Error("randomString charset is too long");let x="";const I=w.length,R=256-256%I;for(;f>0;){const Y=s(Math.ceil(f*256/R),E);for(let W=0;W<Y.length&&f>0;W++){const tt=Y[W];tt<R&&(x+=w.charAt(tt%I),f--)}(0,n.wipe)(Y)}return x}r.randomString=l;function d(f,w=c,E=r.defaultRandomSource){const x=Math.ceil(f/(Math.log(w.length)/Math.LN2));return l(x,w,E)}r.randomStringForEntropy=d})(po);var lc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=oe,e=ni;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var n=function(){function l(){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 l.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},l.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},l.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._temp),this.reset()},l.prototype.update=function(d,f){if(f===void 0&&(f=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var w=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&f>0;)this._buffer[this._bufferLength++]=d[w++],f--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(w=a(this._temp,this._state,d,w,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=d[w++],f--;return this},l.prototype.finish=function(d){if(!this._finished){var f=this._bytesHashed,w=this._bufferLength,E=f/536870912|0,x=f<<3,I=f%64<56?64:128;this._buffer[w]=128;for(var R=w+1;R<I-8;R++)this._buffer[R]=0;t.writeUint32BE(E,this._buffer,I-8),t.writeUint32BE(x,this._buffer,I-4),a(this._temp,this._state,this._buffer,0,I),this._finished=!0}for(var R=0;R<this.digestLength/4;R++)t.writeUint32BE(this._state[R],d,R*4);return this},l.prototype.digest=function(){var d=new Uint8Array(this.digestLength);return this.finish(d),d},l.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}},l.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(d){e.wipe(d.state),d.buffer&&e.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},l}();r.SHA256=n;var s=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 a(l,d,f,w,E){for(;E>=64;){for(var x=d[0],I=d[1],R=d[2],Y=d[3],W=d[4],tt=d[5],K=d[6],V=d[7],B=0;B<16;B++){var z=w+B*4;l[B]=t.readUint32BE(f,z)}for(var B=16;B<64;B++){var $=l[B-2],v=($>>>17|$<<32-17)^($>>>19|$<<32-19)^$>>>10;$=l[B-15];var T=($>>>7|$<<32-7)^($>>>18|$<<32-18)^$>>>3;l[B]=(v+l[B-7]|0)+(T+l[B-16]|0)}for(var B=0;B<64;B++){var v=(((W>>>6|W<<26)^(W>>>11|W<<21)^(W>>>25|W<<7))+(W&tt^~W&K)|0)+(V+(s[B]+l[B]|0)|0)|0,T=((x>>>2|x<<32-2)^(x>>>13|x<<32-13)^(x>>>22|x<<32-22))+(x&I^x&R^I&R)|0;V=K,K=tt,tt=W,W=Y+v|0,Y=R,R=I,I=x,x=v+T|0}d[0]+=x,d[1]+=I,d[2]+=R,d[3]+=Y,d[4]+=W,d[5]+=tt,d[6]+=K,d[7]+=V,w+=64,E-=64}return w}function c(l){var d=new n;d.update(l);var f=d.digest();return d.clean(),f}r.hash=c})(lc);var Vl={};(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 t=po,e=ni;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function n(B){const z=new Float64Array(16);if(B)for(let $=0;$<B.length;$++)z[$]=B[$];return z}const s=new Uint8Array(32);s[0]=9;const a=n([56129,1]);function c(B){let z=1;for(let $=0;$<16;$++){let v=B[$]+z+65535;z=Math.floor(v/65536),B[$]=v-z*65536}B[0]+=z-1+37*(z-1)}function l(B,z,$){const v=~($-1);for(let T=0;T<16;T++){const st=v&(B[T]^z[T]);B[T]^=st,z[T]^=st}}function d(B,z){const $=n(),v=n();for(let T=0;T<16;T++)v[T]=z[T];c(v),c(v),c(v);for(let T=0;T<2;T++){$[0]=v[0]-65517;for(let ft=1;ft<15;ft++)$[ft]=v[ft]-65535-($[ft-1]>>16&1),$[ft-1]&=65535;$[15]=v[15]-32767-($[14]>>16&1);const st=$[15]>>16&1;$[14]&=65535,l(v,$,1-st)}for(let T=0;T<16;T++)B[2*T]=v[T]&255,B[2*T+1]=v[T]>>8}function f(B,z){for(let $=0;$<16;$++)B[$]=z[2*$]+(z[2*$+1]<<8);B[15]&=32767}function w(B,z,$){for(let v=0;v<16;v++)B[v]=z[v]+$[v]}function E(B,z,$){for(let v=0;v<16;v++)B[v]=z[v]-$[v]}function x(B,z,$){let v,T,st=0,ft=0,pt=0,gt=0,h=0,y=0,b=0,C=0,M=0,N=0,q=0,S=0,g=0,O=0,it=0,lt=0,_=0,Z=0,U=0,L=0,k=0,p=0,F=0,et=0,ct=0,at=0,Mt=0,Pt=0,It=0,Ee=0,$t=0,xt=$[0],Bt=$[1],_t=$[2],Et=$[3],Vt=$[4],yt=$[5],At=$[6],Ut=$[7],wt=$[8],Ct=$[9],Lt=$[10],Ot=$[11],Nt=$[12],se=$[13],Tt=$[14],Rt=$[15];v=z[0],st+=v*xt,ft+=v*Bt,pt+=v*_t,gt+=v*Et,h+=v*Vt,y+=v*yt,b+=v*At,C+=v*Ut,M+=v*wt,N+=v*Ct,q+=v*Lt,S+=v*Ot,g+=v*Nt,O+=v*se,it+=v*Tt,lt+=v*Rt,v=z[1],ft+=v*xt,pt+=v*Bt,gt+=v*_t,h+=v*Et,y+=v*Vt,b+=v*yt,C+=v*At,M+=v*Ut,N+=v*wt,q+=v*Ct,S+=v*Lt,g+=v*Ot,O+=v*Nt,it+=v*se,lt+=v*Tt,_+=v*Rt,v=z[2],pt+=v*xt,gt+=v*Bt,h+=v*_t,y+=v*Et,b+=v*Vt,C+=v*yt,M+=v*At,N+=v*Ut,q+=v*wt,S+=v*Ct,g+=v*Lt,O+=v*Ot,it+=v*Nt,lt+=v*se,_+=v*Tt,Z+=v*Rt,v=z[3],gt+=v*xt,h+=v*Bt,y+=v*_t,b+=v*Et,C+=v*Vt,M+=v*yt,N+=v*At,q+=v*Ut,S+=v*wt,g+=v*Ct,O+=v*Lt,it+=v*Ot,lt+=v*Nt,_+=v*se,Z+=v*Tt,U+=v*Rt,v=z[4],h+=v*xt,y+=v*Bt,b+=v*_t,C+=v*Et,M+=v*Vt,N+=v*yt,q+=v*At,S+=v*Ut,g+=v*wt,O+=v*Ct,it+=v*Lt,lt+=v*Ot,_+=v*Nt,Z+=v*se,U+=v*Tt,L+=v*Rt,v=z[5],y+=v*xt,b+=v*Bt,C+=v*_t,M+=v*Et,N+=v*Vt,q+=v*yt,S+=v*At,g+=v*Ut,O+=v*wt,it+=v*Ct,lt+=v*Lt,_+=v*Ot,Z+=v*Nt,U+=v*se,L+=v*Tt,k+=v*Rt,v=z[6],b+=v*xt,C+=v*Bt,M+=v*_t,N+=v*Et,q+=v*Vt,S+=v*yt,g+=v*At,O+=v*Ut,it+=v*wt,lt+=v*Ct,_+=v*Lt,Z+=v*Ot,U+=v*Nt,L+=v*se,k+=v*Tt,p+=v*Rt,v=z[7],C+=v*xt,M+=v*Bt,N+=v*_t,q+=v*Et,S+=v*Vt,g+=v*yt,O+=v*At,it+=v*Ut,lt+=v*wt,_+=v*Ct,Z+=v*Lt,U+=v*Ot,L+=v*Nt,k+=v*se,p+=v*Tt,F+=v*Rt,v=z[8],M+=v*xt,N+=v*Bt,q+=v*_t,S+=v*Et,g+=v*Vt,O+=v*yt,it+=v*At,lt+=v*Ut,_+=v*wt,Z+=v*Ct,U+=v*Lt,L+=v*Ot,k+=v*Nt,p+=v*se,F+=v*Tt,et+=v*Rt,v=z[9],N+=v*xt,q+=v*Bt,S+=v*_t,g+=v*Et,O+=v*Vt,it+=v*yt,lt+=v*At,_+=v*Ut,Z+=v*wt,U+=v*Ct,L+=v*Lt,k+=v*Ot,p+=v*Nt,F+=v*se,et+=v*Tt,ct+=v*Rt,v=z[10],q+=v*xt,S+=v*Bt,g+=v*_t,O+=v*Et,it+=v*Vt,lt+=v*yt,_+=v*At,Z+=v*Ut,U+=v*wt,L+=v*Ct,k+=v*Lt,p+=v*Ot,F+=v*Nt,et+=v*se,ct+=v*Tt,at+=v*Rt,v=z[11],S+=v*xt,g+=v*Bt,O+=v*_t,it+=v*Et,lt+=v*Vt,_+=v*yt,Z+=v*At,U+=v*Ut,L+=v*wt,k+=v*Ct,p+=v*Lt,F+=v*Ot,et+=v*Nt,ct+=v*se,at+=v*Tt,Mt+=v*Rt,v=z[12],g+=v*xt,O+=v*Bt,it+=v*_t,lt+=v*Et,_+=v*Vt,Z+=v*yt,U+=v*At,L+=v*Ut,k+=v*wt,p+=v*Ct,F+=v*Lt,et+=v*Ot,ct+=v*Nt,at+=v*se,Mt+=v*Tt,Pt+=v*Rt,v=z[13],O+=v*xt,it+=v*Bt,lt+=v*_t,_+=v*Et,Z+=v*Vt,U+=v*yt,L+=v*At,k+=v*Ut,p+=v*wt,F+=v*Ct,et+=v*Lt,ct+=v*Ot,at+=v*Nt,Mt+=v*se,Pt+=v*Tt,It+=v*Rt,v=z[14],it+=v*xt,lt+=v*Bt,_+=v*_t,Z+=v*Et,U+=v*Vt,L+=v*yt,k+=v*At,p+=v*Ut,F+=v*wt,et+=v*Ct,ct+=v*Lt,at+=v*Ot,Mt+=v*Nt,Pt+=v*se,It+=v*Tt,Ee+=v*Rt,v=z[15],lt+=v*xt,_+=v*Bt,Z+=v*_t,U+=v*Et,L+=v*Vt,k+=v*yt,p+=v*At,F+=v*Ut,et+=v*wt,ct+=v*Ct,at+=v*Lt,Mt+=v*Ot,Pt+=v*Nt,It+=v*se,Ee+=v*Tt,$t+=v*Rt,st+=38*_,ft+=38*Z,pt+=38*U,gt+=38*L,h+=38*k,y+=38*p,b+=38*F,C+=38*et,M+=38*ct,N+=38*at,q+=38*Mt,S+=38*Pt,g+=38*It,O+=38*Ee,it+=38*$t,T=1,v=st+T+65535,T=Math.floor(v/65536),st=v-T*65536,v=ft+T+65535,T=Math.floor(v/65536),ft=v-T*65536,v=pt+T+65535,T=Math.floor(v/65536),pt=v-T*65536,v=gt+T+65535,T=Math.floor(v/65536),gt=v-T*65536,v=h+T+65535,T=Math.floor(v/65536),h=v-T*65536,v=y+T+65535,T=Math.floor(v/65536),y=v-T*65536,v=b+T+65535,T=Math.floor(v/65536),b=v-T*65536,v=C+T+65535,T=Math.floor(v/65536),C=v-T*65536,v=M+T+65535,T=Math.floor(v/65536),M=v-T*65536,v=N+T+65535,T=Math.floor(v/65536),N=v-T*65536,v=q+T+65535,T=Math.floor(v/65536),q=v-T*65536,v=S+T+65535,T=Math.floor(v/65536),S=v-T*65536,v=g+T+65535,T=Math.floor(v/65536),g=v-T*65536,v=O+T+65535,T=Math.floor(v/65536),O=v-T*65536,v=it+T+65535,T=Math.floor(v/65536),it=v-T*65536,v=lt+T+65535,T=Math.floor(v/65536),lt=v-T*65536,st+=T-1+37*(T-1),T=1,v=st+T+65535,T=Math.floor(v/65536),st=v-T*65536,v=ft+T+65535,T=Math.floor(v/65536),ft=v-T*65536,v=pt+T+65535,T=Math.floor(v/65536),pt=v-T*65536,v=gt+T+65535,T=Math.floor(v/65536),gt=v-T*65536,v=h+T+65535,T=Math.floor(v/65536),h=v-T*65536,v=y+T+65535,T=Math.floor(v/65536),y=v-T*65536,v=b+T+65535,T=Math.floor(v/65536),b=v-T*65536,v=C+T+65535,T=Math.floor(v/65536),C=v-T*65536,v=M+T+65535,T=Math.floor(v/65536),M=v-T*65536,v=N+T+65535,T=Math.floor(v/65536),N=v-T*65536,v=q+T+65535,T=Math.floor(v/65536),q=v-T*65536,v=S+T+65535,T=Math.floor(v/65536),S=v-T*65536,v=g+T+65535,T=Math.floor(v/65536),g=v-T*65536,v=O+T+65535,T=Math.floor(v/65536),O=v-T*65536,v=it+T+65535,T=Math.floor(v/65536),it=v-T*65536,v=lt+T+65535,T=Math.floor(v/65536),lt=v-T*65536,st+=T-1+37*(T-1),B[0]=st,B[1]=ft,B[2]=pt,B[3]=gt,B[4]=h,B[5]=y,B[6]=b,B[7]=C,B[8]=M,B[9]=N,B[10]=q,B[11]=S,B[12]=g,B[13]=O,B[14]=it,B[15]=lt}function I(B,z){x(B,z,z)}function R(B,z){const $=n();for(let v=0;v<16;v++)$[v]=z[v];for(let v=253;v>=0;v--)I($,$),v!==2&&v!==4&&x($,$,z);for(let v=0;v<16;v++)B[v]=$[v]}function Y(B,z){const $=new Uint8Array(32),v=new Float64Array(80),T=n(),st=n(),ft=n(),pt=n(),gt=n(),h=n();for(let M=0;M<31;M++)$[M]=B[M];$[31]=B[31]&127|64,$[0]&=248,f(v,z);for(let M=0;M<16;M++)st[M]=v[M];T[0]=pt[0]=1;for(let M=254;M>=0;--M){const N=$[M>>>3]>>>(M&7)&1;l(T,st,N),l(ft,pt,N),w(gt,T,ft),E(T,T,ft),w(ft,st,pt),E(st,st,pt),I(pt,gt),I(h,T),x(T,ft,T),x(ft,st,gt),w(gt,T,ft),E(T,T,ft),I(st,T),E(ft,pt,h),x(T,ft,a),w(T,T,pt),x(ft,ft,T),x(T,pt,h),x(pt,st,v),I(st,gt),l(T,st,N),l(ft,pt,N)}for(let M=0;M<16;M++)v[M+16]=T[M],v[M+32]=ft[M],v[M+48]=st[M],v[M+64]=pt[M];const y=v.subarray(32),b=v.subarray(16);R(y,y),x(b,b,y);const C=new Uint8Array(32);return d(C,b),C}r.scalarMult=Y;function W(B){return Y(B,s)}r.scalarMultBase=W;function tt(B){if(B.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const z=new Uint8Array(B);return{publicKey:W(z),secretKey:z}}r.generateKeyPairFromSeed=tt;function K(B){const z=(0,t.randomBytes)(32,B),$=tt(z);return(0,e.wipe)(z),$}r.generateKeyPair=K;function V(B,z,$=!1){if(B.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(z.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const v=Y(B,z);if($){let T=0;for(let st=0;st<v.length;st++)T|=v[st];if(T===0)throw new Error("X25519: invalid shared key")}return v}r.sharedKey=V})(Vl);function Gl(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function z1(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Gl(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function wl(r,t){t||(t=r.reduce((s,a)=>s+a.length,0));const e=z1(t);let n=0;for(const s of r)e.set(s,n),n+=s.length;return Gl(e)}function P_(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),c=a.charCodeAt(0);if(e[c]!==255)throw new TypeError(a+" is ambiguous");e[c]=s}var l=r.length,d=r.charAt(0),f=Math.log(l)/Math.log(256),w=Math.log(256)/Math.log(l);function E(R){if(R instanceof Uint8Array||(ArrayBuffer.isView(R)?R=new Uint8Array(R.buffer,R.byteOffset,R.byteLength):Array.isArray(R)&&(R=Uint8Array.from(R))),!(R instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(R.length===0)return"";for(var Y=0,W=0,tt=0,K=R.length;tt!==K&&R[tt]===0;)tt++,Y++;for(var V=(K-tt)*w+1>>>0,B=new Uint8Array(V);tt!==K;){for(var z=R[tt],$=0,v=V-1;(z!==0||$<W)&&v!==-1;v--,$++)z+=256*B[v]>>>0,B[v]=z%l>>>0,z=z/l>>>0;if(z!==0)throw new Error("Non-zero carry");W=$,tt++}for(var T=V-W;T!==V&&B[T]===0;)T++;for(var st=d.repeat(Y);T<V;++T)st+=r.charAt(B[T]);return st}function x(R){if(typeof R!="string")throw new TypeError("Expected String");if(R.length===0)return new Uint8Array;var Y=0;if(R[Y]!==" "){for(var W=0,tt=0;R[Y]===d;)W++,Y++;for(var K=(R.length-Y)*f+1>>>0,V=new Uint8Array(K);R[Y];){var B=e[R.charCodeAt(Y)];if(B===255)return;for(var z=0,$=K-1;(B!==0||z<tt)&&$!==-1;$--,z++)B+=l*V[$]>>>0,V[$]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");tt=z,Y++}if(R[Y]!==" "){for(var v=K-tt;v!==K&&V[v]===0;)v++;for(var T=new Uint8Array(W+(K-v)),st=W;v!==K;)T[st++]=V[v++];return T}}}function I(R){var Y=x(R);if(Y)return Y;throw new Error(`Non-${t} character`)}return{encode:E,decodeUnsafe:x,decode:I}}var O_=P_,N_=O_;const R_=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")},T_=r=>new TextEncoder().encode(r),F_=r=>new TextDecoder().decode(r);class U_{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class B_{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return k1(this,t)}}class L_{constructor(t){this.decoders=t}or(t){return k1(this,t)}decode(t){const e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const k1=(r,t)=>new L_({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});class q_{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new U_(t,e,n),this.decoder=new B_(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const fc=({name:r,prefix:t,encode:e,decode:n})=>new q_(r,t,e,n),pa=({prefix:r,name:t,alphabet:e})=>{const{encode:n,decode:s}=N_(e,t);return fc({prefix:r,name:t,encode:n,decode:a=>R_(s(a))})},j_=(r,t,e,n)=>{const s={};for(let w=0;w<t.length;++w)s[t[w]]=w;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*e/8|0);let l=0,d=0,f=0;for(let w=0;w<a;++w){const E=s[r[w]];if(E===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<e|E,l+=e,l>=8&&(l-=8,c[f++]=255&d>>l)}if(l>=e||255&d<<8-l)throw new SyntaxError("Unexpected end of data");return c},$_=(r,t,e)=>{const n=t[t.length-1]==="=",s=(1<<e)-1;let a="",c=0,l=0;for(let d=0;d<r.length;++d)for(l=l<<8|r[d],c+=8;c>e;)c-=e,a+=t[s&l>>c];if(c&&(a+=t[s&l<<e-c]),n)for(;a.length*e&7;)a+="=";return a},gr=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>fc({prefix:t,name:r,encode(s){return $_(s,n,e)},decode(s){return j_(s,n,e,r)}}),z_=fc({prefix:"\0",name:"identity",encode:r=>F_(r),decode:r=>T_(r)}),k_=Object.freeze(Object.defineProperty({__proto__:null,identity:z_},Symbol.toStringTag,{value:"Module"})),H_=gr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),K_=Object.freeze(Object.defineProperty({__proto__:null,base2:H_},Symbol.toStringTag,{value:"Module"})),V_=gr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),G_=Object.freeze(Object.defineProperty({__proto__:null,base8:V_},Symbol.toStringTag,{value:"Module"})),W_=pa({prefix:"9",name:"base10",alphabet:"0123456789"}),Y_=Object.freeze(Object.defineProperty({__proto__:null,base10:W_},Symbol.toStringTag,{value:"Module"})),Q_=gr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),J_=gr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),X_=Object.freeze(Object.defineProperty({__proto__:null,base16:Q_,base16upper:J_},Symbol.toStringTag,{value:"Module"})),Z_=gr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tE=gr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),eE=gr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),rE=gr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),iE=gr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nE=gr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),sE=gr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oE=gr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),aE=gr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),uE=Object.freeze(Object.defineProperty({__proto__:null,base32:Z_,base32hex:iE,base32hexpad:sE,base32hexpadupper:oE,base32hexupper:nE,base32pad:eE,base32padupper:rE,base32upper:tE,base32z:aE},Symbol.toStringTag,{value:"Module"})),cE=pa({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hE=pa({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),lE=Object.freeze(Object.defineProperty({__proto__:null,base36:cE,base36upper:hE},Symbol.toStringTag,{value:"Module"})),fE=pa({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dE=pa({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),pE=Object.freeze(Object.defineProperty({__proto__:null,base58btc:fE,base58flickr:dE},Symbol.toStringTag,{value:"Module"})),gE=gr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mE=gr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vE=gr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yE=gr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),wE=Object.freeze(Object.defineProperty({__proto__:null,base64:gE,base64pad:mE,base64url:vE,base64urlpad:yE},Symbol.toStringTag,{value:"Module"})),H1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),bE=H1.reduce((r,t,e)=>(r[e]=t,r),[]),_E=H1.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function EE(r){return r.reduce((t,e)=>(t+=bE[e],t),"")}function AE(r){const t=[];for(const e of r){const n=_E[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}const SE=fc({prefix:"🚀",name:"base256emoji",encode:EE,decode:AE}),IE=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:SE},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Rd={...k_,...K_,...G_,...Y_,...X_,...uE,...lE,...pE,...wE,...IE};function K1(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}const Td=K1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Th=K1("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);const t=z1(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),V1={utf8:Td,"utf-8":Td,hex:Rd.base16,latin1:Th,ascii:Th,binary:Th,...Rd};function kr(r,t="utf8"){const e=V1[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Gl(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Rr(r,t="utf8"){const e=V1[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}const DE={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}},xE=":";function Uu(r){const[t,e]=r.split(xE);return{namespace:t,reference:e}}function Fd(r,t=[]){const e=[];return Object.keys(r).forEach(n=>{if(t.length&&!t.includes(n))return;const s=r[n];e.push(...s.accounts)}),e}function G1(r,t){return r.includes(":")?[r]:t.chains||[]}var ME=Object.defineProperty,Ud=Object.getOwnPropertySymbols,CE=Object.prototype.hasOwnProperty,PE=Object.prototype.propertyIsEnumerable,Bd=(r,t,e)=>t in r?ME(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ld=(r,t)=>{for(var e in t||(t={}))CE.call(t,e)&&Bd(r,e,t[e]);if(Ud)for(var e of Ud(t))PE.call(t,e)&&Bd(r,e,t[e]);return r};const OE="ReactNative",ti={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},NE="js";function sa(){return typeof ei<"u"&&typeof ei.versions<"u"&&typeof ei.versions.node<"u"}function go(){return!$l()&&!!zl()&&navigator.product===OE}function mo(){return!sa()&&!!zl()&&!!$l()}function ga(){return go()?ti.reactNative:sa()?ti.node:mo()?ti.browser:ti.unknown}function RE(){var r;try{return go()&&typeof Ie<"u"&&typeof(Ie==null?void 0:Ie.Application)<"u"?(r=Ie.Application)==null?void 0:r.applicationId:void 0}catch{return}}function TE(r,t){let e=na.parse(r);return e=Ld(Ld({},e),t),r=na.stringify(e),r}function FE(){return C1()||{name:"",description:"",url:"",icons:[""]}}function UE(){if(ga()===ti.reactNative&&typeof Ie<"u"&&typeof(Ie==null?void 0:Ie.Platform)<"u"){const{OS:e,Version:n}=Ie.Platform;return[e,n].join("-")}const r=p6();if(r===null)return"unknown";const t=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[t,r.name,r.version].join("-"):[t,r.version].join("-")}function BE(){var r;const t=ga();return t===ti.browser?[t,((r=M1())==null?void 0:r.host)||"unknown"].join(":"):t}function LE(r,t,e){const n=UE(),s=BE();return[[r,t].join("-"),[NE,e].join("-"),n,s].join("/")}function qE({protocol:r,version:t,relayUrl:e,sdkVersion:n,auth:s,projectId:a,useOnCloseEvent:c,bundleId:l}){const d=e.split("?"),f=LE(r,t,n),w={auth:s,ua:f,projectId:a,useOnCloseEvent:c||void 0,origin:l||void 0},E=TE(d[1]||"",w);return d[0]+"?"+E}function As(r,t){return r.filter(e=>t.includes(e)).length===r.length}function W1(r){return Object.fromEntries(r.entries())}function Y1(r){return new Map(Object.entries(r))}function Es(r=bt.FIVE_MINUTES,t){const e=bt.toMiliseconds(r||bt.FIVE_MINUTES);let n,s,a;return{resolve:c=>{a&&n&&(clearTimeout(a),n(c))},reject:c=>{a&&s&&(clearTimeout(a),s(c))},done:()=>new Promise((c,l)=>{a=setTimeout(()=>{l(new Error(t))},e),n=c,s=l})}}function oa(r,t,e){return new Promise(async(n,s)=>{const a=setTimeout(()=>s(new Error(e)),t);try{const c=await r;n(c)}catch(c){s(c)}clearTimeout(a)})}function Q1(r,t){if(typeof t=="string"&&t.startsWith(`${r}:`))return t;if(r.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(r.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${r}`)}function jE(r){return Q1("topic",r)}function $E(r){return Q1("id",r)}function J1(r){const[t,e]=r.split(":"),n={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")n.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))n.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return n}function _r(r,t){return bt.fromMiliseconds((t||Date.now())+bt.toMiliseconds(r))}function Hn(r){return Date.now()>=bt.toMiliseconds(r)}function de(r,t){return`${r}${t?`:${t}`:""}`}function Bu(r=[],t=[]){return[...new Set([...r,...t])]}async function zE({id:r,topic:t,wcDeepLink:e}){try{if(!e)return;const n=typeof e=="string"?JSON.parse(e):e;let s=n==null?void 0:n.href;if(typeof s!="string")return;s.endsWith("/")&&(s=s.slice(0,-1));const a=`${s}/wc?requestId=${r}&sessionTopic=${t}`,c=ga();c===ti.browser?a.startsWith("https://")||a.startsWith("http://")?window.open(a,"_blank","noreferrer noopener"):window.open(a,"_self","noreferrer noopener"):c===ti.reactNative&&typeof(Ie==null?void 0:Ie.Linking)<"u"&&await Ie.Linking.openURL(a)}catch(n){console.error(n)}}async function kE(r,t){try{return await r.getItem(t)||(mo()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}var X1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{};function HE(r){var t=r.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),e}var Z1={exports:{}};/**
2
- * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
- *
4
- * @version 0.8.0
5
- * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
- * @copyright Chen, Yi-Cyuan 2015-2018
7
- * @license MIT
8
- */(function(r){(function(){var t="input is invalid type",e="finalize already called",n=typeof window=="object",s=n?window:{};s.JS_SHA3_NO_WINDOW&&(n=!1);var a=!n&&typeof self=="object",c=!s.JS_SHA3_NO_NODE_JS&&typeof ei=="object"&&ei.versions&&ei.versions.node;c?s=X1:a&&(s=self);var l=!s.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,d=!s.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),w=[31,7936,2031616,520093696],E=[4,1024,262144,67108864],x=[1,256,65536,16777216],I=[6,1536,393216,100663296],R=[0,8,16,24],Y=[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],W=[224,256,384,512],tt=[128,256],K=["hex","buffer","arrayBuffer","array","digest"],V={128:168,256:136};(s.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(_){return Object.prototype.toString.call(_)==="[object Array]"}),d&&(s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(_){return typeof _=="object"&&_.buffer&&_.buffer.constructor===ArrayBuffer});for(var B=function(_,Z,U){return function(L){return new O(_,Z,_).update(L)[U]()}},z=function(_,Z,U){return function(L,k){return new O(_,Z,k).update(L)[U]()}},$=function(_,Z,U){return function(L,k,p,F){return y["cshake"+_].update(L,k,p,F)[U]()}},v=function(_,Z,U){return function(L,k,p,F){return y["kmac"+_].update(L,k,p,F)[U]()}},T=function(_,Z,U,L){for(var k=0;k<K.length;++k){var p=K[k];_[p]=Z(U,L,p)}return _},st=function(_,Z){var U=B(_,Z,"hex");return U.create=function(){return new O(_,Z,_)},U.update=function(L){return U.create().update(L)},T(U,B,_,Z)},ft=function(_,Z){var U=z(_,Z,"hex");return U.create=function(L){return new O(_,Z,L)},U.update=function(L,k){return U.create(k).update(L)},T(U,z,_,Z)},pt=function(_,Z){var U=V[_],L=$(_,Z,"hex");return L.create=function(k,p,F){return!p&&!F?y["shake"+_].create(k):new O(_,Z,k).bytepad([p,F],U)},L.update=function(k,p,F,et){return L.create(p,F,et).update(k)},T(L,$,_,Z)},gt=function(_,Z){var U=V[_],L=v(_,Z,"hex");return L.create=function(k,p,F){return new it(_,Z,p).bytepad(["KMAC",F],U).bytepad([k],U)},L.update=function(k,p,F,et){return L.create(k,F,et).update(p)},T(L,v,_,Z)},h=[{name:"keccak",padding:x,bits:W,createMethod:st},{name:"sha3",padding:I,bits:W,createMethod:st},{name:"shake",padding:w,bits:tt,createMethod:ft},{name:"cshake",padding:E,bits:tt,createMethod:pt},{name:"kmac",padding:E,bits:tt,createMethod:gt}],y={},b=[],C=0;C<h.length;++C)for(var M=h[C],N=M.bits,q=0;q<N.length;++q){var S=M.name+"_"+N[q];if(b.push(S),y[S]=M.createMethod(N[q],M.padding),M.name!=="sha3"){var g=M.name+N[q];b.push(g),y[g]=y[S]}}function O(_,Z,U){this.blocks=[],this.s=[],this.padding=Z,this.outputBits=U,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(_<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=U>>5,this.extraBytes=(U&31)>>3;for(var L=0;L<50;++L)this.s[L]=0}O.prototype.update=function(_){if(this.finalized)throw new Error(e);var Z,U=typeof _;if(U!=="string"){if(U==="object"){if(_===null)throw new Error(t);if(d&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!d||!ArrayBuffer.isView(_)))throw new Error(t)}else throw new Error(t);Z=!0}for(var L=this.blocks,k=this.byteCount,p=_.length,F=this.blockCount,et=0,ct=this.s,at,Mt;et<p;){if(this.reset)for(this.reset=!1,L[0]=this.block,at=1;at<F+1;++at)L[at]=0;if(Z)for(at=this.start;et<p&&at<k;++et)L[at>>2]|=_[et]<<R[at++&3];else for(at=this.start;et<p&&at<k;++et)Mt=_.charCodeAt(et),Mt<128?L[at>>2]|=Mt<<R[at++&3]:Mt<2048?(L[at>>2]|=(192|Mt>>6)<<R[at++&3],L[at>>2]|=(128|Mt&63)<<R[at++&3]):Mt<55296||Mt>=57344?(L[at>>2]|=(224|Mt>>12)<<R[at++&3],L[at>>2]|=(128|Mt>>6&63)<<R[at++&3],L[at>>2]|=(128|Mt&63)<<R[at++&3]):(Mt=65536+((Mt&1023)<<10|_.charCodeAt(++et)&1023),L[at>>2]|=(240|Mt>>18)<<R[at++&3],L[at>>2]|=(128|Mt>>12&63)<<R[at++&3],L[at>>2]|=(128|Mt>>6&63)<<R[at++&3],L[at>>2]|=(128|Mt&63)<<R[at++&3]);if(this.lastByteIndex=at,at>=k){for(this.start=at-k,this.block=L[F],at=0;at<F;++at)ct[at]^=L[at];lt(ct),this.reset=!0}else this.start=at}return this},O.prototype.encode=function(_,Z){var U=_&255,L=1,k=[U];for(_=_>>8,U=_&255;U>0;)k.unshift(U),_=_>>8,U=_&255,++L;return Z?k.push(L):k.unshift(L),this.update(k),k.length},O.prototype.encodeString=function(_){var Z,U=typeof _;if(U!=="string"){if(U==="object"){if(_===null)throw new Error(t);if(d&&_.constructor===ArrayBuffer)_=new Uint8Array(_);else if(!Array.isArray(_)&&(!d||!ArrayBuffer.isView(_)))throw new Error(t)}else throw new Error(t);Z=!0}var L=0,k=_.length;if(Z)L=k;else for(var p=0;p<_.length;++p){var F=_.charCodeAt(p);F<128?L+=1:F<2048?L+=2:F<55296||F>=57344?L+=3:(F=65536+((F&1023)<<10|_.charCodeAt(++p)&1023),L+=4)}return L+=this.encode(L*8),this.update(_),L},O.prototype.bytepad=function(_,Z){for(var U=this.encode(Z),L=0;L<_.length;++L)U+=this.encodeString(_[L]);var k=Z-U%Z,p=[];return p.length=k,this.update(p),this},O.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var _=this.blocks,Z=this.lastByteIndex,U=this.blockCount,L=this.s;if(_[Z>>2]|=this.padding[Z&3],this.lastByteIndex===this.byteCount)for(_[0]=_[U],Z=1;Z<U+1;++Z)_[Z]=0;for(_[U-1]|=2147483648,Z=0;Z<U;++Z)L[Z]^=_[Z];lt(L)}},O.prototype.toString=O.prototype.hex=function(){this.finalize();for(var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,p=0,F="",et;p<U;){for(k=0;k<_&&p<U;++k,++p)et=Z[k],F+=f[et>>4&15]+f[et&15]+f[et>>12&15]+f[et>>8&15]+f[et>>20&15]+f[et>>16&15]+f[et>>28&15]+f[et>>24&15];p%_===0&&(lt(Z),k=0)}return L&&(et=Z[k],F+=f[et>>4&15]+f[et&15],L>1&&(F+=f[et>>12&15]+f[et>>8&15]),L>2&&(F+=f[et>>20&15]+f[et>>16&15])),F},O.prototype.arrayBuffer=function(){this.finalize();var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,p=0,F=this.outputBits>>3,et;L?et=new ArrayBuffer(U+1<<2):et=new ArrayBuffer(F);for(var ct=new Uint32Array(et);p<U;){for(k=0;k<_&&p<U;++k,++p)ct[p]=Z[k];p%_===0&&lt(Z)}return L&&(ct[k]=Z[k],et=et.slice(0,F)),et},O.prototype.buffer=O.prototype.arrayBuffer,O.prototype.digest=O.prototype.array=function(){this.finalize();for(var _=this.blockCount,Z=this.s,U=this.outputBlocks,L=this.extraBytes,k=0,p=0,F=[],et,ct;p<U;){for(k=0;k<_&&p<U;++k,++p)et=p<<2,ct=Z[k],F[et]=ct&255,F[et+1]=ct>>8&255,F[et+2]=ct>>16&255,F[et+3]=ct>>24&255;p%_===0&&lt(Z)}return L&&(et=p<<2,ct=Z[k],F[et]=ct&255,L>1&&(F[et+1]=ct>>8&255),L>2&&(F[et+2]=ct>>16&255)),F};function it(_,Z,U){O.call(this,_,Z,U)}it.prototype=new O,it.prototype.finalize=function(){return this.encode(this.outputBits,!0),O.prototype.finalize.call(this)};var lt=function(_){var Z,U,L,k,p,F,et,ct,at,Mt,Pt,It,Ee,$t,xt,Bt,_t,Et,Vt,yt,At,Ut,wt,Ct,Lt,Ot,Nt,se,Tt,Rt,Ke,ue,pe,Ve,ye,_e,Er,Gt,zt,De,Wt,Kt,Ae,Jt,Xt,xe,Zt,Yt,Ce,Qt,qt,Te,te,Pe,xi,Oe,le,si,oi,ai,ui,ci,or;for(L=0;L<48;L+=2)k=_[0]^_[10]^_[20]^_[30]^_[40],p=_[1]^_[11]^_[21]^_[31]^_[41],F=_[2]^_[12]^_[22]^_[32]^_[42],et=_[3]^_[13]^_[23]^_[33]^_[43],ct=_[4]^_[14]^_[24]^_[34]^_[44],at=_[5]^_[15]^_[25]^_[35]^_[45],Mt=_[6]^_[16]^_[26]^_[36]^_[46],Pt=_[7]^_[17]^_[27]^_[37]^_[47],It=_[8]^_[18]^_[28]^_[38]^_[48],Ee=_[9]^_[19]^_[29]^_[39]^_[49],Z=It^(F<<1|et>>>31),U=Ee^(et<<1|F>>>31),_[0]^=Z,_[1]^=U,_[10]^=Z,_[11]^=U,_[20]^=Z,_[21]^=U,_[30]^=Z,_[31]^=U,_[40]^=Z,_[41]^=U,Z=k^(ct<<1|at>>>31),U=p^(at<<1|ct>>>31),_[2]^=Z,_[3]^=U,_[12]^=Z,_[13]^=U,_[22]^=Z,_[23]^=U,_[32]^=Z,_[33]^=U,_[42]^=Z,_[43]^=U,Z=F^(Mt<<1|Pt>>>31),U=et^(Pt<<1|Mt>>>31),_[4]^=Z,_[5]^=U,_[14]^=Z,_[15]^=U,_[24]^=Z,_[25]^=U,_[34]^=Z,_[35]^=U,_[44]^=Z,_[45]^=U,Z=ct^(It<<1|Ee>>>31),U=at^(Ee<<1|It>>>31),_[6]^=Z,_[7]^=U,_[16]^=Z,_[17]^=U,_[26]^=Z,_[27]^=U,_[36]^=Z,_[37]^=U,_[46]^=Z,_[47]^=U,Z=Mt^(k<<1|p>>>31),U=Pt^(p<<1|k>>>31),_[8]^=Z,_[9]^=U,_[18]^=Z,_[19]^=U,_[28]^=Z,_[29]^=U,_[38]^=Z,_[39]^=U,_[48]^=Z,_[49]^=U,$t=_[0],xt=_[1],xe=_[11]<<4|_[10]>>>28,Zt=_[10]<<4|_[11]>>>28,se=_[20]<<3|_[21]>>>29,Tt=_[21]<<3|_[20]>>>29,ai=_[31]<<9|_[30]>>>23,ui=_[30]<<9|_[31]>>>23,Kt=_[40]<<18|_[41]>>>14,Ae=_[41]<<18|_[40]>>>14,Ve=_[2]<<1|_[3]>>>31,ye=_[3]<<1|_[2]>>>31,Bt=_[13]<<12|_[12]>>>20,_t=_[12]<<12|_[13]>>>20,Yt=_[22]<<10|_[23]>>>22,Ce=_[23]<<10|_[22]>>>22,Rt=_[33]<<13|_[32]>>>19,Ke=_[32]<<13|_[33]>>>19,ci=_[42]<<2|_[43]>>>30,or=_[43]<<2|_[42]>>>30,Pe=_[5]<<30|_[4]>>>2,xi=_[4]<<30|_[5]>>>2,_e=_[14]<<6|_[15]>>>26,Er=_[15]<<6|_[14]>>>26,Et=_[25]<<11|_[24]>>>21,Vt=_[24]<<11|_[25]>>>21,Qt=_[34]<<15|_[35]>>>17,qt=_[35]<<15|_[34]>>>17,ue=_[45]<<29|_[44]>>>3,pe=_[44]<<29|_[45]>>>3,Ct=_[6]<<28|_[7]>>>4,Lt=_[7]<<28|_[6]>>>4,Oe=_[17]<<23|_[16]>>>9,le=_[16]<<23|_[17]>>>9,Gt=_[26]<<25|_[27]>>>7,zt=_[27]<<25|_[26]>>>7,yt=_[36]<<21|_[37]>>>11,At=_[37]<<21|_[36]>>>11,Te=_[47]<<24|_[46]>>>8,te=_[46]<<24|_[47]>>>8,Jt=_[8]<<27|_[9]>>>5,Xt=_[9]<<27|_[8]>>>5,Ot=_[18]<<20|_[19]>>>12,Nt=_[19]<<20|_[18]>>>12,si=_[29]<<7|_[28]>>>25,oi=_[28]<<7|_[29]>>>25,De=_[38]<<8|_[39]>>>24,Wt=_[39]<<8|_[38]>>>24,Ut=_[48]<<14|_[49]>>>18,wt=_[49]<<14|_[48]>>>18,_[0]=$t^~Bt&Et,_[1]=xt^~_t&Vt,_[10]=Ct^~Ot&se,_[11]=Lt^~Nt&Tt,_[20]=Ve^~_e&Gt,_[21]=ye^~Er&zt,_[30]=Jt^~xe&Yt,_[31]=Xt^~Zt&Ce,_[40]=Pe^~Oe&si,_[41]=xi^~le&oi,_[2]=Bt^~Et&yt,_[3]=_t^~Vt&At,_[12]=Ot^~se&Rt,_[13]=Nt^~Tt&Ke,_[22]=_e^~Gt&De,_[23]=Er^~zt&Wt,_[32]=xe^~Yt&Qt,_[33]=Zt^~Ce&qt,_[42]=Oe^~si&ai,_[43]=le^~oi&ui,_[4]=Et^~yt&Ut,_[5]=Vt^~At&wt,_[14]=se^~Rt&ue,_[15]=Tt^~Ke&pe,_[24]=Gt^~De&Kt,_[25]=zt^~Wt&Ae,_[34]=Yt^~Qt&Te,_[35]=Ce^~qt&te,_[44]=si^~ai&ci,_[45]=oi^~ui&or,_[6]=yt^~Ut&$t,_[7]=At^~wt&xt,_[16]=Rt^~ue&Ct,_[17]=Ke^~pe&Lt,_[26]=De^~Kt&Ve,_[27]=Wt^~Ae&ye,_[36]=Qt^~Te&Jt,_[37]=qt^~te&Xt,_[46]=ai^~ci&Pe,_[47]=ui^~or&xi,_[8]=Ut^~$t&Bt,_[9]=wt^~xt&_t,_[18]=ue^~Ct&Ot,_[19]=pe^~Lt&Nt,_[28]=Kt^~Ve&_e,_[29]=Ae^~ye&Er,_[38]=Te^~Jt&xe,_[39]=te^~Xt&Zt,_[48]=ci^~Pe&Oe,_[49]=or^~xi&le,_[0]^=Y[L],_[1]^=Y[L+1]};if(l)r.exports=y;else for(C=0;C<b.length;++C)s[b[C]]=y[b[C]]})()})(Z1);var KE=Z1.exports;const VE="logger/5.7.0";let qd=!1,jd=!1;const Lu={debug:1,default:2,info:2,warning:3,error:4,off:5};let $d=Lu.default,Fh=null;function GE(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{r.push(t)}}),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 zd=GE();var bl;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(bl||(bl={}));var Ui;(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"})(Ui||(Ui={}));const kd="0123456789abcdef";let pr=class sr{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const n=t.toLowerCase();Lu[n]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!($d>Lu[n])&&console.log.apply(console,e)}debug(...t){this._log(sr.levels.DEBUG,t)}info(...t){this._log(sr.levels.INFO,t)}warn(...t){this._log(sr.levels.WARNING,t)}makeError(t,e,n){if(jd)return this.makeError("censored error",e,{});e||(e=sr.errors.UNKNOWN_ERROR),n||(n={});const s=[];Object.keys(n).forEach(d=>{const f=n[d];try{if(f instanceof Uint8Array){let w="";for(let E=0;E<f.length;E++)w+=kd[f[E]>>4],w+=kd[f[E]&15];s.push(d+"=Uint8Array(0x"+w+")")}else s.push(d+"="+JSON.stringify(f))}catch{s.push(d+"="+JSON.stringify(n[d].toString()))}}),s.push(`code=${e}`),s.push(`version=${this.version}`);const a=t;let c="";switch(e){case Ui.NUMERIC_FAULT:{c="NUMERIC_FAULT";const d=t;switch(d){case"overflow":case"underflow":case"division-by-zero":c+="-"+d;break;case"negative-power":case"negative-width":c+="-unsupported";break;case"unbound-bitwise-result":c+="-unbound-result";break}break}case Ui.CALL_EXCEPTION:case Ui.INSUFFICIENT_FUNDS:case Ui.MISSING_NEW:case Ui.NONCE_EXPIRED:case Ui.REPLACEMENT_UNDERPRICED:case Ui.TRANSACTION_REPLACED:case Ui.UNPREDICTABLE_GAS_LIMIT:c=e;break}c&&(t+=" [ See: https://links.ethers.org/v5-errors-"+c+" ]"),s.length&&(t+=" ("+s.join(", ")+")");const l=new Error(t);return l.reason=a,l.code=e,Object.keys(n).forEach(function(d){l[d]=n[d]}),l}throwError(t,e,n){throw this.makeError(t,e,n)}throwArgumentError(t,e,n){return this.throwError(t,sr.errors.INVALID_ARGUMENT,{argument:e,value:n})}assert(t,e,n,s){t||this.throwError(e,n,s)}assertArgument(t,e,n,s){t||this.throwArgumentError(e,n,s)}checkNormalize(t){zd&&this.throwError("platform missing String.prototype.normalize",sr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:zd})}checkSafeUint53(t,e){typeof t=="number"&&(e==null&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,sr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,sr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,n){n?n=": "+n:n="",t<e&&this.throwError("missing argument"+n,sr.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+n,sr.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){(t===Object||t==null)&&this.throwError("missing new",sr.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",sr.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",sr.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Fh||(Fh=new sr(VE)),Fh}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",sr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qd){if(!t)return;this.globalLogger().throwError("error censorship permanent",sr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}jd=!!t,qd=!!e}static setLogLevel(t){const e=Lu[t.toLowerCase()];if(e==null){sr.globalLogger().warn("invalid log level - "+t);return}$d=e}static from(t){return new sr(t)}};pr.errors=Ui,pr.levels=bl;const WE="bytes/5.7.0",Ze=new pr(WE);function tg(r){return!!r.toHexString}function ao(r){return r.slice||(r.slice=function(){const t=Array.prototype.slice.call(arguments);return ao(new Uint8Array(Array.prototype.slice.apply(r,t)))}),r}function YE(r){return ri(r)&&!(r.length%2)||vo(r)}function Hd(r){return typeof r=="number"&&r==r&&r%1===0}function vo(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!Hd(r.length)||r.length<0)return!1;for(let t=0;t<r.length;t++){const e=r[t];if(!Hd(e)||e<0||e>=256)return!1}return!0}function Ye(r,t){if(t||(t={}),typeof r=="number"){Ze.checkSafeUint53(r,"invalid arrayify value");const e=[];for(;r;)e.unshift(r&255),r=parseInt(String(r/256));return e.length===0&&e.push(0),ao(new Uint8Array(e))}if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),tg(r)&&(r=r.toHexString()),ri(r)){let e=r.substring(2);e.length%2&&(t.hexPad==="left"?e="0"+e:t.hexPad==="right"?e+="0":Ze.throwArgumentError("hex data is odd-length","value",r));const n=[];for(let s=0;s<e.length;s+=2)n.push(parseInt(e.substring(s,s+2),16));return ao(new Uint8Array(n))}return vo(r)?ao(new Uint8Array(r)):Ze.throwArgumentError("invalid arrayify value","value",r)}function QE(r){const t=r.map(s=>Ye(s)),e=t.reduce((s,a)=>s+a.length,0),n=new Uint8Array(e);return t.reduce((s,a)=>(n.set(a,s),s+a.length),0),ao(n)}function JE(r,t){r=Ye(r),r.length>t&&Ze.throwArgumentError("value out of range","value",arguments[0]);const e=new Uint8Array(t);return e.set(r,t-r.length),ao(e)}function ri(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||t&&r.length!==2+2*t)}const Uh="0123456789abcdef";function Cr(r,t){if(t||(t={}),typeof r=="number"){Ze.checkSafeUint53(r,"invalid hexlify value");let e="";for(;r;)e=Uh[r&15]+e,r=Math.floor(r/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(t.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),tg(r))return r.toHexString();if(ri(r))return r.length%2&&(t.hexPad==="left"?r="0x0"+r.substring(2):t.hexPad==="right"?r+="0":Ze.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(vo(r)){let e="0x";for(let n=0;n<r.length;n++){let s=r[n];e+=Uh[(s&240)>>4]+Uh[s&15]}return e}return Ze.throwArgumentError("invalid hexlify value","value",r)}function XE(r){if(typeof r!="string")r=Cr(r);else if(!ri(r)||r.length%2)return null;return(r.length-2)/2}function Kd(r,t,e){return typeof r!="string"?r=Cr(r):(!ri(r)||r.length%2)&&Ze.throwArgumentError("invalid hexData","value",r),t=2+2*t,e!=null?"0x"+r.substring(t,2+2*e):"0x"+r.substring(t)}function rn(r,t){for(typeof r!="string"?r=Cr(r):ri(r)||Ze.throwArgumentError("invalid hex string","value",r),r.length>2*t+2&&Ze.throwArgumentError("value out of range","value",arguments[1]);r.length<2*t+2;)r="0x0"+r.substring(2);return r}function eg(r){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(YE(r)){let e=Ye(r);e.length===64?(t.v=27+(e[32]>>7),e[32]&=127,t.r=Cr(e.slice(0,32)),t.s=Cr(e.slice(32,64))):e.length===65?(t.r=Cr(e.slice(0,32)),t.s=Cr(e.slice(32,64)),t.v=e[64]):Ze.throwArgumentError("invalid signature string","signature",r),t.v<27&&(t.v===0||t.v===1?t.v+=27:Ze.throwArgumentError("signature invalid v byte","signature",r)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(e[32]|=128),t._vs=Cr(e.slice(32,64))}else{if(t.r=r.r,t.s=r.s,t.v=r.v,t.recoveryParam=r.recoveryParam,t._vs=r._vs,t._vs!=null){const s=JE(Ye(t._vs),32);t._vs=Cr(s);const a=s[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=a:t.recoveryParam!==a&&Ze.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),s[0]&=127;const c=Cr(s);t.s==null?t.s=c:t.s!==c&&Ze.throwArgumentError("signature v mismatch _vs","signature",r)}if(t.recoveryParam==null)t.v==null?Ze.throwArgumentError("signature missing v and recoveryParam","signature",r):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const s=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==s&&Ze.throwArgumentError("signature recoveryParam mismatch v","signature",r)}t.r==null||!ri(t.r)?Ze.throwArgumentError("signature missing or invalid r","signature",r):t.r=rn(t.r,32),t.s==null||!ri(t.s)?Ze.throwArgumentError("signature missing or invalid s","signature",r):t.s=rn(t.s,32);const e=Ye(t.s);e[0]>=128&&Ze.throwArgumentError("signature s out of range","signature",r),t.recoveryParam&&(e[0]|=128);const n=Cr(e);t._vs&&(ri(t._vs)||Ze.throwArgumentError("signature invalid _vs","signature",r),t._vs=rn(t._vs,32)),t._vs==null?t._vs=n:t._vs!==n&&Ze.throwArgumentError("signature _vs mismatch v and s","signature",r)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function Wl(r){return"0x"+KE.keccak_256(Ye(r))}var rg={exports:{}},ZE={},t5=Object.freeze({__proto__:null,default:ZE}),e5=HE(t5);(function(r){(function(t,e){function n(h,y){if(!h)throw new Error(y||"Assertion failed")}function s(h,y){h.super_=y;var b=function(){};b.prototype=y.prototype,h.prototype=new b,h.prototype.constructor=h}function a(h,y,b){if(a.isBN(h))return h;this.negative=0,this.words=null,this.length=0,this.red=null,h!==null&&((y==="le"||y==="be")&&(b=y,y=10),this._init(h||0,y||10,b||"be"))}typeof t=="object"?t.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var c;try{typeof window<"u"&&typeof window.Buffer<"u"?c=window.Buffer:c=e5.Buffer}catch{}a.isBN=function(h){return h instanceof a?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===a.wordSize&&Array.isArray(h.words)},a.max=function(h,y){return h.cmp(y)>0?h:y},a.min=function(h,y){return h.cmp(y)<0?h:y},a.prototype._init=function(h,y,b){if(typeof h=="number")return this._initNumber(h,y,b);if(typeof h=="object")return this._initArray(h,y,b);y==="hex"&&(y=16),n(y===(y|0)&&y>=2&&y<=36),h=h.toString().replace(/\s+/g,"");var C=0;h[0]==="-"&&(C++,this.negative=1),C<h.length&&(y===16?this._parseHex(h,C,b):(this._parseBase(h,y,C),b==="le"&&this._initArray(this.toArray(),y,b)))},a.prototype._initNumber=function(h,y,b){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(n(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),y,b)},a.prototype._initArray=function(h,y,b){if(n(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var M,N,q=0;if(b==="be")for(C=h.length-1,M=0;C>=0;C-=3)N=h[C]|h[C-1]<<8|h[C-2]<<16,this.words[M]|=N<<q&67108863,this.words[M+1]=N>>>26-q&67108863,q+=24,q>=26&&(q-=26,M++);else if(b==="le")for(C=0,M=0;C<h.length;C+=3)N=h[C]|h[C+1]<<8|h[C+2]<<16,this.words[M]|=N<<q&67108863,this.words[M+1]=N>>>26-q&67108863,q+=24,q>=26&&(q-=26,M++);return this._strip()};function l(h,y){var b=h.charCodeAt(y);if(b>=48&&b<=57)return b-48;if(b>=65&&b<=70)return b-55;if(b>=97&&b<=102)return b-87;n(!1,"Invalid character in "+h)}function d(h,y,b){var C=l(h,b);return b-1>=y&&(C|=l(h,b-1)<<4),C}a.prototype._parseHex=function(h,y,b){this.length=Math.ceil((h.length-y)/6),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var M=0,N=0,q;if(b==="be")for(C=h.length-1;C>=y;C-=2)q=d(h,y,C)<<M,this.words[N]|=q&67108863,M>=18?(M-=18,N+=1,this.words[N]|=q>>>26):M+=8;else{var S=h.length-y;for(C=S%2===0?y+1:y;C<h.length;C+=2)q=d(h,y,C)<<M,this.words[N]|=q&67108863,M>=18?(M-=18,N+=1,this.words[N]|=q>>>26):M+=8}this._strip()};function f(h,y,b,C){for(var M=0,N=0,q=Math.min(h.length,b),S=y;S<q;S++){var g=h.charCodeAt(S)-48;M*=C,g>=49?N=g-49+10:g>=17?N=g-17+10:N=g,n(g>=0&&N<C,"Invalid character"),M+=N}return M}a.prototype._parseBase=function(h,y,b){this.words=[0],this.length=1;for(var C=0,M=1;M<=67108863;M*=y)C++;C--,M=M/y|0;for(var N=h.length-b,q=N%C,S=Math.min(N,N-q)+b,g=0,O=b;O<S;O+=C)g=f(h,O,O+C,y),this.imuln(M),this.words[0]+g<67108864?this.words[0]+=g:this._iaddn(g);if(q!==0){var it=1;for(g=f(h,O,h.length,y),O=0;O<q;O++)it*=y;this.imuln(it),this.words[0]+g<67108864?this.words[0]+=g:this._iaddn(g)}this._strip()},a.prototype.copy=function(h){h.words=new Array(this.length);for(var y=0;y<this.length;y++)h.words[y]=this.words[y];h.length=this.length,h.negative=this.negative,h.red=this.red};function w(h,y){h.words=y.words,h.length=y.length,h.negative=y.negative,h.red=y.red}if(a.prototype._move=function(h){w(h,this)},a.prototype.clone=function(){var h=new a(null);return this.copy(h),h},a.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=E}catch{a.prototype.inspect=E}else a.prototype.inspect=E;function E(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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],R=[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];a.prototype.toString=function(h,y){h=h||10,y=y|0||1;var b;if(h===16||h==="hex"){b="";for(var C=0,M=0,N=0;N<this.length;N++){var q=this.words[N],S=((q<<C|M)&16777215).toString(16);M=q>>>24-C&16777215,C+=2,C>=26&&(C-=26,N--),M!==0||N!==this.length-1?b=x[6-S.length]+S+b:b=S+b}for(M!==0&&(b=M.toString(16)+b);b.length%y!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(h===(h|0)&&h>=2&&h<=36){var g=I[h],O=R[h];b="";var it=this.clone();for(it.negative=0;!it.isZero();){var lt=it.modrn(O).toString(h);it=it.idivn(O),it.isZero()?b=lt+b:b=x[g-lt.length]+lt+b}for(this.isZero()&&(b="0"+b);b.length%y!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},a.prototype.toJSON=function(){return this.toString(16,2)},c&&(a.prototype.toBuffer=function(h,y){return this.toArrayLike(c,h,y)}),a.prototype.toArray=function(h,y){return this.toArrayLike(Array,h,y)};var Y=function(h,y){return h.allocUnsafe?h.allocUnsafe(y):new h(y)};a.prototype.toArrayLike=function(h,y,b){this._strip();var C=this.byteLength(),M=b||Math.max(1,C);n(C<=M,"byte array longer than desired length"),n(M>0,"Requested array length <= 0");var N=Y(h,M),q=y==="le"?"LE":"BE";return this["_toArrayLike"+q](N,C),N},a.prototype._toArrayLikeLE=function(h,y){for(var b=0,C=0,M=0,N=0;M<this.length;M++){var q=this.words[M]<<N|C;h[b++]=q&255,b<h.length&&(h[b++]=q>>8&255),b<h.length&&(h[b++]=q>>16&255),N===6?(b<h.length&&(h[b++]=q>>24&255),C=0,N=0):(C=q>>>24,N+=2)}if(b<h.length)for(h[b++]=C;b<h.length;)h[b++]=0},a.prototype._toArrayLikeBE=function(h,y){for(var b=h.length-1,C=0,M=0,N=0;M<this.length;M++){var q=this.words[M]<<N|C;h[b--]=q&255,b>=0&&(h[b--]=q>>8&255),b>=0&&(h[b--]=q>>16&255),N===6?(b>=0&&(h[b--]=q>>24&255),C=0,N=0):(C=q>>>24,N+=2)}if(b>=0)for(h[b--]=C;b>=0;)h[b--]=0},Math.clz32?a.prototype._countBits=function(h){return 32-Math.clz32(h)}:a.prototype._countBits=function(h){var y=h,b=0;return y>=4096&&(b+=13,y>>>=13),y>=64&&(b+=7,y>>>=7),y>=8&&(b+=4,y>>>=4),y>=2&&(b+=2,y>>>=2),b+y},a.prototype._zeroBits=function(h){if(h===0)return 26;var y=h,b=0;return y&8191||(b+=13,y>>>=13),y&127||(b+=7,y>>>=7),y&15||(b+=4,y>>>=4),y&3||(b+=2,y>>>=2),y&1||b++,b},a.prototype.bitLength=function(){var h=this.words[this.length-1],y=this._countBits(h);return(this.length-1)*26+y};function W(h){for(var y=new Array(h.bitLength()),b=0;b<y.length;b++){var C=b/26|0,M=b%26;y[b]=h.words[C]>>>M&1}return y}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,y=0;y<this.length;y++){var b=this._zeroBits(this.words[y]);if(h+=b,b!==26)break}return h},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},a.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]|h.words[y];return this._strip()},a.prototype.ior=function(h){return n((this.negative|h.negative)===0),this.iuor(h)},a.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},a.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},a.prototype.iuand=function(h){var y;this.length>h.length?y=h:y=this;for(var b=0;b<y.length;b++)this.words[b]=this.words[b]&h.words[b];return this.length=y.length,this._strip()},a.prototype.iand=function(h){return n((this.negative|h.negative)===0),this.iuand(h)},a.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},a.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},a.prototype.iuxor=function(h){var y,b;this.length>h.length?(y=this,b=h):(y=h,b=this);for(var C=0;C<b.length;C++)this.words[C]=y.words[C]^b.words[C];if(this!==y)for(;C<y.length;C++)this.words[C]=y.words[C];return this.length=y.length,this._strip()},a.prototype.ixor=function(h){return n((this.negative|h.negative)===0),this.iuxor(h)},a.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},a.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},a.prototype.inotn=function(h){n(typeof h=="number"&&h>=0);var y=Math.ceil(h/26)|0,b=h%26;this._expand(y),b>0&&y--;for(var C=0;C<y;C++)this.words[C]=~this.words[C]&67108863;return b>0&&(this.words[C]=~this.words[C]&67108863>>26-b),this._strip()},a.prototype.notn=function(h){return this.clone().inotn(h)},a.prototype.setn=function(h,y){n(typeof h=="number"&&h>=0);var b=h/26|0,C=h%26;return this._expand(b+1),y?this.words[b]=this.words[b]|1<<C:this.words[b]=this.words[b]&~(1<<C),this._strip()},a.prototype.iadd=function(h){var y;if(this.negative!==0&&h.negative===0)return this.negative=0,y=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,y=this.isub(h),h.negative=1,y._normSign();var b,C;this.length>h.length?(b=this,C=h):(b=h,C=this);for(var M=0,N=0;N<C.length;N++)y=(b.words[N]|0)+(C.words[N]|0)+M,this.words[N]=y&67108863,M=y>>>26;for(;M!==0&&N<b.length;N++)y=(b.words[N]|0)+M,this.words[N]=y&67108863,M=y>>>26;if(this.length=b.length,M!==0)this.words[this.length]=M,this.length++;else if(b!==this)for(;N<b.length;N++)this.words[N]=b.words[N];return this},a.prototype.add=function(h){var y;return h.negative!==0&&this.negative===0?(h.negative=0,y=this.sub(h),h.negative^=1,y):h.negative===0&&this.negative!==0?(this.negative=0,y=h.sub(this),this.negative=1,y):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},a.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var y=this.iadd(h);return h.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var b=this.cmp(h);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C,M;b>0?(C=this,M=h):(C=h,M=this);for(var N=0,q=0;q<M.length;q++)y=(C.words[q]|0)-(M.words[q]|0)+N,N=y>>26,this.words[q]=y&67108863;for(;N!==0&&q<C.length;q++)y=(C.words[q]|0)+N,N=y>>26,this.words[q]=y&67108863;if(N===0&&q<C.length&&C!==this)for(;q<C.length;q++)this.words[q]=C.words[q];return this.length=Math.max(this.length,q),C!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(h){return this.clone().isub(h)};function tt(h,y,b){b.negative=y.negative^h.negative;var C=h.length+y.length|0;b.length=C,C=C-1|0;var M=h.words[0]|0,N=y.words[0]|0,q=M*N,S=q&67108863,g=q/67108864|0;b.words[0]=S;for(var O=1;O<C;O++){for(var it=g>>>26,lt=g&67108863,_=Math.min(O,y.length-1),Z=Math.max(0,O-h.length+1);Z<=_;Z++){var U=O-Z|0;M=h.words[U]|0,N=y.words[Z]|0,q=M*N+lt,it+=q/67108864|0,lt=q&67108863}b.words[O]=lt|0,g=it|0}return g!==0?b.words[O]=g|0:b.length--,b._strip()}var K=function(h,y,b){var C=h.words,M=y.words,N=b.words,q=0,S,g,O,it=C[0]|0,lt=it&8191,_=it>>>13,Z=C[1]|0,U=Z&8191,L=Z>>>13,k=C[2]|0,p=k&8191,F=k>>>13,et=C[3]|0,ct=et&8191,at=et>>>13,Mt=C[4]|0,Pt=Mt&8191,It=Mt>>>13,Ee=C[5]|0,$t=Ee&8191,xt=Ee>>>13,Bt=C[6]|0,_t=Bt&8191,Et=Bt>>>13,Vt=C[7]|0,yt=Vt&8191,At=Vt>>>13,Ut=C[8]|0,wt=Ut&8191,Ct=Ut>>>13,Lt=C[9]|0,Ot=Lt&8191,Nt=Lt>>>13,se=M[0]|0,Tt=se&8191,Rt=se>>>13,Ke=M[1]|0,ue=Ke&8191,pe=Ke>>>13,Ve=M[2]|0,ye=Ve&8191,_e=Ve>>>13,Er=M[3]|0,Gt=Er&8191,zt=Er>>>13,De=M[4]|0,Wt=De&8191,Kt=De>>>13,Ae=M[5]|0,Jt=Ae&8191,Xt=Ae>>>13,xe=M[6]|0,Zt=xe&8191,Yt=xe>>>13,Ce=M[7]|0,Qt=Ce&8191,qt=Ce>>>13,Te=M[8]|0,te=Te&8191,Pe=Te>>>13,xi=M[9]|0,Oe=xi&8191,le=xi>>>13;b.negative=h.negative^y.negative,b.length=19,S=Math.imul(lt,Tt),g=Math.imul(lt,Rt),g=g+Math.imul(_,Tt)|0,O=Math.imul(_,Rt);var si=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(si>>>26)|0,si&=67108863,S=Math.imul(U,Tt),g=Math.imul(U,Rt),g=g+Math.imul(L,Tt)|0,O=Math.imul(L,Rt),S=S+Math.imul(lt,ue)|0,g=g+Math.imul(lt,pe)|0,g=g+Math.imul(_,ue)|0,O=O+Math.imul(_,pe)|0;var oi=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(oi>>>26)|0,oi&=67108863,S=Math.imul(p,Tt),g=Math.imul(p,Rt),g=g+Math.imul(F,Tt)|0,O=Math.imul(F,Rt),S=S+Math.imul(U,ue)|0,g=g+Math.imul(U,pe)|0,g=g+Math.imul(L,ue)|0,O=O+Math.imul(L,pe)|0,S=S+Math.imul(lt,ye)|0,g=g+Math.imul(lt,_e)|0,g=g+Math.imul(_,ye)|0,O=O+Math.imul(_,_e)|0;var ai=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(ai>>>26)|0,ai&=67108863,S=Math.imul(ct,Tt),g=Math.imul(ct,Rt),g=g+Math.imul(at,Tt)|0,O=Math.imul(at,Rt),S=S+Math.imul(p,ue)|0,g=g+Math.imul(p,pe)|0,g=g+Math.imul(F,ue)|0,O=O+Math.imul(F,pe)|0,S=S+Math.imul(U,ye)|0,g=g+Math.imul(U,_e)|0,g=g+Math.imul(L,ye)|0,O=O+Math.imul(L,_e)|0,S=S+Math.imul(lt,Gt)|0,g=g+Math.imul(lt,zt)|0,g=g+Math.imul(_,Gt)|0,O=O+Math.imul(_,zt)|0;var ui=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(ui>>>26)|0,ui&=67108863,S=Math.imul(Pt,Tt),g=Math.imul(Pt,Rt),g=g+Math.imul(It,Tt)|0,O=Math.imul(It,Rt),S=S+Math.imul(ct,ue)|0,g=g+Math.imul(ct,pe)|0,g=g+Math.imul(at,ue)|0,O=O+Math.imul(at,pe)|0,S=S+Math.imul(p,ye)|0,g=g+Math.imul(p,_e)|0,g=g+Math.imul(F,ye)|0,O=O+Math.imul(F,_e)|0,S=S+Math.imul(U,Gt)|0,g=g+Math.imul(U,zt)|0,g=g+Math.imul(L,Gt)|0,O=O+Math.imul(L,zt)|0,S=S+Math.imul(lt,Wt)|0,g=g+Math.imul(lt,Kt)|0,g=g+Math.imul(_,Wt)|0,O=O+Math.imul(_,Kt)|0;var ci=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(ci>>>26)|0,ci&=67108863,S=Math.imul($t,Tt),g=Math.imul($t,Rt),g=g+Math.imul(xt,Tt)|0,O=Math.imul(xt,Rt),S=S+Math.imul(Pt,ue)|0,g=g+Math.imul(Pt,pe)|0,g=g+Math.imul(It,ue)|0,O=O+Math.imul(It,pe)|0,S=S+Math.imul(ct,ye)|0,g=g+Math.imul(ct,_e)|0,g=g+Math.imul(at,ye)|0,O=O+Math.imul(at,_e)|0,S=S+Math.imul(p,Gt)|0,g=g+Math.imul(p,zt)|0,g=g+Math.imul(F,Gt)|0,O=O+Math.imul(F,zt)|0,S=S+Math.imul(U,Wt)|0,g=g+Math.imul(U,Kt)|0,g=g+Math.imul(L,Wt)|0,O=O+Math.imul(L,Kt)|0,S=S+Math.imul(lt,Jt)|0,g=g+Math.imul(lt,Xt)|0,g=g+Math.imul(_,Jt)|0,O=O+Math.imul(_,Xt)|0;var or=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(or>>>26)|0,or&=67108863,S=Math.imul(_t,Tt),g=Math.imul(_t,Rt),g=g+Math.imul(Et,Tt)|0,O=Math.imul(Et,Rt),S=S+Math.imul($t,ue)|0,g=g+Math.imul($t,pe)|0,g=g+Math.imul(xt,ue)|0,O=O+Math.imul(xt,pe)|0,S=S+Math.imul(Pt,ye)|0,g=g+Math.imul(Pt,_e)|0,g=g+Math.imul(It,ye)|0,O=O+Math.imul(It,_e)|0,S=S+Math.imul(ct,Gt)|0,g=g+Math.imul(ct,zt)|0,g=g+Math.imul(at,Gt)|0,O=O+Math.imul(at,zt)|0,S=S+Math.imul(p,Wt)|0,g=g+Math.imul(p,Kt)|0,g=g+Math.imul(F,Wt)|0,O=O+Math.imul(F,Kt)|0,S=S+Math.imul(U,Jt)|0,g=g+Math.imul(U,Xt)|0,g=g+Math.imul(L,Jt)|0,O=O+Math.imul(L,Xt)|0,S=S+Math.imul(lt,Zt)|0,g=g+Math.imul(lt,Yt)|0,g=g+Math.imul(_,Zt)|0,O=O+Math.imul(_,Yt)|0;var qi=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(qi>>>26)|0,qi&=67108863,S=Math.imul(yt,Tt),g=Math.imul(yt,Rt),g=g+Math.imul(At,Tt)|0,O=Math.imul(At,Rt),S=S+Math.imul(_t,ue)|0,g=g+Math.imul(_t,pe)|0,g=g+Math.imul(Et,ue)|0,O=O+Math.imul(Et,pe)|0,S=S+Math.imul($t,ye)|0,g=g+Math.imul($t,_e)|0,g=g+Math.imul(xt,ye)|0,O=O+Math.imul(xt,_e)|0,S=S+Math.imul(Pt,Gt)|0,g=g+Math.imul(Pt,zt)|0,g=g+Math.imul(It,Gt)|0,O=O+Math.imul(It,zt)|0,S=S+Math.imul(ct,Wt)|0,g=g+Math.imul(ct,Kt)|0,g=g+Math.imul(at,Wt)|0,O=O+Math.imul(at,Kt)|0,S=S+Math.imul(p,Jt)|0,g=g+Math.imul(p,Xt)|0,g=g+Math.imul(F,Jt)|0,O=O+Math.imul(F,Xt)|0,S=S+Math.imul(U,Zt)|0,g=g+Math.imul(U,Yt)|0,g=g+Math.imul(L,Zt)|0,O=O+Math.imul(L,Yt)|0,S=S+Math.imul(lt,Qt)|0,g=g+Math.imul(lt,qt)|0,g=g+Math.imul(_,Qt)|0,O=O+Math.imul(_,qt)|0;var Zn=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(Zn>>>26)|0,Zn&=67108863,S=Math.imul(wt,Tt),g=Math.imul(wt,Rt),g=g+Math.imul(Ct,Tt)|0,O=Math.imul(Ct,Rt),S=S+Math.imul(yt,ue)|0,g=g+Math.imul(yt,pe)|0,g=g+Math.imul(At,ue)|0,O=O+Math.imul(At,pe)|0,S=S+Math.imul(_t,ye)|0,g=g+Math.imul(_t,_e)|0,g=g+Math.imul(Et,ye)|0,O=O+Math.imul(Et,_e)|0,S=S+Math.imul($t,Gt)|0,g=g+Math.imul($t,zt)|0,g=g+Math.imul(xt,Gt)|0,O=O+Math.imul(xt,zt)|0,S=S+Math.imul(Pt,Wt)|0,g=g+Math.imul(Pt,Kt)|0,g=g+Math.imul(It,Wt)|0,O=O+Math.imul(It,Kt)|0,S=S+Math.imul(ct,Jt)|0,g=g+Math.imul(ct,Xt)|0,g=g+Math.imul(at,Jt)|0,O=O+Math.imul(at,Xt)|0,S=S+Math.imul(p,Zt)|0,g=g+Math.imul(p,Yt)|0,g=g+Math.imul(F,Zt)|0,O=O+Math.imul(F,Yt)|0,S=S+Math.imul(U,Qt)|0,g=g+Math.imul(U,qt)|0,g=g+Math.imul(L,Qt)|0,O=O+Math.imul(L,qt)|0,S=S+Math.imul(lt,te)|0,g=g+Math.imul(lt,Pe)|0,g=g+Math.imul(_,te)|0,O=O+Math.imul(_,Pe)|0;var ji=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(ji>>>26)|0,ji&=67108863,S=Math.imul(Ot,Tt),g=Math.imul(Ot,Rt),g=g+Math.imul(Nt,Tt)|0,O=Math.imul(Nt,Rt),S=S+Math.imul(wt,ue)|0,g=g+Math.imul(wt,pe)|0,g=g+Math.imul(Ct,ue)|0,O=O+Math.imul(Ct,pe)|0,S=S+Math.imul(yt,ye)|0,g=g+Math.imul(yt,_e)|0,g=g+Math.imul(At,ye)|0,O=O+Math.imul(At,_e)|0,S=S+Math.imul(_t,Gt)|0,g=g+Math.imul(_t,zt)|0,g=g+Math.imul(Et,Gt)|0,O=O+Math.imul(Et,zt)|0,S=S+Math.imul($t,Wt)|0,g=g+Math.imul($t,Kt)|0,g=g+Math.imul(xt,Wt)|0,O=O+Math.imul(xt,Kt)|0,S=S+Math.imul(Pt,Jt)|0,g=g+Math.imul(Pt,Xt)|0,g=g+Math.imul(It,Jt)|0,O=O+Math.imul(It,Xt)|0,S=S+Math.imul(ct,Zt)|0,g=g+Math.imul(ct,Yt)|0,g=g+Math.imul(at,Zt)|0,O=O+Math.imul(at,Yt)|0,S=S+Math.imul(p,Qt)|0,g=g+Math.imul(p,qt)|0,g=g+Math.imul(F,Qt)|0,O=O+Math.imul(F,qt)|0,S=S+Math.imul(U,te)|0,g=g+Math.imul(U,Pe)|0,g=g+Math.imul(L,te)|0,O=O+Math.imul(L,Pe)|0,S=S+Math.imul(lt,Oe)|0,g=g+Math.imul(lt,le)|0,g=g+Math.imul(_,Oe)|0,O=O+Math.imul(_,le)|0;var ts=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(ts>>>26)|0,ts&=67108863,S=Math.imul(Ot,ue),g=Math.imul(Ot,pe),g=g+Math.imul(Nt,ue)|0,O=Math.imul(Nt,pe),S=S+Math.imul(wt,ye)|0,g=g+Math.imul(wt,_e)|0,g=g+Math.imul(Ct,ye)|0,O=O+Math.imul(Ct,_e)|0,S=S+Math.imul(yt,Gt)|0,g=g+Math.imul(yt,zt)|0,g=g+Math.imul(At,Gt)|0,O=O+Math.imul(At,zt)|0,S=S+Math.imul(_t,Wt)|0,g=g+Math.imul(_t,Kt)|0,g=g+Math.imul(Et,Wt)|0,O=O+Math.imul(Et,Kt)|0,S=S+Math.imul($t,Jt)|0,g=g+Math.imul($t,Xt)|0,g=g+Math.imul(xt,Jt)|0,O=O+Math.imul(xt,Xt)|0,S=S+Math.imul(Pt,Zt)|0,g=g+Math.imul(Pt,Yt)|0,g=g+Math.imul(It,Zt)|0,O=O+Math.imul(It,Yt)|0,S=S+Math.imul(ct,Qt)|0,g=g+Math.imul(ct,qt)|0,g=g+Math.imul(at,Qt)|0,O=O+Math.imul(at,qt)|0,S=S+Math.imul(p,te)|0,g=g+Math.imul(p,Pe)|0,g=g+Math.imul(F,te)|0,O=O+Math.imul(F,Pe)|0,S=S+Math.imul(U,Oe)|0,g=g+Math.imul(U,le)|0,g=g+Math.imul(L,Oe)|0,O=O+Math.imul(L,le)|0;var es=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(es>>>26)|0,es&=67108863,S=Math.imul(Ot,ye),g=Math.imul(Ot,_e),g=g+Math.imul(Nt,ye)|0,O=Math.imul(Nt,_e),S=S+Math.imul(wt,Gt)|0,g=g+Math.imul(wt,zt)|0,g=g+Math.imul(Ct,Gt)|0,O=O+Math.imul(Ct,zt)|0,S=S+Math.imul(yt,Wt)|0,g=g+Math.imul(yt,Kt)|0,g=g+Math.imul(At,Wt)|0,O=O+Math.imul(At,Kt)|0,S=S+Math.imul(_t,Jt)|0,g=g+Math.imul(_t,Xt)|0,g=g+Math.imul(Et,Jt)|0,O=O+Math.imul(Et,Xt)|0,S=S+Math.imul($t,Zt)|0,g=g+Math.imul($t,Yt)|0,g=g+Math.imul(xt,Zt)|0,O=O+Math.imul(xt,Yt)|0,S=S+Math.imul(Pt,Qt)|0,g=g+Math.imul(Pt,qt)|0,g=g+Math.imul(It,Qt)|0,O=O+Math.imul(It,qt)|0,S=S+Math.imul(ct,te)|0,g=g+Math.imul(ct,Pe)|0,g=g+Math.imul(at,te)|0,O=O+Math.imul(at,Pe)|0,S=S+Math.imul(p,Oe)|0,g=g+Math.imul(p,le)|0,g=g+Math.imul(F,Oe)|0,O=O+Math.imul(F,le)|0;var $i=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+($i>>>26)|0,$i&=67108863,S=Math.imul(Ot,Gt),g=Math.imul(Ot,zt),g=g+Math.imul(Nt,Gt)|0,O=Math.imul(Nt,zt),S=S+Math.imul(wt,Wt)|0,g=g+Math.imul(wt,Kt)|0,g=g+Math.imul(Ct,Wt)|0,O=O+Math.imul(Ct,Kt)|0,S=S+Math.imul(yt,Jt)|0,g=g+Math.imul(yt,Xt)|0,g=g+Math.imul(At,Jt)|0,O=O+Math.imul(At,Xt)|0,S=S+Math.imul(_t,Zt)|0,g=g+Math.imul(_t,Yt)|0,g=g+Math.imul(Et,Zt)|0,O=O+Math.imul(Et,Yt)|0,S=S+Math.imul($t,Qt)|0,g=g+Math.imul($t,qt)|0,g=g+Math.imul(xt,Qt)|0,O=O+Math.imul(xt,qt)|0,S=S+Math.imul(Pt,te)|0,g=g+Math.imul(Pt,Pe)|0,g=g+Math.imul(It,te)|0,O=O+Math.imul(It,Pe)|0,S=S+Math.imul(ct,Oe)|0,g=g+Math.imul(ct,le)|0,g=g+Math.imul(at,Oe)|0,O=O+Math.imul(at,le)|0;var On=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(On>>>26)|0,On&=67108863,S=Math.imul(Ot,Wt),g=Math.imul(Ot,Kt),g=g+Math.imul(Nt,Wt)|0,O=Math.imul(Nt,Kt),S=S+Math.imul(wt,Jt)|0,g=g+Math.imul(wt,Xt)|0,g=g+Math.imul(Ct,Jt)|0,O=O+Math.imul(Ct,Xt)|0,S=S+Math.imul(yt,Zt)|0,g=g+Math.imul(yt,Yt)|0,g=g+Math.imul(At,Zt)|0,O=O+Math.imul(At,Yt)|0,S=S+Math.imul(_t,Qt)|0,g=g+Math.imul(_t,qt)|0,g=g+Math.imul(Et,Qt)|0,O=O+Math.imul(Et,qt)|0,S=S+Math.imul($t,te)|0,g=g+Math.imul($t,Pe)|0,g=g+Math.imul(xt,te)|0,O=O+Math.imul(xt,Pe)|0,S=S+Math.imul(Pt,Oe)|0,g=g+Math.imul(Pt,le)|0,g=g+Math.imul(It,Oe)|0,O=O+Math.imul(It,le)|0;var Nn=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,S=Math.imul(Ot,Jt),g=Math.imul(Ot,Xt),g=g+Math.imul(Nt,Jt)|0,O=Math.imul(Nt,Xt),S=S+Math.imul(wt,Zt)|0,g=g+Math.imul(wt,Yt)|0,g=g+Math.imul(Ct,Zt)|0,O=O+Math.imul(Ct,Yt)|0,S=S+Math.imul(yt,Qt)|0,g=g+Math.imul(yt,qt)|0,g=g+Math.imul(At,Qt)|0,O=O+Math.imul(At,qt)|0,S=S+Math.imul(_t,te)|0,g=g+Math.imul(_t,Pe)|0,g=g+Math.imul(Et,te)|0,O=O+Math.imul(Et,Pe)|0,S=S+Math.imul($t,Oe)|0,g=g+Math.imul($t,le)|0,g=g+Math.imul(xt,Oe)|0,O=O+Math.imul(xt,le)|0;var Ar=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(Ar>>>26)|0,Ar&=67108863,S=Math.imul(Ot,Zt),g=Math.imul(Ot,Yt),g=g+Math.imul(Nt,Zt)|0,O=Math.imul(Nt,Yt),S=S+Math.imul(wt,Qt)|0,g=g+Math.imul(wt,qt)|0,g=g+Math.imul(Ct,Qt)|0,O=O+Math.imul(Ct,qt)|0,S=S+Math.imul(yt,te)|0,g=g+Math.imul(yt,Pe)|0,g=g+Math.imul(At,te)|0,O=O+Math.imul(At,Pe)|0,S=S+Math.imul(_t,Oe)|0,g=g+Math.imul(_t,le)|0,g=g+Math.imul(Et,Oe)|0,O=O+Math.imul(Et,le)|0;var rs=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(rs>>>26)|0,rs&=67108863,S=Math.imul(Ot,Qt),g=Math.imul(Ot,qt),g=g+Math.imul(Nt,Qt)|0,O=Math.imul(Nt,qt),S=S+Math.imul(wt,te)|0,g=g+Math.imul(wt,Pe)|0,g=g+Math.imul(Ct,te)|0,O=O+Math.imul(Ct,Pe)|0,S=S+Math.imul(yt,Oe)|0,g=g+Math.imul(yt,le)|0,g=g+Math.imul(At,Oe)|0,O=O+Math.imul(At,le)|0;var is=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(is>>>26)|0,is&=67108863,S=Math.imul(Ot,te),g=Math.imul(Ot,Pe),g=g+Math.imul(Nt,te)|0,O=Math.imul(Nt,Pe),S=S+Math.imul(wt,Oe)|0,g=g+Math.imul(wt,le)|0,g=g+Math.imul(Ct,Oe)|0,O=O+Math.imul(Ct,le)|0;var ns=(q+S|0)+((g&8191)<<13)|0;q=(O+(g>>>13)|0)+(ns>>>26)|0,ns&=67108863,S=Math.imul(Ot,Oe),g=Math.imul(Ot,le),g=g+Math.imul(Nt,Oe)|0,O=Math.imul(Nt,le);var ss=(q+S|0)+((g&8191)<<13)|0;return q=(O+(g>>>13)|0)+(ss>>>26)|0,ss&=67108863,N[0]=si,N[1]=oi,N[2]=ai,N[3]=ui,N[4]=ci,N[5]=or,N[6]=qi,N[7]=Zn,N[8]=ji,N[9]=ts,N[10]=es,N[11]=$i,N[12]=On,N[13]=Nn,N[14]=Ar,N[15]=rs,N[16]=is,N[17]=ns,N[18]=ss,q!==0&&(N[19]=q,b.length++),b};Math.imul||(K=tt);function V(h,y,b){b.negative=y.negative^h.negative,b.length=h.length+y.length;for(var C=0,M=0,N=0;N<b.length-1;N++){var q=M;M=0;for(var S=C&67108863,g=Math.min(N,y.length-1),O=Math.max(0,N-h.length+1);O<=g;O++){var it=N-O,lt=h.words[it]|0,_=y.words[O]|0,Z=lt*_,U=Z&67108863;q=q+(Z/67108864|0)|0,U=U+S|0,S=U&67108863,q=q+(U>>>26)|0,M+=q>>>26,q&=67108863}b.words[N]=S,C=q,q=M}return C!==0?b.words[N]=C:b.length--,b._strip()}function B(h,y,b){return V(h,y,b)}a.prototype.mulTo=function(h,y){var b,C=this.length+h.length;return this.length===10&&h.length===10?b=K(this,h,y):C<63?b=tt(this,h,y):C<1024?b=V(this,h,y):b=B(this,h,y),b},a.prototype.mul=function(h){var y=new a(null);return y.words=new Array(this.length+h.length),this.mulTo(h,y)},a.prototype.mulf=function(h){var y=new a(null);return y.words=new Array(this.length+h.length),B(this,h,y)},a.prototype.imul=function(h){return this.clone().mulTo(h,this)},a.prototype.imuln=function(h){var y=h<0;y&&(h=-h),n(typeof h=="number"),n(h<67108864);for(var b=0,C=0;C<this.length;C++){var M=(this.words[C]|0)*h,N=(M&67108863)+(b&67108863);b>>=26,b+=M/67108864|0,b+=N>>>26,this.words[C]=N&67108863}return b!==0&&(this.words[C]=b,this.length++),y?this.ineg():this},a.prototype.muln=function(h){return this.clone().imuln(h)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(h){var y=W(h);if(y.length===0)return new a(1);for(var b=this,C=0;C<y.length&&y[C]===0;C++,b=b.sqr());if(++C<y.length)for(var M=b.sqr();C<y.length;C++,M=M.sqr())y[C]!==0&&(b=b.mul(M));return b},a.prototype.iushln=function(h){n(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26,C=67108863>>>26-y<<26-y,M;if(y!==0){var N=0;for(M=0;M<this.length;M++){var q=this.words[M]&C,S=(this.words[M]|0)-q<<y;this.words[M]=S|N,N=q>>>26-y}N&&(this.words[M]=N,this.length++)}if(b!==0){for(M=this.length-1;M>=0;M--)this.words[M+b]=this.words[M];for(M=0;M<b;M++)this.words[M]=0;this.length+=b}return this._strip()},a.prototype.ishln=function(h){return n(this.negative===0),this.iushln(h)},a.prototype.iushrn=function(h,y,b){n(typeof h=="number"&&h>=0);var C;y?C=(y-y%26)/26:C=0;var M=h%26,N=Math.min((h-M)/26,this.length),q=67108863^67108863>>>M<<M,S=b;if(C-=N,C=Math.max(0,C),S){for(var g=0;g<N;g++)S.words[g]=this.words[g];S.length=N}if(N!==0)if(this.length>N)for(this.length-=N,g=0;g<this.length;g++)this.words[g]=this.words[g+N];else this.words[0]=0,this.length=1;var O=0;for(g=this.length-1;g>=0&&(O!==0||g>=C);g--){var it=this.words[g]|0;this.words[g]=O<<26-M|it>>>M,O=it&q}return S&&O!==0&&(S.words[S.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(h,y,b){return n(this.negative===0),this.iushrn(h,y,b)},a.prototype.shln=function(h){return this.clone().ishln(h)},a.prototype.ushln=function(h){return this.clone().iushln(h)},a.prototype.shrn=function(h){return this.clone().ishrn(h)},a.prototype.ushrn=function(h){return this.clone().iushrn(h)},a.prototype.testn=function(h){n(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26,C=1<<y;if(this.length<=b)return!1;var M=this.words[b];return!!(M&C)},a.prototype.imaskn=function(h){n(typeof h=="number"&&h>=0);var y=h%26,b=(h-y)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(y!==0&&b++,this.length=Math.min(b,this.length),y!==0){var C=67108863^67108863>>>y<<y;this.words[this.length-1]&=C}return this._strip()},a.prototype.maskn=function(h){return this.clone().imaskn(h)},a.prototype.iaddn=function(h){return n(typeof h=="number"),n(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<=h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},a.prototype._iaddn=function(h){this.words[0]+=h;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},a.prototype.isubn=function(h){if(n(typeof h=="number"),n(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},a.prototype.addn=function(h){return this.clone().iaddn(h)},a.prototype.subn=function(h){return this.clone().isubn(h)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(h,y,b){var C=h.length+b,M;this._expand(C);var N,q=0;for(M=0;M<h.length;M++){N=(this.words[M+b]|0)+q;var S=(h.words[M]|0)*y;N-=S&67108863,q=(N>>26)-(S/67108864|0),this.words[M+b]=N&67108863}for(;M<this.length-b;M++)N=(this.words[M+b]|0)+q,q=N>>26,this.words[M+b]=N&67108863;if(q===0)return this._strip();for(n(q===-1),q=0,M=0;M<this.length;M++)N=-(this.words[M]|0)+q,q=N>>26,this.words[M]=N&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(h,y){var b=this.length-h.length,C=this.clone(),M=h,N=M.words[M.length-1]|0,q=this._countBits(N);b=26-q,b!==0&&(M=M.ushln(b),C.iushln(b),N=M.words[M.length-1]|0);var S=C.length-M.length,g;if(y!=="mod"){g=new a(null),g.length=S+1,g.words=new Array(g.length);for(var O=0;O<g.length;O++)g.words[O]=0}var it=C.clone()._ishlnsubmul(M,1,S);it.negative===0&&(C=it,g&&(g.words[S]=1));for(var lt=S-1;lt>=0;lt--){var _=(C.words[M.length+lt]|0)*67108864+(C.words[M.length+lt-1]|0);for(_=Math.min(_/N|0,67108863),C._ishlnsubmul(M,_,lt);C.negative!==0;)_--,C.negative=0,C._ishlnsubmul(M,1,lt),C.isZero()||(C.negative^=1);g&&(g.words[lt]=_)}return g&&g._strip(),C._strip(),y!=="div"&&b!==0&&C.iushrn(b),{div:g||null,mod:C}},a.prototype.divmod=function(h,y,b){if(n(!h.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var C,M,N;return this.negative!==0&&h.negative===0?(N=this.neg().divmod(h,y),y!=="mod"&&(C=N.div.neg()),y!=="div"&&(M=N.mod.neg(),b&&M.negative!==0&&M.iadd(h)),{div:C,mod:M}):this.negative===0&&h.negative!==0?(N=this.divmod(h.neg(),y),y!=="mod"&&(C=N.div.neg()),{div:C,mod:N.mod}):this.negative&h.negative?(N=this.neg().divmod(h.neg(),y),y!=="div"&&(M=N.mod.neg(),b&&M.negative!==0&&M.isub(h)),{div:N.div,mod:M}):h.length>this.length||this.cmp(h)<0?{div:new a(0),mod:this}:h.length===1?y==="div"?{div:this.divn(h.words[0]),mod:null}:y==="mod"?{div:null,mod:new a(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new a(this.modrn(h.words[0]))}:this._wordDiv(h,y)},a.prototype.div=function(h){return this.divmod(h,"div",!1).div},a.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},a.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},a.prototype.divRound=function(h){var y=this.divmod(h);if(y.mod.isZero())return y.div;var b=y.div.negative!==0?y.mod.isub(h):y.mod,C=h.ushrn(1),M=h.andln(1),N=b.cmp(C);return N<0||M===1&&N===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},a.prototype.modrn=function(h){var y=h<0;y&&(h=-h),n(h<=67108863);for(var b=(1<<26)%h,C=0,M=this.length-1;M>=0;M--)C=(b*C+(this.words[M]|0))%h;return y?-C:C},a.prototype.modn=function(h){return this.modrn(h)},a.prototype.idivn=function(h){var y=h<0;y&&(h=-h),n(h<=67108863);for(var b=0,C=this.length-1;C>=0;C--){var M=(this.words[C]|0)+b*67108864;this.words[C]=M/h|0,b=M%h}return this._strip(),y?this.ineg():this},a.prototype.divn=function(h){return this.clone().idivn(h)},a.prototype.egcd=function(h){n(h.negative===0),n(!h.isZero());var y=this,b=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var C=new a(1),M=new a(0),N=new a(0),q=new a(1),S=0;y.isEven()&&b.isEven();)y.iushrn(1),b.iushrn(1),++S;for(var g=b.clone(),O=y.clone();!y.isZero();){for(var it=0,lt=1;!(y.words[0]&lt)&&it<26;++it,lt<<=1);if(it>0)for(y.iushrn(it);it-- >0;)(C.isOdd()||M.isOdd())&&(C.iadd(g),M.isub(O)),C.iushrn(1),M.iushrn(1);for(var _=0,Z=1;!(b.words[0]&Z)&&_<26;++_,Z<<=1);if(_>0)for(b.iushrn(_);_-- >0;)(N.isOdd()||q.isOdd())&&(N.iadd(g),q.isub(O)),N.iushrn(1),q.iushrn(1);y.cmp(b)>=0?(y.isub(b),C.isub(N),M.isub(q)):(b.isub(y),N.isub(C),q.isub(M))}return{a:N,b:q,gcd:b.iushln(S)}},a.prototype._invmp=function(h){n(h.negative===0),n(!h.isZero());var y=this,b=h.clone();y.negative!==0?y=y.umod(h):y=y.clone();for(var C=new a(1),M=new a(0),N=b.clone();y.cmpn(1)>0&&b.cmpn(1)>0;){for(var q=0,S=1;!(y.words[0]&S)&&q<26;++q,S<<=1);if(q>0)for(y.iushrn(q);q-- >0;)C.isOdd()&&C.iadd(N),C.iushrn(1);for(var g=0,O=1;!(b.words[0]&O)&&g<26;++g,O<<=1);if(g>0)for(b.iushrn(g);g-- >0;)M.isOdd()&&M.iadd(N),M.iushrn(1);y.cmp(b)>=0?(y.isub(b),C.isub(M)):(b.isub(y),M.isub(C))}var it;return y.cmpn(1)===0?it=C:it=M,it.cmpn(0)<0&&it.iadd(h),it},a.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var y=this.clone(),b=h.clone();y.negative=0,b.negative=0;for(var C=0;y.isEven()&&b.isEven();C++)y.iushrn(1),b.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;b.isEven();)b.iushrn(1);var M=y.cmp(b);if(M<0){var N=y;y=b,b=N}else if(M===0||b.cmpn(1)===0)break;y.isub(b)}while(!0);return b.iushln(C)},a.prototype.invm=function(h){return this.egcd(h).a.umod(h)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(h){return this.words[0]&h},a.prototype.bincn=function(h){n(typeof h=="number");var y=h%26,b=(h-y)/26,C=1<<y;if(this.length<=b)return this._expand(b+1),this.words[b]|=C,this;for(var M=C,N=b;M!==0&&N<this.length;N++){var q=this.words[N]|0;q+=M,M=q>>>26,q&=67108863,this.words[N]=q}return M!==0&&(this.words[N]=M,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(h){var y=h<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var b;if(this.length>1)b=1;else{y&&(h=-h),n(h<=67108863,"Number is too big");var C=this.words[0]|0;b=C===h?0:C<h?-1:1}return this.negative!==0?-b|0:b},a.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var y=this.ucmp(h);return this.negative!==0?-y|0:y},a.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var y=0,b=this.length-1;b>=0;b--){var C=this.words[b]|0,M=h.words[b]|0;if(C!==M){C<M?y=-1:C>M&&(y=1);break}}return y},a.prototype.gtn=function(h){return this.cmpn(h)===1},a.prototype.gt=function(h){return this.cmp(h)===1},a.prototype.gten=function(h){return this.cmpn(h)>=0},a.prototype.gte=function(h){return this.cmp(h)>=0},a.prototype.ltn=function(h){return this.cmpn(h)===-1},a.prototype.lt=function(h){return this.cmp(h)===-1},a.prototype.lten=function(h){return this.cmpn(h)<=0},a.prototype.lte=function(h){return this.cmp(h)<=0},a.prototype.eqn=function(h){return this.cmpn(h)===0},a.prototype.eq=function(h){return this.cmp(h)===0},a.red=function(h){return new pt(h)},a.prototype.toRed=function(h){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},a.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(h){return this.red=h,this},a.prototype.forceRed=function(h){return n(!this.red,"Already a number in reduction context"),this._forceRed(h)},a.prototype.redAdd=function(h){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},a.prototype.redIAdd=function(h){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},a.prototype.redSub=function(h){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},a.prototype.redISub=function(h){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},a.prototype.redShl=function(h){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},a.prototype.redMul=function(h){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},a.prototype.redIMul=function(h){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},a.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(h){return n(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var z={k256:null,p224:null,p192:null,p25519:null};function $(h,y){this.name=h,this.p=new a(y,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}$.prototype._tmp=function(){var h=new a(null);return h.words=new Array(Math.ceil(this.n/13)),h},$.prototype.ireduce=function(h){var y=h,b;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),b=y.bitLength();while(b>this.n);var C=b<this.n?-1:y.ucmp(this.p);return C===0?(y.words[0]=0,y.length=1):C>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},$.prototype.split=function(h,y){h.iushrn(this.n,0,y)},$.prototype.imulK=function(h){return h.imul(this.k)};function v(){$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(v,$),v.prototype.split=function(h,y){for(var b=4194303,C=Math.min(h.length,9),M=0;M<C;M++)y.words[M]=h.words[M];if(y.length=C,h.length<=9){h.words[0]=0,h.length=1;return}var N=h.words[9];for(y.words[y.length++]=N&b,M=10;M<h.length;M++){var q=h.words[M]|0;h.words[M-10]=(q&b)<<4|N>>>22,N=q}N>>>=22,h.words[M-10]=N,N===0&&h.length>10?h.length-=10:h.length-=9},v.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var y=0,b=0;b<h.length;b++){var C=h.words[b]|0;y+=C*977,h.words[b]=y&67108863,y=C*64+(y/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function T(){$.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(T,$);function st(){$.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(st,$);function ft(){$.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ft,$),ft.prototype.imulK=function(h){for(var y=0,b=0;b<h.length;b++){var C=(h.words[b]|0)*19+y,M=C&67108863;C>>>=26,h.words[b]=M,y=C}return y!==0&&(h.words[h.length++]=y),h},a._prime=function(h){if(z[h])return z[h];var y;if(h==="k256")y=new v;else if(h==="p224")y=new T;else if(h==="p192")y=new st;else if(h==="p25519")y=new ft;else throw new Error("Unknown prime "+h);return z[h]=y,y};function pt(h){if(typeof h=="string"){var y=a._prime(h);this.m=y.p,this.prime=y}else n(h.gtn(1),"modulus must be greater than 1"),this.m=h,this.prime=null}pt.prototype._verify1=function(h){n(h.negative===0,"red works only with positives"),n(h.red,"red works only with red numbers")},pt.prototype._verify2=function(h,y){n((h.negative|y.negative)===0,"red works only with positives"),n(h.red&&h.red===y.red,"red works only with red numbers")},pt.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(w(h,h.umod(this.m)._forceRed(this)),h)},pt.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},pt.prototype.add=function(h,y){this._verify2(h,y);var b=h.add(y);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},pt.prototype.iadd=function(h,y){this._verify2(h,y);var b=h.iadd(y);return b.cmp(this.m)>=0&&b.isub(this.m),b},pt.prototype.sub=function(h,y){this._verify2(h,y);var b=h.sub(y);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},pt.prototype.isub=function(h,y){this._verify2(h,y);var b=h.isub(y);return b.cmpn(0)<0&&b.iadd(this.m),b},pt.prototype.shl=function(h,y){return this._verify1(h),this.imod(h.ushln(y))},pt.prototype.imul=function(h,y){return this._verify2(h,y),this.imod(h.imul(y))},pt.prototype.mul=function(h,y){return this._verify2(h,y),this.imod(h.mul(y))},pt.prototype.isqr=function(h){return this.imul(h,h.clone())},pt.prototype.sqr=function(h){return this.mul(h,h)},pt.prototype.sqrt=function(h){if(h.isZero())return h.clone();var y=this.m.andln(3);if(n(y%2===1),y===3){var b=this.m.add(new a(1)).iushrn(2);return this.pow(h,b)}for(var C=this.m.subn(1),M=0;!C.isZero()&&C.andln(1)===0;)M++,C.iushrn(1);n(!C.isZero());var N=new a(1).toRed(this),q=N.redNeg(),S=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new a(2*g*g).toRed(this);this.pow(g,S).cmp(q)!==0;)g.redIAdd(q);for(var O=this.pow(g,C),it=this.pow(h,C.addn(1).iushrn(1)),lt=this.pow(h,C),_=M;lt.cmp(N)!==0;){for(var Z=lt,U=0;Z.cmp(N)!==0;U++)Z=Z.redSqr();n(U<_);var L=this.pow(O,new a(1).iushln(_-U-1));it=it.redMul(L),O=L.redSqr(),lt=lt.redMul(O),_=U}return it},pt.prototype.invm=function(h){var y=h._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},pt.prototype.pow=function(h,y){if(y.isZero())return new a(1).toRed(this);if(y.cmpn(1)===0)return h.clone();var b=4,C=new Array(1<<b);C[0]=new a(1).toRed(this),C[1]=h;for(var M=2;M<C.length;M++)C[M]=this.mul(C[M-1],h);var N=C[0],q=0,S=0,g=y.bitLength()%26;for(g===0&&(g=26),M=y.length-1;M>=0;M--){for(var O=y.words[M],it=g-1;it>=0;it--){var lt=O>>it&1;if(N!==C[0]&&(N=this.sqr(N)),lt===0&&q===0){S=0;continue}q<<=1,q|=lt,S++,!(S!==b&&(M!==0||it!==0))&&(N=this.mul(N,C[q]),S=0,q=0)}g=26}return N},pt.prototype.convertTo=function(h){var y=h.umod(this.m);return y===h?y.clone():y},pt.prototype.convertFrom=function(h){var y=h.clone();return y.red=null,y},a.mont=function(h){return new gt(h)};function gt(h){pt.call(this,h),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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)}s(gt,pt),gt.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},gt.prototype.convertFrom=function(h){var y=this.imod(h.mul(this.rinv));return y.red=null,y},gt.prototype.imul=function(h,y){if(h.isZero()||y.isZero())return h.words[0]=0,h.length=1,h;var b=h.imul(y),C=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),M=b.isub(C).iushrn(this.shift),N=M;return M.cmp(this.m)>=0?N=M.isub(this.m):M.cmpn(0)<0&&(N=M.iadd(this.m)),N._forceRed(this)},gt.prototype.mul=function(h,y){if(h.isZero()||y.isZero())return new a(0)._forceRed(this);var b=h.mul(y),C=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),M=b.isub(C).iushrn(this.shift),N=M;return M.cmp(this.m)>=0?N=M.isub(this.m):M.cmpn(0)<0&&(N=M.iadd(this.m)),N._forceRed(this)},gt.prototype.invm=function(h){var y=this.imod(h._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(r,X1)})(rg);var ne=rg.exports;const ig="bignumber/5.7.0";var Yu=ne.BN;const Sn=new pr(ig),Bh={},Vd=9007199254740991;function r5(r){return r!=null&&(Tr.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||ri(r)||typeof r=="bigint"||vo(r))}let Gd=!1,Tr=class Fi{constructor(t,e){t!==Bh&&Sn.throwError("cannot call constructor directly; use BigNumber.from",pr.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return jr(me(this).fromTwos(t))}toTwos(t){return jr(me(this).toTwos(t))}abs(){return this._hex[0]==="-"?Fi.from(this._hex.substring(1)):this}add(t){return jr(me(this).add(me(t)))}sub(t){return jr(me(this).sub(me(t)))}div(t){return Fi.from(t).isZero()&&yi("division-by-zero","div"),jr(me(this).div(me(t)))}mul(t){return jr(me(this).mul(me(t)))}mod(t){const e=me(t);return e.isNeg()&&yi("division-by-zero","mod"),jr(me(this).umod(e))}pow(t){const e=me(t);return e.isNeg()&&yi("negative-power","pow"),jr(me(this).pow(e))}and(t){const e=me(t);return(this.isNegative()||e.isNeg())&&yi("unbound-bitwise-result","and"),jr(me(this).and(e))}or(t){const e=me(t);return(this.isNegative()||e.isNeg())&&yi("unbound-bitwise-result","or"),jr(me(this).or(e))}xor(t){const e=me(t);return(this.isNegative()||e.isNeg())&&yi("unbound-bitwise-result","xor"),jr(me(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&yi("negative-width","mask"),jr(me(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&yi("negative-width","shl"),jr(me(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&yi("negative-width","shr"),jr(me(this).shrn(t))}eq(t){return me(this).eq(me(t))}lt(t){return me(this).lt(me(t))}lte(t){return me(this).lte(me(t))}gt(t){return me(this).gt(me(t))}gte(t){return me(this).gte(me(t))}isNegative(){return this._hex[0]==="-"}isZero(){return me(this).isZero()}toNumber(){try{return me(this).toNumber()}catch{yi("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return Sn.throwError("this platform does not support BigInt",pr.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Gd||(Gd=!0,Sn.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Sn.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",pr.errors.UNEXPECTED_ARGUMENT,{}):Sn.throwError("BigNumber.toString does not accept parameters",pr.errors.UNEXPECTED_ARGUMENT,{})),me(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof Fi)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new Fi(Bh,aa(t)):t.match(/^-?[0-9]+$/)?new Fi(Bh,aa(new Yu(t))):Sn.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&yi("underflow","BigNumber.from",t),(t>=Vd||t<=-Vd)&&yi("overflow","BigNumber.from",t),Fi.from(String(t));const e=t;if(typeof e=="bigint")return Fi.from(e.toString());if(vo(e))return Fi.from(Cr(e));if(e)if(e.toHexString){const n=e.toHexString();if(typeof n=="string")return Fi.from(n)}else{let n=e._hex;if(n==null&&e.type==="BigNumber"&&(n=e.hex),typeof n=="string"&&(ri(n)||n[0]==="-"&&ri(n.substring(1))))return Fi.from(n)}return Sn.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}};function aa(r){if(typeof r!="string")return aa(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&Sn.throwArgumentError("invalid hex","value",r),r=aa(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 jr(r){return Tr.from(aa(r))}function me(r){const t=Tr.from(r).toHexString();return t[0]==="-"?new Yu("-"+t.substring(3),16):new Yu(t.substring(2),16)}function yi(r,t,e){const n={fault:r,operation:t};return e!=null&&(n.value=e),Sn.throwError(r,pr.errors.NUMERIC_FAULT,n)}function i5(r){return new Yu(r,36).toString(16)}const Pr=new pr(ig),ea={},ng=Tr.from(0),sg=Tr.from(-1);function og(r,t,e,n){const s={fault:t,operation:e};return n!==void 0&&(s.value=n),Pr.throwError(r,pr.errors.NUMERIC_FAULT,s)}let ra="0";for(;ra.length<256;)ra+=ra;function Yl(r){if(typeof r!="number")try{r=Tr.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+ra.substring(0,r):Pr.throwArgumentError("invalid decimal size","decimals",r)}function Lh(r,t){t==null&&(t=0);const e=Yl(t);r=Tr.from(r);const n=r.lt(ng);n&&(r=r.mul(sg));let s=r.mod(e).toString();for(;s.length<e.length-1;)s="0"+s;s=s.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=r.div(e).toString();return e.length===1?r=a:r=a+"."+s,n&&(r="-"+r),r}function bn(r,t){t==null&&(t=0);const e=Yl(t);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Pr.throwArgumentError("invalid decimal value","value",r);const n=r.substring(0,1)==="-";n&&(r=r.substring(1)),r==="."&&Pr.throwArgumentError("missing value","value",r);const s=r.split(".");s.length>2&&Pr.throwArgumentError("too many decimal points","value",r);let a=s[0],c=s[1];for(a||(a="0"),c||(c="0");c[c.length-1]==="0";)c=c.substring(0,c.length-1);for(c.length>e.length-1&&og("fractional component exceeds decimals","underflow","parseFixed"),c===""&&(c="0");c.length<e.length-1;)c+="0";const l=Tr.from(a),d=Tr.from(c);let f=l.mul(e).add(d);return n&&(f=f.mul(sg)),f}let qh=class _l{constructor(t,e,n,s){t!==ea&&Pr.throwError("cannot use FixedFormat constructor; use FixedFormat.from",pr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=e,this.width=n,this.decimals=s,this.name=(e?"":"u")+"fixed"+String(n)+"x"+String(s),this._multiplier=Yl(s),Object.freeze(this)}static from(t){if(t instanceof _l)return t;typeof t=="number"&&(t=`fixed128x${t}`);let e=!0,n=128,s=18;if(typeof t=="string"){if(t!=="fixed")if(t==="ufixed")e=!1;else{const a=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);a||Pr.throwArgumentError("invalid fixed format","format",t),e=a[1]!=="u",n=parseInt(a[2]),s=parseInt(a[3])}}else if(t){const a=(c,l,d)=>t[c]==null?d:(typeof t[c]!==l&&Pr.throwArgumentError("invalid fixed format ("+c+" not "+l+")","format."+c,t[c]),t[c]);e=a("signed","boolean",e),n=a("width","number",n),s=a("decimals","number",s)}return n%8&&Pr.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",n),s>80&&Pr.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",s),new _l(ea,e,n,s)}},ag=class Mr{constructor(t,e,n,s){t!==ea&&Pr.throwError("cannot use FixedNumber constructor; use FixedNumber.from",pr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=s,this._hex=e,this._value=n,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&Pr.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),n=bn(t._value,t.format.decimals);return Mr.fromValue(e.add(n),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),n=bn(t._value,t.format.decimals);return Mr.fromValue(e.sub(n),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),n=bn(t._value,t.format.decimals);return Mr.fromValue(e.mul(n).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const e=bn(this._value,this.format.decimals),n=bn(t._value,t.format.decimals);return Mr.fromValue(e.mul(this.format._multiplier).div(n),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");t.length===1&&t.push("0");let e=Mr.from(t[0],this.format);const n=!t[1].match(/^(0*)$/);return this.isNegative()&&n&&(e=e.subUnsafe(Wd.toFormat(e.format))),e}ceiling(){const t=this.toString().split(".");t.length===1&&t.push("0");let e=Mr.from(t[0],this.format);const n=!t[1].match(/^(0*)$/);return!this.isNegative()&&n&&(e=e.addUnsafe(Wd.toFormat(e.format))),e}round(t){t==null&&(t=0);const e=this.toString().split(".");if(e.length===1&&e.push("0"),(t<0||t>80||t%1)&&Pr.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;const n=Mr.from("1"+ra.substring(0,t),this.format),s=n5.toFormat(this.format);return this.mulUnsafe(n).addUnsafe(s).floor().divUnsafe(n)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(t){if(t==null)return this._hex;t%8&&Pr.throwArgumentError("invalid byte width","width",t);const e=Tr.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return rn(e,t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return Mr.fromString(this._value,t)}static fromValue(t,e,n){return n==null&&e!=null&&!r5(e)&&(n=e,e=null),e==null&&(e=0),n==null&&(n="fixed"),Mr.fromString(Lh(t,e),qh.from(n))}static fromString(t,e){e==null&&(e="fixed");const n=qh.from(e),s=bn(t,n.decimals);!n.signed&&s.lt(ng)&&og("unsigned value cannot be negative","overflow","value",t);let a=null;n.signed?a=s.toTwos(n.width).toHexString():(a=s.toHexString(),a=rn(a,n.width/8));const c=Lh(s,n.decimals);return new Mr(ea,a,c,n)}static fromBytes(t,e){e==null&&(e="fixed");const n=qh.from(e);if(Ye(t).length>n.width/8)throw new Error("overflow");let s=Tr.from(t);n.signed&&(s=s.fromTwos(n.width));const a=s.toTwos((n.signed?0:1)+n.width).toHexString(),c=Lh(s,n.decimals);return new Mr(ea,a,c,n)}static from(t,e){if(typeof t=="string")return Mr.fromString(t,e);if(vo(t))return Mr.fromBytes(t,e);try{return Mr.fromValue(t,0,e)}catch(n){if(n.code!==pr.errors.INVALID_ARGUMENT)throw n}return Pr.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}};const Wd=ag.from(1),n5=ag.from("0.5"),s5="strings/5.7.0",o5=new pr(s5);var Qu;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Qu||(Qu={}));var Yd;(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"})(Yd||(Yd={}));function jh(r,t=Qu.current){t!=Qu.current&&(o5.checkNormalize(),r=r.normalize(t));let e=[];for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);if(s<128)e.push(s);else if(s<2048)e.push(s>>6|192),e.push(s&63|128);else if((s&64512)==55296){n++;const a=r.charCodeAt(n);if(n>=r.length||(a&64512)!==56320)throw new Error("invalid utf-8 string");const c=65536+((s&1023)<<10)+(a&1023);e.push(c>>18|240),e.push(c>>12&63|128),e.push(c>>6&63|128),e.push(c&63|128)}else e.push(s>>12|224),e.push(s>>6&63|128),e.push(s&63|128)}return Ye(e)}function a5(r){if(r.length%4!==0)throw new Error("bad data");let t=[];for(let e=0;e<r.length;e+=4)t.push(parseInt(r.substring(e,e+4),16));return t}function $h(r,t){t||(t=function(s){return[parseInt(s,16)]});let e=0,n={};return r.split(",").forEach(s=>{let a=s.split(":");e+=parseInt(a[0],16),n[e]=t(a[1])}),n}function Qd(r){let t=0;return r.split(",").map(e=>{let n=e.split("-");n.length===1?n[1]="0":n[1]===""&&(n[1]="1");let s=t+parseInt(n[0],16);return t=parseInt(n[1],16),{l:s,h:t}})}Qd("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)),$h("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"),$h("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"),$h("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",a5),Qd("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function u5(r){r=atob(r);const t=[];for(let e=0;e<r.length;e++)t.push(r.charCodeAt(e));return Ye(t)}function ug(r,t){t==null&&(t=1);const e=[],n=e.forEach,s=function(a,c){n.call(a,function(l){c>0&&Array.isArray(l)?s(l,c-1):e.push(l)})};return s(r,t),e}function c5(r){const t={};for(let e=0;e<r.length;e++){const n=r[e];t[n[0]]=n[1]}return t}function h5(r){let t=0;function e(){return r[t++]<<8|r[t++]}let n=e(),s=1,a=[0,1];for(let z=1;z<n;z++)a.push(s+=e());let c=e(),l=t;t+=c;let d=0,f=0;function w(){return d==0&&(f=f<<8|r[t++],d=8),f>>--d&1}const E=31,x=Math.pow(2,E),I=x>>>1,R=I>>1,Y=x-1;let W=0;for(let z=0;z<E;z++)W=W<<1|w();let tt=[],K=0,V=x;for(;;){let z=Math.floor(((W-K+1)*s-1)/V),$=0,v=n;for(;v-$>1;){let ft=$+v>>>1;z<a[ft]?v=ft:$=ft}if($==0)break;tt.push($);let T=K+Math.floor(V*a[$]/s),st=K+Math.floor(V*a[$+1]/s)-1;for(;!((T^st)&I);)W=W<<1&Y|w(),T=T<<1&Y,st=st<<1&Y|1;for(;T&~st&R;)W=W&I|W<<1&Y>>>1|w(),T=T<<1^I,st=(st^I)<<1|I|1;K=T,V=1+st-T}let B=n-4;return tt.map(z=>{switch(z-B){case 3:return B+65792+(r[l++]<<16|r[l++]<<8|r[l++]);case 2:return B+256+(r[l++]<<8|r[l++]);case 1:return B+r[l++];default:return z-1}})}function l5(r){let t=0;return()=>r[t++]}function f5(r){return l5(h5(r))}function d5(r){return r&1?~r>>1:r>>1}function p5(r,t){let e=Array(r);for(let n=0;n<r;n++)e[n]=1+t();return e}function Jd(r,t){let e=Array(r);for(let n=0,s=-1;n<r;n++)e[n]=s+=1+t();return e}function g5(r,t){let e=Array(r);for(let n=0,s=0;n<r;n++)e[n]=s+=d5(t());return e}function Ju(r,t){let e=Jd(r(),r),n=r(),s=Jd(n,r),a=p5(n,r);for(let c=0;c<n;c++)for(let l=0;l<a[c];l++)e.push(s[c]+l);return t?e.map(c=>t[c]):e}function m5(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(y5(e,r))}for(;;){let e=r()-1;if(e<0)break;t.push(w5(e,r))}return c5(ug(t))}function v5(r){let t=[];for(;;){let e=r();if(e==0)break;t.push(e)}return t}function cg(r,t,e){let n=Array(r).fill(void 0).map(()=>[]);for(let s=0;s<t;s++)g5(r,e).forEach((a,c)=>n[c].push(a));return n}function y5(r,t){let e=1+t(),n=t(),s=v5(t),a=cg(s.length,1+r,t);return ug(a.map((c,l)=>{const d=c[0],f=c.slice(1);return Array(s[l]).fill(void 0).map((w,E)=>{let x=E*n;return[d+E*e,f.map(I=>I+x)]})}))}function w5(r,t){let e=1+t();return cg(e,1+r,t).map(n=>[n[0],n.slice(1)])}function b5(r){let t=Ju(r).sort((n,s)=>n-s);return e();function e(){let n=[];for(;;){let f=Ju(r,t);if(f.length==0)break;n.push({set:new Set(f),node:e()})}n.sort((f,w)=>w.set.size-f.set.size);let s=r(),a=s%3;s=s/3|0;let c=!!(s&1);s>>=1;let l=s==1,d=s==2;return{branches:n,valid:a,fe0f:c,save:l,check:d}}}function _5(){return f5(u5("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 Iu=_5();new Set(Ju(Iu)),new Set(Ju(Iu)),m5(Iu),b5(Iu);const E5=new Uint8Array(32);E5.fill(0);const A5=`Ethereum Signed Message:
9
- `;function hg(r){return typeof r=="string"&&(r=jh(r)),Wl(QE([jh(A5),jh(String(r.length)),r]))}const S5="address/5.7.0",Zo=new pr(S5);function Xd(r){ri(r,20)||Zo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let s=0;s<40;s++)e[s]=t[s].charCodeAt(0);const n=Ye(Wl(e));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(n[s>>1]&15)>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const I5=9007199254740991;function D5(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Ql={};for(let r=0;r<10;r++)Ql[String(r)]=String(r);for(let r=0;r<26;r++)Ql[String.fromCharCode(65+r)]=String(10+r);const Zd=Math.floor(D5(I5));function x5(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(n=>Ql[n]).join("");for(;t.length>=Zd;){let n=t.substring(0,Zd);t=parseInt(n,10)%97+t.substring(n.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}function M5(r){let t=null;if(typeof r!="string"&&Zo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),t=Xd(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==r&&Zo.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)!==x5(r)&&Zo.throwArgumentError("bad icap checksum","address",r),t=i5(r.substring(4));t.length<40;)t="0"+t;t=Xd("0x"+t)}else Zo.throwArgumentError("invalid address","address",r);return t}function Ho(r,t,e){Object.defineProperty(r,t,{enumerable:!0,value:e,writable:!1})}const C5=new Uint8Array(32);C5.fill(0),Tr.from(-1);const P5=Tr.from(0),O5=Tr.from(1);Tr.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),rn(O5.toHexString(),32),rn(P5.toHexString(),32);var Wi={},ve={},ma=lg;function lg(r,t){if(!r)throw new Error(t||"Assertion failed")}lg.equal=function(r,t,e){if(r!=t)throw new Error(e||"Assertion failed: "+r+" != "+t)};var El={exports:{}};typeof Object.create=="function"?El.exports=function(r,t){t&&(r.super_=t,r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:El.exports=function(r,t){if(t){r.super_=t;var e=function(){};e.prototype=t.prototype,r.prototype=new e,r.prototype.constructor=r}};var N5=ma,R5=El.exports;ve.inherits=R5;function T5(r,t){return(r.charCodeAt(t)&64512)!==55296||t<0||t+1>=r.length?!1:(r.charCodeAt(t+1)&64512)===56320}function F5(r,t){if(Array.isArray(r))return r.slice();if(!r)return[];var e=[];if(typeof r=="string")if(t){if(t==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),s=0;s<r.length;s+=2)e.push(parseInt(r[s]+r[s+1],16))}else for(var n=0,s=0;s<r.length;s++){var a=r.charCodeAt(s);a<128?e[n++]=a:a<2048?(e[n++]=a>>6|192,e[n++]=a&63|128):T5(r,s)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++s)&1023),e[n++]=a>>18|240,e[n++]=a>>12&63|128,e[n++]=a>>6&63|128,e[n++]=a&63|128):(e[n++]=a>>12|224,e[n++]=a>>6&63|128,e[n++]=a&63|128)}else for(s=0;s<r.length;s++)e[s]=r[s]|0;return e}ve.toArray=F5;function U5(r){for(var t="",e=0;e<r.length;e++)t+=dg(r[e].toString(16));return t}ve.toHex=U5;function fg(r){var t=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return t>>>0}ve.htonl=fg;function B5(r,t){for(var e="",n=0;n<r.length;n++){var s=r[n];t==="little"&&(s=fg(s)),e+=pg(s.toString(16))}return e}ve.toHex32=B5;function dg(r){return r.length===1?"0"+r:r}ve.zero2=dg;function pg(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}ve.zero8=pg;function L5(r,t,e,n){var s=e-t;N5(s%4===0);for(var a=new Array(s/4),c=0,l=t;c<a.length;c++,l+=4){var d;n==="big"?d=r[l]<<24|r[l+1]<<16|r[l+2]<<8|r[l+3]:d=r[l+3]<<24|r[l+2]<<16|r[l+1]<<8|r[l],a[c]=d>>>0}return a}ve.join32=L5;function q5(r,t){for(var e=new Array(r.length*4),n=0,s=0;n<r.length;n++,s+=4){var a=r[n];t==="big"?(e[s]=a>>>24,e[s+1]=a>>>16&255,e[s+2]=a>>>8&255,e[s+3]=a&255):(e[s+3]=a>>>24,e[s+2]=a>>>16&255,e[s+1]=a>>>8&255,e[s]=a&255)}return e}ve.split32=q5;function j5(r,t){return r>>>t|r<<32-t}ve.rotr32=j5;function $5(r,t){return r<<t|r>>>32-t}ve.rotl32=$5;function z5(r,t){return r+t>>>0}ve.sum32=z5;function k5(r,t,e){return r+t+e>>>0}ve.sum32_3=k5;function H5(r,t,e,n){return r+t+e+n>>>0}ve.sum32_4=H5;function K5(r,t,e,n,s){return r+t+e+n+s>>>0}ve.sum32_5=K5;function V5(r,t,e,n){var s=r[t],a=r[t+1],c=n+a>>>0,l=(c<n?1:0)+e+s;r[t]=l>>>0,r[t+1]=c}ve.sum64=V5;function G5(r,t,e,n){var s=t+n>>>0,a=(s<t?1:0)+r+e;return a>>>0}ve.sum64_hi=G5;function W5(r,t,e,n){var s=t+n;return s>>>0}ve.sum64_lo=W5;function Y5(r,t,e,n,s,a,c,l){var d=0,f=t;f=f+n>>>0,d+=f<t?1:0,f=f+a>>>0,d+=f<a?1:0,f=f+l>>>0,d+=f<l?1:0;var w=r+e+s+c+d;return w>>>0}ve.sum64_4_hi=Y5;function Q5(r,t,e,n,s,a,c,l){var d=t+n+a+l;return d>>>0}ve.sum64_4_lo=Q5;function J5(r,t,e,n,s,a,c,l,d,f){var w=0,E=t;E=E+n>>>0,w+=E<t?1:0,E=E+a>>>0,w+=E<a?1:0,E=E+l>>>0,w+=E<l?1:0,E=E+f>>>0,w+=E<f?1:0;var x=r+e+s+c+d+w;return x>>>0}ve.sum64_5_hi=J5;function X5(r,t,e,n,s,a,c,l,d,f){var w=t+n+a+l+f;return w>>>0}ve.sum64_5_lo=X5;function Z5(r,t,e){var n=t<<32-e|r>>>e;return n>>>0}ve.rotr64_hi=Z5;function tA(r,t,e){var n=r<<32-e|t>>>e;return n>>>0}ve.rotr64_lo=tA;function eA(r,t,e){return r>>>e}ve.shr64_hi=eA;function rA(r,t,e){var n=r<<32-e|t>>>e;return n>>>0}ve.shr64_lo=rA;var yo={},tp=ve,iA=ma;function Du(){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}yo.BlockHash=Du,Du.prototype.update=function(r,t){if(r=tp.toArray(r,t),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var e=r.length%this._delta8;this.pending=r.slice(r.length-e,r.length),this.pending.length===0&&(this.pending=null),r=tp.join32(r,0,r.length-e,this.endian);for(var n=0;n<r.length;n+=this._delta32)this._update(r,n,n+this._delta32)}return this},Du.prototype.digest=function(r){return this.update(this._pad()),iA(this.pending===null),this._digest(r)},Du.prototype._pad=function(){var r=this.pendingTotal,t=this._delta8,e=t-(r+this.padLength)%t,n=new Array(e+this.padLength);n[0]=128;for(var s=1;s<e;s++)n[s]=0;if(r<<=3,this.endian==="big"){for(var a=8;a<this.padLength;a++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=r>>>24&255,n[s++]=r>>>16&255,n[s++]=r>>>8&255,n[s++]=r&255}else for(n[s++]=r&255,n[s++]=r>>>8&255,n[s++]=r>>>16&255,n[s++]=r>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,a=8;a<this.padLength;a++)n[s++]=0;return n};var ro={},cn={},nA=ve,nn=nA.rotr32;function sA(r,t,e,n){if(r===0)return gg(t,e,n);if(r===1||r===3)return vg(t,e,n);if(r===2)return mg(t,e,n)}cn.ft_1=sA;function gg(r,t,e){return r&t^~r&e}cn.ch32=gg;function mg(r,t,e){return r&t^r&e^t&e}cn.maj32=mg;function vg(r,t,e){return r^t^e}cn.p32=vg;function oA(r){return nn(r,2)^nn(r,13)^nn(r,22)}cn.s0_256=oA;function aA(r){return nn(r,6)^nn(r,11)^nn(r,25)}cn.s1_256=aA;function uA(r){return nn(r,7)^nn(r,18)^r>>>3}cn.g0_256=uA;function cA(r){return nn(r,17)^nn(r,19)^r>>>10}cn.g1_256=cA;var ho=ve,hA=yo,lA=cn,zh=ho.rotl32,Ko=ho.sum32,fA=ho.sum32_5,dA=lA.ft_1,yg=hA.BlockHash,pA=[1518500249,1859775393,2400959708,3395469782];function Zi(){if(!(this instanceof Zi))return new Zi;yg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ho.inherits(Zi,yg);var gA=Zi;Zi.blockSize=512,Zi.outSize=160,Zi.hmacStrength=80,Zi.padLength=64,Zi.prototype._update=function(r,t){for(var e=this.W,n=0;n<16;n++)e[n]=r[t+n];for(;n<e.length;n++)e[n]=zh(e[n-3]^e[n-8]^e[n-14]^e[n-16],1);var s=this.h[0],a=this.h[1],c=this.h[2],l=this.h[3],d=this.h[4];for(n=0;n<e.length;n++){var f=~~(n/20),w=fA(zh(s,5),dA(f,a,c,l),d,e[n],pA[f]);d=l,l=c,c=zh(a,30),a=s,s=w}this.h[0]=Ko(this.h[0],s),this.h[1]=Ko(this.h[1],a),this.h[2]=Ko(this.h[2],c),this.h[3]=Ko(this.h[3],l),this.h[4]=Ko(this.h[4],d)},Zi.prototype._digest=function(r){return r==="hex"?ho.toHex32(this.h,"big"):ho.split32(this.h,"big")};var lo=ve,mA=yo,wo=cn,vA=ma,Ri=lo.sum32,yA=lo.sum32_4,wA=lo.sum32_5,bA=wo.ch32,_A=wo.maj32,EA=wo.s0_256,AA=wo.s1_256,SA=wo.g0_256,IA=wo.g1_256,wg=mA.BlockHash,DA=[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 tn(){if(!(this instanceof tn))return new tn;wg.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=DA,this.W=new Array(64)}lo.inherits(tn,wg);var bg=tn;tn.blockSize=512,tn.outSize=256,tn.hmacStrength=192,tn.padLength=64,tn.prototype._update=function(r,t){for(var e=this.W,n=0;n<16;n++)e[n]=r[t+n];for(;n<e.length;n++)e[n]=yA(IA(e[n-2]),e[n-7],SA(e[n-15]),e[n-16]);var s=this.h[0],a=this.h[1],c=this.h[2],l=this.h[3],d=this.h[4],f=this.h[5],w=this.h[6],E=this.h[7];for(vA(this.k.length===e.length),n=0;n<e.length;n++){var x=wA(E,AA(d),bA(d,f,w),this.k[n],e[n]),I=Ri(EA(s),_A(s,a,c));E=w,w=f,f=d,d=Ri(l,x),l=c,c=a,a=s,s=Ri(x,I)}this.h[0]=Ri(this.h[0],s),this.h[1]=Ri(this.h[1],a),this.h[2]=Ri(this.h[2],c),this.h[3]=Ri(this.h[3],l),this.h[4]=Ri(this.h[4],d),this.h[5]=Ri(this.h[5],f),this.h[6]=Ri(this.h[6],w),this.h[7]=Ri(this.h[7],E)},tn.prototype._digest=function(r){return r==="hex"?lo.toHex32(this.h,"big"):lo.split32(this.h,"big")};var Al=ve,_g=bg;function In(){if(!(this instanceof In))return new In;_g.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Al.inherits(In,_g);var xA=In;In.blockSize=512,In.outSize=224,In.hmacStrength=192,In.padLength=64,In.prototype._digest=function(r){return r==="hex"?Al.toHex32(this.h.slice(0,7),"big"):Al.split32(this.h.slice(0,7),"big")};var Hr=ve,MA=yo,CA=ma,sn=Hr.rotr64_hi,on=Hr.rotr64_lo,Eg=Hr.shr64_hi,Ag=Hr.shr64_lo,kn=Hr.sum64,kh=Hr.sum64_hi,Hh=Hr.sum64_lo,PA=Hr.sum64_4_hi,OA=Hr.sum64_4_lo,NA=Hr.sum64_5_hi,RA=Hr.sum64_5_lo,Sg=MA.BlockHash,TA=[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 Bi(){if(!(this instanceof Bi))return new Bi;Sg.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=TA,this.W=new Array(160)}Hr.inherits(Bi,Sg);var Ig=Bi;Bi.blockSize=1024,Bi.outSize=512,Bi.hmacStrength=192,Bi.padLength=128,Bi.prototype._prepareBlock=function(r,t){for(var e=this.W,n=0;n<32;n++)e[n]=r[t+n];for(;n<e.length;n+=2){var s=KA(e[n-4],e[n-3]),a=VA(e[n-4],e[n-3]),c=e[n-14],l=e[n-13],d=kA(e[n-30],e[n-29]),f=HA(e[n-30],e[n-29]),w=e[n-32],E=e[n-31];e[n]=PA(s,a,c,l,d,f,w,E),e[n+1]=OA(s,a,c,l,d,f,w,E)}},Bi.prototype._update=function(r,t){this._prepareBlock(r,t);var e=this.W,n=this.h[0],s=this.h[1],a=this.h[2],c=this.h[3],l=this.h[4],d=this.h[5],f=this.h[6],w=this.h[7],E=this.h[8],x=this.h[9],I=this.h[10],R=this.h[11],Y=this.h[12],W=this.h[13],tt=this.h[14],K=this.h[15];CA(this.k.length===e.length);for(var V=0;V<e.length;V+=2){var B=tt,z=K,$=$A(E,x),v=zA(E,x),T=FA(E,x,I,R,Y),st=UA(E,x,I,R,Y,W),ft=this.k[V],pt=this.k[V+1],gt=e[V],h=e[V+1],y=NA(B,z,$,v,T,st,ft,pt,gt,h),b=RA(B,z,$,v,T,st,ft,pt,gt,h);B=qA(n,s),z=jA(n,s),$=BA(n,s,a,c,l),v=LA(n,s,a,c,l,d);var C=kh(B,z,$,v),M=Hh(B,z,$,v);tt=Y,K=W,Y=I,W=R,I=E,R=x,E=kh(f,w,y,b),x=Hh(w,w,y,b),f=l,w=d,l=a,d=c,a=n,c=s,n=kh(y,b,C,M),s=Hh(y,b,C,M)}kn(this.h,0,n,s),kn(this.h,2,a,c),kn(this.h,4,l,d),kn(this.h,6,f,w),kn(this.h,8,E,x),kn(this.h,10,I,R),kn(this.h,12,Y,W),kn(this.h,14,tt,K)},Bi.prototype._digest=function(r){return r==="hex"?Hr.toHex32(this.h,"big"):Hr.split32(this.h,"big")};function FA(r,t,e,n,s){var a=r&e^~r&s;return a<0&&(a+=4294967296),a}function UA(r,t,e,n,s,a){var c=t&n^~t&a;return c<0&&(c+=4294967296),c}function BA(r,t,e,n,s){var a=r&e^r&s^e&s;return a<0&&(a+=4294967296),a}function LA(r,t,e,n,s,a){var c=t&n^t&a^n&a;return c<0&&(c+=4294967296),c}function qA(r,t){var e=sn(r,t,28),n=sn(t,r,2),s=sn(t,r,7),a=e^n^s;return a<0&&(a+=4294967296),a}function jA(r,t){var e=on(r,t,28),n=on(t,r,2),s=on(t,r,7),a=e^n^s;return a<0&&(a+=4294967296),a}function $A(r,t){var e=sn(r,t,14),n=sn(r,t,18),s=sn(t,r,9),a=e^n^s;return a<0&&(a+=4294967296),a}function zA(r,t){var e=on(r,t,14),n=on(r,t,18),s=on(t,r,9),a=e^n^s;return a<0&&(a+=4294967296),a}function kA(r,t){var e=sn(r,t,1),n=sn(r,t,8),s=Eg(r,t,7),a=e^n^s;return a<0&&(a+=4294967296),a}function HA(r,t){var e=on(r,t,1),n=on(r,t,8),s=Ag(r,t,7),a=e^n^s;return a<0&&(a+=4294967296),a}function KA(r,t){var e=sn(r,t,19),n=sn(t,r,29),s=Eg(r,t,6),a=e^n^s;return a<0&&(a+=4294967296),a}function VA(r,t){var e=on(r,t,19),n=on(t,r,29),s=Ag(r,t,6),a=e^n^s;return a<0&&(a+=4294967296),a}var Sl=ve,Dg=Ig;function Dn(){if(!(this instanceof Dn))return new Dn;Dg.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Sl.inherits(Dn,Dg);var GA=Dn;Dn.blockSize=1024,Dn.outSize=384,Dn.hmacStrength=192,Dn.padLength=128,Dn.prototype._digest=function(r){return r==="hex"?Sl.toHex32(this.h.slice(0,12),"big"):Sl.split32(this.h.slice(0,12),"big")},ro.sha1=gA,ro.sha224=xA,ro.sha256=bg,ro.sha384=GA,ro.sha512=Ig;var xg={},Ds=ve,WA=yo,xu=Ds.rotl32,ep=Ds.sum32,Vo=Ds.sum32_3,rp=Ds.sum32_4,Mg=WA.BlockHash;function Yi(){if(!(this instanceof Yi))return new Yi;Mg.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Ds.inherits(Yi,Mg),xg.ripemd160=Yi,Yi.blockSize=512,Yi.outSize=160,Yi.hmacStrength=192,Yi.padLength=64,Yi.prototype._update=function(r,t){for(var e=this.h[0],n=this.h[1],s=this.h[2],a=this.h[3],c=this.h[4],l=e,d=n,f=s,w=a,E=c,x=0;x<80;x++){var I=ep(xu(rp(e,ip(x,n,s,a),r[JA[x]+t],YA(x)),ZA[x]),c);e=c,c=a,a=xu(s,10),s=n,n=I,I=ep(xu(rp(l,ip(79-x,d,f,w),r[XA[x]+t],QA(x)),t8[x]),E),l=E,E=w,w=xu(f,10),f=d,d=I}I=Vo(this.h[1],s,w),this.h[1]=Vo(this.h[2],a,E),this.h[2]=Vo(this.h[3],c,l),this.h[3]=Vo(this.h[4],e,d),this.h[4]=Vo(this.h[0],n,f),this.h[0]=I},Yi.prototype._digest=function(r){return r==="hex"?Ds.toHex32(this.h,"little"):Ds.split32(this.h,"little")};function ip(r,t,e,n){return r<=15?t^e^n:r<=31?t&e|~t&n:r<=47?(t|~e)^n:r<=63?t&n|e&~n:t^(e|~n)}function YA(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function QA(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var JA=[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],XA=[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],ZA=[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],t8=[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],e8=ve,r8=ma;function uo(r,t,e){if(!(this instanceof uo))return new uo(r,t,e);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(e8.toArray(t,e))}var i8=uo;uo.prototype._init=function(r){r.length>this.blockSize&&(r=new this.Hash().update(r).digest()),r8(r.length<=this.blockSize);for(var t=r.length;t<this.blockSize;t++)r.push(0);for(t=0;t<r.length;t++)r[t]^=54;for(this.inner=new this.Hash().update(r),t=0;t<r.length;t++)r[t]^=106;this.outer=new this.Hash().update(r)},uo.prototype.update=function(r,t){return this.inner.update(r,t),this},uo.prototype.digest=function(r){return this.outer.update(this.inner.digest()),this.outer.digest(r)},function(r){var t=r;t.utils=ve,t.common=yo,t.sha=ro,t.ripemd=xg,t.hmac=i8,t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160}(Wi);function bo(r,t,e){return e={path:t,exports:{},require:function(n,s){return n8(n,s??e.path)}},r(e,e.exports),e.exports}function n8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Jl=Cg;function Cg(r,t){if(!r)throw new Error(t||"Assertion failed")}Cg.equal=function(r,t,e){if(r!=t)throw new Error(e||"Assertion failed: "+r+" != "+t)};var Li=bo(function(r,t){var e=t;function n(c,l){if(Array.isArray(c))return c.slice();if(!c)return[];var d=[];if(typeof c!="string"){for(var f=0;f<c.length;f++)d[f]=c[f]|0;return d}if(l==="hex"){c=c.replace(/[^a-z0-9]+/ig,""),c.length%2!==0&&(c="0"+c);for(var f=0;f<c.length;f+=2)d.push(parseInt(c[f]+c[f+1],16))}else for(var f=0;f<c.length;f++){var w=c.charCodeAt(f),E=w>>8,x=w&255;E?d.push(E,x):d.push(x)}return d}e.toArray=n;function s(c){return c.length===1?"0"+c:c}e.zero2=s;function a(c){for(var l="",d=0;d<c.length;d++)l+=s(c[d].toString(16));return l}e.toHex=a,e.encode=function(c,l){return l==="hex"?a(c):c}}),ii=bo(function(r,t){var e=t;e.assert=Jl,e.toArray=Li.toArray,e.zero2=Li.zero2,e.toHex=Li.toHex,e.encode=Li.encode;function n(d,f,w){var E=new Array(Math.max(d.bitLength(),w)+1);E.fill(0);for(var x=1<<f+1,I=d.clone(),R=0;R<E.length;R++){var Y,W=I.andln(x-1);I.isOdd()?(W>(x>>1)-1?Y=(x>>1)-W:Y=W,I.isubn(Y)):Y=0,E[R]=Y,I.iushrn(1)}return E}e.getNAF=n;function s(d,f){var w=[[],[]];d=d.clone(),f=f.clone();for(var E=0,x=0,I;d.cmpn(-E)>0||f.cmpn(-x)>0;){var R=d.andln(3)+E&3,Y=f.andln(3)+x&3;R===3&&(R=-1),Y===3&&(Y=-1);var W;R&1?(I=d.andln(7)+E&7,(I===3||I===5)&&Y===2?W=-R:W=R):W=0,w[0].push(W);var tt;Y&1?(I=f.andln(7)+x&7,(I===3||I===5)&&R===2?tt=-Y:tt=Y):tt=0,w[1].push(tt),2*E===W+1&&(E=1-E),2*x===tt+1&&(x=1-x),d.iushrn(1),f.iushrn(1)}return w}e.getJSF=s;function a(d,f,w){var E="_"+f;d.prototype[f]=function(){return this[E]!==void 0?this[E]:this[E]=w.call(this)}}e.cachedProperty=a;function c(d){return typeof d=="string"?e.toArray(d,"hex"):d}e.parseBytes=c;function l(d){return new ne(d,"hex","le")}e.intFromLE=l}),Mu=ii.getNAF,s8=ii.getJSF,Xu=ii.assert;function Vn(r,t){this.type=r,this.p=new ne(t.p,16),this.red=t.prime?ne.red(t.prime):ne.mont(this.p),this.zero=new ne(0).toRed(this.red),this.one=new ne(1).toRed(this.red),this.two=new ne(2).toRed(this.red),this.n=t.n&&new ne(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.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 e=this.n&&this.p.div(this.n);!e||e.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Cs=Vn;Vn.prototype.point=function(){throw new Error("Not implemented")},Vn.prototype.validate=function(){throw new Error("Not implemented")},Vn.prototype._fixedNafMul=function(r,t){Xu(r.precomputed);var e=r._getDoubles(),n=Mu(t,1,this._bitLength),s=(1<<e.step+1)-(e.step%2===0?2:1);s/=3;var a=[],c,l;for(c=0;c<n.length;c+=e.step){l=0;for(var d=c+e.step-1;d>=c;d--)l=(l<<1)+n[d];a.push(l)}for(var f=this.jpoint(null,null,null),w=this.jpoint(null,null,null),E=s;E>0;E--){for(c=0;c<a.length;c++)l=a[c],l===E?w=w.mixedAdd(e.points[c]):l===-E&&(w=w.mixedAdd(e.points[c].neg()));f=f.add(w)}return f.toP()},Vn.prototype._wnafMul=function(r,t){var e=4,n=r._getNAFPoints(e);e=n.wnd;for(var s=n.points,a=Mu(t,e,this._bitLength),c=this.jpoint(null,null,null),l=a.length-1;l>=0;l--){for(var d=0;l>=0&&a[l]===0;l--)d++;if(l>=0&&d++,c=c.dblp(d),l<0)break;var f=a[l];Xu(f!==0),r.type==="affine"?f>0?c=c.mixedAdd(s[f-1>>1]):c=c.mixedAdd(s[-f-1>>1].neg()):f>0?c=c.add(s[f-1>>1]):c=c.add(s[-f-1>>1].neg())}return r.type==="affine"?c.toP():c},Vn.prototype._wnafMulAdd=function(r,t,e,n,s){var a=this._wnafT1,c=this._wnafT2,l=this._wnafT3,d=0,f,w,E;for(f=0;f<n;f++){E=t[f];var x=E._getNAFPoints(r);a[f]=x.wnd,c[f]=x.points}for(f=n-1;f>=1;f-=2){var I=f-1,R=f;if(a[I]!==1||a[R]!==1){l[I]=Mu(e[I],a[I],this._bitLength),l[R]=Mu(e[R],a[R],this._bitLength),d=Math.max(l[I].length,d),d=Math.max(l[R].length,d);continue}var Y=[t[I],null,null,t[R]];t[I].y.cmp(t[R].y)===0?(Y[1]=t[I].add(t[R]),Y[2]=t[I].toJ().mixedAdd(t[R].neg())):t[I].y.cmp(t[R].y.redNeg())===0?(Y[1]=t[I].toJ().mixedAdd(t[R]),Y[2]=t[I].add(t[R].neg())):(Y[1]=t[I].toJ().mixedAdd(t[R]),Y[2]=t[I].toJ().mixedAdd(t[R].neg()));var W=[-3,-1,-5,-7,0,7,5,1,3],tt=s8(e[I],e[R]);for(d=Math.max(tt[0].length,d),l[I]=new Array(d),l[R]=new Array(d),w=0;w<d;w++){var K=tt[0][w]|0,V=tt[1][w]|0;l[I][w]=W[(K+1)*3+(V+1)],l[R][w]=0,c[I]=Y}}var B=this.jpoint(null,null,null),z=this._wnafT4;for(f=d;f>=0;f--){for(var $=0;f>=0;){var v=!0;for(w=0;w<n;w++)z[w]=l[w][f]|0,z[w]!==0&&(v=!1);if(!v)break;$++,f--}if(f>=0&&$++,B=B.dblp($),f<0)break;for(w=0;w<n;w++){var T=z[w];T!==0&&(T>0?E=c[w][T-1>>1]:T<0&&(E=c[w][-T-1>>1].neg()),E.type==="affine"?B=B.mixedAdd(E):B=B.add(E))}}for(f=0;f<n;f++)c[f]=null;return s?B:B.toP()};function wi(r,t){this.curve=r,this.type=t,this.precomputed=null}Vn.BasePoint=wi,wi.prototype.eq=function(){throw new Error("Not implemented")},wi.prototype.validate=function(){return this.curve.validate(this)},Vn.prototype.decodePoint=function(r,t){r=ii.toArray(r,t);var e=this.p.byteLength();if((r[0]===4||r[0]===6||r[0]===7)&&r.length-1===2*e){r[0]===6?Xu(r[r.length-1]%2===0):r[0]===7&&Xu(r[r.length-1]%2===1);var n=this.point(r.slice(1,1+e),r.slice(1+e,1+2*e));return n}else if((r[0]===2||r[0]===3)&&r.length-1===e)return this.pointFromX(r.slice(1,1+e),r[0]===3);throw new Error("Unknown point format")},wi.prototype.encodeCompressed=function(r){return this.encode(r,!0)},wi.prototype._encode=function(r){var t=this.curve.p.byteLength(),e=this.getX().toArray("be",t);return r?[this.getY().isEven()?2:3].concat(e):[4].concat(e,this.getY().toArray("be",t))},wi.prototype.encode=function(r,t){return ii.encode(this._encode(t),r)},wi.prototype.precompute=function(r){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,r),t.beta=this._getBeta(),this.precomputed=t,this},wi.prototype._hasDoubles=function(r){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((r.bitLength()+1)/t.step):!1},wi.prototype._getDoubles=function(r,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var e=[this],n=this,s=0;s<t;s+=r){for(var a=0;a<r;a++)n=n.dbl();e.push(n)}return{step:r,points:e}},wi.prototype._getNAFPoints=function(r){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],e=(1<<r)-1,n=e===1?null:this.dbl(),s=1;s<e;s++)t[s]=t[s-1].add(n);return{wnd:r,points:t}},wi.prototype._getBeta=function(){return null},wi.prototype.dblp=function(r){for(var t=this,e=0;e<r;e++)t=t.dbl();return t};var Xl=bo(function(r){typeof Object.create=="function"?r.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}}),o8=ii.assert;function Ii(r){Cs.call(this,"short",r),this.a=new ne(r.a,16).toRed(this.red),this.b=new ne(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)}Xl(Ii,Cs);var a8=Ii;Ii.prototype._getEndomorphism=function(r){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,e;if(r.beta)t=new ne(r.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(r.lambda)e=new ne(r.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?e=s[0]:(e=s[1],o8(this.g.mul(e).x.cmp(this.g.x.redMul(t))===0))}var a;return r.basis?a=r.basis.map(function(c){return{a:new ne(c.a,16),b:new ne(c.b,16)}}):a=this._getEndoBasis(e),{beta:t,lambda:e,basis:a}}},Ii.prototype._getEndoRoots=function(r){var t=r===this.p?this.red:ne.mont(r),e=new ne(2).toRed(t).redInvm(),n=e.redNeg(),s=new ne(3).toRed(t).redNeg().redSqrt().redMul(e),a=n.redAdd(s).fromRed(),c=n.redSub(s).fromRed();return[a,c]},Ii.prototype._getEndoBasis=function(r){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),e=r,n=this.n.clone(),s=new ne(1),a=new ne(0),c=new ne(0),l=new ne(1),d,f,w,E,x,I,R,Y=0,W,tt;e.cmpn(0)!==0;){var K=n.div(e);W=n.sub(K.mul(e)),tt=c.sub(K.mul(s));var V=l.sub(K.mul(a));if(!w&&W.cmp(t)<0)d=R.neg(),f=s,w=W.neg(),E=tt;else if(w&&++Y===2)break;R=W,n=e,e=W,c=s,s=tt,l=a,a=V}x=W.neg(),I=tt;var B=w.sqr().add(E.sqr()),z=x.sqr().add(I.sqr());return z.cmp(B)>=0&&(x=d,I=f),w.negative&&(w=w.neg(),E=E.neg()),x.negative&&(x=x.neg(),I=I.neg()),[{a:w,b:E},{a:x,b:I}]},Ii.prototype._endoSplit=function(r){var t=this.endo.basis,e=t[0],n=t[1],s=n.b.mul(r).divRound(this.n),a=e.b.neg().mul(r).divRound(this.n),c=s.mul(e.a),l=a.mul(n.a),d=s.mul(e.b),f=a.mul(n.b),w=r.sub(c).sub(l),E=d.add(f).neg();return{k1:w,k2:E}},Ii.prototype.pointFromX=function(r,t){r=new ne(r,16),r.red||(r=r.toRed(this.red));var e=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),n=e.redSqrt();if(n.redSqr().redSub(e).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(r,n)},Ii.prototype.validate=function(r){if(r.inf)return!0;var t=r.x,e=r.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return e.redSqr().redISub(s).cmpn(0)===0},Ii.prototype._endoWnafMulAdd=function(r,t,e){for(var n=this._endoWnafT1,s=this._endoWnafT2,a=0;a<r.length;a++){var c=this._endoSplit(t[a]),l=r[a],d=l._getBeta();c.k1.negative&&(c.k1.ineg(),l=l.neg(!0)),c.k2.negative&&(c.k2.ineg(),d=d.neg(!0)),n[a*2]=l,n[a*2+1]=d,s[a*2]=c.k1,s[a*2+1]=c.k2}for(var f=this._wnafMulAdd(1,n,s,a*2,e),w=0;w<a*2;w++)n[w]=null,s[w]=null;return f};function cr(r,t,e,n){Cs.BasePoint.call(this,r,"affine"),t===null&&e===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new ne(t,16),this.y=new ne(e,16),n&&(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)}Xl(cr,Cs.BasePoint),Ii.prototype.point=function(r,t,e){return new cr(this,r,t,e)},Ii.prototype.pointFromJSON=function(r,t){return cr.fromJSON(this,r,t)},cr.prototype._getBeta=function(){if(this.curve.endo){var r=this.precomputed;if(r&&r.beta)return r.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(r){var e=this.curve,n=function(s){return e.point(s.x.redMul(e.endo.beta),s.y)};r.beta=t,t.precomputed={beta:null,naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t}},cr.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]},cr.fromJSON=function(r,t,e){typeof t=="string"&&(t=JSON.parse(t));var n=r.point(t[0],t[1],e);if(!t[2])return n;function s(c){return r.point(c[0],c[1],e)}var a=t[2];return n.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[n].concat(a.doubles.points.map(s))},naf:a.naf&&{wnd:a.naf.wnd,points:[n].concat(a.naf.points.map(s))}},n},cr.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)+">"},cr.prototype.isInfinity=function(){return this.inf},cr.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(this.x.cmp(r.x)===0)return this.curve.point(null,null);var t=this.y.redSub(r.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(r.x).redInvm()));var e=t.redSqr().redISub(this.x).redISub(r.x),n=t.redMul(this.x.redSub(e)).redISub(this.y);return this.curve.point(e,n)},cr.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(r.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,e=this.x.redSqr(),n=r.redInvm(),s=e.redAdd(e).redIAdd(e).redIAdd(t).redMul(n),a=s.redSqr().redISub(this.x.redAdd(this.x)),c=s.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,c)},cr.prototype.getX=function(){return this.x.fromRed()},cr.prototype.getY=function(){return this.y.fromRed()},cr.prototype.mul=function(r){return r=new ne(r,16),this.isInfinity()?this:this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},cr.prototype.mulAdd=function(r,t,e){var n=[this,t],s=[r,e];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},cr.prototype.jmulAdd=function(r,t,e){var n=[this,t],s=[r,e];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},cr.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||this.x.cmp(r.x)===0&&this.y.cmp(r.y)===0)},cr.prototype.neg=function(r){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var e=this.precomputed,n=function(s){return s.neg()};t.precomputed={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},cr.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var r=this.curve.jpoint(this.x,this.y,this.curve.one);return r};function dr(r,t,e,n){Cs.BasePoint.call(this,r,"jacobian"),t===null&&e===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new ne(0)):(this.x=new ne(t,16),this.y=new ne(e,16),this.z=new ne(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.zOne=this.z===this.curve.one}Xl(dr,Cs.BasePoint),Ii.prototype.jpoint=function(r,t,e){return new dr(this,r,t,e)},dr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),t=r.redSqr(),e=this.x.redMul(t),n=this.y.redMul(t).redMul(r);return this.curve.point(e,n)},dr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},dr.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var t=r.z.redSqr(),e=this.z.redSqr(),n=this.x.redMul(t),s=r.x.redMul(e),a=this.y.redMul(t.redMul(r.z)),c=r.y.redMul(e.redMul(this.z)),l=n.redSub(s),d=a.redSub(c);if(l.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f=l.redSqr(),w=f.redMul(l),E=n.redMul(f),x=d.redSqr().redIAdd(w).redISub(E).redISub(E),I=d.redMul(E.redISub(x)).redISub(a.redMul(w)),R=this.z.redMul(r.z).redMul(l);return this.curve.jpoint(x,I,R)},dr.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var t=this.z.redSqr(),e=this.x,n=r.x.redMul(t),s=this.y,a=r.y.redMul(t).redMul(this.z),c=e.redSub(n),l=s.redSub(a);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=c.redSqr(),f=d.redMul(c),w=e.redMul(d),E=l.redSqr().redIAdd(f).redISub(w).redISub(w),x=l.redMul(w.redISub(E)).redISub(s.redMul(f)),I=this.z.redMul(c);return this.curve.jpoint(E,x,I)},dr.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var e=this;for(t=0;t<r;t++)e=e.dbl();return e}var n=this.curve.a,s=this.curve.tinv,a=this.x,c=this.y,l=this.z,d=l.redSqr().redSqr(),f=c.redAdd(c);for(t=0;t<r;t++){var w=a.redSqr(),E=f.redSqr(),x=E.redSqr(),I=w.redAdd(w).redIAdd(w).redIAdd(n.redMul(d)),R=a.redMul(E),Y=I.redSqr().redISub(R.redAdd(R)),W=R.redISub(Y),tt=I.redMul(W);tt=tt.redIAdd(tt).redISub(x);var K=f.redMul(l);t+1<r&&(d=d.redMul(x)),a=Y,l=K,f=tt}return this.curve.jpoint(a,f.redMul(s),l)},dr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},dr.prototype._zeroDbl=function(){var r,t,e;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(n).redISub(a);c=c.redIAdd(c);var l=n.redAdd(n).redIAdd(n),d=l.redSqr().redISub(c).redISub(c),f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),r=d,t=l.redMul(c.redISub(d)).redISub(f),e=this.y.redAdd(this.y)}else{var w=this.x.redSqr(),E=this.y.redSqr(),x=E.redSqr(),I=this.x.redAdd(E).redSqr().redISub(w).redISub(x);I=I.redIAdd(I);var R=w.redAdd(w).redIAdd(w),Y=R.redSqr(),W=x.redIAdd(x);W=W.redIAdd(W),W=W.redIAdd(W),r=Y.redISub(I).redISub(I),t=R.redMul(I.redISub(r)).redISub(W),e=this.y.redMul(this.z),e=e.redIAdd(e)}return this.curve.jpoint(r,t,e)},dr.prototype._threeDbl=function(){var r,t,e;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),a=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(n).redISub(a);c=c.redIAdd(c);var l=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),d=l.redSqr().redISub(c).redISub(c);r=d;var f=a.redIAdd(a);f=f.redIAdd(f),f=f.redIAdd(f),t=l.redMul(c.redISub(d)).redISub(f),e=this.y.redAdd(this.y)}else{var w=this.z.redSqr(),E=this.y.redSqr(),x=this.x.redMul(E),I=this.x.redSub(w).redMul(this.x.redAdd(w));I=I.redAdd(I).redIAdd(I);var R=x.redIAdd(x);R=R.redIAdd(R);var Y=R.redAdd(R);r=I.redSqr().redISub(Y),e=this.y.redAdd(this.z).redSqr().redISub(E).redISub(w);var W=E.redSqr();W=W.redIAdd(W),W=W.redIAdd(W),W=W.redIAdd(W),t=I.redMul(R.redISub(r)).redISub(W)}return this.curve.jpoint(r,t,e)},dr.prototype._dbl=function(){var r=this.curve.a,t=this.x,e=this.y,n=this.z,s=n.redSqr().redSqr(),a=t.redSqr(),c=e.redSqr(),l=a.redAdd(a).redIAdd(a).redIAdd(r.redMul(s)),d=t.redAdd(t);d=d.redIAdd(d);var f=d.redMul(c),w=l.redSqr().redISub(f.redAdd(f)),E=f.redISub(w),x=c.redSqr();x=x.redIAdd(x),x=x.redIAdd(x),x=x.redIAdd(x);var I=l.redMul(E).redISub(x),R=e.redAdd(e).redMul(n);return this.curve.jpoint(w,I,R)},dr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var r=this.x.redSqr(),t=this.y.redSqr(),e=this.z.redSqr(),n=t.redSqr(),s=r.redAdd(r).redIAdd(r),a=s.redSqr(),c=this.x.redAdd(t).redSqr().redISub(r).redISub(n);c=c.redIAdd(c),c=c.redAdd(c).redIAdd(c),c=c.redISub(a);var l=c.redSqr(),d=n.redIAdd(n);d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var f=s.redIAdd(c).redSqr().redISub(a).redISub(l).redISub(d),w=t.redMul(f);w=w.redIAdd(w),w=w.redIAdd(w);var E=this.x.redMul(l).redISub(w);E=E.redIAdd(E),E=E.redIAdd(E);var x=this.y.redMul(f.redMul(d.redISub(f)).redISub(c.redMul(l)));x=x.redIAdd(x),x=x.redIAdd(x),x=x.redIAdd(x);var I=this.z.redAdd(c).redSqr().redISub(e).redISub(l);return this.curve.jpoint(E,x,I)},dr.prototype.mul=function(r,t){return r=new ne(r,t),this.curve._wnafMul(this,r)},dr.prototype.eq=function(r){if(r.type==="affine")return this.eq(r.toJ());if(this===r)return!0;var t=this.z.redSqr(),e=r.z.redSqr();if(this.x.redMul(e).redISub(r.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=e.redMul(r.z);return this.y.redMul(s).redISub(r.y.redMul(n)).cmpn(0)===0},dr.prototype.eqXToP=function(r){var t=this.z.redSqr(),e=r.toRed(this.curve.red).redMul(t);if(this.x.cmp(e)===0)return!0;for(var n=r.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(s),this.x.cmp(e)===0)return!0}},dr.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)+">"},dr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var qu=bo(function(r,t){var e=t;e.base=Cs,e.short=a8,e.mont=null,e.edwards=null}),ju=bo(function(r,t){var e=t,n=ii.assert;function s(l){l.type==="short"?this.curve=new qu.short(l):l.type==="edwards"?this.curve=new qu.edwards(l):this.curve=new qu.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=s;function a(l,d){Object.defineProperty(e,l,{configurable:!0,enumerable:!0,get:function(){var f=new s(d);return Object.defineProperty(e,l,{configurable:!0,enumerable:!0,value:f}),f}})}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:Wi.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:Wi.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:Wi.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:Wi.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:Wi.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:Wi.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:Wi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=null.crash()}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:Wi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})});function Gn(r){if(!(this instanceof Gn))return new Gn(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 t=Li.toArray(r.entropy,r.entropyEnc||"hex"),e=Li.toArray(r.nonce,r.nonceEnc||"hex"),n=Li.toArray(r.pers,r.persEnc||"hex");Jl(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,e,n)}var np=Gn;Gn.prototype._init=function(r,t,e){var n=r.concat(t).concat(e);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},Gn.prototype._hmac=function(){return new Wi.hmac(this.hash,this.K)},Gn.prototype._update=function(r){var t=this._hmac().update(this.V).update([0]);r&&(t=t.update(r)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),r&&(this.K=this._hmac().update(this.V).update([1]).update(r).digest(),this.V=this._hmac().update(this.V).digest())},Gn.prototype.reseed=function(r,t,e,n){typeof t!="string"&&(n=e,e=t,t=null),r=Li.toArray(r,t),e=Li.toArray(e,n),Jl(r.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(e||[])),this._reseed=1},Gn.prototype.generate=function(r,t,e,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=e,e=t,t=null),e&&(e=Li.toArray(e,n||"hex"),this._update(e));for(var s=[];s.length<r;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var a=s.slice(0,r);return this._update(e),this._reseed++,Li.encode(a,t)};var Kh=ii.assert;function br(r,t){this.ec=r,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var Vh=br;br.fromPublic=function(r,t,e){return t instanceof br?t:new br(r,{pub:t,pubEnc:e})},br.fromPrivate=function(r,t,e){return t instanceof br?t:new br(r,{priv:t,privEnc:e})},br.prototype.validate=function(){var r=this.getPublic();return r.isInfinity()?{result:!1,reason:"Invalid public key"}:r.validate()?r.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"}},br.prototype.getPublic=function(r,t){return typeof r=="string"&&(t=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,r):this.pub},br.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},br.prototype._importPrivate=function(r,t){this.priv=new ne(r,t||16),this.priv=this.priv.umod(this.ec.curve.n)},br.prototype._importPublic=function(r,t){if(r.x||r.y){this.ec.curve.type==="mont"?Kh(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Kh(r.x&&r.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(r.x,r.y);return}this.pub=this.ec.curve.decodePoint(r,t)},br.prototype.derive=function(r){return r.validate()||Kh(r.validate(),"public point not validated"),r.mul(this.priv).getX()},br.prototype.sign=function(r,t,e){return this.ec.sign(r,this,t,e)},br.prototype.verify=function(r,t){return this.ec.verify(r,t,this)},br.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var u8=ii.assert;function dc(r,t){if(r instanceof dc)return r;this._importDER(r,t)||(u8(r.r&&r.s,"Signature without r or s"),this.r=new ne(r.r,16),this.s=new ne(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var Cu=dc;function c8(){this.place=0}function Gh(r,t){var e=r[t.place++];if(!(e&128))return e;var n=e&15;if(n===0||n>4)return!1;for(var s=0,a=0,c=t.place;a<n;a++,c++)s<<=8,s|=r[c],s>>>=0;return s<=127?!1:(t.place=c,s)}function sp(r){for(var t=0,e=r.length-1;!r[t]&&!(r[t+1]&128)&&t<e;)t++;return t===0?r:r.slice(t)}dc.prototype._importDER=function(r,t){r=ii.toArray(r,t);var e=new c8;if(r[e.place++]!==48)return!1;var n=Gh(r,e);if(n===!1||n+e.place!==r.length||r[e.place++]!==2)return!1;var s=Gh(r,e);if(s===!1)return!1;var a=r.slice(e.place,s+e.place);if(e.place+=s,r[e.place++]!==2)return!1;var c=Gh(r,e);if(c===!1||r.length!==c+e.place)return!1;var l=r.slice(e.place,c+e.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new ne(a),this.s=new ne(l),this.recoveryParam=null,!0};function Wh(r,t){if(t<128){r.push(t);return}var e=1+(Math.log(t)/Math.LN2>>>3);for(r.push(e|128);--e;)r.push(t>>>(e<<3)&255);r.push(t)}dc.prototype.toDER=function(r){var t=this.r.toArray(),e=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),e[0]&128&&(e=[0].concat(e)),t=sp(t),e=sp(e);!e[0]&&!(e[1]&128);)e=e.slice(1);var n=[2];Wh(n,t.length),n=n.concat(t),n.push(2),Wh(n,e.length);var s=n.concat(e),a=[48];return Wh(a,s.length),a=a.concat(s),ii.encode(a,r)};var h8=function(){throw new Error("unsupported")},Pg=ii.assert;function Ai(r){if(!(this instanceof Ai))return new Ai(r);typeof r=="string"&&(Pg(Object.prototype.hasOwnProperty.call(ju,r),"Unknown curve "+r),r=ju[r]),r instanceof ju.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 l8=Ai;Ai.prototype.keyPair=function(r){return new Vh(this,r)},Ai.prototype.keyFromPrivate=function(r,t){return Vh.fromPrivate(this,r,t)},Ai.prototype.keyFromPublic=function(r,t){return Vh.fromPublic(this,r,t)},Ai.prototype.genKeyPair=function(r){r||(r={});for(var t=new np({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||h8(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),e=this.n.byteLength(),n=this.n.sub(new ne(2));;){var s=new ne(t.generate(e));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Ai.prototype._truncateToN=function(r,t){var e=r.byteLength()*8-this.n.bitLength();return e>0&&(r=r.ushrn(e)),!t&&r.cmp(this.n)>=0?r.sub(this.n):r},Ai.prototype.sign=function(r,t,e,n){typeof e=="object"&&(n=e,e=null),n||(n={}),t=this.keyFromPrivate(t,e),r=this._truncateToN(new ne(r,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),c=r.toArray("be",s),l=new np({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),d=this.n.sub(new ne(1)),f=0;;f++){var w=n.k?n.k(f):new ne(l.generate(this.n.byteLength()));if(w=this._truncateToN(w,!0),!(w.cmpn(1)<=0||w.cmp(d)>=0)){var E=this.g.mul(w);if(!E.isInfinity()){var x=E.getX(),I=x.umod(this.n);if(I.cmpn(0)!==0){var R=w.invm(this.n).mul(I.mul(t.getPrivate()).iadd(r));if(R=R.umod(this.n),R.cmpn(0)!==0){var Y=(E.getY().isOdd()?1:0)|(x.cmp(I)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),Y^=1),new Cu({r:I,s:R,recoveryParam:Y})}}}}}},Ai.prototype.verify=function(r,t,e,n){r=this._truncateToN(new ne(r,16)),e=this.keyFromPublic(e,n),t=new Cu(t,"hex");var s=t.r,a=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),l=c.mul(r).umod(this.n),d=c.mul(s).umod(this.n),f;return this.curve._maxwellTrick?(f=this.g.jmulAdd(l,e.getPublic(),d),f.isInfinity()?!1:f.eqXToP(s)):(f=this.g.mulAdd(l,e.getPublic(),d),f.isInfinity()?!1:f.getX().umod(this.n).cmp(s)===0)},Ai.prototype.recoverPubKey=function(r,t,e,n){Pg((3&e)===e,"The recovery param is more than two bits"),t=new Cu(t,n);var s=this.n,a=new ne(r),c=t.r,l=t.s,d=e&1,f=e>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");f?c=this.curve.pointFromX(c.add(this.curve.n),d):c=this.curve.pointFromX(c,d);var w=t.r.invm(s),E=s.sub(a).mul(w).umod(s),x=l.mul(w).umod(s);return this.g.mulAdd(E,c,x)},Ai.prototype.getKeyRecoveryParam=function(r,t,e,n){if(t=new Cu(t,n),t.recoveryParam!==null)return t.recoveryParam;for(var s=0;s<4;s++){var a;try{a=this.recoverPubKey(r,t,s)}catch{continue}if(a.eq(e))return s}throw new Error("Unable to find valid recovery factor")};var f8=bo(function(r,t){var e=t;e.version="6.5.4",e.utils=ii,e.rand=function(){throw new Error("unsupported")},e.curve=qu,e.curves=ju,e.ec=l8,e.eddsa=null}),d8=f8.ec;const p8="signing-key/5.7.0",Il=new pr(p8);let Yh=null;function en(){return Yh||(Yh=new d8("secp256k1")),Yh}class g8{constructor(t){Ho(this,"curve","secp256k1"),Ho(this,"privateKey",Cr(t)),XE(this.privateKey)!==32&&Il.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const e=en().keyFromPrivate(Ye(this.privateKey));Ho(this,"publicKey","0x"+e.getPublic(!1,"hex")),Ho(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Ho(this,"_isSigningKey",!0)}_addPoint(t){const e=en().keyFromPublic(Ye(this.publicKey)),n=en().keyFromPublic(Ye(t));return"0x"+e.pub.add(n.pub).encodeCompressed("hex")}signDigest(t){const e=en().keyFromPrivate(Ye(this.privateKey)),n=Ye(t);n.length!==32&&Il.throwArgumentError("bad digest length","digest",t);const s=e.sign(n,{canonical:!0});return eg({recoveryParam:s.recoveryParam,r:rn("0x"+s.r.toString(16),32),s:rn("0x"+s.s.toString(16),32)})}computeSharedSecret(t){const e=en().keyFromPrivate(Ye(this.privateKey)),n=en().keyFromPublic(Ye(Og(t)));return rn("0x"+e.derive(n.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function m8(r,t){const e=eg(t),n={r:Ye(e.r),s:Ye(e.s)};return"0x"+en().recoverPubKey(Ye(r),n,e.recoveryParam).encode("hex",!1)}function Og(r,t){const e=Ye(r);if(e.length===32){const n=new g8(e);return t?"0x"+en().keyFromPrivate(e).getPublic(!0,"hex"):n.publicKey}else{if(e.length===33)return t?Cr(e):"0x"+en().keyFromPublic(e).getPublic(!1,"hex");if(e.length===65)return t?"0x"+en().keyFromPublic(e).getPublic(!0,"hex"):Cr(e)}return Il.throwArgumentError("invalid public or private key","key","[REDACTED]")}var op;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(op||(op={}));function v8(r){const t=Og(r);return M5(Kd(Wl(Kd(t,1)),12))}function y8(r,t){return v8(m8(Ye(r),t))}const w8="https://rpc.walletconnect.com/v1";async function b8(r,t,e,n,s,a){switch(e.t){case"eip191":return _8(r,t,e.s);case"eip1271":return await E8(r,t,e.s,n,s,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${e.t}`)}}function _8(r,t,e){return y8(hg(t),e).toLowerCase()===r.toLowerCase()}async function E8(r,t,e,n,s,a){try{const c="0x1626ba7e",l="0000000000000000000000000000000000000000000000000000000000000040",d="0000000000000000000000000000000000000000000000000000000000000041",f=e.substring(2),w=hg(t).substring(2),E=c+w+l+d+f,x=await fetch(`${a||w8}/?chainId=${n}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:A8(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:E},"latest"]})}),{result:I}=await x.json();return I?I.slice(0,c.length).toLowerCase()===c.toLowerCase():!1}catch(c){return console.error("isValidEip1271Signature: ",c),!1}}function A8(){return Date.now()+Math.floor(Math.random()*1e3)}var S8=Object.defineProperty,I8=Object.defineProperties,D8=Object.getOwnPropertyDescriptors,ap=Object.getOwnPropertySymbols,x8=Object.prototype.hasOwnProperty,M8=Object.prototype.propertyIsEnumerable,up=(r,t,e)=>t in r?S8(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C8=(r,t)=>{for(var e in t||(t={}))x8.call(t,e)&&up(r,e,t[e]);if(ap)for(var e of ap(t))M8.call(t,e)&&up(r,e,t[e]);return r},P8=(r,t)=>I8(r,D8(t));const O8="did:pkh:",Zl=r=>r==null?void 0:r.split(":"),Ng=r=>{const t=r&&Zl(r);if(t)return r.includes(O8)?t[3]:t[1]},cp=r=>{const t=r&&Zl(r);if(t)return t[2]+":"+t[3]},Zu=r=>{const t=r&&Zl(r);if(t)return t.pop()};async function hp(r){const{cacao:t,projectId:e}=r,{s:n,p:s}=t,a=Rg(s,s.iss),c=Zu(s.iss);return await b8(c,a,n,Ng(s.iss),e)}const Rg=(r,t)=>{const e=`${r.domain} wants you to sign in with your Ethereum account:`,n=Zu(t);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=r.statement||void 0;const a=`URI: ${r.aud||r.uri}`,c=`Version: ${r.version}`,l=`Chain ID: ${Ng(t)}`,d=`Nonce: ${r.nonce}`,f=`Issued At: ${r.iat}`,w=r.resources?`Resources:${r.resources.map(x=>`
10
- - ${x}`).join("")}`:void 0,E=$u(r.resources);if(E){const x=ua(E);s=j8(s,x)}return[e,n,"",s,"",a,c,l,d,f,w].filter(x=>x!=null).join(`
11
- `)};function N8(r){return fa.from(JSON.stringify(r)).toString("base64")}function R8(r){return JSON.parse(fa.from(r,"base64").toString("utf-8"))}function xs(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const t=Object.keys(r.att);if(!(t!=null&&t.length))throw new Error("No resources found in `att` property");t.forEach(e=>{const n=r.att[e];if(Array.isArray(n))throw new Error(`Resource must be an object: ${e}`);if(typeof n!="object")throw new Error(`Resource must be an object: ${e}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${e}`);Object.keys(n).forEach(s=>{const a=n[s];if(!Array.isArray(a))throw new Error(`Ability limits ${s} must be an array of objects, found: ${a}`);if(!a.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);a.forEach(c=>{if(typeof c!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${c}`)})})})}function T8(r,t,e,n={}){return e==null||e.sort((s,a)=>s.localeCompare(a)),{att:{[r]:F8(t,e,n)}}}function F8(r,t,e={}){t=t==null?void 0:t.sort((s,a)=>s.localeCompare(a));const n=t.map(s=>({[`${r}/${s}`]:[e]}));return Object.assign({},...n)}function Tg(r){return xs(r),`urn:recap:${N8(r).replace(/=/g,"")}`}function ua(r){const t=R8(r.replace("urn:recap:",""));return xs(t),t}function U8(r,t,e){const n=T8(r,t,e);return Tg(n)}function B8(r){return r&&r.includes("urn:recap:")}function L8(r,t){const e=ua(r),n=ua(t),s=q8(e,n);return Tg(s)}function q8(r,t){xs(r),xs(t);const e=Object.keys(r.att).concat(Object.keys(t.att)).sort((s,a)=>s.localeCompare(a)),n={att:{}};return e.forEach(s=>{var a,c;Object.keys(((a=r.att)==null?void 0:a[s])||{}).concat(Object.keys(((c=t.att)==null?void 0:c[s])||{})).sort((l,d)=>l.localeCompare(d)).forEach(l=>{var d,f;n.att[s]=P8(C8({},n.att[s]),{[l]:((d=r.att[s])==null?void 0:d[l])||((f=t.att[s])==null?void 0:f[l])})})}),n}function j8(r="",t){xs(t);const e="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(e))return r;const n=[];let s=0;Object.keys(t.att).forEach(l=>{const d=Object.keys(t.att[l]).map(E=>({ability:E.split("/")[0],action:E.split("/")[1]}));d.sort((E,x)=>E.action.localeCompare(x.action));const f={};d.forEach(E=>{f[E.ability]||(f[E.ability]=[]),f[E.ability].push(E.action)});const w=Object.keys(f).map(E=>(s++,`(${s}) '${E}': '${f[E].join("', '")}' for '${l}'.`));n.push(w.join(", ").replace(".,","."))});const a=n.join(" "),c=`${e}${a}`;return`${r?r+" ":""}${c}`}function lp(r){var t;const e=ua(r);xs(e);const n=(t=e.att)==null?void 0:t.eip155;return n?Object.keys(n).map(s=>s.split("/")[1]):[]}function fp(r){const t=ua(r);xs(t);const e=[];return Object.values(t.att).forEach(n=>{Object.values(n).forEach(s=>{var a;(a=s==null?void 0:s[0])!=null&&a.chains&&e.push(s[0].chains)})}),[...new Set(e.flat())]}function $u(r){if(!r)return;const t=r==null?void 0:r[r.length-1];return B8(t)?t:void 0}const Fg="base10",Nr="base16",Dl="base64pad",tf="utf8",Ug=0,Wn=1,$8=0,dp=1,xl=12,ef=32;function z8(){const r=Vl.generateKeyPair();return{privateKey:Rr(r.secretKey,Nr),publicKey:Rr(r.publicKey,Nr)}}function Ml(){const r=po.randomBytes(ef);return Rr(r,Nr)}function k8(r,t){const e=Vl.sharedKey(kr(r,Nr),kr(t,Nr),!0),n=new A_(lc.SHA256,e).expand(ef);return Rr(n,Nr)}function zu(r){const t=lc.hash(kr(r,Nr));return Rr(t,Nr)}function Ss(r){const t=lc.hash(kr(r,tf));return Rr(t,Nr)}function H8(r){return kr(`${r}`,Fg)}function va(r){return Number(Rr(r,Fg))}function K8(r){const t=H8(typeof r.type<"u"?r.type:Ug);if(va(t)===Wn&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const e=typeof r.senderPublicKey<"u"?kr(r.senderPublicKey,Nr):void 0,n=typeof r.iv<"u"?kr(r.iv,Nr):po.randomBytes(xl),s=new Hl.ChaCha20Poly1305(kr(r.symKey,Nr)).seal(n,kr(r.message,tf));return G8({type:t,sealed:s,iv:n,senderPublicKey:e})}function V8(r){const t=new Hl.ChaCha20Poly1305(kr(r.symKey,Nr)),{sealed:e,iv:n}=tc(r.encoded),s=t.open(n,e);if(s===null)throw new Error("Failed to decrypt");return Rr(s,tf)}function G8(r){if(va(r.type)===Wn){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Rr(wl([r.type,r.senderPublicKey,r.iv,r.sealed]),Dl)}return Rr(wl([r.type,r.iv,r.sealed]),Dl)}function tc(r){const t=kr(r,Dl),e=t.slice($8,dp),n=dp;if(va(e)===Wn){const l=n+ef,d=l+xl,f=t.slice(n,l),w=t.slice(l,d),E=t.slice(d);return{type:e,sealed:E,iv:w,senderPublicKey:f}}const s=n+xl,a=t.slice(n,s),c=t.slice(s);return{type:e,sealed:c,iv:a}}function W8(r,t){const e=tc(r);return Bg({type:va(e.type),senderPublicKey:typeof e.senderPublicKey<"u"?Rr(e.senderPublicKey,Nr):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function Bg(r){const t=(r==null?void 0:r.type)||Ug;if(t===Wn){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function pp(r){return r.type===Wn&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}const Y8="irn";function Cl(r){return(r==null?void 0:r.relay)||{protocol:Y8}}function ku(r){const t=DE[r];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${r}`);return t}var Q8=Object.defineProperty,J8=Object.defineProperties,X8=Object.getOwnPropertyDescriptors,gp=Object.getOwnPropertySymbols,Z8=Object.prototype.hasOwnProperty,t4=Object.prototype.propertyIsEnumerable,mp=(r,t,e)=>t in r?Q8(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,vp=(r,t)=>{for(var e in t||(t={}))Z8.call(t,e)&&mp(r,e,t[e]);if(gp)for(var e of gp(t))t4.call(t,e)&&mp(r,e,t[e]);return r},e4=(r,t)=>J8(r,X8(t));function r4(r,t="-"){const e={},n="relay"+t;return Object.keys(r).forEach(s=>{if(s.startsWith(n)){const a=s.replace(n,""),c=r[s];e[a]=c}}),e}function yp(r){r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const t=r.indexOf(":"),e=r.indexOf("?")!==-1?r.indexOf("?"):void 0,n=r.substring(0,t),s=r.substring(t+1,e).split("@"),a=typeof e<"u"?r.substring(e):"",c=na.parse(a),l=typeof c.methods=="string"?c.methods.split(","):void 0;return{protocol:n,topic:i4(s[0]),version:parseInt(s[1],10),symKey:c.symKey,relay:r4(c),methods:l,expiryTimestamp:c.expiryTimestamp?parseInt(c.expiryTimestamp,10):void 0}}function i4(r){return r.startsWith("//")?r.substring(2):r}function n4(r,t="-"){const e="relay",n={};return Object.keys(r).forEach(s=>{const a=e+t+s;r[s]&&(n[a]=r[s])}),n}function s4(r){return`${r.protocol}:${r.topic}@${r.version}?`+na.stringify(vp(e4(vp({symKey:r.symKey},n4(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function _o(r){const t=[];return r.forEach(e=>{const[n,s]=e.split(":");t.push(`${n}:${s}`)}),t}function o4(r){const t=[];return Object.values(r).forEach(e=>{t.push(..._o(e.accounts))}),t}function a4(r,t){const e=[];return Object.values(r).forEach(n=>{_o(n.accounts).includes(t)&&e.push(...n.methods)}),e}function u4(r,t){const e=[];return Object.values(r).forEach(n=>{_o(n.accounts).includes(t)&&e.push(...n.events)}),e}function rf(r){return r.includes(":")}function ta(r){return rf(r)?r.split(":")[0]:r}function c4(r){const t={};return r==null||r.forEach(e=>{const[n,s]=e.split(":");t[n]||(t[n]={accounts:[],chains:[],events:[]}),t[n].accounts.push(e),t[n].chains.push(`${n}:${s}`)}),t}function wp(r,t){t=t.map(n=>n.replace("did:pkh:",""));const e=c4(t);for(const[n,s]of Object.entries(e))s.methods?s.methods=Bu(s.methods,r):s.methods=r,s.events=["chainChanged","accountsChanged"];return e}const h4={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}},l4={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 mt(r,t){const{message:e,code:n}=l4[r];return{message:t?`${e} ${t}`:e,code:n}}function Re(r,t){const{message:e,code:n}=h4[r];return{message:t?`${e} ${t}`:e,code:n}}function un(r,t){return Array.isArray(r)?typeof t<"u"&&r.length?r.every(t):!0:!1}function ca(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function Or(r){return typeof r>"u"}function tr(r,t){return t&&Or(r)?!0:typeof r=="string"&&!!r.trim().length}function nf(r,t){return t&&Or(r)?!0:typeof r=="number"&&!isNaN(r)}function f4(r,t){const{requiredNamespaces:e}=t,n=Object.keys(r.namespaces),s=Object.keys(e);let a=!0;return As(s,n)?(n.forEach(c=>{const{accounts:l,methods:d,events:f}=r.namespaces[c],w=_o(l),E=e[c];(!As(G1(c,E),w)||!As(E.methods,d)||!As(E.events,f))&&(a=!1)}),a):!1}function ec(r){return tr(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function d4(r){if(tr(r,!1)&&r.includes(":")){const t=r.split(":");if(t.length===3){const e=t[0]+":"+t[1];return!!t[2]&&ec(e)}}return!1}function p4(r){if(tr(r,!1))try{return typeof new URL(r)<"u"}catch{return!1}return!1}function g4(r){var t;return(t=r==null?void 0:r.proposer)==null?void 0:t.publicKey}function m4(r){return r==null?void 0:r.topic}function v4(r,t){let e=null;return tr(r==null?void 0:r.publicKey,!1)||(e=mt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),e}function bp(r){let t=!0;return un(r)?r.length&&(t=r.every(e=>tr(e,!1))):t=!1,t}function y4(r,t,e){let n=null;return un(t)&&t.length?t.forEach(s=>{n||ec(s)||(n=Re("UNSUPPORTED_CHAINS",`${e}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):ec(r)||(n=Re("UNSUPPORTED_CHAINS",`${e}, 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"] }`)),n}function w4(r,t,e){let n=null;return Object.entries(r).forEach(([s,a])=>{if(n)return;const c=y4(s,G1(s,a),`${t} ${e}`);c&&(n=c)}),n}function b4(r,t){let e=null;return un(r)?r.forEach(n=>{e||d4(n)||(e=Re("UNSUPPORTED_ACCOUNTS",`${t}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):e=Re("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),e}function _4(r,t){let e=null;return Object.values(r).forEach(n=>{if(e)return;const s=b4(n==null?void 0:n.accounts,`${t} namespace`);s&&(e=s)}),e}function E4(r,t){let e=null;return bp(r==null?void 0:r.methods)?bp(r==null?void 0:r.events)||(e=Re("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):e=Re("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),e}function Lg(r,t){let e=null;return Object.values(r).forEach(n=>{if(e)return;const s=E4(n,`${t}, namespace`);s&&(e=s)}),e}function A4(r,t,e){let n=null;if(r&&ca(r)){const s=Lg(r,t);s&&(n=s);const a=w4(r,t,e);a&&(n=a)}else n=mt("MISSING_OR_INVALID",`${t}, ${e} should be an object with data`);return n}function Qh(r,t){let e=null;if(r&&ca(r)){const n=Lg(r,t);n&&(e=n);const s=_4(r,t);s&&(e=s)}else e=mt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return e}function qg(r){return tr(r.protocol,!0)}function S4(r,t){let e=!1;return t&&!r?e=!0:r&&un(r)&&r.length&&r.forEach(n=>{e=qg(n)}),e}function I4(r){return typeof r=="number"}function zr(r){return typeof r<"u"&&typeof r!==null}function D4(r){return!(!r||typeof r!="object"||!r.code||!nf(r.code,!1)||!r.message||!tr(r.message,!1))}function x4(r){return!(Or(r)||!tr(r.method,!1))}function M4(r){return!(Or(r)||Or(r.result)&&Or(r.error)||!nf(r.id,!1)||!tr(r.jsonrpc,!1))}function C4(r){return!(Or(r)||!tr(r.name,!1))}function _p(r,t){return!(!ec(t)||!o4(r).includes(t))}function P4(r,t,e){return tr(e,!1)?a4(r,t).includes(e):!1}function O4(r,t,e){return tr(e,!1)?u4(r,t).includes(e):!1}function Ep(r,t,e){let n=null;const s=N4(r),a=R4(t),c=Object.keys(s),l=Object.keys(a),d=Ap(Object.keys(r)),f=Ap(Object.keys(t)),w=d.filter(E=>!f.includes(E));return w.length&&(n=mt("NON_CONFORMING_NAMESPACES",`${e} namespaces keys don't satisfy requiredNamespaces.
12
- Required: ${w.toString()}
13
- Received: ${Object.keys(t).toString()}`)),As(c,l)||(n=mt("NON_CONFORMING_NAMESPACES",`${e} namespaces chains don't satisfy required namespaces.
14
- Required: ${c.toString()}
15
- Approved: ${l.toString()}`)),Object.keys(t).forEach(E=>{if(!E.includes(":")||n)return;const x=_o(t[E].accounts);x.includes(E)||(n=mt("NON_CONFORMING_NAMESPACES",`${e} namespaces accounts don't satisfy namespace accounts for ${E}
16
- Required: ${E}
17
- Approved: ${x.toString()}`))}),c.forEach(E=>{n||(As(s[E].methods,a[E].methods)?As(s[E].events,a[E].events)||(n=mt("NON_CONFORMING_NAMESPACES",`${e} namespaces events don't satisfy namespace events for ${E}`)):n=mt("NON_CONFORMING_NAMESPACES",`${e} namespaces methods don't satisfy namespace methods for ${E}`))}),n}function N4(r){const t={};return Object.keys(r).forEach(e=>{var n;e.includes(":")?t[e]=r[e]:(n=r[e].chains)==null||n.forEach(s=>{t[s]={methods:r[e].methods,events:r[e].events}})}),t}function Ap(r){return[...new Set(r.map(t=>t.includes(":")?t.split(":")[0]:t))]}function R4(r){const t={};return Object.keys(r).forEach(e=>{if(e.includes(":"))t[e]=r[e];else{const n=_o(r[e].accounts);n==null||n.forEach(s=>{t[s]={accounts:r[e].accounts.filter(a=>a.includes(`${s}:`)),methods:r[e].methods,events:r[e].events}})}}),t}function T4(r,t){return nf(r,!1)&&r<=t.max&&r>=t.min}function Sp(){const r=ga();return new Promise(t=>{switch(r){case ti.browser:t(F4());break;case ti.reactNative:t(U4());break;case ti.node:t(B4());break;default:t(!0)}})}function F4(){return mo()&&(navigator==null?void 0:navigator.onLine)}async function U4(){if(go()&&typeof Ie<"u"&&Ie!=null&&Ie.NetInfo){const r=await(Ie==null?void 0:Ie.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function B4(){return!0}function L4(r){switch(ga()){case ti.browser:q4(r);break;case ti.reactNative:j4(r);break}}function q4(r){!go()&&mo()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function j4(r){var t;go()&&typeof Ie<"u"&&Ie!=null&&Ie.NetInfo&&((t=Ie)==null||t.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const Jh={};class Go{static get(t){return Jh[t]}static set(t,e){Jh[t]=e}static delete(t){delete Jh[t]}}const $4=/"(?:_|\\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*:/,z4=/"(?: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*:/,k4=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function H4(r,t){if(r==="__proto__"||r==="constructor"&&t&&typeof t=="object"&&"prototype"in t){K4(r);return}return t}function K4(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Pu(r,t={}){if(typeof r!="string")return r;const e=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return e.slice(1,-1);if(e.length<=9){const n=e.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!k4.test(r)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if($4.test(r)||z4.test(r)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,H4)}return JSON.parse(r)}catch(n){if(t.strict)throw n;return r}}function V4(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function lr(r,...t){try{return V4(r(...t))}catch(e){return Promise.reject(e)}}function G4(r){const t=typeof r;return r===null||t!=="object"&&t!=="function"}function W4(r){const t=Object.getPrototypeOf(r);return!t||t.isPrototypeOf(Object)}function Hu(r){if(G4(r))return String(r);if(W4(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return Hu(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function jg(){if(typeof fa===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const Pl="base64:";function Y4(r){if(typeof r=="string")return r;jg();const t=fa.from(r).toString("base64");return Pl+t}function Q4(r){return typeof r!="string"||!r.startsWith(Pl)?r:(jg(),fa.from(r.slice(Pl.length),"base64"))}function $r(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function J4(...r){return $r(r.join(":"))}function Ou(r){return r=$r(r),r?r+":":""}const X4="memory",Z4=()=>{const r=new Map;return{name:X4,options:{},hasItem(t){return r.has(t)},getItem(t){return r.get(t)??null},getItemRaw(t){return r.get(t)??null},setItem(t,e){r.set(t,e)},setItemRaw(t,e){r.set(t,e)},removeItem(t){r.delete(t)},getKeys(){return Array.from(r.keys())},clear(){r.clear()},dispose(){r.clear()}}};function tS(r={}){const t={mounts:{"":r.driver||Z4()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},e=f=>{for(const w of t.mountpoints)if(f.startsWith(w))return{base:w,relativeKey:f.slice(w.length),driver:t.mounts[w]};return{base:"",relativeKey:f,driver:t.mounts[""]}},n=(f,w)=>t.mountpoints.filter(E=>E.startsWith(f)||w&&f.startsWith(E)).map(E=>({relativeBase:f.length>E.length?f.slice(E.length):void 0,mountpoint:E,driver:t.mounts[E]})),s=(f,w)=>{if(t.watching){w=$r(w);for(const E of t.watchListeners)E(f,w)}},a=async()=>{if(!t.watching){t.watching=!0;for(const f in t.mounts)t.unwatch[f]=await Ip(t.mounts[f],s,f)}},c=async()=>{if(t.watching){for(const f in t.unwatch)await t.unwatch[f]();t.unwatch={},t.watching=!1}},l=(f,w,E)=>{const x=new Map,I=R=>{let Y=x.get(R.base);return Y||(Y={driver:R.driver,base:R.base,items:[]},x.set(R.base,Y)),Y};for(const R of f){const Y=typeof R=="string",W=$r(Y?R:R.key),tt=Y?void 0:R.value,K=Y||!R.options?w:{...w,...R.options},V=e(W);I(V).items.push({key:W,value:tt,relativeKey:V.relativeKey,options:K})}return Promise.all([...x.values()].map(R=>E(R))).then(R=>R.flat())},d={hasItem(f,w={}){f=$r(f);const{relativeKey:E,driver:x}=e(f);return lr(x.hasItem,E,w)},getItem(f,w={}){f=$r(f);const{relativeKey:E,driver:x}=e(f);return lr(x.getItem,E,w).then(I=>Pu(I))},getItems(f,w){return l(f,w,E=>E.driver.getItems?lr(E.driver.getItems,E.items.map(x=>({key:x.relativeKey,options:x.options})),w).then(x=>x.map(I=>({key:J4(E.base,I.key),value:Pu(I.value)}))):Promise.all(E.items.map(x=>lr(E.driver.getItem,x.relativeKey,x.options).then(I=>({key:x.key,value:Pu(I)})))))},getItemRaw(f,w={}){f=$r(f);const{relativeKey:E,driver:x}=e(f);return x.getItemRaw?lr(x.getItemRaw,E,w):lr(x.getItem,E,w).then(I=>Q4(I))},async setItem(f,w,E={}){if(w===void 0)return d.removeItem(f);f=$r(f);const{relativeKey:x,driver:I}=e(f);I.setItem&&(await lr(I.setItem,x,Hu(w),E),I.watch||s("update",f))},async setItems(f,w){await l(f,w,async E=>{if(E.driver.setItems)return lr(E.driver.setItems,E.items.map(x=>({key:x.relativeKey,value:Hu(x.value),options:x.options})),w);E.driver.setItem&&await Promise.all(E.items.map(x=>lr(E.driver.setItem,x.relativeKey,Hu(x.value),x.options)))})},async setItemRaw(f,w,E={}){if(w===void 0)return d.removeItem(f,E);f=$r(f);const{relativeKey:x,driver:I}=e(f);if(I.setItemRaw)await lr(I.setItemRaw,x,w,E);else if(I.setItem)await lr(I.setItem,x,Y4(w),E);else return;I.watch||s("update",f)},async removeItem(f,w={}){typeof w=="boolean"&&(w={removeMeta:w}),f=$r(f);const{relativeKey:E,driver:x}=e(f);x.removeItem&&(await lr(x.removeItem,E,w),(w.removeMeta||w.removeMata)&&await lr(x.removeItem,E+"$",w),x.watch||s("remove",f))},async getMeta(f,w={}){typeof w=="boolean"&&(w={nativeOnly:w}),f=$r(f);const{relativeKey:E,driver:x}=e(f),I=Object.create(null);if(x.getMeta&&Object.assign(I,await lr(x.getMeta,E,w)),!w.nativeOnly){const R=await lr(x.getItem,E+"$",w).then(Y=>Pu(Y));R&&typeof R=="object"&&(typeof R.atime=="string"&&(R.atime=new Date(R.atime)),typeof R.mtime=="string"&&(R.mtime=new Date(R.mtime)),Object.assign(I,R))}return I},setMeta(f,w,E={}){return this.setItem(f+"$",w,E)},removeMeta(f,w={}){return this.removeItem(f+"$",w)},async getKeys(f,w={}){f=Ou(f);const E=n(f,!0);let x=[];const I=[];for(const R of E){const W=(await lr(R.driver.getKeys,R.relativeBase,w)).map(tt=>R.mountpoint+$r(tt)).filter(tt=>!x.some(K=>tt.startsWith(K)));I.push(...W),x=[R.mountpoint,...x.filter(tt=>!tt.startsWith(R.mountpoint))]}return f?I.filter(R=>R.startsWith(f)&&!R.endsWith("$")):I.filter(R=>!R.endsWith("$"))},async clear(f,w={}){f=Ou(f),await Promise.all(n(f,!1).map(async E=>{if(E.driver.clear)return lr(E.driver.clear,E.relativeBase,w);if(E.driver.removeItem){const x=await E.driver.getKeys(E.relativeBase||"",w);return Promise.all(x.map(I=>E.driver.removeItem(I,w)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(f=>Dp(f)))},async watch(f){return await a(),t.watchListeners.push(f),async()=>{t.watchListeners=t.watchListeners.filter(w=>w!==f),t.watchListeners.length===0&&await c()}},async unwatch(){t.watchListeners=[],await c()},mount(f,w){if(f=Ou(f),f&&t.mounts[f])throw new Error(`already mounted at ${f}`);return f&&(t.mountpoints.push(f),t.mountpoints.sort((E,x)=>x.length-E.length)),t.mounts[f]=w,t.watching&&Promise.resolve(Ip(w,s,f)).then(E=>{t.unwatch[f]=E}).catch(console.error),d},async unmount(f,w=!0){f=Ou(f),!(!f||!t.mounts[f])&&(t.watching&&f in t.unwatch&&(t.unwatch[f](),delete t.unwatch[f]),w&&await Dp(t.mounts[f]),t.mountpoints=t.mountpoints.filter(E=>E!==f),delete t.mounts[f])},getMount(f=""){f=$r(f)+":";const w=e(f);return{driver:w.driver,base:w.base}},getMounts(f="",w={}){return f=$r(f),n(f,w.parents).map(x=>({driver:x.driver,base:x.mountpoint}))}};return d}function Ip(r,t,e){return r.watch?r.watch((n,s)=>t(n,e+s)):()=>{}}async function Dp(r){typeof r.dispose=="function"&&await lr(r.dispose)}function Ps(r){return new Promise((t,e)=>{r.oncomplete=r.onsuccess=()=>t(r.result),r.onabort=r.onerror=()=>e(r.error)})}function $g(r,t){const e=indexedDB.open(r);e.onupgradeneeded=()=>e.result.createObjectStore(t);const n=Ps(e);return(s,a)=>n.then(c=>a(c.transaction(t,s).objectStore(t)))}let Xh;function ya(){return Xh||(Xh=$g("keyval-store","keyval")),Xh}function xp(r,t=ya()){return t("readonly",e=>Ps(e.get(r)))}function eS(r,t,e=ya()){return e("readwrite",n=>(n.put(t,r),Ps(n.transaction)))}function rS(r,t=ya()){return t("readwrite",e=>(e.delete(r),Ps(e.transaction)))}function iS(r=ya()){return r("readwrite",t=>(t.clear(),Ps(t.transaction)))}function nS(r,t){return r.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Ps(r.transaction)}function sS(r=ya()){return r("readonly",t=>{if(t.getAllKeys)return Ps(t.getAllKeys());const e=[];return nS(t,n=>e.push(n.key)).then(()=>e)})}const oS=r=>JSON.stringify(r,(t,e)=>typeof e=="bigint"?e.toString()+"n":e),aS=r=>{const t=/([\[:])?(\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,e=r.replace(t,'$1"$2n"$3');return JSON.parse(e,(n,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function wa(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return aS(r)}catch{return r}}function xn(r){return typeof r=="string"?r:oS(r)||""}const uS="idb-keyval";var cS=(r={})=>{const t=r.base&&r.base.length>0?`${r.base}:`:"",e=s=>t+s;let n;return r.dbName&&r.storeName&&(n=$g(r.dbName,r.storeName)),{name:uS,options:r,async hasItem(s){return!(typeof await xp(e(s),n)>"u")},async getItem(s){return await xp(e(s),n)??null},setItem(s,a){return eS(e(s),a,n)},removeItem(s){return rS(e(s),n)},getKeys(){return sS(n)},clear(){return iS(n)}}};const hS="WALLET_CONNECT_V2_INDEXED_DB",lS="keyvaluestorage";let fS=class{constructor(){this.indexedDb=tS({driver:cS({dbName:hS,storeName:lS})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const e=await this.indexedDb.getItem(t);if(e!==null)return e}async setItem(t,e){await this.indexedDb.setItem(t,xn(e))}async removeItem(t){await this.indexedDb.removeItem(t)}};var Zh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{},Ku={exports:{}};(function(){let r;function t(){}r=t,r.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},r.prototype.setItem=function(e,n){this[e]=String(n)},r.prototype.removeItem=function(e){delete this[e]},r.prototype.clear=function(){const e=this;Object.keys(e).forEach(function(n){e[n]=void 0,delete e[n]})},r.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Zh<"u"&&Zh.localStorage?Ku.exports=Zh.localStorage:typeof window<"u"&&window.localStorage?Ku.exports=window.localStorage:Ku.exports=new t})();function dS(r){var t;return[r[0],wa((t=r[1])!=null?t:"")]}let pS=class{constructor(){this.localStorage=Ku.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(dS)}async getItem(t){const e=this.localStorage.getItem(t);if(e!==null)return wa(e)}async setItem(t,e){this.localStorage.setItem(t,xn(e))}async removeItem(t){this.localStorage.removeItem(t)}};const gS="wc_storage_version",Mp=1,mS=async(r,t,e)=>{const n=gS,s=await t.getItem(n);if(s&&s>=Mp){e(t);return}const a=await r.getKeys();if(!a.length){e(t);return}const c=[];for(;a.length;){const l=a.shift();if(!l)continue;const d=l.toLowerCase();if(d.includes("wc@")||d.includes("walletconnect")||d.includes("wc_")||d.includes("wallet_connect")){const f=await r.getItem(l);await t.setItem(l,f),c.push(l)}}await t.setItem(n,Mp),e(t),vS(r,c)},vS=async(r,t)=>{t.length&&t.forEach(async e=>{await r.removeItem(e)})};let yS=class{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const t=new pS;this.storage=t;try{const e=new fS;mS(t,e,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(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,e){return await this.initialize(),this.storage.setItem(t,e)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const e=setInterval(()=>{this.initialized&&(clearInterval(e),t())},20)})}};var Eo={},Wo={},tl={},Yo={};let Os=class{};const wS=Object.freeze(Object.defineProperty({__proto__:null,IEvents:Os},Symbol.toStringTag,{value:"Module"})),bS=Ll(wS);var Cp;function _S(){if(Cp)return Yo;Cp=1,Object.defineProperty(Yo,"__esModule",{value:!0}),Yo.IHeartBeat=void 0;const r=bS;class t extends r.IEvents{constructor(n){super()}}return Yo.IHeartBeat=t,Yo}var Pp;function zg(){return Pp||(Pp=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Mn.__exportStar(_S(),r)}(tl)),tl}var el={},_s={},Op;function ES(){if(Op)return _s;Op=1,Object.defineProperty(_s,"__esModule",{value:!0}),_s.HEARTBEAT_EVENTS=_s.HEARTBEAT_INTERVAL=void 0;const r=bt;return _s.HEARTBEAT_INTERVAL=r.FIVE_SECONDS,_s.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},_s}var Np;function kg(){return Np||(Np=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Mn.__exportStar(ES(),r)}(el)),el}var Rp;function AS(){if(Rp)return Wo;Rp=1,Object.defineProperty(Wo,"__esModule",{value:!0}),Wo.HeartBeat=void 0;const r=Mn,t=Di,e=bt,n=zg(),s=kg();class a extends n.IHeartBeat{constructor(l){super(l),this.events=new t.EventEmitter,this.interval=s.HEARTBEAT_INTERVAL,this.interval=(l==null?void 0:l.interval)||s.HEARTBEAT_INTERVAL}static init(l){return r.__awaiter(this,void 0,void 0,function*(){const d=new a(l);return yield d.init(),d})}init(){return r.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(l,d){this.events.on(l,d)}once(l,d){this.events.once(l,d)}off(l,d){this.events.off(l,d)}removeListener(l,d){this.events.removeListener(l,d)}initialize(){return r.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),e.toMiliseconds(this.interval))})}pulse(){this.events.emit(s.HEARTBEAT_EVENTS.pulse)}}return Wo.HeartBeat=a,Wo}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;t.__exportStar(AS(),r),t.__exportStar(zg(),r),t.__exportStar(kg(),r)})(Eo);function SS(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var IS=DS;function DS(r,t,e){var n=e&&e.stringify||SS,s=1;if(typeof r=="object"&&r!==null){var a=t.length+s;if(a===1)return r;var c=new Array(a);c[0]=n(r);for(var l=1;l<a;l++)c[l]=n(t[l]);return c.join(" ")}if(typeof r!="string")return r;var d=t.length;if(d===0)return r;for(var f="",w=1-s,E=-1,x=r&&r.length||0,I=0;I<x;){if(r.charCodeAt(I)===37&&I+1<x){switch(E=E>-1?E:0,r.charCodeAt(I+1)){case 100:case 102:if(w>=d||t[w]==null)break;E<I&&(f+=r.slice(E,I)),f+=Number(t[w]),E=I+2,I++;break;case 105:if(w>=d||t[w]==null)break;E<I&&(f+=r.slice(E,I)),f+=Math.floor(Number(t[w])),E=I+2,I++;break;case 79:case 111:case 106:if(w>=d||t[w]===void 0)break;E<I&&(f+=r.slice(E,I));var R=typeof t[w];if(R==="string"){f+="'"+t[w]+"'",E=I+2,I++;break}if(R==="function"){f+=t[w].name||"<anonymous>",E=I+2,I++;break}f+=n(t[w]),E=I+2,I++;break;case 115:if(w>=d)break;E<I&&(f+=r.slice(E,I)),f+=String(t[w]),E=I+2,I++;break;case 37:E<I&&(f+=r.slice(E,I)),f+="%",E=I+2,I++,w--;break}++w}++I}return E===-1?r:(E<x&&(f+=r.slice(E)),f)}const Tp=IS;var io=an;const ha=US().console||{},xS={mapHttpRequest:Nu,mapHttpResponse:Nu,wrapRequestSerializer:rl,wrapResponseSerializer:rl,wrapErrorSerializer:rl,req:Nu,res:Nu,err:NS};function MS(r,t){return Array.isArray(r)?r.filter(function(n){return n!=="!stdSerializers.err"}):r===!0?Object.keys(t):!1}function an(r){r=r||{},r.browser=r.browser||{};const t=r.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const e=r.browser.write||ha;r.browser.write&&(r.browser.asObject=!0);const n=r.serializers||{},s=MS(r.browser.serialize,n);let a=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(a=!1);const c=["error","fatal","warn","info","debug","trace"];typeof e=="function"&&(e.error=e.fatal=e.warn=e.info=e.debug=e.trace=e),r.enabled===!1&&(r.level="silent");const l=r.level||"info",d=Object.create(e);d.log||(d.log=la),Object.defineProperty(d,"levelVal",{get:w}),Object.defineProperty(d,"level",{get:E,set:x});const f={transmit:t,serialize:s,asObject:r.browser.asObject,levels:c,timestamp:RS(r)};d.levels=an.levels,d.level=l,d.setMaxListeners=d.getMaxListeners=d.emit=d.addListener=d.on=d.prependListener=d.once=d.prependOnceListener=d.removeListener=d.removeAllListeners=d.listeners=d.listenerCount=d.eventNames=d.write=d.flush=la,d.serializers=n,d._serialize=s,d._stdErrSerialize=a,d.child=I,t&&(d._logEvent=Ol());function w(){return this.level==="silent"?1/0:this.levels.values[this.level]}function E(){return this._level}function x(R){if(R!=="silent"&&!this.levels.values[R])throw Error("unknown level "+R);this._level=R,Xs(f,d,"error","log"),Xs(f,d,"fatal","error"),Xs(f,d,"warn","error"),Xs(f,d,"info","log"),Xs(f,d,"debug","log"),Xs(f,d,"trace","log")}function I(R,Y){if(!R)throw new Error("missing bindings for child Pino");Y=Y||{},s&&R.serializers&&(Y.serializers=R.serializers);const W=Y.serializers;if(s&&W){var tt=Object.assign({},n,W),K=r.browser.serialize===!0?Object.keys(tt):s;delete R.serializers,pc([R],K,tt,this._stdErrSerialize)}function V(B){this._childLevel=(B._childLevel|0)+1,this.error=Zs(B,R,"error"),this.fatal=Zs(B,R,"fatal"),this.warn=Zs(B,R,"warn"),this.info=Zs(B,R,"info"),this.debug=Zs(B,R,"debug"),this.trace=Zs(B,R,"trace"),tt&&(this.serializers=tt,this._serialize=K),t&&(this._logEvent=Ol([].concat(B._logEvent.bindings,R)))}return V.prototype=this,new V(this)}return d}an.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"}};an.stdSerializers=xS;an.stdTimeFunctions=Object.assign({},{nullTime:Hg,epochTime:Kg,unixTime:TS,isoTime:FS});function Xs(r,t,e,n){const s=Object.getPrototypeOf(t);t[e]=t.levelVal>t.levels.values[e]?la:s[e]?s[e]:ha[e]||ha[n]||la,CS(r,t,e)}function CS(r,t,e){!r.transmit&&t[e]===la||(t[e]=function(n){return function(){const a=r.timestamp(),c=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===ha?ha:this;for(var d=0;d<c.length;d++)c[d]=arguments[d];if(r.serialize&&!r.asObject&&pc(c,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?n.call(l,PS(this,e,c,a)):n.apply(l,c),r.transmit){const f=r.transmit.level||t.level,w=an.levels.values[f],E=an.levels.values[e];if(E<w)return;OS(this,{ts:a,methodLevel:e,methodValue:E,transmitLevel:f,transmitValue:an.levels.values[r.transmit.level||t.level],send:r.transmit.send,val:t.levelVal},c)}}}(t[e]))}function PS(r,t,e,n){r._serialize&&pc(e,r._serialize,r.serializers,r._stdErrSerialize);const s=e.slice();let a=s[0];const c={};n&&(c.time=n),c.level=an.levels.values[t];let l=(r._childLevel|0)+1;if(l<1&&(l=1),a!==null&&typeof a=="object"){for(;l--&&typeof s[0]=="object";)Object.assign(c,s.shift());a=s.length?Tp(s.shift(),s):void 0}else typeof a=="string"&&(a=Tp(s.shift(),s));return a!==void 0&&(c.msg=a),c}function pc(r,t,e,n){for(const s in r)if(n&&r[s]instanceof Error)r[s]=an.stdSerializers.err(r[s]);else if(typeof r[s]=="object"&&!Array.isArray(r[s]))for(const a in r[s])t&&t.indexOf(a)>-1&&a in e&&(r[s][a]=e[a](r[s][a]))}function Zs(r,t,e){return function(){const n=new Array(1+arguments.length);n[0]=t;for(var s=1;s<n.length;s++)n[s]=arguments[s-1];return r[e].apply(this,n)}}function OS(r,t,e){const n=t.send,s=t.ts,a=t.methodLevel,c=t.methodValue,l=t.val,d=r._logEvent.bindings;pc(e,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=s,r._logEvent.messages=e.filter(function(f){return d.indexOf(f)===-1}),r._logEvent.level.label=a,r._logEvent.level.value=c,n(a,r._logEvent,l),r._logEvent=Ol(d)}function Ol(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function NS(r){const t={type:r.constructor.name,msg:r.message,stack:r.stack};for(const e in r)t[e]===void 0&&(t[e]=r[e]);return t}function RS(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?Hg:Kg}function Nu(){return{}}function rl(r){return r}function la(){}function Hg(){return!1}function Kg(){return Date.now()}function TS(){return Math.round(Date.now()/1e3)}function FS(){return new Date(Date.now()).toISOString()}function US(){function r(t){return typeof t<"u"&&t}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 ba=ql(io),BS={level:"info"},_a="custom_context",sf=1e3*1024;let LS=class{constructor(t){this.nodeValue=t,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Fp=class{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0}append(t){const e=new LS(t);if(e.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${e.size}`);for(;this.size+e.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=e),this.tail=e):(this.head=e,this.tail=e),this.lengthInNodes++,this.sizeInBytes+=e.size}shift(){if(!this.head)return;const t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size}toArray(){const t=[];let e=this.head;for(;e!==null;)t.push(e.value),e=e.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return{next:()=>{if(!t)return{done:!0,value:null};const e=t.value;return t=t.next,{done:!1,value:e}}}}},Vg=class{constructor(t,e=sf){this.level=t??"error",this.levelValue=io.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=e,this.logs=new Fp(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(t,e){e===io.levels.values.error?console.error(t):e===io.levels.values.warn?console.warn(t):e===io.levels.values.debug?console.debug(t):e===io.levels.values.trace?console.trace(t):console.log(t)}appendToLogs(t){this.logs.append(xn({timestamp:new Date().toISOString(),log:t}));const e=typeof t=="string"?JSON.parse(t).level:t.level;e>=this.levelValue&&this.forwardToConsole(t,e)}getLogs(){return this.logs}clearLogs(){this.logs=new Fp(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(t){const e=this.getLogArray();return e.push(xn({extraMetadata:t})),new Blob(e,{type:"application/json"})}};class qS{constructor(t,e=sf){this.baseChunkLogger=new Vg(t,e)}write(t){this.baseChunkLogger.appendToLogs(t)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){const e=URL.createObjectURL(this.logsToBlob(t)),n=document.createElement("a");n.href=e,n.download=`w3i-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}}class jS extends i6.Writable{constructor(t,e=sf){super({objectMode:!0}),this.baseChunkLogger=new Vg(t,e)}_write(t,e,n){try{this.baseChunkLogger.appendToLogs(t),n()}catch(s){n(s)}}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}}var $S=Object.defineProperty,zS=Object.defineProperties,kS=Object.getOwnPropertyDescriptors,Up=Object.getOwnPropertySymbols,HS=Object.prototype.hasOwnProperty,KS=Object.prototype.propertyIsEnumerable,Bp=(r,t,e)=>t in r?$S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rc=(r,t)=>{for(var e in t||(t={}))HS.call(t,e)&&Bp(r,e,t[e]);if(Up)for(var e of Up(t))KS.call(t,e)&&Bp(r,e,t[e]);return r},ic=(r,t)=>zS(r,kS(t));function gc(r){return ic(rc({},r),{level:(r==null?void 0:r.level)||BS.level})}function VS(r,t=_a){return r[t]||""}function GS(r,t,e=_a){return r[e]=t,r}function Kr(r,t=_a){let e="";return typeof r.bindings>"u"?e=VS(r,t):e=r.bindings().context||"",e}function WS(r,t,e=_a){const n=Kr(r,e);return n.trim()?`${n}/${t}`:t}function Vr(r,t,e=_a){const n=WS(r,t,e),s=r.child({context:n});return GS(s,n,e)}function YS(r){var t,e;const n=new qS((t=r.opts)==null?void 0:t.level,r.maxSizeInBytes);return{logger:ba(ic(rc({},r.opts),{level:"trace",browser:ic(rc({},(e=r.opts)==null?void 0:e.browser),{write:s=>n.write(s)})})),chunkLoggerController:n}}function QS(r){var t;const e=new jS((t=r.opts)==null?void 0:t.level,r.maxSizeInBytes);return{logger:ba(ic(rc({},r.opts),{level:"trace"}),e),chunkLoggerController:e}}function JS(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?YS(r):QS(r)}class XS extends Os{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}let ZS=class extends Os{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}},tI=class{constructor(t,e){this.logger=t,this.core=e}},eI=class extends Os{constructor(t,e){super(),this.relayer=t,this.logger=e}},rI=class extends Os{constructor(t){super()}},iI=class{constructor(t,e,n,s){this.core=t,this.logger=e,this.name=n}};class nI extends Os{constructor(t,e){super(),this.relayer=t,this.logger=e}}let sI=class extends Os{constructor(t,e){super(),this.core=t,this.logger=e}},oI=class{constructor(t,e){this.projectId=t,this.logger=e}},aI=class{constructor(t,e){this.projectId=t,this.logger=e}},uI=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},cI=class{constructor(t){this.client=t}};var of={},Gg={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var t=oe,e=ni;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var n=function(){function l(){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 l.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},l.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},l.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._tempHi),e.wipe(this._tempLo),this.reset()},l.prototype.update=function(d,f){if(f===void 0&&(f=d.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var w=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&f>0;)this._buffer[this._bufferLength++]=d[w++],f--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(w=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,d,w,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=d[w++],f--;return this},l.prototype.finish=function(d){if(!this._finished){var f=this._bytesHashed,w=this._bufferLength,E=f/536870912|0,x=f<<3,I=f%128<112?128:256;this._buffer[w]=128;for(var R=w+1;R<I-8;R++)this._buffer[R]=0;t.writeUint32BE(E,this._buffer,I-8),t.writeUint32BE(x,this._buffer,I-4),a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,I),this._finished=!0}for(var R=0;R<this.digestLength/8;R++)t.writeUint32BE(this._stateHi[R],d,R*8),t.writeUint32BE(this._stateLo[R],d,R*8+4);return this},l.prototype.digest=function(){var d=new Uint8Array(this.digestLength);return this.finish(d),d},l.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}},l.prototype.restoreState=function(d){return this._stateHi.set(d.stateHi),this._stateLo.set(d.stateLo),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},l.prototype.cleanSavedState=function(d){e.wipe(d.stateHi),e.wipe(d.stateLo),d.buffer&&e.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},l}();r.SHA512=n;var s=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 a(l,d,f,w,E,x,I){for(var R=f[0],Y=f[1],W=f[2],tt=f[3],K=f[4],V=f[5],B=f[6],z=f[7],$=w[0],v=w[1],T=w[2],st=w[3],ft=w[4],pt=w[5],gt=w[6],h=w[7],y,b,C,M,N,q,S,g;I>=128;){for(var O=0;O<16;O++){var it=8*O+x;l[O]=t.readUint32BE(E,it),d[O]=t.readUint32BE(E,it+4)}for(var O=0;O<80;O++){var lt=R,_=Y,Z=W,U=tt,L=K,k=V,p=B,F=z,et=$,ct=v,at=T,Mt=st,Pt=ft,It=pt,Ee=gt,$t=h;if(y=z,b=h,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=(K>>>14|ft<<32-14)^(K>>>18|ft<<32-18)^(ft>>>41-32|K<<32-(41-32)),b=(ft>>>14|K<<32-14)^(ft>>>18|K<<32-18)^(K>>>41-32|ft<<32-(41-32)),N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,y=K&V^~K&B,b=ft&pt^~ft&gt,N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,y=s[O*2],b=s[O*2+1],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,y=l[O%16],b=d[O%16],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,C=S&65535|g<<16,M=N&65535|q<<16,y=C,b=M,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=(R>>>28|$<<32-28)^($>>>34-32|R<<32-(34-32))^($>>>39-32|R<<32-(39-32)),b=($>>>28|R<<32-28)^(R>>>34-32|$<<32-(34-32))^(R>>>39-32|$<<32-(39-32)),N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,y=R&Y^R&W^Y&W,b=$&v^$&T^v&T,N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,F=S&65535|g<<16,$t=N&65535|q<<16,y=U,b=Mt,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=C,b=M,N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,U=S&65535|g<<16,Mt=N&65535|q<<16,Y=lt,W=_,tt=Z,K=U,V=L,B=k,z=p,R=F,v=et,T=ct,st=at,ft=Mt,pt=Pt,gt=It,h=Ee,$=$t,O%16===15)for(var it=0;it<16;it++)y=l[it],b=d[it],N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=l[(it+9)%16],b=d[(it+9)%16],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,C=l[(it+1)%16],M=d[(it+1)%16],y=(C>>>1|M<<32-1)^(C>>>8|M<<32-8)^C>>>7,b=(M>>>1|C<<32-1)^(M>>>8|C<<32-8)^(M>>>7|C<<32-7),N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,C=l[(it+14)%16],M=d[(it+14)%16],y=(C>>>19|M<<32-19)^(M>>>61-32|C<<32-(61-32))^C>>>6,b=(M>>>19|C<<32-19)^(C>>>61-32|M<<32-(61-32))^(M>>>6|C<<32-6),N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,l[it]=S&65535|g<<16,d[it]=N&65535|q<<16}y=R,b=$,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[0],b=w[0],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[0]=R=S&65535|g<<16,w[0]=$=N&65535|q<<16,y=Y,b=v,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[1],b=w[1],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[1]=Y=S&65535|g<<16,w[1]=v=N&65535|q<<16,y=W,b=T,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[2],b=w[2],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[2]=W=S&65535|g<<16,w[2]=T=N&65535|q<<16,y=tt,b=st,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[3],b=w[3],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[3]=tt=S&65535|g<<16,w[3]=st=N&65535|q<<16,y=K,b=ft,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[4],b=w[4],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[4]=K=S&65535|g<<16,w[4]=ft=N&65535|q<<16,y=V,b=pt,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[5],b=w[5],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[5]=V=S&65535|g<<16,w[5]=pt=N&65535|q<<16,y=B,b=gt,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[6],b=w[6],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[6]=B=S&65535|g<<16,w[6]=gt=N&65535|q<<16,y=z,b=h,N=b&65535,q=b>>>16,S=y&65535,g=y>>>16,y=f[7],b=w[7],N+=b&65535,q+=b>>>16,S+=y&65535,g+=y>>>16,q+=N>>>16,S+=q>>>16,g+=S>>>16,f[7]=z=S&65535|g<<16,w[7]=h=N&65535|q<<16,x+=128,I-=128}return x}function c(l){var d=new n;d.update(l);var f=d.digest();return d.clean(),f}r.hash=c})(Gg);(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 t=po,e=Gg,n=ni;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function s(U){const L=new Float64Array(16);if(U)for(let k=0;k<U.length;k++)L[k]=U[k];return L}const a=new Uint8Array(32);a[0]=9;const c=s(),l=s([1]),d=s([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=s([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=s([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=s([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),x=s([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function I(U,L){for(let k=0;k<16;k++)U[k]=L[k]|0}function R(U){let L=1;for(let k=0;k<16;k++){let p=U[k]+L+65535;L=Math.floor(p/65536),U[k]=p-L*65536}U[0]+=L-1+37*(L-1)}function Y(U,L,k){const p=~(k-1);for(let F=0;F<16;F++){const et=p&(U[F]^L[F]);U[F]^=et,L[F]^=et}}function W(U,L){const k=s(),p=s();for(let F=0;F<16;F++)p[F]=L[F];R(p),R(p),R(p);for(let F=0;F<2;F++){k[0]=p[0]-65517;for(let ct=1;ct<15;ct++)k[ct]=p[ct]-65535-(k[ct-1]>>16&1),k[ct-1]&=65535;k[15]=p[15]-32767-(k[14]>>16&1);const et=k[15]>>16&1;k[14]&=65535,Y(p,k,1-et)}for(let F=0;F<16;F++)U[2*F]=p[F]&255,U[2*F+1]=p[F]>>8}function tt(U,L){let k=0;for(let p=0;p<32;p++)k|=U[p]^L[p];return(1&k-1>>>8)-1}function K(U,L){const k=new Uint8Array(32),p=new Uint8Array(32);return W(k,U),W(p,L),tt(k,p)}function V(U){const L=new Uint8Array(32);return W(L,U),L[0]&1}function B(U,L){for(let k=0;k<16;k++)U[k]=L[2*k]+(L[2*k+1]<<8);U[15]&=32767}function z(U,L,k){for(let p=0;p<16;p++)U[p]=L[p]+k[p]}function $(U,L,k){for(let p=0;p<16;p++)U[p]=L[p]-k[p]}function v(U,L,k){let p,F,et=0,ct=0,at=0,Mt=0,Pt=0,It=0,Ee=0,$t=0,xt=0,Bt=0,_t=0,Et=0,Vt=0,yt=0,At=0,Ut=0,wt=0,Ct=0,Lt=0,Ot=0,Nt=0,se=0,Tt=0,Rt=0,Ke=0,ue=0,pe=0,Ve=0,ye=0,_e=0,Er=0,Gt=k[0],zt=k[1],De=k[2],Wt=k[3],Kt=k[4],Ae=k[5],Jt=k[6],Xt=k[7],xe=k[8],Zt=k[9],Yt=k[10],Ce=k[11],Qt=k[12],qt=k[13],Te=k[14],te=k[15];p=L[0],et+=p*Gt,ct+=p*zt,at+=p*De,Mt+=p*Wt,Pt+=p*Kt,It+=p*Ae,Ee+=p*Jt,$t+=p*Xt,xt+=p*xe,Bt+=p*Zt,_t+=p*Yt,Et+=p*Ce,Vt+=p*Qt,yt+=p*qt,At+=p*Te,Ut+=p*te,p=L[1],ct+=p*Gt,at+=p*zt,Mt+=p*De,Pt+=p*Wt,It+=p*Kt,Ee+=p*Ae,$t+=p*Jt,xt+=p*Xt,Bt+=p*xe,_t+=p*Zt,Et+=p*Yt,Vt+=p*Ce,yt+=p*Qt,At+=p*qt,Ut+=p*Te,wt+=p*te,p=L[2],at+=p*Gt,Mt+=p*zt,Pt+=p*De,It+=p*Wt,Ee+=p*Kt,$t+=p*Ae,xt+=p*Jt,Bt+=p*Xt,_t+=p*xe,Et+=p*Zt,Vt+=p*Yt,yt+=p*Ce,At+=p*Qt,Ut+=p*qt,wt+=p*Te,Ct+=p*te,p=L[3],Mt+=p*Gt,Pt+=p*zt,It+=p*De,Ee+=p*Wt,$t+=p*Kt,xt+=p*Ae,Bt+=p*Jt,_t+=p*Xt,Et+=p*xe,Vt+=p*Zt,yt+=p*Yt,At+=p*Ce,Ut+=p*Qt,wt+=p*qt,Ct+=p*Te,Lt+=p*te,p=L[4],Pt+=p*Gt,It+=p*zt,Ee+=p*De,$t+=p*Wt,xt+=p*Kt,Bt+=p*Ae,_t+=p*Jt,Et+=p*Xt,Vt+=p*xe,yt+=p*Zt,At+=p*Yt,Ut+=p*Ce,wt+=p*Qt,Ct+=p*qt,Lt+=p*Te,Ot+=p*te,p=L[5],It+=p*Gt,Ee+=p*zt,$t+=p*De,xt+=p*Wt,Bt+=p*Kt,_t+=p*Ae,Et+=p*Jt,Vt+=p*Xt,yt+=p*xe,At+=p*Zt,Ut+=p*Yt,wt+=p*Ce,Ct+=p*Qt,Lt+=p*qt,Ot+=p*Te,Nt+=p*te,p=L[6],Ee+=p*Gt,$t+=p*zt,xt+=p*De,Bt+=p*Wt,_t+=p*Kt,Et+=p*Ae,Vt+=p*Jt,yt+=p*Xt,At+=p*xe,Ut+=p*Zt,wt+=p*Yt,Ct+=p*Ce,Lt+=p*Qt,Ot+=p*qt,Nt+=p*Te,se+=p*te,p=L[7],$t+=p*Gt,xt+=p*zt,Bt+=p*De,_t+=p*Wt,Et+=p*Kt,Vt+=p*Ae,yt+=p*Jt,At+=p*Xt,Ut+=p*xe,wt+=p*Zt,Ct+=p*Yt,Lt+=p*Ce,Ot+=p*Qt,Nt+=p*qt,se+=p*Te,Tt+=p*te,p=L[8],xt+=p*Gt,Bt+=p*zt,_t+=p*De,Et+=p*Wt,Vt+=p*Kt,yt+=p*Ae,At+=p*Jt,Ut+=p*Xt,wt+=p*xe,Ct+=p*Zt,Lt+=p*Yt,Ot+=p*Ce,Nt+=p*Qt,se+=p*qt,Tt+=p*Te,Rt+=p*te,p=L[9],Bt+=p*Gt,_t+=p*zt,Et+=p*De,Vt+=p*Wt,yt+=p*Kt,At+=p*Ae,Ut+=p*Jt,wt+=p*Xt,Ct+=p*xe,Lt+=p*Zt,Ot+=p*Yt,Nt+=p*Ce,se+=p*Qt,Tt+=p*qt,Rt+=p*Te,Ke+=p*te,p=L[10],_t+=p*Gt,Et+=p*zt,Vt+=p*De,yt+=p*Wt,At+=p*Kt,Ut+=p*Ae,wt+=p*Jt,Ct+=p*Xt,Lt+=p*xe,Ot+=p*Zt,Nt+=p*Yt,se+=p*Ce,Tt+=p*Qt,Rt+=p*qt,Ke+=p*Te,ue+=p*te,p=L[11],Et+=p*Gt,Vt+=p*zt,yt+=p*De,At+=p*Wt,Ut+=p*Kt,wt+=p*Ae,Ct+=p*Jt,Lt+=p*Xt,Ot+=p*xe,Nt+=p*Zt,se+=p*Yt,Tt+=p*Ce,Rt+=p*Qt,Ke+=p*qt,ue+=p*Te,pe+=p*te,p=L[12],Vt+=p*Gt,yt+=p*zt,At+=p*De,Ut+=p*Wt,wt+=p*Kt,Ct+=p*Ae,Lt+=p*Jt,Ot+=p*Xt,Nt+=p*xe,se+=p*Zt,Tt+=p*Yt,Rt+=p*Ce,Ke+=p*Qt,ue+=p*qt,pe+=p*Te,Ve+=p*te,p=L[13],yt+=p*Gt,At+=p*zt,Ut+=p*De,wt+=p*Wt,Ct+=p*Kt,Lt+=p*Ae,Ot+=p*Jt,Nt+=p*Xt,se+=p*xe,Tt+=p*Zt,Rt+=p*Yt,Ke+=p*Ce,ue+=p*Qt,pe+=p*qt,Ve+=p*Te,ye+=p*te,p=L[14],At+=p*Gt,Ut+=p*zt,wt+=p*De,Ct+=p*Wt,Lt+=p*Kt,Ot+=p*Ae,Nt+=p*Jt,se+=p*Xt,Tt+=p*xe,Rt+=p*Zt,Ke+=p*Yt,ue+=p*Ce,pe+=p*Qt,Ve+=p*qt,ye+=p*Te,_e+=p*te,p=L[15],Ut+=p*Gt,wt+=p*zt,Ct+=p*De,Lt+=p*Wt,Ot+=p*Kt,Nt+=p*Ae,se+=p*Jt,Tt+=p*Xt,Rt+=p*xe,Ke+=p*Zt,ue+=p*Yt,pe+=p*Ce,Ve+=p*Qt,ye+=p*qt,_e+=p*Te,Er+=p*te,et+=38*wt,ct+=38*Ct,at+=38*Lt,Mt+=38*Ot,Pt+=38*Nt,It+=38*se,Ee+=38*Tt,$t+=38*Rt,xt+=38*Ke,Bt+=38*ue,_t+=38*pe,Et+=38*Ve,Vt+=38*ye,yt+=38*_e,At+=38*Er,F=1,p=et+F+65535,F=Math.floor(p/65536),et=p-F*65536,p=ct+F+65535,F=Math.floor(p/65536),ct=p-F*65536,p=at+F+65535,F=Math.floor(p/65536),at=p-F*65536,p=Mt+F+65535,F=Math.floor(p/65536),Mt=p-F*65536,p=Pt+F+65535,F=Math.floor(p/65536),Pt=p-F*65536,p=It+F+65535,F=Math.floor(p/65536),It=p-F*65536,p=Ee+F+65535,F=Math.floor(p/65536),Ee=p-F*65536,p=$t+F+65535,F=Math.floor(p/65536),$t=p-F*65536,p=xt+F+65535,F=Math.floor(p/65536),xt=p-F*65536,p=Bt+F+65535,F=Math.floor(p/65536),Bt=p-F*65536,p=_t+F+65535,F=Math.floor(p/65536),_t=p-F*65536,p=Et+F+65535,F=Math.floor(p/65536),Et=p-F*65536,p=Vt+F+65535,F=Math.floor(p/65536),Vt=p-F*65536,p=yt+F+65535,F=Math.floor(p/65536),yt=p-F*65536,p=At+F+65535,F=Math.floor(p/65536),At=p-F*65536,p=Ut+F+65535,F=Math.floor(p/65536),Ut=p-F*65536,et+=F-1+37*(F-1),F=1,p=et+F+65535,F=Math.floor(p/65536),et=p-F*65536,p=ct+F+65535,F=Math.floor(p/65536),ct=p-F*65536,p=at+F+65535,F=Math.floor(p/65536),at=p-F*65536,p=Mt+F+65535,F=Math.floor(p/65536),Mt=p-F*65536,p=Pt+F+65535,F=Math.floor(p/65536),Pt=p-F*65536,p=It+F+65535,F=Math.floor(p/65536),It=p-F*65536,p=Ee+F+65535,F=Math.floor(p/65536),Ee=p-F*65536,p=$t+F+65535,F=Math.floor(p/65536),$t=p-F*65536,p=xt+F+65535,F=Math.floor(p/65536),xt=p-F*65536,p=Bt+F+65535,F=Math.floor(p/65536),Bt=p-F*65536,p=_t+F+65535,F=Math.floor(p/65536),_t=p-F*65536,p=Et+F+65535,F=Math.floor(p/65536),Et=p-F*65536,p=Vt+F+65535,F=Math.floor(p/65536),Vt=p-F*65536,p=yt+F+65535,F=Math.floor(p/65536),yt=p-F*65536,p=At+F+65535,F=Math.floor(p/65536),At=p-F*65536,p=Ut+F+65535,F=Math.floor(p/65536),Ut=p-F*65536,et+=F-1+37*(F-1),U[0]=et,U[1]=ct,U[2]=at,U[3]=Mt,U[4]=Pt,U[5]=It,U[6]=Ee,U[7]=$t,U[8]=xt,U[9]=Bt,U[10]=_t,U[11]=Et,U[12]=Vt,U[13]=yt,U[14]=At,U[15]=Ut}function T(U,L){v(U,L,L)}function st(U,L){const k=s();let p;for(p=0;p<16;p++)k[p]=L[p];for(p=253;p>=0;p--)T(k,k),p!==2&&p!==4&&v(k,k,L);for(p=0;p<16;p++)U[p]=k[p]}function ft(U,L){const k=s();let p;for(p=0;p<16;p++)k[p]=L[p];for(p=250;p>=0;p--)T(k,k),p!==1&&v(k,k,L);for(p=0;p<16;p++)U[p]=k[p]}function pt(U,L){const k=s(),p=s(),F=s(),et=s(),ct=s(),at=s(),Mt=s(),Pt=s(),It=s();$(k,U[1],U[0]),$(It,L[1],L[0]),v(k,k,It),z(p,U[0],U[1]),z(It,L[0],L[1]),v(p,p,It),v(F,U[3],L[3]),v(F,F,f),v(et,U[2],L[2]),z(et,et,et),$(ct,p,k),$(at,et,F),z(Mt,et,F),z(Pt,p,k),v(U[0],ct,at),v(U[1],Pt,Mt),v(U[2],Mt,at),v(U[3],ct,Pt)}function gt(U,L,k){for(let p=0;p<4;p++)Y(U[p],L[p],k)}function h(U,L){const k=s(),p=s(),F=s();st(F,L[2]),v(k,L[0],F),v(p,L[1],F),W(U,p),U[31]^=V(k)<<7}function y(U,L,k){I(U[0],c),I(U[1],l),I(U[2],l),I(U[3],c);for(let p=255;p>=0;--p){const F=k[p/8|0]>>(p&7)&1;gt(U,L,F),pt(L,U),pt(U,U),gt(U,L,F)}}function b(U,L){const k=[s(),s(),s(),s()];I(k[0],w),I(k[1],E),I(k[2],l),v(k[3],w,E),y(U,k,L)}function C(U){if(U.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const L=(0,e.hash)(U);L[0]&=248,L[31]&=127,L[31]|=64;const k=new Uint8Array(32),p=[s(),s(),s(),s()];b(p,L),h(k,p);const F=new Uint8Array(64);return F.set(U),F.set(k,32),{publicKey:k,secretKey:F}}r.generateKeyPairFromSeed=C;function M(U){const L=(0,t.randomBytes)(32,U),k=C(L);return(0,n.wipe)(L),k}r.generateKeyPair=M;function N(U){if(U.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(U.subarray(32))}r.extractPublicKeyFromSecretKey=N;const q=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 S(U,L){let k,p,F,et;for(p=63;p>=32;--p){for(k=0,F=p-32,et=p-12;F<et;++F)L[F]+=k-16*L[p]*q[F-(p-32)],k=Math.floor((L[F]+128)/256),L[F]-=k*256;L[F]+=k,L[p]=0}for(k=0,F=0;F<32;F++)L[F]+=k-(L[31]>>4)*q[F],k=L[F]>>8,L[F]&=255;for(F=0;F<32;F++)L[F]-=k*q[F];for(p=0;p<32;p++)L[p+1]+=L[p]>>8,U[p]=L[p]&255}function g(U){const L=new Float64Array(64);for(let k=0;k<64;k++)L[k]=U[k];for(let k=0;k<64;k++)U[k]=0;S(U,L)}function O(U,L){const k=new Float64Array(64),p=[s(),s(),s(),s()],F=(0,e.hash)(U.subarray(0,32));F[0]&=248,F[31]&=127,F[31]|=64;const et=new Uint8Array(64);et.set(F.subarray(32),32);const ct=new e.SHA512;ct.update(et.subarray(32)),ct.update(L);const at=ct.digest();ct.clean(),g(at),b(p,at),h(et,p),ct.reset(),ct.update(et.subarray(0,32)),ct.update(U.subarray(32)),ct.update(L);const Mt=ct.digest();g(Mt);for(let Pt=0;Pt<32;Pt++)k[Pt]=at[Pt];for(let Pt=0;Pt<32;Pt++)for(let It=0;It<32;It++)k[Pt+It]+=Mt[Pt]*F[It];return S(et.subarray(32),k),et}r.sign=O;function it(U,L){const k=s(),p=s(),F=s(),et=s(),ct=s(),at=s(),Mt=s();return I(U[2],l),B(U[1],L),T(F,U[1]),v(et,F,d),$(F,F,U[2]),z(et,U[2],et),T(ct,et),T(at,ct),v(Mt,at,ct),v(k,Mt,F),v(k,k,et),ft(k,k),v(k,k,F),v(k,k,et),v(k,k,et),v(U[0],k,et),T(p,U[0]),v(p,p,et),K(p,F)&&v(U[0],U[0],x),T(p,U[0]),v(p,p,et),K(p,F)?-1:(V(U[0])===L[31]>>7&&$(U[0],c,U[0]),v(U[3],U[0],U[1]),0)}function lt(U,L,k){const p=new Uint8Array(32),F=[s(),s(),s(),s()],et=[s(),s(),s(),s()];if(k.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(it(et,U))return!1;const ct=new e.SHA512;ct.update(k.subarray(0,32)),ct.update(U),ct.update(L);const at=ct.digest();return g(at),y(F,et,at),b(et,k.subarray(32)),pt(F,et),h(p,F),!tt(k,p)}r.verify=lt;function _(U){let L=[s(),s(),s(),s()];if(it(L,U))throw new Error("Ed25519: invalid public key");let k=s(),p=s(),F=L[1];z(k,l,F),$(p,l,F),st(p,p),v(k,k,p);let et=new Uint8Array(32);return W(et,k),et}r.convertPublicKeyToX25519=_;function Z(U){const L=(0,e.hash)(U.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const k=new Uint8Array(L.subarray(0,32));return(0,n.wipe)(L),k}r.convertSecretKeyToX25519=Z})(of);const hI="EdDSA",lI="JWT",Wg=".",Yg="base64url",fI="utf8",dI="utf8",pI=":",gI="did",mI="key",Lp="base58btc",vI="z",yI="K36",wI=32;function nc(r){return Rr(kr(xn(r),fI),Yg)}function Qg(r){const t=kr(yI,Lp),e=vI+Rr(wl([t,r]),Lp);return[gI,mI,e].join(pI)}function bI(r){return Rr(r,Yg)}function _I(r){return kr([nc(r.header),nc(r.payload)].join(Wg),dI)}function EI(r){return[nc(r.header),nc(r.payload),bI(r.signature)].join(Wg)}function qp(r=po.randomBytes(wI)){return of.generateKeyPairFromSeed(r)}async function AI(r,t,e,n,s=bt.fromMiliseconds(Date.now())){const a={alg:hI,typ:lI},c=Qg(n.publicKey),l=s+e,d={iss:c,sub:r,aud:t,iat:s,exp:l},f=_I({header:a,payload:d}),w=of.sign(n.secretKey,f);return EI({header:a,payload:d,signature:w})}const SI="PARSE_ERROR",II="INVALID_REQUEST",DI="METHOD_NOT_FOUND",xI="INVALID_PARAMS",Jg="INTERNAL_ERROR",af="SERVER_ERROR",MI=[-32700,-32600,-32601,-32602,-32603],ia={[SI]:{code:-32700,message:"Parse error"},[II]:{code:-32600,message:"Invalid Request"},[DI]:{code:-32601,message:"Method not found"},[xI]:{code:-32602,message:"Invalid params"},[Jg]:{code:-32603,message:"Internal error"},[af]:{code:-32e3,message:"Server error"}},Xg=af;function CI(r){return MI.includes(r)}function jp(r){return Object.keys(ia).includes(r)?ia[r]:ia[Xg]}function PI(r){const t=Object.values(ia).find(e=>e.code===r);return t||ia[Xg]}function Zg(r,t,e){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${e} RPC url at ${t}`):r}var tm={},_n={},$p;function OI(){if($p)return _n;$p=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.isBrowserCryptoAvailable=_n.getSubtleCrypto=_n.getBrowerCrypto=void 0;function r(){return(Xi===null||Xi===void 0?void 0:Xi.crypto)||(Xi===null||Xi===void 0?void 0:Xi.msCrypto)||{}}_n.getBrowerCrypto=r;function t(){const n=r();return n.subtle||n.webkitSubtle}_n.getSubtleCrypto=t;function e(){return!!r()&&!!t()}return _n.isBrowserCryptoAvailable=e,_n}var En={},zp;function NI(){if(zp)return En;zp=1,Object.defineProperty(En,"__esModule",{value:!0}),En.isBrowser=En.isNode=En.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}En.isReactNative=r;function t(){return typeof ei<"u"&&typeof ei.versions<"u"&&typeof ei.versions.node<"u"}En.isNode=t;function e(){return!r()&&!t()}return En.isBrowser=e,En}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const t=Mn;t.__exportStar(OI(),r),t.__exportStar(NI(),r)})(tm);function Kn(r=3){const t=Date.now()*Math.pow(10,r),e=Math.floor(Math.random()*Math.pow(10,r));return t+e}function Is(r=6){return BigInt(Kn(r))}function co(r,t,e){return{id:e||Kn(),jsonrpc:"2.0",method:r,params:t}}function mc(r,t){return{id:r,jsonrpc:"2.0",result:t}}function vc(r,t,e){return{id:r,jsonrpc:"2.0",error:RI(t,e)}}function RI(r,t){return typeof r>"u"?jp(Jg):(typeof r=="string"&&(r=Object.assign(Object.assign({},jp(af)),{message:r})),typeof t<"u"&&(r.data=t),CI(r.code)&&(r=PI(r.code)),r)}class TI{}class FI extends TI{constructor(){super()}}class UI extends FI{constructor(t){super()}}const BI="^https?:",LI="^wss?:";function qI(r){const t=r.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function em(r,t){const e=qI(r);return typeof e>"u"?!1:new RegExp(t).test(e)}function kp(r){return em(r,BI)}function Hp(r){return em(r,LI)}function jI(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function rm(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function uf(r){return rm(r)&&"method"in r}function yc(r){return rm(r)&&(Qi(r)||Si(r))}function Qi(r){return"result"in r}function Si(r){return"error"in r}class Cn extends UI{constructor(t){super(t),this.events=new Di.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async request(t,e){return this.requestStrict(co(t.method,t.params||[],t.id||Is().toString()),e)}async requestStrict(t,e){return new Promise(async(n,s)=>{if(!this.connection.connected)try{await this.open()}catch(a){s(a)}this.events.on(`${t.id}`,a=>{Si(a)?s(a.error):n(a.result)});try{await this.connection.send(t,e)}catch(a){s(a)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),yc(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const $I=()=>typeof WebSocket<"u"?WebSocket:typeof Ie<"u"&&typeof Ie.WebSocket<"u"?Ie.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),zI=()=>typeof WebSocket<"u"||typeof Ie<"u"&&typeof Ie.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Kp=r=>r.split("?")[0],Vp=10,kI=$I();let HI=class{constructor(t){if(this.url=t,this.events=new Di.EventEmitter,this.registering=!1,!Hp(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,e)=>{if(typeof this.socket>"u"){e(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(xn(t))}catch(e){this.onError(t.id,e)}}register(t=this.url){if(!Hp(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((n,s)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),s(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=t,this.registering=!0,new Promise((e,n)=>{const s=new URLSearchParams(t).get("origin"),a=tm.isReactNative()?{headers:{origin:s}}:{rejectUnauthorized:!jI(t)},c=new kI(t,[],a);zI()?c.onerror=l=>{const d=l;n(this.emitError(d.error))}:c.on("error",l=>{n(this.emitError(l))}),c.onopen=()=>{this.onOpen(c),e(c)}})}onOpen(t){t.onmessage=e=>this.onPayload(e),t.onclose=e=>this.onClose(e),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?wa(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const n=this.parseError(e),s=n.message||n.toString(),a=vc(t,s);this.events.emit("payload",a)}parseError(t,e=this.url){return Zg(t,Kp(e),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Vp&&this.events.setMaxListeners(Vp)}emitError(t){const e=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Kp(this.url)}`));return this.events.emit("register_error",e),e}};var sc={exports:{}};sc.exports;(function(r,t){var e=200,n="__lodash_hash_undefined__",s=1,a=2,c=9007199254740991,l="[object Arguments]",d="[object Array]",f="[object AsyncFunction]",w="[object Boolean]",E="[object Date]",x="[object Error]",I="[object Function]",R="[object GeneratorFunction]",Y="[object Map]",W="[object Number]",tt="[object Null]",K="[object Object]",V="[object Promise]",B="[object Proxy]",z="[object RegExp]",$="[object Set]",v="[object String]",T="[object Symbol]",st="[object Undefined]",ft="[object WeakMap]",pt="[object ArrayBuffer]",gt="[object DataView]",h="[object Float32Array]",y="[object Float64Array]",b="[object Int8Array]",C="[object Int16Array]",M="[object Int32Array]",N="[object Uint8Array]",q="[object Uint8ClampedArray]",S="[object Uint16Array]",g="[object Uint32Array]",O=/[\\^$.*+?()[\]{}|]/g,it=/^\[object .+?Constructor\]$/,lt=/^(?:0|[1-9]\d*)$/,_={};_[h]=_[y]=_[b]=_[C]=_[M]=_[N]=_[q]=_[S]=_[g]=!0,_[l]=_[d]=_[pt]=_[w]=_[gt]=_[E]=_[x]=_[I]=_[Y]=_[W]=_[K]=_[z]=_[$]=_[v]=_[ft]=!1;var Z=typeof Xi=="object"&&Xi&&Xi.Object===Object&&Xi,U=typeof self=="object"&&self&&self.Object===Object&&self,L=Z||U||Function("return this")(),k=t&&!t.nodeType&&t,p=k&&!0&&r&&!r.nodeType&&r,F=p&&p.exports===k,et=F&&Z.process,ct=function(){try{return et&&et.binding&&et.binding("util")}catch{}}(),at=ct&&ct.isTypedArray;function Mt(j,Q){for(var ht=-1,St=j==null?0:j.length,Be=0,re=[];++ht<St;){var $e=j[ht];Q($e,ht,j)&&(re[Be++]=$e)}return re}function Pt(j,Q){for(var ht=-1,St=Q.length,Be=j.length;++ht<St;)j[Be+ht]=Q[ht];return j}function It(j,Q){for(var ht=-1,St=j==null?0:j.length;++ht<St;)if(Q(j[ht],ht,j))return!0;return!1}function Ee(j,Q){for(var ht=-1,St=Array(j);++ht<j;)St[ht]=Q(ht);return St}function $t(j){return function(Q){return j(Q)}}function xt(j,Q){return j.has(Q)}function Bt(j,Q){return j==null?void 0:j[Q]}function _t(j){var Q=-1,ht=Array(j.size);return j.forEach(function(St,Be){ht[++Q]=[Be,St]}),ht}function Et(j,Q){return function(ht){return j(Q(ht))}}function Vt(j){var Q=-1,ht=Array(j.size);return j.forEach(function(St){ht[++Q]=St}),ht}var yt=Array.prototype,At=Function.prototype,Ut=Object.prototype,wt=L["__core-js_shared__"],Ct=At.toString,Lt=Ut.hasOwnProperty,Ot=function(){var j=/[^.]+$/.exec(wt&&wt.keys&&wt.keys.IE_PROTO||"");return j?"Symbol(src)_1."+j:""}(),Nt=Ut.toString,se=RegExp("^"+Ct.call(Lt).replace(O,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tt=F?L.Buffer:void 0,Rt=L.Symbol,Ke=L.Uint8Array,ue=Ut.propertyIsEnumerable,pe=yt.splice,Ve=Rt?Rt.toStringTag:void 0,ye=Object.getOwnPropertySymbols,_e=Tt?Tt.isBuffer:void 0,Er=Et(Object.keys,Object),Gt=Gr(L,"DataView"),zt=Gr(L,"Map"),De=Gr(L,"Promise"),Wt=Gr(L,"Set"),Kt=Gr(L,"WeakMap"),Ae=Gr(Object,"create"),Jt=hn(Gt),Xt=hn(zt),xe=hn(De),Zt=hn(Wt),Yt=hn(Kt),Ce=Rt?Rt.prototype:void 0,Qt=Ce?Ce.valueOf:void 0;function qt(j){var Q=-1,ht=j==null?0:j.length;for(this.clear();++Q<ht;){var St=j[Q];this.set(St[0],St[1])}}function Te(){this.__data__=Ae?Ae(null):{},this.size=0}function te(j){var Q=this.has(j)&&delete this.__data__[j];return this.size-=Q?1:0,Q}function Pe(j){var Q=this.__data__;if(Ae){var ht=Q[j];return ht===n?void 0:ht}return Lt.call(Q,j)?Q[j]:void 0}function xi(j){var Q=this.__data__;return Ae?Q[j]!==void 0:Lt.call(Q,j)}function Oe(j,Q){var ht=this.__data__;return this.size+=this.has(j)?0:1,ht[j]=Ae&&Q===void 0?n:Q,this}qt.prototype.clear=Te,qt.prototype.delete=te,qt.prototype.get=Pe,qt.prototype.has=xi,qt.prototype.set=Oe;function le(j){var Q=-1,ht=j==null?0:j.length;for(this.clear();++Q<ht;){var St=j[Q];this.set(St[0],St[1])}}function si(){this.__data__=[],this.size=0}function oi(j){var Q=this.__data__,ht=os(Q,j);if(ht<0)return!1;var St=Q.length-1;return ht==St?Q.pop():pe.call(Q,ht,1),--this.size,!0}function ai(j){var Q=this.__data__,ht=os(Q,j);return ht<0?void 0:Q[ht][1]}function ui(j){return os(this.__data__,j)>-1}function ci(j,Q){var ht=this.__data__,St=os(ht,j);return St<0?(++this.size,ht.push([j,Q])):ht[St][1]=Q,this}le.prototype.clear=si,le.prototype.delete=oi,le.prototype.get=ai,le.prototype.has=ui,le.prototype.set=ci;function or(j){var Q=-1,ht=j==null?0:j.length;for(this.clear();++Q<ht;){var St=j[Q];this.set(St[0],St[1])}}function qi(){this.size=0,this.__data__={hash:new qt,map:new(zt||le),string:new qt}}function Zn(j){var Q=Rn(this,j).delete(j);return this.size-=Q?1:0,Q}function ji(j){return Rn(this,j).get(j)}function ts(j){return Rn(this,j).has(j)}function es(j,Q){var ht=Rn(this,j),St=ht.size;return ht.set(j,Q),this.size+=ht.size==St?0:1,this}or.prototype.clear=qi,or.prototype.delete=Zn,or.prototype.get=ji,or.prototype.has=ts,or.prototype.set=es;function $i(j){var Q=-1,ht=j==null?0:j.length;for(this.__data__=new or;++Q<ht;)this.add(j[Q])}function On(j){return this.__data__.set(j,n),this}function Nn(j){return this.__data__.has(j)}$i.prototype.add=$i.prototype.push=On,$i.prototype.has=Nn;function Ar(j){var Q=this.__data__=new le(j);this.size=Q.size}function rs(){this.__data__=new le,this.size=0}function is(j){var Q=this.__data__,ht=Q.delete(j);return this.size=Q.size,ht}function ns(j){return this.__data__.get(j)}function ss(j){return this.__data__.has(j)}function Aa(j,Q){var ht=this.__data__;if(ht instanceof le){var St=ht.__data__;if(!zt||St.length<e-1)return St.push([j,Q]),this.size=++ht.size,this;ht=this.__data__=new or(St)}return ht.set(j,Q),this.size=ht.size,this}Ar.prototype.clear=rs,Ar.prototype.delete=is,Ar.prototype.get=ns,Ar.prototype.has=ss,Ar.prototype.set=Aa;function Sa(j,Q){var ht=Us(j),St=!ht&&Ua(j),Be=!ht&&!St&&Io(j),re=!ht&&!St&&!Be&&qa(j),$e=ht||St||Be||re,er=$e?Ee(j.length,String):[],we=er.length;for(var Le in j)(Q||Lt.call(j,Le))&&!($e&&(Le=="length"||Be&&(Le=="offset"||Le=="parent")||re&&(Le=="buffer"||Le=="byteLength"||Le=="byteOffset")||Oa(Le,we)))&&er.push(Le);return er}function os(j,Q){for(var ht=j.length;ht--;)if(Fa(j[ht][0],Q))return ht;return-1}function Ao(j,Q,ht){var St=Q(j);return Us(j)?St:Pt(St,ht(j))}function as(j){return j==null?j===void 0?st:tt:Ve&&Ve in Object(j)?Ca(j):Ac(j)}function So(j){return cs(j)&&as(j)==l}function us(j,Q,ht,St,Be){return j===Q?!0:j==null||Q==null||!cs(j)&&!cs(Q)?j!==j&&Q!==Q:Ia(j,Q,ht,St,us,Be)}function Ia(j,Q,ht,St,Be,re){var $e=Us(j),er=Us(Q),we=$e?d:zi(j),Le=er?d:zi(Q);we=we==l?K:we,Le=Le==l?K:Le;var Qe=we==K,Fr=Le==K,rr=we==Le;if(rr&&Io(j)){if(!Io(Q))return!1;$e=!0,Qe=!1}if(rr&&!Qe)return re||(re=new Ar),$e||qa(j)?Ts(j,Q,ht,St,Be,re):Ec(j,Q,we,ht,St,Be,re);if(!(ht&s)){var ze=Qe&&Lt.call(j,"__wrapped__"),Sr=Fr&&Lt.call(Q,"__wrapped__");if(ze||Sr){var Mi=ze?j.value():j,hi=Sr?Q.value():Q;return re||(re=new Ar),Be(Mi,hi,ht,St,re)}}return rr?(re||(re=new Ar),Ma(j,Q,ht,St,Be,re)):!1}function _c(j){if(!La(j)||Ra(j))return!1;var Q=Bs(j)?se:it;return Q.test(hn(j))}function Da(j){return cs(j)&&Ba(j.length)&&!!_[as(j)]}function xa(j){if(!Ta(j))return Er(j);var Q=[];for(var ht in Object(j))Lt.call(j,ht)&&ht!="constructor"&&Q.push(ht);return Q}function Ts(j,Q,ht,St,Be,re){var $e=ht&s,er=j.length,we=Q.length;if(er!=we&&!($e&&we>er))return!1;var Le=re.get(j);if(Le&&re.get(Q))return Le==Q;var Qe=-1,Fr=!0,rr=ht&a?new $i:void 0;for(re.set(j,Q),re.set(Q,j);++Qe<er;){var ze=j[Qe],Sr=Q[Qe];if(St)var Mi=$e?St(Sr,ze,Qe,Q,j,re):St(ze,Sr,Qe,j,Q,re);if(Mi!==void 0){if(Mi)continue;Fr=!1;break}if(rr){if(!It(Q,function(hi,ki){if(!xt(rr,ki)&&(ze===hi||Be(ze,hi,ht,St,re)))return rr.push(ki)})){Fr=!1;break}}else if(!(ze===Sr||Be(ze,Sr,ht,St,re))){Fr=!1;break}}return re.delete(j),re.delete(Q),Fr}function Ec(j,Q,ht,St,Be,re,$e){switch(ht){case gt:if(j.byteLength!=Q.byteLength||j.byteOffset!=Q.byteOffset)return!1;j=j.buffer,Q=Q.buffer;case pt:return!(j.byteLength!=Q.byteLength||!re(new Ke(j),new Ke(Q)));case w:case E:case W:return Fa(+j,+Q);case x:return j.name==Q.name&&j.message==Q.message;case z:case v:return j==Q+"";case Y:var er=_t;case $:var we=St&s;if(er||(er=Vt),j.size!=Q.size&&!we)return!1;var Le=$e.get(j);if(Le)return Le==Q;St|=a,$e.set(j,Q);var Qe=Ts(er(j),er(Q),St,Be,re,$e);return $e.delete(j),Qe;case T:if(Qt)return Qt.call(j)==Qt.call(Q)}return!1}function Ma(j,Q,ht,St,Be,re){var $e=ht&s,er=Fs(j),we=er.length,Le=Fs(Q),Qe=Le.length;if(we!=Qe&&!$e)return!1;for(var Fr=we;Fr--;){var rr=er[Fr];if(!($e?rr in Q:Lt.call(Q,rr)))return!1}var ze=re.get(j);if(ze&&re.get(Q))return ze==Q;var Sr=!0;re.set(j,Q),re.set(Q,j);for(var Mi=$e;++Fr<we;){rr=er[Fr];var hi=j[rr],ki=Q[rr];if(St)var Do=$e?St(ki,hi,rr,Q,j,re):St(hi,ki,rr,j,Q,re);if(!(Do===void 0?hi===ki||Be(hi,ki,ht,St,re):Do)){Sr=!1;break}Mi||(Mi=rr=="constructor")}if(Sr&&!Mi){var hs=j.constructor,ar=Q.constructor;hs!=ar&&"constructor"in j&&"constructor"in Q&&!(typeof hs=="function"&&hs instanceof hs&&typeof ar=="function"&&ar instanceof ar)&&(Sr=!1)}return re.delete(j),re.delete(Q),Sr}function Fs(j){return Ao(j,Dc,Pa)}function Rn(j,Q){var ht=j.__data__;return Na(Q)?ht[typeof Q=="string"?"string":"hash"]:ht.map}function Gr(j,Q){var ht=Bt(j,Q);return _c(ht)?ht:void 0}function Ca(j){var Q=Lt.call(j,Ve),ht=j[Ve];try{j[Ve]=void 0;var St=!0}catch{}var Be=Nt.call(j);return St&&(Q?j[Ve]=ht:delete j[Ve]),Be}var Pa=ye?function(j){return j==null?[]:(j=Object(j),Mt(ye(j),function(Q){return ue.call(j,Q)}))}:Ue,zi=as;(Gt&&zi(new Gt(new ArrayBuffer(1)))!=gt||zt&&zi(new zt)!=Y||De&&zi(De.resolve())!=V||Wt&&zi(new Wt)!=$||Kt&&zi(new Kt)!=ft)&&(zi=function(j){var Q=as(j),ht=Q==K?j.constructor:void 0,St=ht?hn(ht):"";if(St)switch(St){case Jt:return gt;case Xt:return Y;case xe:return V;case Zt:return $;case Yt:return ft}return Q});function Oa(j,Q){return Q=Q??c,!!Q&&(typeof j=="number"||lt.test(j))&&j>-1&&j%1==0&&j<Q}function Na(j){var Q=typeof j;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?j!=="__proto__":j===null}function Ra(j){return!!Ot&&Ot in j}function Ta(j){var Q=j&&j.constructor,ht=typeof Q=="function"&&Q.prototype||Ut;return j===ht}function Ac(j){return Nt.call(j)}function hn(j){if(j!=null){try{return Ct.call(j)}catch{}try{return j+""}catch{}}return""}function Fa(j,Q){return j===Q||j!==j&&Q!==Q}var Ua=So(function(){return arguments}())?So:function(j){return cs(j)&&Lt.call(j,"callee")&&!ue.call(j,"callee")},Us=Array.isArray;function Sc(j){return j!=null&&Ba(j.length)&&!Bs(j)}var Io=_e||Fe;function Ic(j,Q){return us(j,Q)}function Bs(j){if(!La(j))return!1;var Q=as(j);return Q==I||Q==R||Q==f||Q==B}function Ba(j){return typeof j=="number"&&j>-1&&j%1==0&&j<=c}function La(j){var Q=typeof j;return j!=null&&(Q=="object"||Q=="function")}function cs(j){return j!=null&&typeof j=="object"}var qa=at?$t(at):Da;function Dc(j){return Sc(j)?Sa(j):xa(j)}function Ue(){return[]}function Fe(){return!1}r.exports=Ic})(sc,sc.exports);var KI=sc.exports;const VI=ql(KI);function GI(r,t){return t=t||{},new Promise(function(e,n){var s=new XMLHttpRequest,a=[],c=[],l={},d=function(){return{ok:(s.status/100|0)==2,statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:d,headers:{keys:function(){return a},entries:function(){return c},get:function(w){return l[w.toLowerCase()]},has:function(w){return w.toLowerCase()in l}}}};for(var f in s.open(t.method||"get",r,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(w,E,x){a.push(E=E.toLowerCase()),c.push([E,x]),l[E]=l[E]?l[E]+","+x:x}),e(d())},s.onerror=n,s.withCredentials=t.credentials=="include",t.headers)s.setRequestHeader(f,t.headers[f]);s.send(t.body||null)})}const WI=Object.freeze(Object.defineProperty({__proto__:null,default:GI},Symbol.toStringTag,{value:"Module"})),Gp=Ll(WI);var YI=self.fetch||(self.fetch=Gp.default||Gp);const QI=ql(YI);function JI(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var a=r.charAt(s),c=a.charCodeAt(0);if(e[c]!==255)throw new TypeError(a+" is ambiguous");e[c]=s}var l=r.length,d=r.charAt(0),f=Math.log(l)/Math.log(256),w=Math.log(256)/Math.log(l);function E(R){if(R instanceof Uint8Array||(ArrayBuffer.isView(R)?R=new Uint8Array(R.buffer,R.byteOffset,R.byteLength):Array.isArray(R)&&(R=Uint8Array.from(R))),!(R instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(R.length===0)return"";for(var Y=0,W=0,tt=0,K=R.length;tt!==K&&R[tt]===0;)tt++,Y++;for(var V=(K-tt)*w+1>>>0,B=new Uint8Array(V);tt!==K;){for(var z=R[tt],$=0,v=V-1;(z!==0||$<W)&&v!==-1;v--,$++)z+=256*B[v]>>>0,B[v]=z%l>>>0,z=z/l>>>0;if(z!==0)throw new Error("Non-zero carry");W=$,tt++}for(var T=V-W;T!==V&&B[T]===0;)T++;for(var st=d.repeat(Y);T<V;++T)st+=r.charAt(B[T]);return st}function x(R){if(typeof R!="string")throw new TypeError("Expected String");if(R.length===0)return new Uint8Array;var Y=0;if(R[Y]!==" "){for(var W=0,tt=0;R[Y]===d;)W++,Y++;for(var K=(R.length-Y)*f+1>>>0,V=new Uint8Array(K);R[Y];){var B=e[R.charCodeAt(Y)];if(B===255)return;for(var z=0,$=K-1;(B!==0||z<tt)&&$!==-1;$--,z++)B+=l*V[$]>>>0,V[$]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");tt=z,Y++}if(R[Y]!==" "){for(var v=K-tt;v!==K&&V[v]===0;)v++;for(var T=new Uint8Array(W+(K-v)),st=W;v!==K;)T[st++]=V[v++];return T}}}function I(R){var Y=x(R);if(Y)return Y;throw new Error(`Non-${t} character`)}return{encode:E,decodeUnsafe:x,decode:I}}var XI=JI,ZI=XI;const im=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")},tD=r=>new TextEncoder().encode(r),eD=r=>new TextDecoder().decode(r);let rD=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},iD=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return nm(this,t)}},nD=class{constructor(t){this.decoders=t}or(t){return nm(this,t)}decode(t){const e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const nm=(r,t)=>new nD({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}});let sD=class{constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new rD(t,e,n),this.decoder=new iD(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const wc=({name:r,prefix:t,encode:e,decode:n})=>new sD(r,t,e,n),Ea=({prefix:r,name:t,alphabet:e})=>{const{encode:n,decode:s}=ZI(e,t);return wc({prefix:r,name:t,encode:n,decode:a=>im(s(a))})},oD=(r,t,e,n)=>{const s={};for(let w=0;w<t.length;++w)s[t[w]]=w;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*e/8|0);let l=0,d=0,f=0;for(let w=0;w<a;++w){const E=s[r[w]];if(E===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<e|E,l+=e,l>=8&&(l-=8,c[f++]=255&d>>l)}if(l>=e||255&d<<8-l)throw new SyntaxError("Unexpected end of data");return c},aD=(r,t,e)=>{const n=t[t.length-1]==="=",s=(1<<e)-1;let a="",c=0,l=0;for(let d=0;d<r.length;++d)for(l=l<<8|r[d],c+=8;c>e;)c-=e,a+=t[s&l>>c];if(c&&(a+=t[s&l<<e-c]),n)for(;a.length*e&7;)a+="=";return a},mr=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>wc({prefix:t,name:r,encode(s){return aD(s,n,e)},decode(s){return oD(s,n,e,r)}}),uD=wc({prefix:"\0",name:"identity",encode:r=>eD(r),decode:r=>tD(r)});var cD=Object.freeze({__proto__:null,identity:uD});const hD=mr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var lD=Object.freeze({__proto__:null,base2:hD});const fD=mr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var dD=Object.freeze({__proto__:null,base8:fD});const pD=Ea({prefix:"9",name:"base10",alphabet:"0123456789"});var gD=Object.freeze({__proto__:null,base10:pD});const mD=mr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vD=mr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yD=Object.freeze({__proto__:null,base16:mD,base16upper:vD});const wD=mr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bD=mr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_D=mr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ED=mr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),AD=mr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),SD=mr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ID=mr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),DD=mr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xD=mr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var MD=Object.freeze({__proto__:null,base32:wD,base32upper:bD,base32pad:_D,base32padupper:ED,base32hex:AD,base32hexupper:SD,base32hexpad:ID,base32hexpadupper:DD,base32z:xD});const CD=Ea({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),PD=Ea({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var OD=Object.freeze({__proto__:null,base36:CD,base36upper:PD});const ND=Ea({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),RD=Ea({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var TD=Object.freeze({__proto__:null,base58btc:ND,base58flickr:RD});const FD=mr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),UD=mr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),BD=mr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),LD=mr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qD=Object.freeze({__proto__:null,base64:FD,base64pad:UD,base64url:BD,base64urlpad:LD});const sm=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),jD=sm.reduce((r,t,e)=>(r[e]=t,r),[]),$D=sm.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function zD(r){return r.reduce((t,e)=>(t+=jD[e],t),"")}function kD(r){const t=[];for(const e of r){const n=$D[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}const HD=wc({prefix:"🚀",name:"base256emoji",encode:zD,decode:kD});var KD=Object.freeze({__proto__:null,base256emoji:HD}),VD=om,Wp=128,GD=127,WD=~GD,YD=Math.pow(2,31);function om(r,t,e){t=t||[],e=e||0;for(var n=e;r>=YD;)t[e++]=r&255|Wp,r/=128;for(;r&WD;)t[e++]=r&255|Wp,r>>>=7;return t[e]=r|0,om.bytes=e-n+1,t}var QD=Nl,JD=128,Yp=127;function Nl(r,n){var e=0,n=n||0,s=0,a=n,c,l=r.length;do{if(a>=l)throw Nl.bytes=0,new RangeError("Could not decode varint");c=r[a++],e+=s<28?(c&Yp)<<s:(c&Yp)*Math.pow(2,s),s+=7}while(c>=JD);return Nl.bytes=a-n,e}var XD=Math.pow(2,7),ZD=Math.pow(2,14),tx=Math.pow(2,21),ex=Math.pow(2,28),rx=Math.pow(2,35),ix=Math.pow(2,42),nx=Math.pow(2,49),sx=Math.pow(2,56),ox=Math.pow(2,63),ax=function(r){return r<XD?1:r<ZD?2:r<tx?3:r<ex?4:r<rx?5:r<ix?6:r<nx?7:r<sx?8:r<ox?9:10},ux={encode:VD,decode:QD,encodingLength:ax},am=ux;const Qp=(r,t,e=0)=>(am.encode(r,t,e),t),Jp=r=>am.encodingLength(r),Rl=(r,t)=>{const e=t.byteLength,n=Jp(r),s=n+Jp(e),a=new Uint8Array(s+e);return Qp(r,a,0),Qp(e,a,n),a.set(t,s),new cx(r,e,t,a)};class cx{constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}}const um=({name:r,code:t,encode:e})=>new hx(r,t,e);let hx=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?Rl(this.code,e):e.then(n=>Rl(this.code,n))}else throw Error("Unknown type, must be binary type")}};const cm=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),lx=um({name:"sha2-256",code:18,encode:cm("SHA-256")}),fx=um({name:"sha2-512",code:19,encode:cm("SHA-512")});var dx=Object.freeze({__proto__:null,sha256:lx,sha512:fx});const hm=0,px="identity",lm=im,gx=r=>Rl(hm,lm(r)),mx={code:hm,name:px,encode:lm,digest:gx};var vx=Object.freeze({__proto__:null,identity:mx});new TextEncoder,new TextDecoder;const Xp={...cD,...lD,...dD,...gD,...yD,...MD,...OD,...TD,...qD,...KD};({...dx,...vx});function fm(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function yx(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?fm(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function dm(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}const Zp=dm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),il=dm("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);const t=yx(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),wx={utf8:Zp,"utf-8":Zp,hex:Xp.base16,latin1:il,ascii:il,binary:il,...Xp};function bx(r,t="utf8"){const e=wx[t];if(!e)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?fm(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}const pm="wc",_x=2,cf="core",Yn=`${pm}@2:${cf}:`,Ex={name:cf,logger:"error"},Ax={database:":memory:"},Sx="crypto",t1="client_ed25519_seed",Ix=bt.ONE_DAY,Dx="keychain",xx="0.3",Mx="messages",Cx="0.3",Px=bt.SIX_HOURS,Ox="publisher",gm="irn",Nx="error",mm="wss://relay.walletconnect.com",e1="wss://relay.walletconnect.org",Rx="relayer",Zr={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"},Tx="_subscription",bi={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Fx=bt.ONE_SECOND,Ux="2.12.1",Bx=1e4,Lx="0.3",qx="WALLETCONNECT_CLIENT_ID",Ji={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},jx="subscription",$x="0.3",zx=bt.FIVE_SECONDS*1e3,kx="pairing",Hx="0.3",Qo={wc_pairingDelete:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:bt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:bt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:0},res:{ttl:bt.ONE_DAY,prompt:!1,tag:0}}},so={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ti={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Kx="history",Vx="0.3",Gx="expirer",Ei={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Wx="0.3",nl="verify-api",oo="https://verify.walletconnect.com",Tl="https://verify.walletconnect.org",Yx=[oo,Tl],Qx="echo",Jx="https://echo.walletconnect.com";class Xx{constructor(t,e){this.core=t,this.logger=e,this.keychain=new Map,this.name=Dx,this.version=xx,this.initialized=!1,this.storagePrefix=Yn,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,s)=>{this.isInitialized(),this.keychain.set(n,s),await this.persist()},this.get=n=>{this.isInitialized();const s=this.keychain.get(n);if(typeof s>"u"){const{message:a}=mt("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(a)}return s},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=t,this.logger=Vr(e,this.name)}get context(){return Kr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,W1(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Y1(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Zx{constructor(t,e,n){this.core=t,this.logger=e,this.name=Sx,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),a=qp(s);return Qg(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=z8();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const a=await this.getClientSeed(),c=qp(a),l=Ml();return await AI(l,s,Ix,c)},this.generateSharedKey=(s,a,c)=>{this.isInitialized();const l=this.getPrivateKey(s),d=k8(l,a);return this.setSymKey(d,c)},this.setSymKey=async(s,a)=>{this.isInitialized();const c=a||zu(s);return await this.keychain.set(c,s),c},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s)},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s)},this.encode=async(s,a,c)=>{this.isInitialized();const l=Bg(c),d=xn(a);if(pp(l)){const x=l.senderPublicKey,I=l.receiverPublicKey;s=await this.generateSharedKey(x,I)}const f=this.getSymKey(s),{type:w,senderPublicKey:E}=l;return K8({type:w,symKey:f,message:d,senderPublicKey:E})},this.decode=async(s,a,c)=>{this.isInitialized();const l=W8(a,c);if(pp(l)){const d=l.receiverPublicKey,f=l.senderPublicKey;s=await this.generateSharedKey(d,f)}try{const d=this.getSymKey(s),f=V8({symKey:d,encoded:a});return wa(f)}catch(d){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(d)}},this.getPayloadType=s=>{const a=tc(s);return va(a.type)},this.getPayloadSenderPublicKey=s=>{const a=tc(s);return a.senderPublicKey?Rr(a.senderPublicKey,Nr):void 0},this.core=t,this.logger=Vr(e,this.name),this.keychain=n||new Xx(this.core,this.logger)}get context(){return Kr(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(t1)}catch{t=Ml(),await this.keychain.set(t1,t)}return bx(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class t7 extends tI{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name=Mx,this.version=Cx,this.initialized=!1,this.storagePrefix=Yn,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,s)=>{this.isInitialized();const a=Ss(s);let c=this.messages.get(n);return typeof c>"u"&&(c={}),typeof c[a]<"u"||(c[a]=s,this.messages.set(n,c),await this.persist()),a},this.get=n=>{this.isInitialized();let s=this.messages.get(n);return typeof s>"u"&&(s={}),s},this.has=(n,s)=>{this.isInitialized();const a=this.get(n),c=Ss(s);return typeof a[c]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Vr(t,this.name),this.core=e}get context(){return Kr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,W1(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Y1(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class e7 extends eI{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new Di.EventEmitter,this.name=Ox,this.queue=new Map,this.publishTimeout=bt.toMiliseconds(bt.ONE_MINUTE),this.failedPublishTimeout=bt.toMiliseconds(bt.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(n,s,a)=>{var c;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:s,opts:a}});const l=(a==null?void 0:a.ttl)||Px,d=Cl(a),f=(a==null?void 0:a.prompt)||!1,w=(a==null?void 0:a.tag)||0,E=(a==null?void 0:a.id)||Is().toString(),x={topic:n,message:s,opts:{ttl:l,relay:d,prompt:f,tag:w,id:E}},I=`Failed to publish payload, please try again. id:${E} tag:${w}`,R=Date.now();let Y,W=1;try{for(;Y===void 0;){if(Date.now()-R>this.publishTimeout)throw new Error(I);this.logger.trace({id:E,attempts:W},`publisher.publish - attempt ${W}`),Y=await await oa(this.rpcPublish(n,s,l,d,f,w,E).catch(tt=>this.logger.warn(tt)),this.publishTimeout,I),W++,Y||await new Promise(tt=>setTimeout(tt,this.failedPublishTimeout))}this.relayer.events.emit(Zr.publish,x),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:E,topic:n,message:s,opts:a}})}catch(tt){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(tt),(c=a==null?void 0:a.internal)!=null&&c.throwOnFailedPublish)throw tt;this.queue.set(E,x)}},this.on=(n,s)=>{this.events.on(n,s)},this.once=(n,s)=>{this.events.once(n,s)},this.off=(n,s)=>{this.events.off(n,s)},this.removeListener=(n,s)=>{this.events.removeListener(n,s)},this.relayer=t,this.logger=Vr(e,this.name),this.registerEventListeners()}get context(){return Kr(this.logger)}rpcPublish(t,e,n,s,a,c,l){var d,f,w,E;const x={method:ku(s.protocol).publish,params:{topic:t,message:e,ttl:n,prompt:a,tag:c},id:l};return Or((d=x.params)==null?void 0:d.prompt)&&((f=x.params)==null||delete f.prompt),Or((w=x.params)==null?void 0:w.tag)&&((E=x.params)==null||delete E.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:x}),this.relayer.request(x)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:e,message:n,opts:s}=t;await this.publish(e,n,s)})}registerEventListeners(){this.relayer.core.heartbeat.on(Eo.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Zr.connection_stalled);return}this.checkQueue()}),this.relayer.on(Zr.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class r7{constructor(){this.map=new Map,this.set=(t,e)=>{const n=this.get(t);this.exists(t,e)||this.map.set(t,[...n,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const n=this.get(t);if(!this.exists(t,e))return;const s=n.filter(a=>a!==e);if(!s.length){this.map.delete(t);return}this.map.set(t,s)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var i7=Object.defineProperty,n7=Object.defineProperties,s7=Object.getOwnPropertyDescriptors,r1=Object.getOwnPropertySymbols,o7=Object.prototype.hasOwnProperty,a7=Object.prototype.propertyIsEnumerable,i1=(r,t,e)=>t in r?i7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jo=(r,t)=>{for(var e in t||(t={}))o7.call(t,e)&&i1(r,e,t[e]);if(r1)for(var e of r1(t))a7.call(t,e)&&i1(r,e,t[e]);return r},sl=(r,t)=>n7(r,s7(t));class u7 extends nI{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new r7,this.events=new Di.EventEmitter,this.name=jx,this.version=$x,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Yn,this.subscribeTimeout=bt.toMiliseconds(bt.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(n,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:s}});try{const a=Cl(s),c={topic:n,relay:a};this.pending.set(n,c);const l=await this.rpcSubscribe(n,a);return typeof l=="string"&&(this.onSubscribe(l,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:s}})),l}catch(a){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(a),a}},this.unsubscribe=async(n,s)=>{await this.restartToComplete(),this.isInitialized(),typeof(s==null?void 0:s.id)<"u"?await this.unsubscribeById(n,s.id,s):await this.unsubscribeByTopic(n,s)},this.isSubscribed=async n=>{if(this.topics.includes(n))return!0;const s=`${this.pendingSubscriptionWatchLabel}_${n}`;return await new Promise((a,c)=>{const l=new bt.Watch;l.start(s);const d=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(d),l.stop(s),a(!0)),l.elapsed(s)>=zx&&(clearInterval(d),l.stop(s),c(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(n,s)=>{this.events.on(n,s)},this.once=(n,s)=>{this.events.once(n,s)},this.off=(n,s)=>{this.events.off(n,s)},this.removeListener=(n,s)=>{this.events.removeListener(n,s)},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=t,this.logger=Vr(e,this.name),this.clientId=""}get context(){return Kr(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(t,e){let n=!1;try{n=this.getSubscription(t).topic===e}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const n=this.topicMap.get(t);await Promise.all(n.map(async s=>await this.unsubscribeById(t,s,e)))}async unsubscribeById(t,e,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:n}});try{const s=Cl(n);await this.rpcUnsubscribe(t,e,s);const a=Re("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:n}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(t,e){const n={method:ku(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await oa(this.relayer.request(n).catch(s=>this.logger.warn(s)),this.subscribeTimeout)?Ss(t+this.clientId):null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Zr.connection_stalled)}return null}async rpcBatchSubscribe(t){if(!t.length)return;const e=t[0].relay,n={method:ku(e.protocol).batchSubscribe,params:{topics:t.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await oa(this.relayer.request(n).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Zr.connection_stalled)}}rpcUnsubscribe(t,e,n){const s={method:ku(n.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(t,e){this.setSubscription(t,sl(Jo({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach(e=>{this.setSubscription(e.id,Jo({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(t,e,n){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,n),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e)}addSubscription(t,e){this.subscriptions.set(t,Jo({},e)),this.topicMap.set(e.topic,t),this.events.emit(Ji.created,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:n}=mt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const n=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(n.topic,t),this.events.emit(Ji.deleted,sl(Jo({},n),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ji.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e<t;e++){const n=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(Ji.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:e}=mt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);un(e)&&this.onBatchSubscribe(e.map((n,s)=>sl(Jo({},t[s]),{id:n})))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const t=[];this.pending.forEach(e=>{t.push(e)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(Eo.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.events.on(Ji.created,async t=>{const e=Ji.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}),this.events.on(Ji.deleted,async t=>{const e=Ji.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.restartInProgress||(clearInterval(e),t())},this.pollingInterval)})}}var c7=Object.defineProperty,n1=Object.getOwnPropertySymbols,h7=Object.prototype.hasOwnProperty,l7=Object.prototype.propertyIsEnumerable,s1=(r,t,e)=>t in r?c7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,f7=(r,t)=>{for(var e in t||(t={}))h7.call(t,e)&&s1(r,e,t[e]);if(n1)for(var e of n1(t))l7.call(t,e)&&s1(r,e,t[e]);return r};class d7 extends rI{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new Di.EventEmitter,this.name=Rx,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=bt.toMiliseconds(bt.THIRTY_SECONDS+bt.ONE_SECOND),this.request=async e=>{var n,s;this.logger.debug("Publishing Request Payload");const a=e.id||Is().toString();await this.toEstablishConnection();try{const c=this.provider.request(e);this.requestsInFlight.set(a,{promise:c,request:e}),this.logger.trace({id:a,method:e.method,topic:(n=e.params)==null?void 0:n.topic},"relayer.request - attempt to publish...");const l=await new Promise(async(d,f)=>{const w=()=>{f(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(bi.disconnect,w);const E=await c;this.provider.off(bi.disconnect,w),d(E)});return this.logger.trace({id:a,method:e.method,topic:(s=e.params)==null?void 0:s.topic},"relayer.request - published"),l}catch(c){throw this.logger.debug(`Failed to Publish Request: ${a}`),c}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(sa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,n,s;(s=(n=(e=this.provider)==null?void 0:e.connection)==null?void 0:n.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e)}},this.onPayloadHandler=e=>{this.onProviderPayload(e),this.resetPingTimeout()},this.onConnectHandler=()=>{this.startPingTimeout(),this.events.emit(Zr.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=e=>{this.logger.error(e),this.events.emit(Zr.error,e),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(bi.payload,this.onPayloadHandler),this.provider.on(bi.connect,this.onConnectHandler),this.provider.on(bi.disconnect,this.onDisconnectHandler),this.provider.on(bi.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?Vr(t.logger,this.name):ba(gc({level:t.logger||Nx})),this.messages=new t7(this.logger,t.core),this.subscriber=new u7(this,this.logger),this.publisher=new e7(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||mm,this.projectId=t.projectId,this.bundleId=RE(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${e1}...`),await this.restartTransport(e1)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&this.subscriber.pending.size===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},Bx)}get context(){return Kr(this.logger)}get connected(){var t,e,n;return((n=(e=(t=this.provider)==null?void 0:t.connection)==null?void 0:e.socket)==null?void 0:n.readyState)===1}get connecting(){var t,e,n;return((n=(e=(t=this.provider)==null?void 0:t.connection)==null?void 0:e.socket)==null?void 0:n.readyState)===0}async publish(t,e,n){this.isInitialized(),await this.publisher.publish(t,e,n),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var n;this.isInitialized();let s=((n=this.subscriber.topicMap.get(t))==null?void 0:n[0])||"",a;const c=l=>{l.topic===t&&(this.subscriber.off(Ji.created,c),a())};return await Promise.all([new Promise(l=>{a=l,this.subscriber.on(Ji.created,c)}),new Promise(async l=>{s=await this.subscriber.subscribe(t,e)||s,l()})]),s}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(t=>t.promise))}catch(t){this.logger.warn(t)}this.hasExperiencedNetworkDisruption||this.connected?await oa(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(t){await this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportDisconnect(),await this.createProvider()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(e,n)=>{const s=()=>{this.provider.off(bi.disconnect,s),n(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(bi.disconnect,s),await oa(this.provider.connect(),bt.toMiliseconds(bt.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{n(a)}),await this.subscriber.start(),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){this.logger.error(e);const n=e;if(!this.isConnectionStalled(n.message))throw e}finally{this.connectionAttemptInProgress=!1}}async restartTransport(t){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Sp())throw new Error("No internet connection detected. Please restart your network and try again.")}startPingTimeout(){var t,e,n,s,a;if(sa())try{(e=(t=this.provider)==null?void 0:t.connection)!=null&&e.socket&&((a=(s=(n=this.provider)==null?void 0:n.connection)==null?void 0:s.socket)==null||a.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(c){this.logger.warn(c)}}isConnectionStalled(t){return this.staleConnectionErrors.some(e=>t.includes(e))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Cn(new HI(qE({sdkVersion:Ux,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:n}=t;await this.messages.set(e,n)}async shouldIgnoreMessageEvent(t){const{topic:e,message:n}=t;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;const s=this.messages.has(e,n);return s&&this.logger.debug(`Ignoring duplicate message: ${n}`),s}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),uf(t)){if(!t.method.endsWith(Tx))return;const e=t.params,{topic:n,message:s,publishedAt:a}=e.data,c={topic:n,message:s,publishedAt:a};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(f7({type:"event",event:e.id},c)),this.events.emit(e.id,c),await this.acknowledgePayload(t),await this.onMessageEvent(c)}else yc(t)&&this.events.emit(Zr.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Zr.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=mc(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(bi.payload,this.onPayloadHandler),this.provider.off(bi.connect,this.onConnectHandler),this.provider.off(bi.disconnect,this.onDisconnectHandler),this.provider.off(bi.error,this.onProviderErrorHandler)}async registerEventListeners(){let t=await Sp();L4(async e=>{t!==e&&(t=e,e?await this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.events.emit(Zr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&setTimeout(async()=>{await this.transportOpen().catch(t=>this.logger.error(t))},bt.toMiliseconds(Fx))}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(t=>{const e=setInterval(()=>{this.connected&&(clearInterval(e),t())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var p7=Object.defineProperty,o1=Object.getOwnPropertySymbols,g7=Object.prototype.hasOwnProperty,m7=Object.prototype.propertyIsEnumerable,a1=(r,t,e)=>t in r?p7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,u1=(r,t)=>{for(var e in t||(t={}))g7.call(t,e)&&a1(r,e,t[e]);if(o1)for(var e of o1(t))m7.call(t,e)&&a1(r,e,t[e]);return r};class Ns extends iI{constructor(t,e,n,s=Yn,a=void 0){super(t,e,n,s),this.core=t,this.logger=e,this.name=n,this.map=new Map,this.version=Lx,this.cached=[],this.initialized=!1,this.storagePrefix=Yn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(c=>{this.getKey&&c!==null&&!Or(c)?this.map.set(this.getKey(c),c):g4(c)?this.map.set(c.id,c):m4(c)&&this.map.set(c.topic,c)}),this.cached=[],this.initialized=!0)},this.set=async(c,l)=>{this.isInitialized(),this.map.has(c)?await this.update(c,l):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:c,value:l}),this.map.set(c,l),await this.persist())},this.get=c=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:c}),this.getData(c)),this.getAll=c=>(this.isInitialized(),c?this.values.filter(l=>Object.keys(c).every(d=>VI(l[d],c[d]))):this.values),this.update=async(c,l)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:c,update:l});const d=u1(u1({},this.getData(c)),l);this.map.set(c,d),await this.persist()},this.delete=async(c,l)=>{this.isInitialized(),this.map.has(c)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:c,reason:l}),this.map.delete(c),this.addToRecentlyDeleted(c),await this.persist())},this.logger=Vr(e,this.name),this.storagePrefix=s,this.getKey=a}get context(){return Kr(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(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const e=this.map.get(t);if(!e){if(this.recentlyDeleted.includes(t)){const{message:s}=mt("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}const{message:n}=mt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:e}=mt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class v7{constructor(t,e){this.core=t,this.logger=e,this.name=kx,this.version=Hx,this.events=new jl,this.initialized=!1,this.storagePrefix=Yn,this.ignoredPayloadTypes=[Wn],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:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async n=>{this.isInitialized();const s=Ml(),a=await this.core.crypto.setSymKey(s),c=_r(bt.FIVE_MINUTES),l={protocol:gm},d={topic:a,expiry:c,relay:l,active:!1},f=s4({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:s,relay:l,expiryTimestamp:c,methods:n==null?void 0:n.methods});return await this.pairings.set(a,d),await this.core.relayer.subscribe(a),this.core.expirer.set(a,c),{topic:a,uri:f}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:s,symKey:a,relay:c,expiryTimestamp:l,methods:d}=yp(n.uri);let f;if(this.pairings.keys.includes(s)&&(f=this.pairings.get(s),f.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const w=l||_r(bt.FIVE_MINUTES),E={topic:s,relay:c,expiry:w,active:!1,methods:d};return await this.pairings.set(s,E),this.core.expirer.set(s,w),n.activatePairing&&await this.activate({topic:s}),this.events.emit(so.create,E),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(a,s),await this.core.relayer.subscribe(s,{relay:c}),E},this.activate=async({topic:n})=>{this.isInitialized();const s=_r(bt.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:s}),this.core.expirer.set(n,s)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:s}=n;if(this.pairings.keys.includes(s)){const a=await this.sendRequest(s,"wc_pairingPing",{}),{done:c,resolve:l,reject:d}=Es();this.events.once(de("pairing_ping",a),({error:f})=>{f?d(f):l()}),await c()}},this.updateExpiry=async({topic:n,expiry:s})=>{this.isInitialized(),await this.pairings.update(n,{expiry:s})},this.updateMetadata=async({topic:n,metadata:s})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:s})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:s}=n;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",Re("USER_DISCONNECTED")),await this.deletePairing(s))},this.sendRequest=async(n,s,a)=>{const c=co(s,a),l=await this.core.crypto.encode(n,c),d=Qo[s].req;return this.core.history.set(n,c),this.core.relayer.publish(n,l,d),c.id},this.sendResult=async(n,s,a)=>{const c=mc(n,a),l=await this.core.crypto.encode(s,c),d=await this.core.history.get(s,n),f=Qo[d.request.method].res;await this.core.relayer.publish(s,l,f),await this.core.history.resolve(c)},this.sendError=async(n,s,a)=>{const c=vc(n,a),l=await this.core.crypto.encode(s,c),d=await this.core.history.get(s,n),f=Qo[d.request.method]?Qo[d.request.method].res:Qo.unregistered_method.res;await this.core.relayer.publish(s,l,f),await this.core.history.resolve(c)},this.deletePairing=async(n,s)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Re("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),s?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(s=>Hn(s.expiry));await Promise.all(n.map(s=>this.deletePairing(s.topic)))},this.onRelayEventRequest=n=>{const{topic:s,payload:a}=n;switch(a.method){case"wc_pairingPing":return this.onPairingPingRequest(s,a);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,a);default:return this.onUnknownRpcMethodRequest(s,a)}},this.onRelayEventResponse=async n=>{const{topic:s,payload:a}=n,c=(await this.core.history.get(s,a.id)).request.method;switch(c){case"wc_pairingPing":return this.onPairingPingResponse(s,a);default:return this.onUnknownRpcMethodResponse(c)}},this.onPairingPingRequest=async(n,s)=>{const{id:a}=s;try{this.isValidPing({topic:n}),await this.sendResult(a,n,!0),this.events.emit(so.ping,{id:a,topic:n})}catch(c){await this.sendError(a,n,c),this.logger.error(c)}},this.onPairingPingResponse=(n,s)=>{const{id:a}=s;setTimeout(()=>{Qi(s)?this.events.emit(de("pairing_ping",a),{}):Si(s)&&this.events.emit(de("pairing_ping",a),{error:s.error})},500)},this.onPairingDeleteRequest=async(n,s)=>{const{id:a}=s;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(so.delete,{id:a,topic:n})}catch(c){await this.sendError(a,n,c),this.logger.error(c)}},this.onUnknownRpcMethodRequest=async(n,s)=>{const{id:a,method:c}=s;try{if(this.registeredMethods.includes(c))return;const l=Re("WC_METHOD_UNSUPPORTED",c);await this.sendError(a,n,l),this.logger.error(l)}catch(l){await this.sendError(a,n,l),this.logger.error(l)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Re("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{var s;if(!zr(n)){const{message:c}=mt("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(c)}if(!p4(n.uri)){const{message:c}=mt("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(c)}const a=yp(n.uri);if(!((s=a==null?void 0:a.relay)!=null&&s.protocol)){const{message:c}=mt("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(c)}if(!(a!=null&&a.symKey)){const{message:c}=mt("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(c)}if(a!=null&&a.expiryTimestamp&&bt.toMiliseconds(a==null?void 0:a.expiryTimestamp)<Date.now()){const{message:c}=mt("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(c)}},this.isValidPing=async n=>{if(!zr(n)){const{message:a}=mt("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(a)}const{topic:s}=n;await this.isValidPairingTopic(s)},this.isValidDisconnect=async n=>{if(!zr(n)){const{message:a}=mt("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(a)}const{topic:s}=n;await this.isValidPairingTopic(s)},this.isValidPairingTopic=async n=>{if(!tr(n,!1)){const{message:s}=mt("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(s)}if(!this.pairings.keys.includes(n)){const{message:s}=mt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(s)}if(Hn(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:s}=mt("EXPIRED",`pairing topic: ${n}`);throw new Error(s)}},this.core=t,this.logger=Vr(e,this.name),this.pairings=new Ns(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Kr(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Zr.message,async t=>{const{topic:e,message:n}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const s=await this.core.crypto.decode(e,n);try{uf(s)?(this.core.history.set(e,s),this.onRelayEventRequest({topic:e,payload:s})):yc(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:e,payload:s}),this.core.history.delete(e,s.id))}catch(a){this.logger.error(a)}})}registerExpirerEvents(){this.core.expirer.on(Ei.expired,async t=>{const{topic:e}=J1(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit(so.expire,{topic:e}))})}}class y7 extends ZS{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new Di.EventEmitter,this.name=Kx,this.version=Vx,this.cached=[],this.initialized=!1,this.storagePrefix=Yn,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,s,a)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:s,chainId:a}),this.records.has(s.id))return;const c={id:s.id,topic:n,request:{method:s.method,params:s.params||null},chainId:a,expiry:_r(bt.THIRTY_DAYS)};this.records.set(c.id,c),this.persist(),this.events.emit(Ti.created,c)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const s=await this.getRecord(n.id);typeof s.response>"u"&&(s.response=Si(n)?{error:n.error}:{result:n.result},this.records.set(s.id,s),this.persist(),this.events.emit(Ti.updated,s))},this.get=async(n,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:s}),await this.getRecord(s)),this.delete=(n,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(a=>{if(a.topic===n){if(typeof s<"u"&&a.id!==s)return;this.records.delete(a.id),this.events.emit(Ti.deleted,a)}}),this.persist()},this.exists=async(n,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===n:!1),this.on=(n,s)=>{this.events.on(n,s)},this.once=(n,s)=>{this.events.once(n,s)},this.off=(n,s)=>{this.events.off(n,s)},this.removeListener=(n,s)=>{this.events.removeListener(n,s)},this.logger=Vr(e,this.name)}get context(){return Kr(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 t=[];return this.values.forEach(e=>{if(typeof e.response<"u")return;const n={topic:e.topic,request:co(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(n)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const e=this.records.get(t);if(!e){const{message:n}=mt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ti.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:e}=mt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(Ti.created,t=>{const e=Ti.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(Ti.updated,t=>{const e=Ti.updated;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(Ti.deleted,t=>{const e=Ti.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.core.heartbeat.on(Eo.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach(e=>{bt.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.records.delete(e.id),this.events.emit(Ti.deleted,e,!1),t=!0)}),t&&this.persist()}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}}class w7 extends sI{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new Di.EventEmitter,this.name=Gx,this.version=Wx,this.cached=[],this.initialized=!1,this.storagePrefix=Yn,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const s=this.formatTarget(n);return typeof this.getExpiration(s)<"u"}catch{return!1}},this.set=(n,s)=>{this.isInitialized();const a=this.formatTarget(n),c={target:a,expiry:s};this.expirations.set(a,c),this.checkExpiry(a,c),this.events.emit(Ei.created,{target:a,expiration:c})},this.get=n=>{this.isInitialized();const s=this.formatTarget(n);return this.getExpiration(s)},this.del=n=>{if(this.isInitialized(),this.has(n)){const s=this.formatTarget(n),a=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Ei.deleted,{target:s,expiration:a})}},this.on=(n,s)=>{this.events.on(n,s)},this.once=(n,s)=>{this.events.once(n,s)},this.off=(n,s)=>{this.events.off(n,s)},this.removeListener=(n,s)=>{this.events.removeListener(n,s)},this.logger=Vr(e,this.name)}get context(){return Kr(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(t){if(typeof t=="string")return jE(t);if(typeof t=="number")return $E(t);const{message:e}=mt("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ei.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:e}=mt("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:n}=mt("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(n),new Error(n)}return e}checkExpiry(t,e){const{expiry:n}=e;bt.toMiliseconds(n)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Ei.expired,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,e)=>this.checkExpiry(e,t))}registerEventListeners(){this.core.heartbeat.on(Eo.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Ei.created,t=>{const e=Ei.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Ei.expired,t=>{const e=Ei.expired;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(Ei.deleted,t=>{const e=Ei.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}}}let b7=class extends oI{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=nl,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async n=>{if(this.verifyDisabled||go()||!mo())return;const s=this.getVerifyUrl(n==null?void 0:n.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe()}catch(a){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(a)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Tl;try{await this.createIframe()}catch(a){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(a),this.verifyDisabled=!0}}},this.register=async n=>{this.initialized?this.sendPost(n.attestationId):(this.addToQueue(n.attestationId),await this.init())},this.resolve=async n=>{if(this.isDevEnv)return"";const s=this.getVerifyUrl(n==null?void 0:n.verifyUrl);let a;try{a=await this.fetchAttestation(n.attestationId,s)}catch(c){this.logger.info(`failed to resolve attestation: ${n.attestationId} from url: ${s}`),this.logger.info(c),a=await this.fetchAttestation(n.attestationId,Tl)}return a},this.fetchAttestation=async(n,s)=>{this.logger.info(`resolving attestation: ${n} from url: ${s}`);const a=this.startAbortTimer(bt.ONE_SECOND*2),c=await fetch(`${s}/attestation/${n}`,{signal:this.abortController.signal});return clearTimeout(a),c.status===200?await c.json():void 0},this.addToQueue=n=>{this.queue.push(n)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(n=>this.sendPost(n)),this.queue=[])},this.sendPost=n=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(n,"*"),this.logger.info(`postMessage sent: ${n} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let n;const s=a=>{a.data==="verify_ready"&&(this.onInit(),window.removeEventListener("message",s),n())};await Promise.race([new Promise(a=>{const c=document.getElementById(nl);if(c)return this.iframe=c,this.onInit(),a();window.addEventListener("message",s);const l=document.createElement("iframe");l.id=nl,l.src=`${this.verifyUrl}/${this.projectId}`,l.style.display="none",document.body.append(l),this.iframe=l,n=a}),new Promise((a,c)=>setTimeout(()=>{window.removeEventListener("message",s),c("verify iframe load timeout")},bt.toMiliseconds(bt.FIVE_SECONDS)))])},this.onInit=()=>{this.initialized=!0,this.processQueue()},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=n=>{let s=n||oo;return Yx.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${oo}`),s=oo),s},this.logger=Vr(e,this.name),this.verifyUrl=oo,this.abortController=new AbortController,this.isDevEnv=sa()&&{}.IS_VITEST}get context(){return Kr(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),bt.toMiliseconds(t))}},_7=class extends aI{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.context=Qx,this.registerDeviceToken=async n=>{const{clientId:s,token:a,notificationType:c,enableEncrypted:l=!1}=n,d=`${Jx}/${this.projectId}/clients`;await QI(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:c,token:a,always_raw:l})})},this.logger=Vr(e,this.context)}};var E7=Object.defineProperty,c1=Object.getOwnPropertySymbols,A7=Object.prototype.hasOwnProperty,S7=Object.prototype.propertyIsEnumerable,h1=(r,t,e)=>t in r?E7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,l1=(r,t)=>{for(var e in t||(t={}))A7.call(t,e)&&h1(r,e,t[e]);if(c1)for(var e of c1(t))S7.call(t,e)&&h1(r,e,t[e]);return r};let I7=class vm extends XS{constructor(t){var e;super(t),this.protocol=pm,this.version=_x,this.name=cf,this.events=new Di.EventEmitter,this.initialized=!1,this.on=(c,l)=>this.events.on(c,l),this.once=(c,l)=>this.events.once(c,l),this.off=(c,l)=>this.events.off(c,l),this.removeListener=(c,l)=>this.events.removeListener(c,l),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||mm,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const n=gc({level:typeof(t==null?void 0:t.logger)=="string"&&t.logger?t.logger:Ex.logger}),{logger:s,chunkLoggerController:a}=JS({opts:n,maxSizeInBytes:t==null?void 0:t.maxLogBlobSizeInBytes,loggerOverride:t==null?void 0:t.logger});this.logChunkController=a,(e=this.logChunkController)!=null&&e.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var c,l;(c=this.logChunkController)!=null&&c.downloadLogsBlobInBrowser&&((l=this.logChunkController)==null||l.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Vr(s,this.name),this.heartbeat=new Eo.HeartBeat,this.crypto=new Zx(this,this.logger,t==null?void 0:t.keychain),this.history=new y7(this,this.logger),this.expirer=new w7(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new yS(l1(l1({},Ax),t==null?void 0:t.storageOptions)),this.relayer=new d7({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new v7(this,this.logger),this.verify=new b7(this.projectId||"",this.logger),this.echoClient=new _7(this.projectId||"",this.logger)}static async init(t){const e=new vm(t);await e.initialize();const n=await e.crypto.getClientId();return await e.storage.setItem(qx,n),e}get context(){return Kr(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var t;return(t=this.logChunkController)==null?void 0:t.logsToBlob({clientId:await this.crypto.getClientId()})}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.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}};const D7=I7,ym="wc",wm=2,bm="client",hf=`${ym}@${wm}:${bm}:`,ol={name:bm,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},f1="WALLETCONNECT_DEEPLINK_CHOICE",x7="proposal",_m="Proposal expired",M7="session",to=bt.SEVEN_DAYS,C7="engine",_i={wc_sessionPropose:{req:{ttl:bt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:bt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:bt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:bt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:bt.ONE_DAY,prompt:!1,tag:1114},res:{ttl:bt.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:bt.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:bt.ONE_HOUR,prompt:!1,tag:1117}}},al={min:bt.FIVE_MINUTES,max:bt.SEVEN_DAYS},An={idle:"IDLE",active:"ACTIVE"},P7="request",O7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"],N7="wc",R7="auth",T7="authKeys",F7="pairingTopics",U7="requests",bc=`${N7}@${1.5}:${R7}:`,Vu=`${bc}:PUB_KEY`;var B7=Object.defineProperty,L7=Object.defineProperties,q7=Object.getOwnPropertyDescriptors,d1=Object.getOwnPropertySymbols,j7=Object.prototype.hasOwnProperty,$7=Object.prototype.propertyIsEnumerable,p1=(r,t,e)=>t in r?B7(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hr=(r,t)=>{for(var e in t||(t={}))j7.call(t,e)&&p1(r,e,t[e]);if(d1)for(var e of d1(t))$7.call(t,e)&&p1(r,e,t[e]);return r},eo=(r,t)=>L7(r,q7(t));class z7 extends cI{constructor(t){super(t),this.name=C7,this.events=new jl,this.initialized=!1,this.requestQueue={state:An.idle,queue:[]},this.sessionRequestQueue={state:An.idle,queue:[]},this.requestQueueDelay=bt.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(_i)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},bt.toMiliseconds(this.requestQueueDelay)))},this.connect=async e=>{await this.isInitialized();const n=eo(hr({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:s,requiredNamespaces:a,optionalNamespaces:c,sessionProperties:l,relays:d}=n;let f=s,w,E=!1;try{f&&(E=this.client.core.pairing.pairings.get(f).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${f}) failed`),B}if(!f||!E){const{topic:B,uri:z}=await this.client.core.pairing.create();f=B,w=z}if(!f){const{message:B}=mt("NO_MATCHING_KEY",`connect() pairing topic: ${f}`);throw new Error(B)}const x=await this.client.core.crypto.generateKeyPair(),I=_i.wc_sessionPropose.req.ttl||bt.FIVE_MINUTES,R=_r(I),Y=hr({requiredNamespaces:a,optionalNamespaces:c,relays:d??[{protocol:gm}],proposer:{publicKey:x,metadata:this.client.metadata},expiryTimestamp:R},l&&{sessionProperties:l}),{reject:W,resolve:tt,done:K}=Es(I,_m);this.events.once(de("session_connect"),async({error:B,session:z})=>{if(B)W(B);else if(z){z.self.publicKey=x;const $=eo(hr({},z),{requiredNamespaces:Y.requiredNamespaces,optionalNamespaces:Y.optionalNamespaces});await this.client.session.set(z.topic,$),await this.setExpiry(z.topic,z.expiry),f&&await this.client.core.pairing.updateMetadata({topic:f,metadata:z.peer.metadata}),tt($)}});const V=await this.sendRequest({topic:f,method:"wc_sessionPropose",params:Y,throwOnFailedPublish:!0});return await this.setProposal(V,hr({id:V},Y)),{uri:w,approval:K}},this.pair=async e=>{await this.isInitialized();try{return await this.client.core.pairing.pair(e)}catch(n){throw this.client.logger.error("pair() failed"),n}},this.approve=async e=>{await this.isInitialized();try{await this.isValidApprove(e)}catch(K){throw this.client.logger.error("approve() -> isValidApprove() failed"),K}const{id:n,relayProtocol:s,namespaces:a,sessionProperties:c,sessionConfig:l}=e;let d;try{d=this.client.proposal.get(n)}catch(K){throw this.client.logger.error(`approve() -> proposal.get(${n}) failed`),K}let{pairingTopic:f,proposer:w,requiredNamespaces:E,optionalNamespaces:x}=d;f=f||"";const I=await this.client.core.crypto.generateKeyPair(),R=w.publicKey,Y=await this.client.core.crypto.generateSharedKey(I,R),W=hr(hr({relay:{protocol:s??"irn"},namespaces:a,pairingTopic:f,controller:{publicKey:I,metadata:this.client.metadata},expiry:_r(to)},c&&{sessionProperties:c}),l&&{sessionConfig:l});await this.client.core.relayer.subscribe(Y);const tt=eo(hr({},W),{topic:Y,requiredNamespaces:E,optionalNamespaces:x,pairingTopic:f,acknowledged:!1,self:W.controller,peer:{publicKey:w.publicKey,metadata:w.metadata},controller:I});await this.client.session.set(Y,tt);try{await this.sendResult({id:n,topic:f,result:{relay:{protocol:s??"irn"},responderPublicKey:I},throwOnFailedPublish:!0}),await this.sendRequest({topic:Y,method:"wc_sessionSettle",params:W,throwOnFailedPublish:!0})}catch(K){throw this.client.logger.error(K),this.client.session.delete(Y,Re("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(Y),K}return await this.client.core.pairing.updateMetadata({topic:f,metadata:w.metadata}),await this.client.proposal.delete(n,Re("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(Y,_r(to)),{topic:Y,acknowledged:()=>new Promise(K=>setTimeout(()=>K(this.client.session.get(Y)),500))}},this.reject=async e=>{await this.isInitialized();try{await this.isValidReject(e)}catch(c){throw this.client.logger.error("reject() -> isValidReject() failed"),c}const{id:n,reason:s}=e;let a;try{a=this.client.proposal.get(n).pairingTopic}catch(c){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),c}a&&(await this.sendError({id:n,topic:a,error:s}),await this.client.proposal.delete(n,Re("USER_DISCONNECTED")))},this.update=async e=>{await this.isInitialized();try{await this.isValidUpdate(e)}catch(E){throw this.client.logger.error("update() -> isValidUpdate() failed"),E}const{topic:n,namespaces:s}=e,{done:a,resolve:c,reject:l}=Es(),d=Kn(),f=Is().toString(),w=this.client.session.get(n).namespaces;return this.events.once(de("session_update",d),({error:E})=>{E?l(E):c()}),await this.client.session.update(n,{namespaces:s}),this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:d,relayRpcId:f}).catch(E=>{this.client.logger.error(E),this.client.session.update(n,{namespaces:w}),l(E)}),{acknowledged:a}},this.extend=async e=>{await this.isInitialized();try{await this.isValidExtend(e)}catch(d){throw this.client.logger.error("extend() -> isValidExtend() failed"),d}const{topic:n}=e,s=Kn(),{done:a,resolve:c,reject:l}=Es();return this.events.once(de("session_extend",s),({error:d})=>{d?l(d):c()}),await this.setExpiry(n,_r(to)),this.sendRequest({topic:n,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(d=>{l(d)}),{acknowledged:a}},this.request=async e=>{await this.isInitialized();try{await this.isValidRequest(e)}catch(I){throw this.client.logger.error("request() -> isValidRequest() failed"),I}const{chainId:n,request:s,topic:a,expiry:c=_i.wc_sessionRequest.req.ttl}=e,l=this.client.session.get(a),d=Kn(),f=Is().toString(),{done:w,resolve:E,reject:x}=Es(c,"Request expired. Please try again.");return this.events.once(de("session_request",d),({error:I,result:R})=>{I?x(I):E(R)}),await Promise.all([new Promise(async I=>{await this.sendRequest({clientRpcId:d,relayRpcId:f,topic:a,method:"wc_sessionRequest",params:{request:eo(hr({},s),{expiryTimestamp:_r(c)}),chainId:n},expiry:c,throwOnFailedPublish:!0}).catch(R=>x(R)),this.client.events.emit("session_request_sent",{topic:a,request:s,chainId:n,id:d}),I()}),new Promise(async I=>{var R;if(!((R=l.sessionConfig)!=null&&R.disableDeepLink)){const Y=await kE(this.client.core.storage,f1);zE({id:d,topic:a,wcDeepLink:Y})}I()}),w()]).then(I=>I[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:n,response:s}=e,{id:a}=s;Qi(s)?await this.sendResult({id:a,topic:n,result:s.result,throwOnFailedPublish:!0}):Si(s)&&await this.sendError({id:a,topic:n,error:s.error}),this.cleanupAfterResponse(e)},this.ping=async e=>{await this.isInitialized();try{await this.isValidPing(e)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:n}=e;if(this.client.session.keys.includes(n)){const s=Kn(),a=Is().toString(),{done:c,resolve:l,reject:d}=Es();this.events.once(de("session_ping",s),({error:f})=>{f?d(f):l()}),await Promise.all([this.sendRequest({topic:n,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:a}),c()])}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:n,event:s,chainId:a}=e,c=Is().toString();await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:s,chainId:a},throwOnFailedPublish:!0,relayRpcId:c})},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:n}=e;if(this.client.session.keys.includes(n))await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Re("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:n,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(n))await this.client.core.pairing.disconnect({topic:n});else{const{message:s}=mt("MISMATCHED_TOPIC",`Session or pairing topic not found: ${n}`);throw new Error(s)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(n=>f4(n,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async e=>{this.isInitialized(),this.isValidAuthenticate(e);const{chains:n,statement:s="",uri:a,domain:c,nonce:l,type:d,exp:f,nbf:w,methods:E=[]}=e,x=[...e.resources||[]],{topic:I,uri:R}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"]});this.client.logger.info({message:"Generated new pairing",pairing:{topic:I,uri:R}});const Y=await this.client.core.crypto.generateKeyPair(),W=zu(Y);if(await Promise.all([this.client.auth.authKeys.set(Vu,{responseTopic:W,publicKey:Y}),this.client.auth.pairingTopics.set(W,{topic:W,pairingTopic:I})]),await this.client.core.relayer.subscribe(W),this.client.logger.info(`sending request to new pairing topic: ${I}`),E.length>0){const{namespace:gt}=Uu(n[0]);let h=U8(gt,"request",E);$u(x)&&(h=L8(h,x.pop())),x.push(h)}const tt=_r(_i.wc_sessionPropose.req.ttl),K={authPayload:{type:d??"caip122",chains:n,statement:s,aud:a,domain:c,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:w,resources:x},requester:{publicKey:Y,metadata:this.client.metadata},expiryTimestamp:tt},V={eip155:{chains:n,methods:[...new Set(["personal_sign",...E])],events:["chainChanged","accountsChanged"]}},B={requiredNamespaces:{},optionalNamespaces:V,relays:[{protocol:"irn"}],proposer:{publicKey:Y,metadata:this.client.metadata},expiryTimestamp:tt},{done:z,resolve:$,reject:v}=Es(_i.wc_sessionAuthenticate.req.ttl,"Request expired"),T=async({error:gt,session:h})=>{if(this.events.off(de("session_request",ft),st),gt)v(gt);else if(h){h.self.publicKey=Y,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),I&&await this.client.core.pairing.updateMetadata({topic:I,metadata:h.peer.metadata});const y=this.client.session.get(h.topic);$({session:y})}},st=async gt=>{if(gt.error){const q=Re("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return gt.error.code===q.code?void 0:(this.events.off(de("session_connect"),T),v(gt.error.message))}this.events.off(de("session_connect"),T);const{cacaos:h,responder:y}=gt.result,b=[],C=[];for(const q of h){await hp({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),v(Re("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:S}=q,g=$u(S.resources),O=[cp(S.iss)],it=Zu(S.iss);if(g){const lt=lp(g),_=fp(g);b.push(...lt),O.push(..._)}for(const lt of O)C.push(`${lt}:${it}`)}const M=await this.client.core.crypto.generateSharedKey(Y,y.publicKey);let N;b.length>0&&(N={topic:M,acknowledged:!0,self:{publicKey:Y,metadata:this.client.metadata},peer:y,controller:y.publicKey,expiry:_r(to),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:I,namespaces:wp([...new Set(b)],[...new Set(C)])},await this.client.core.relayer.subscribe(M),await this.client.session.set(M,N),N=this.client.session.get(M)),$({auths:h,session:N})},ft=Kn(),pt=Kn();this.events.once(de("session_connect"),T),this.events.once(de("session_request",ft),st);try{await Promise.all([this.sendRequest({topic:I,method:"wc_sessionAuthenticate",params:K,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:ft}),this.sendRequest({topic:I,method:"wc_sessionPropose",params:B,expiry:_i.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:pt})])}catch(gt){throw this.events.off(de("session_connect"),T),this.events.off(de("session_request",ft),st),gt}return await this.setProposal(pt,hr({id:pt},B)),await this.client.auth.requests.set(ft,{authPayload:K.authPayload,requester:K.requester,expiryTimestamp:tt,id:ft,pairingTopic:I,verifyContext:{}}),{uri:R,response:z}},this.approveSessionAuthenticate=async e=>{this.isInitialized();const{id:n,auths:s}=e,a=this.getPendingAuthRequest(n);if(!a)throw new Error(`Could not find pending auth request with id ${n}`);const c=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=zu(c),f={type:Wn,receiverPublicKey:c,senderPublicKey:l},w=[],E=[];for(const R of s){if(!await hp({cacao:R,projectId:this.client.core.projectId})){const V=Re("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:d,error:V,encodeOpts:f}),new Error(V.message)}const{p:Y}=R,W=$u(Y.resources),tt=[cp(Y.iss)],K=Zu(Y.iss);if(W){const V=lp(W),B=fp(W);w.push(...V),tt.push(...B)}for(const V of tt)E.push(`${V}:${K}`)}const x=await this.client.core.crypto.generateSharedKey(l,c);let I;return(w==null?void 0:w.length)>0&&(I={topic:x,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:a.requester.metadata},controller:c,expiry:_r(to),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:"",namespaces:wp([...new Set(w)],[...new Set(E)])},await this.client.core.relayer.subscribe(x),await this.client.session.set(x,I)),await this.sendResult({topic:d,id:n,result:{cacaos:s,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:f,throwOnFailedPublish:!0}),await this.client.auth.requests.delete(n,{message:"fullfilled",code:0}),await this.client.core.pairing.activate({topic:a.pairingTopic}),{session:I}},this.rejectSessionAuthenticate=async e=>{await this.isInitialized();const{id:n,reason:s}=e,a=this.getPendingAuthRequest(n);if(!a)throw new Error(`Could not find pending auth request with id ${n}`);const c=a.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=zu(c),f={type:Wn,receiverPublicKey:c,senderPublicKey:l};await this.sendError({id:n,topic:d,error:s,encodeOpts:f}),await this.client.auth.requests.delete(n,{message:"rejected",code:0}),await this.client.proposal.delete(n,Re("USER_DISCONNECTED"))},this.formatAuthMessage=e=>{this.isInitialized();const{request:n,iss:s}=e;return Rg(n,s)},this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const n=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(a=>{var c,l;return((c=a.peerMetadata)==null?void 0:c.url)&&((l=a.peerMetadata)==null?void 0:l.url)===e.peer.metadata.url&&a.topic&&a.topic!==n.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(a=>this.client.core.pairing.disconnect({topic:a.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async e=>{const{topic:n,expirerHasDeleted:s=!1,emitEvent:a=!0,id:c=0}=e,{self:l}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Re("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.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(f1).catch(d=>this.client.logger.warn(d)),this.getPendingSessionRequests().forEach(d=>{d.topic===n&&this.deletePendingSessionRequest(d.id,Re("USER_DISCONNECTED"))}),a&&this.client.events.emit("session_delete",{id:c,topic:n})},this.deleteProposal=async(e,n)=>{await Promise.all([this.client.proposal.delete(e,Re("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")},this.deletePendingSessionRequest=async(e,n,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,n),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==e),s&&(this.sessionRequestQueue.state=An.idle,this.client.events.emit("session_request_expire",{id:e}))},this.setExpiry=async(e,n)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:n}),this.client.core.expirer.set(e,n)},this.setProposal=async(e,n)=>{await this.client.proposal.set(e,n),this.client.core.expirer.set(e,_r(_i.wc_sessionPropose.req.ttl))},this.setPendingSessionRequest=async e=>{const{id:n,topic:s,params:a,verifyContext:c}=e,l=a.request.expiryTimestamp||_r(_i.wc_sessionRequest.req.ttl);await this.client.pendingRequest.set(n,{id:n,topic:s,params:a,verifyContext:c}),l&&this.client.core.expirer.set(n,l)},this.sendRequest=async e=>{const{topic:n,method:s,params:a,expiry:c,relayRpcId:l,clientRpcId:d,throwOnFailedPublish:f}=e,w=co(s,a,d);if(mo()&&O7.includes(s)){const I=Ss(JSON.stringify(w));this.client.core.verify.register({attestationId:I})}let E;try{E=await this.client.core.crypto.encode(n,w)}catch(I){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`),I}const x=_i[s].req;return c&&(x.ttl=c),l&&(x.id=l),this.client.core.history.set(n,w),f?(x.internal=eo(hr({},x.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,E,x)):this.client.core.relayer.publish(n,E,x).catch(I=>this.client.logger.error(I)),w.id},this.sendResult=async e=>{const{id:n,topic:s,result:a,throwOnFailedPublish:c,encodeOpts:l}=e,d=mc(n,a);let f;try{f=await this.client.core.crypto.encode(s,d,l)}catch(x){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),x}let w;try{w=await this.client.core.history.get(s,n)}catch(x){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${n}) failed`),x}const E=_i[w.request.method].res;c?(E.internal=eo(hr({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,f,E)):this.client.core.relayer.publish(s,f,E).catch(x=>this.client.logger.error(x)),await this.client.core.history.resolve(d)},this.sendError=async e=>{const{id:n,topic:s,error:a,encodeOpts:c}=e,l=vc(n,a);let d;try{d=await this.client.core.crypto.encode(s,l,c)}catch(E){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),E}let f;try{f=await this.client.core.history.get(s,n)}catch(E){throw this.client.logger.error(`sendError() -> history.get(${s}, ${n}) failed`),E}const w=_i[f.request.method].res;this.client.core.relayer.publish(s,d,w),await this.client.core.history.resolve(l)},this.cleanup=async()=>{const e=[],n=[];this.client.session.getAll().forEach(s=>{let a=!1;Hn(s.expiry)&&(a=!0),this.client.core.crypto.keychain.has(s.topic)||(a=!0),a&&e.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Hn(s.expiryTimestamp)&&n.push(s.id)}),await Promise.all([...e.map(s=>this.deleteSession({topic:s})),...n.map(s=>this.deleteProposal(s))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===An.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=An.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(n=>setTimeout(n,300))}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=An.idle},this.processRequest=e=>{const{topic:n,payload:s}=e,a=s.method;if(!this.shouldIgnorePairingRequest({topic:n,requestMethod:a}))switch(a){case"wc_sessionPropose":return this.onSessionProposeRequest(n,s);case"wc_sessionSettle":return this.onSessionSettleRequest(n,s);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,s);case"wc_sessionExtend":return this.onSessionExtendRequest(n,s);case"wc_sessionPing":return this.onSessionPingRequest(n,s);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,s);case"wc_sessionRequest":return this.onSessionRequest(n,s);case"wc_sessionEvent":return this.onSessionEventRequest(n,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateRequest(n,s);default:return this.client.logger.info(`Unsupported request method ${a}`)}},this.onRelayEventResponse=async e=>{const{topic:n,payload:s}=e,a=(await this.client.core.history.get(n,s.id)).request.method;switch(a){case"wc_sessionPropose":return this.onSessionProposeResponse(n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(n,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,s);case"wc_sessionExtend":return this.onSessionExtendResponse(n,s);case"wc_sessionPing":return this.onSessionPingResponse(n,s);case"wc_sessionRequest":return this.onSessionRequestResponse(n,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(n,s);default:return this.client.logger.info(`Unsupported response method ${a}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:n}=e,{message:s}=mt("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=e=>{const{topic:n,requestMethod:s}=e,a=this.expectedPairingMethodMap.get(n);return!a||a.includes(s)?!1:!!(a.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async(e,n)=>{const{params:s,id:a}=n;try{this.isValidConnect(hr({},n.params));const c=s.expiryTimestamp||_r(_i.wc_sessionPropose.req.ttl),l=hr({id:a,pairingTopic:e,expiryTimestamp:c},s);await this.setProposal(a,l);const d=Ss(JSON.stringify(n)),f=await this.getVerifyContext(d,l.proposer.metadata);this.client.events.emit("session_proposal",{id:a,params:l,verifyContext:f})}catch(c){await this.sendError({id:a,topic:e,error:c}),this.client.logger.error(c)}},this.onSessionProposeResponse=async(e,n)=>{const{id:s}=n;if(Qi(n)){const{result:a}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:a});const c=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const l=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const d=a.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:d});const f=await this.client.core.crypto.generateSharedKey(l,d);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const w=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:w}),await this.client.core.pairing.activate({topic:e})}else if(Si(n)){await this.client.proposal.delete(s,Re("USER_DISCONNECTED"));const a=de("session_connect");if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners, 954`);this.events.emit(de("session_connect"),{error:n.error})}},this.onSessionSettleRequest=async(e,n)=>{const{id:s,params:a}=n;try{this.isValidSessionSettleRequest(a);const{relay:c,controller:l,expiry:d,namespaces:f,sessionProperties:w,pairingTopic:E,sessionConfig:x}=n.params,I=hr(hr({topic:e,relay:c,expiry:d,namespaces:f,acknowledged:!0,pairingTopic:E,requiredNamespaces:{},optionalNamespaces:{},controller:l.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:l.publicKey,metadata:l.metadata}},w&&{sessionProperties:w}),x&&{sessionConfig:x});await this.sendResult({id:n.id,topic:e,result:!0,throwOnFailedPublish:!0});const R=de("session_connect");if(this.events.listenerCount(R)===0)throw new Error(`emitting ${R} without any listeners 997`);this.events.emit(de("session_connect"),{session:I}),this.cleanupDuplicatePairings(I)}catch(c){await this.sendError({id:s,topic:e,error:c}),this.client.logger.error(c)}},this.onSessionSettleResponse=async(e,n)=>{const{id:s}=n;Qi(n)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(de("session_approve",s),{})):Si(n)&&(await this.client.session.delete(e,Re("USER_DISCONNECTED")),this.events.emit(de("session_approve",s),{error:n.error}))},this.onSessionUpdateRequest=async(e,n)=>{const{params:s,id:a}=n;try{const c=`${e}_session_update`,l=Go.get(c);if(l&&this.isRequestOutOfSync(l,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:e,error:Re("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(hr({topic:e},s));try{Go.set(c,a),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:a,topic:e,result:!0,throwOnFailedPublish:!0})}catch(d){throw Go.delete(c),d}this.client.events.emit("session_update",{id:a,topic:e,params:s})}catch(c){await this.sendError({id:a,topic:e,error:c}),this.client.logger.error(c)}},this.isRequestOutOfSync=(e,n)=>parseInt(n.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,n)=>{const{id:s}=n,a=de("session_update",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Qi(n)?this.events.emit(de("session_update",s),{}):Si(n)&&this.events.emit(de("session_update",s),{error:n.error})},this.onSessionExtendRequest=async(e,n)=>{const{id:s}=n;try{this.isValidExtend({topic:e}),await this.setExpiry(e,_r(to)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(a){await this.sendError({id:s,topic:e,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(e,n)=>{const{id:s}=n,a=de("session_extend",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Qi(n)?this.events.emit(de("session_extend",s),{}):Si(n)&&this.events.emit(de("session_extend",s),{error:n.error})},this.onSessionPingRequest=async(e,n)=>{const{id:s}=n;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(a){await this.sendError({id:s,topic:e,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(e,n)=>{const{id:s}=n,a=de("session_ping",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{Qi(n)?this.events.emit(de("session_ping",s),{}):Si(n)&&this.events.emit(de("session_ping",s),{error:n.error})},500)},this.onSessionDeleteRequest=async(e,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:e,reason:n.params}),await Promise.all([new Promise(a=>{this.client.core.relayer.once(Zr.publish,async()=>{a(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:Re("USER_DISCONNECTED")})])}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async(e,n)=>{const{id:s,params:a}=n;try{await this.isValidRequest(hr({topic:e},a));const c=Ss(JSON.stringify(co("wc_sessionRequest",a,s))),l=this.client.session.get(e),d=await this.getVerifyContext(c,l.peer.metadata),f={id:s,topic:e,params:a,verifyContext:d};await this.setPendingSessionRequest(f),this.addSessionRequestToSessionRequestQueue(f),this.processSessionRequestQueue()}catch(c){await this.sendError({id:s,topic:e,error:c}),this.client.logger.error(c)}},this.onSessionRequestResponse=(e,n)=>{const{id:s}=n,a=de("session_request",s);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Qi(n)?this.events.emit(de("session_request",s),{result:n.result}):Si(n)&&this.events.emit(de("session_request",s),{error:n.error})},this.onSessionEventRequest=async(e,n)=>{const{id:s,params:a}=n;try{const c=`${e}_session_event_${a.event.name}`,l=Go.get(c);if(l&&this.isRequestOutOfSync(l,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(hr({topic:e},a)),this.client.events.emit("session_event",{id:s,topic:e,params:a}),Go.set(c,s)}catch(c){await this.sendError({id:s,topic:e,error:c}),this.client.logger.error(c)}},this.onSessionAuthenticateResponse=(e,n)=>{const{id:s}=n;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:n}),Qi(n)?this.events.emit(de("session_request",s),{result:n.result}):Si(n)&&this.events.emit(de("session_request",s),{error:n.error})},this.onSessionAuthenticateRequest=async(e,n)=>{const{requester:s,authPayload:a,expiryTimestamp:c}=n.params,l=Ss(JSON.stringify(n)),d=await this.getVerifyContext(l,this.client.metadata),f={requester:s,pairingTopic:e,id:n.id,authPayload:a,verifyContext:d,expiryTimestamp:c};await this.client.auth.requests.set(n.id,f),this.client.events.emit("session_authenticate",{topic:e,params:n.params,id:n.id})},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=An.idle,this.processSessionRequestQueue()},bt.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:e,error:n})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(a=>a.topic===e&&a.request.method==="wc_sessionRequest").forEach(a=>{const c=a.request.id,l=de("session_request",c);if(this.events.listenerCount(l)===0)throw new Error(`emitting ${l} without any listeners`);this.events.emit(de("session_request",a.request.id),{error:n})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===An.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=An.active,this.client.events.emit("session_request",e)}catch(n){this.client.logger.error(n)}},this.onPairingCreated=e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const n=this.client.proposal.getAll().find(s=>s.pairingTopic===e.topic);n&&this.onSessionProposeRequest(e.topic,co("wc_sessionPropose",{requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties},n.id))},this.isValidConnect=async e=>{if(!zr(e)){const{message:d}=mt("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(d)}const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:a,sessionProperties:c,relays:l}=e;if(Or(n)||await this.isValidPairingTopic(n),!S4(l,!0)){const{message:d}=mt("MISSING_OR_INVALID",`connect() relays: ${l}`);throw new Error(d)}!Or(s)&&ca(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!Or(a)&&ca(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),Or(c)||this.validateSessionProps(c,"sessionProperties")},this.validateNamespaces=(e,n)=>{const s=A4(e,"connect()",n);if(s)throw new Error(s.message)},this.isValidApprove=async e=>{if(!zr(e))throw new Error(mt("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:n,namespaces:s,relayProtocol:a,sessionProperties:c}=e;this.checkRecentlyDeleted(n),await this.isValidProposalId(n);const l=this.client.proposal.get(n),d=Qh(s,"approve()");if(d)throw new Error(d.message);const f=Ep(l.requiredNamespaces,s,"approve()");if(f)throw new Error(f.message);if(!tr(a,!0)){const{message:w}=mt("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(w)}Or(c)||this.validateSessionProps(c,"sessionProperties")},this.isValidReject=async e=>{if(!zr(e)){const{message:a}=mt("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(a)}const{id:n,reason:s}=e;if(this.checkRecentlyDeleted(n),await this.isValidProposalId(n),!D4(s)){const{message:a}=mt("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(a)}},this.isValidSessionSettleRequest=e=>{if(!zr(e)){const{message:f}=mt("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(f)}const{relay:n,controller:s,namespaces:a,expiry:c}=e;if(!qg(n)){const{message:f}=mt("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const l=v4(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);const d=Qh(a,"onSessionSettleRequest()");if(d)throw new Error(d.message);if(Hn(c)){const{message:f}=mt("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async e=>{if(!zr(e)){const{message:d}=mt("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(d)}const{topic:n,namespaces:s}=e;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const a=this.client.session.get(n),c=Qh(s,"update()");if(c)throw new Error(c.message);const l=Ep(a.requiredNamespaces,s,"update()");if(l)throw new Error(l.message)},this.isValidExtend=async e=>{if(!zr(e)){const{message:s}=mt("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(s)}const{topic:n}=e;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n)},this.isValidRequest=async e=>{if(!zr(e)){const{message:d}=mt("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(d)}const{topic:n,request:s,chainId:a,expiry:c}=e;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const{namespaces:l}=this.client.session.get(n);if(!_p(l,a)){const{message:d}=mt("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(d)}if(!x4(s)){const{message:d}=mt("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(d)}if(!P4(l,a,s.method)){const{message:d}=mt("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(d)}if(c&&!T4(c,al)){const{message:d}=mt("MISSING_OR_INVALID",`request() expiry: ${c}. Expiry must be a number (in seconds) between ${al.min} and ${al.max}`);throw new Error(d)}},this.isValidRespond=async e=>{var n;if(!zr(e)){const{message:c}=mt("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(c)}const{topic:s,response:a}=e;try{await this.isValidSessionTopic(s)}catch(c){throw(n=e==null?void 0:e.response)!=null&&n.id&&this.cleanupAfterResponse(e),c}if(!M4(a)){const{message:c}=mt("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(c)}},this.isValidPing=async e=>{if(!zr(e)){const{message:s}=mt("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(s)}const{topic:n}=e;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async e=>{if(!zr(e)){const{message:l}=mt("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(l)}const{topic:n,event:s,chainId:a}=e;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!_p(c,a)){const{message:l}=mt("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(l)}if(!C4(s)){const{message:l}=mt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(l)}if(!O4(c,a,s.name)){const{message:l}=mt("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(l)}},this.isValidDisconnect=async e=>{if(!zr(e)){const{message:s}=mt("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(s)}const{topic:n}=e;await this.isValidSessionOrPairingTopic(n)},this.isValidAuthenticate=e=>{const{chains:n,uri:s,domain:a,nonce:c}=e;if(!Array.isArray(n)||n.length===0)throw new Error("chains is required and must be a non-empty array");if(!tr(s,!1))throw new Error("uri is required parameter");if(!tr(a,!1))throw new Error("domain is required parameter");if(!tr(c,!1))throw new Error("nonce is required parameter");if([...new Set(n.map(d=>Uu(d).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:l}=Uu(n[0]);if(l!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async(e,n)=>{const s={verified:{verifyUrl:n.verifyUrl||oo,validation:"UNKNOWN",origin:n.url||""}};try{const a=await this.client.core.verify.resolve({attestationId:e,verifyUrl:n.verifyUrl});a&&(s.verified.origin=a.origin,s.verified.isScam=a.isScam,s.verified.validation=a.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(a){this.client.logger.info(a)}return this.client.logger.info(`Verify context: ${JSON.stringify(s)}`),s},this.validateSessionProps=(e,n)=>{Object.values(e).forEach(s=>{if(!tr(s,!1)){const{message:a}=mt("MISSING_OR_INVALID",`${n} must be in Record<string, string> format. Received: ${JSON.stringify(s)}`);throw new Error(a)}})},this.getPendingAuthRequest=e=>{const n=this.client.auth.requests.get(e);return typeof n=="object"?n:void 0},this.addToRecentlyDeleted=(e,n)=>{if(this.recentlyDeletedMap.set(e,n),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const a=this.recentlyDeletedLimit/2;for(const c of this.recentlyDeletedMap.keys()){if(s++>=a)break;this.recentlyDeletedMap.delete(c)}}},this.checkRecentlyDeleted=e=>{const n=this.recentlyDeletedMap.get(e);if(n){const{message:s}=mt("MISSING_OR_INVALID",`Record was recently deleted - ${n}: ${e}`);throw new Error(s)}}}async isInitialized(){if(!this.initialized){const{message:t}=mt("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Zr.message,async t=>{const{topic:e,message:n}=t,{publicKey:s}=this.client.auth.authKeys.keys.includes(Vu)?this.client.auth.authKeys.get(Vu):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(e,n,{receiverPublicKey:s});try{uf(a)?(this.client.core.history.set(e,a),this.onRelayEventRequest({topic:e,payload:a})):yc(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:e,payload:a}),this.client.core.history.delete(e,a.id)):this.onRelayEventUnknownPayload({topic:e,payload:a})}catch(c){this.client.logger.error(c)}})}registerExpirerEvents(){this.client.core.expirer.on(Ei.expired,async t=>{const{topic:e,id:n}=J1(t.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,mt("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerPairingEvents(){this.client.core.pairing.events.on(so.create,t=>this.onPairingCreated(t)),this.client.core.pairing.events.on(so.delete,t=>{this.addToRecentlyDeleted(t.topic,"pairing")})}isValidPairingTopic(t){if(!tr(t,!1)){const{message:e}=mt("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=mt("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(e)}if(Hn(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=mt("EXPIRED",`pairing topic: ${t}`);throw new Error(e)}}async isValidSessionTopic(t){if(!tr(t,!1)){const{message:e}=mt("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(e)}if(this.checkRecentlyDeleted(t),!this.client.session.keys.includes(t)){const{message:e}=mt("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(e)}if(Hn(this.client.session.get(t).expiry)){await this.deleteSession({topic:t});const{message:e}=mt("EXPIRED",`session topic: ${t}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(t)){const{message:e}=mt("MISSING_OR_INVALID",`session topic does not exist in keychain: ${t}`);throw await this.deleteSession({topic:t}),new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.checkRecentlyDeleted(t),this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(tr(t,!1)){const{message:e}=mt("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(e)}else{const{message:e}=mt("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(e)}}async isValidProposalId(t){if(!I4(t)){const{message:e}=mt("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=mt("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(e)}if(Hn(this.client.proposal.get(t).expiryTimestamp)){await this.deleteProposal(t);const{message:e}=mt("EXPIRED",`proposal id: ${t}`);throw new Error(e)}}}class k7 extends Ns{constructor(t,e){super(t,e,x7,hf),this.core=t,this.logger=e}}class H7 extends Ns{constructor(t,e){super(t,e,M7,hf),this.core=t,this.logger=e}}class K7 extends Ns{constructor(t,e){super(t,e,P7,hf,n=>n.id),this.core=t,this.logger=e}}class V7 extends Ns{constructor(t,e){super(t,e,T7,bc,()=>Vu),this.core=t,this.logger=e}}class G7 extends Ns{constructor(t,e){super(t,e,F7,bc),this.core=t,this.logger=e}}class W7 extends Ns{constructor(t,e){super(t,e,U7,bc,n=>n.id),this.core=t,this.logger=e}}class Y7{constructor(t,e){this.core=t,this.logger=e,this.authKeys=new V7(this.core,this.logger),this.pairingTopics=new G7(this.core,this.logger),this.requests=new W7(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class lf extends uI{constructor(t){super(t),this.protocol=ym,this.version=wm,this.name=ol.name,this.events=new Di.EventEmitter,this.on=(n,s)=>this.events.on(n,s),this.once=(n,s)=>this.events.once(n,s),this.off=(n,s)=>this.events.off(n,s),this.removeListener=(n,s)=>this.events.removeListener(n,s),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(s){throw this.logger.error(s.message),s}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(s){throw this.logger.error(s.message),s}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(s){throw this.logger.error(s.message),s}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(s){throw this.logger.error(s.message),s}},this.update=async n=>{try{return await this.engine.update(n)}catch(s){throw this.logger.error(s.message),s}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(s){throw this.logger.error(s.message),s}},this.request=async n=>{try{return await this.engine.request(n)}catch(s){throw this.logger.error(s.message),s}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(s){throw this.logger.error(s.message),s}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(s){throw this.logger.error(s.message),s}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(s){throw this.logger.error(s.message),s}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(s){throw this.logger.error(s.message),s}},this.find=n=>{try{return this.engine.find(n)}catch(s){throw this.logger.error(s.message),s}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.authenticate=async n=>{try{return await this.engine.authenticate(n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=n=>{try{return this.engine.formatAuthMessage(n)}catch(s){throw this.logger.error(s.message),s}},this.approveSessionAuthenticate=async n=>{try{return await this.engine.approveSessionAuthenticate(n)}catch(s){throw this.logger.error(s.message),s}},this.rejectSessionAuthenticate=async n=>{try{return await this.engine.rejectSessionAuthenticate(n)}catch(s){throw this.logger.error(s.message),s}},this.name=(t==null?void 0:t.name)||ol.name,this.metadata=(t==null?void 0:t.metadata)||FE();const e=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:ba(gc({level:(t==null?void 0:t.logger)||ol.logger}));this.core=(t==null?void 0:t.core)||new D7(t),this.logger=Vr(e,this.name),this.session=new H7(this.core,this.logger),this.proposal=new k7(this.core,this.logger),this.pendingRequest=new K7(this.core,this.logger),this.engine=new z7(this),this.auth=new Y7(this.core,this.logger)}static async init(t){const e=new lf(t);return await e.initialize(),e}get context(){return Kr(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.engine.init(),await this.auth.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}}const Q7={Accept:"application/json","Content-Type":"application/json"},J7="POST",g1={headers:Q7,method:J7},m1=10;class Xn{constructor(t,e=!1){if(this.url=t,this.disableProviderPing=e,this.events=new Di.EventEmitter,this.isAvailable=!1,this.registering=!1,!kp(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t,e){this.isAvailable||await this.register();try{const n=xn(t),a=await(await dd(this.url,Object.assign(Object.assign({},g1),{body:n}))).json();this.onPayload({data:a})}catch(n){this.onError(t.id,n)}}async register(t=this.url){if(!kp(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((n,s)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),s(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return s(new Error("HTTP connection is missing or invalid"));n()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const e=xn({id:1,jsonrpc:"2.0",method:"test",params:[]});await dd(t,Object.assign(Object.assign({},g1),{body:e}))}this.onOpen()}catch(e){const n=this.parseError(e);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?wa(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const n=this.parseError(e),s=n.message||n.toString(),a=vc(t,s);this.events.emit("payload",a)}parseError(t,e=this.url){return Zg(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>m1&&this.events.setMaxListeners(m1)}}const v1="error",X7="wss://relay.walletconnect.com",Z7="wc",t9="universal_provider",y1=`${Z7}@2:${t9}:`,e9="https://rpc.walletconnect.com/v1/",Pn={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Xo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Ie<"u"?Ie:typeof self<"u"?self:{},Fl={exports:{}};/**
18
- * @license
19
- * Lodash <https://lodash.com/>
20
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
21
- * Released under MIT license <https://lodash.com/license>
22
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
23
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
24
- */(function(r,t){(function(){var e,n="4.17.21",s=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",c="Expected a function",l="Invalid `variable` option passed into `_.template`",d="__lodash_hash_undefined__",f=500,w="__lodash_placeholder__",E=1,x=2,I=4,R=1,Y=2,W=1,tt=2,K=4,V=8,B=16,z=32,$=64,v=128,T=256,st=512,ft=30,pt="...",gt=800,h=16,y=1,b=2,C=3,M=1/0,N=9007199254740991,q=17976931348623157e292,S=0/0,g=4294967295,O=g-1,it=g>>>1,lt=[["ary",v],["bind",W],["bindKey",tt],["curry",V],["curryRight",B],["flip",st],["partial",z],["partialRight",$],["rearg",T]],_="[object Arguments]",Z="[object Array]",U="[object AsyncFunction]",L="[object Boolean]",k="[object Date]",p="[object DOMException]",F="[object Error]",et="[object Function]",ct="[object GeneratorFunction]",at="[object Map]",Mt="[object Number]",Pt="[object Null]",It="[object Object]",Ee="[object Promise]",$t="[object Proxy]",xt="[object RegExp]",Bt="[object Set]",_t="[object String]",Et="[object Symbol]",Vt="[object Undefined]",yt="[object WeakMap]",At="[object WeakSet]",Ut="[object ArrayBuffer]",wt="[object DataView]",Ct="[object Float32Array]",Lt="[object Float64Array]",Ot="[object Int8Array]",Nt="[object Int16Array]",se="[object Int32Array]",Tt="[object Uint8Array]",Rt="[object Uint8ClampedArray]",Ke="[object Uint16Array]",ue="[object Uint32Array]",pe=/\b__p \+= '';/g,Ve=/\b(__p \+=) '' \+/g,ye=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_e=/&(?:amp|lt|gt|quot|#39);/g,Er=/[&<>"']/g,Gt=RegExp(_e.source),zt=RegExp(Er.source),De=/<%-([\s\S]+?)%>/g,Wt=/<%([\s\S]+?)%>/g,Kt=/<%=([\s\S]+?)%>/g,Ae=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jt=/^\w*$/,Xt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xe=/[\\^$.*+?()[\]{}|]/g,Zt=RegExp(xe.source),Yt=/^\s+/,Ce=/\s/,Qt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,qt=/\{\n\/\* \[wrapped with (.+)\] \*/,Te=/,? & /,te=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Pe=/[()=,{}\[\]\/\s]/,xi=/\\(\\)?/g,Oe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,le=/\w*$/,si=/^[-+]0x[0-9a-f]+$/i,oi=/^0b[01]+$/i,ai=/^\[object .+?Constructor\]$/,ui=/^0o[0-7]+$/i,ci=/^(?:0|[1-9]\d*)$/,or=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,qi=/($^)/,Zn=/['\n\r\u2028\u2029\\]/g,ji="\\ud800-\\udfff",ts="\\u0300-\\u036f",es="\\ufe20-\\ufe2f",$i="\\u20d0-\\u20ff",On=ts+es+$i,Nn="\\u2700-\\u27bf",Ar="a-z\\xdf-\\xf6\\xf8-\\xff",rs="\\xac\\xb1\\xd7\\xf7",is="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ns="\\u2000-\\u206f",ss=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Aa="A-Z\\xc0-\\xd6\\xd8-\\xde",Sa="\\ufe0e\\ufe0f",os=rs+is+ns+ss,Ao="['’]",as="["+ji+"]",So="["+os+"]",us="["+On+"]",Ia="\\d+",_c="["+Nn+"]",Da="["+Ar+"]",xa="[^"+ji+os+Ia+Nn+Ar+Aa+"]",Ts="\\ud83c[\\udffb-\\udfff]",Ec="(?:"+us+"|"+Ts+")",Ma="[^"+ji+"]",Fs="(?:\\ud83c[\\udde6-\\uddff]){2}",Rn="[\\ud800-\\udbff][\\udc00-\\udfff]",Gr="["+Aa+"]",Ca="\\u200d",Pa="(?:"+Da+"|"+xa+")",zi="(?:"+Gr+"|"+xa+")",Oa="(?:"+Ao+"(?:d|ll|m|re|s|t|ve))?",Na="(?:"+Ao+"(?:D|LL|M|RE|S|T|VE))?",Ra=Ec+"?",Ta="["+Sa+"]?",Ac="(?:"+Ca+"(?:"+[Ma,Fs,Rn].join("|")+")"+Ta+Ra+")*",hn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Fa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ua=Ta+Ra+Ac,Us="(?:"+[_c,Fs,Rn].join("|")+")"+Ua,Sc="(?:"+[Ma+us+"?",us,Fs,Rn,as].join("|")+")",Io=RegExp(Ao,"g"),Ic=RegExp(us,"g"),Bs=RegExp(Ts+"(?="+Ts+")|"+Sc+Ua,"g"),Ba=RegExp([Gr+"?"+Da+"+"+Oa+"(?="+[So,Gr,"$"].join("|")+")",zi+"+"+Na+"(?="+[So,Gr+Pa,"$"].join("|")+")",Gr+"?"+Pa+"+"+Oa,Gr+"+"+Na,Fa,hn,Ia,Us].join("|"),"g"),La=RegExp("["+Ca+ji+On+Sa+"]"),cs=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,qa=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Dc=-1,Ue={};Ue[Ct]=Ue[Lt]=Ue[Ot]=Ue[Nt]=Ue[se]=Ue[Tt]=Ue[Rt]=Ue[Ke]=Ue[ue]=!0,Ue[_]=Ue[Z]=Ue[Ut]=Ue[L]=Ue[wt]=Ue[k]=Ue[F]=Ue[et]=Ue[at]=Ue[Mt]=Ue[It]=Ue[xt]=Ue[Bt]=Ue[_t]=Ue[yt]=!1;var Fe={};Fe[_]=Fe[Z]=Fe[Ut]=Fe[wt]=Fe[L]=Fe[k]=Fe[Ct]=Fe[Lt]=Fe[Ot]=Fe[Nt]=Fe[se]=Fe[at]=Fe[Mt]=Fe[It]=Fe[xt]=Fe[Bt]=Fe[_t]=Fe[Et]=Fe[Tt]=Fe[Rt]=Fe[Ke]=Fe[ue]=!0,Fe[F]=Fe[et]=Fe[yt]=!1;var j={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Q={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ht={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Be=parseFloat,re=parseInt,$e=typeof Xo=="object"&&Xo&&Xo.Object===Object&&Xo,er=typeof self=="object"&&self&&self.Object===Object&&self,we=$e||er||Function("return this")(),Le=t&&!t.nodeType&&t,Qe=Le&&!0&&r&&!r.nodeType&&r,Fr=Qe&&Qe.exports===Le,rr=Fr&&$e.process,ze=function(){try{var J=Qe&&Qe.require&&Qe.require("util").types;return J||rr&&rr.binding&&rr.binding("util")}catch{}}(),Sr=ze&&ze.isArrayBuffer,Mi=ze&&ze.isDate,hi=ze&&ze.isMap,ki=ze&&ze.isRegExp,Do=ze&&ze.isSet,hs=ze&&ze.isTypedArray;function ar(J,nt,rt){switch(rt.length){case 0:return J.call(nt);case 1:return J.call(nt,rt[0]);case 2:return J.call(nt,rt[0],rt[1]);case 3:return J.call(nt,rt[0],rt[1],rt[2])}return J.apply(nt,rt)}function Sm(J,nt,rt,Dt){for(var ee=-1,Se=J==null?0:J.length;++ee<Se;){var ir=J[ee];nt(Dt,ir,rt(ir),J)}return Dt}function li(J,nt){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt&&nt(J[rt],rt,J)!==!1;);return J}function Im(J,nt){for(var rt=J==null?0:J.length;rt--&&nt(J[rt],rt,J)!==!1;);return J}function pf(J,nt){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt;)if(!nt(J[rt],rt,J))return!1;return!0}function Tn(J,nt){for(var rt=-1,Dt=J==null?0:J.length,ee=0,Se=[];++rt<Dt;){var ir=J[rt];nt(ir,rt,J)&&(Se[ee++]=ir)}return Se}function ja(J,nt){var rt=J==null?0:J.length;return!!rt&&Ls(J,nt,0)>-1}function xc(J,nt,rt){for(var Dt=-1,ee=J==null?0:J.length;++Dt<ee;)if(rt(nt,J[Dt]))return!0;return!1}function ke(J,nt){for(var rt=-1,Dt=J==null?0:J.length,ee=Array(Dt);++rt<Dt;)ee[rt]=nt(J[rt],rt,J);return ee}function Fn(J,nt){for(var rt=-1,Dt=nt.length,ee=J.length;++rt<Dt;)J[ee+rt]=nt[rt];return J}function Mc(J,nt,rt,Dt){var ee=-1,Se=J==null?0:J.length;for(Dt&&Se&&(rt=J[++ee]);++ee<Se;)rt=nt(rt,J[ee],ee,J);return rt}function Dm(J,nt,rt,Dt){var ee=J==null?0:J.length;for(Dt&&ee&&(rt=J[--ee]);ee--;)rt=nt(rt,J[ee],ee,J);return rt}function Cc(J,nt){for(var rt=-1,Dt=J==null?0:J.length;++rt<Dt;)if(nt(J[rt],rt,J))return!0;return!1}var xm=Pc("length");function Mm(J){return J.split("")}function Cm(J){return J.match(te)||[]}function gf(J,nt,rt){var Dt;return rt(J,function(ee,Se,ir){if(nt(ee,Se,ir))return Dt=Se,!1}),Dt}function $a(J,nt,rt,Dt){for(var ee=J.length,Se=rt+(Dt?1:-1);Dt?Se--:++Se<ee;)if(nt(J[Se],Se,J))return Se;return-1}function Ls(J,nt,rt){return nt===nt?$m(J,nt,rt):$a(J,mf,rt)}function Pm(J,nt,rt,Dt){for(var ee=rt-1,Se=J.length;++ee<Se;)if(Dt(J[ee],nt))return ee;return-1}function mf(J){return J!==J}function vf(J,nt){var rt=J==null?0:J.length;return rt?Nc(J,nt)/rt:S}function Pc(J){return function(nt){return nt==null?e:nt[J]}}function Oc(J){return function(nt){return J==null?e:J[nt]}}function yf(J,nt,rt,Dt,ee){return ee(J,function(Se,ir,qe){rt=Dt?(Dt=!1,Se):nt(rt,Se,ir,qe)}),rt}function Om(J,nt){var rt=J.length;for(J.sort(nt);rt--;)J[rt]=J[rt].value;return J}function Nc(J,nt){for(var rt,Dt=-1,ee=J.length;++Dt<ee;){var Se=nt(J[Dt]);Se!==e&&(rt=rt===e?Se:rt+Se)}return rt}function Rc(J,nt){for(var rt=-1,Dt=Array(J);++rt<J;)Dt[rt]=nt(rt);return Dt}function Nm(J,nt){return ke(nt,function(rt){return[rt,J[rt]]})}function wf(J){return J&&J.slice(0,Af(J)+1).replace(Yt,"")}function Wr(J){return function(nt){return J(nt)}}function Tc(J,nt){return ke(nt,function(rt){return J[rt]})}function xo(J,nt){return J.has(nt)}function bf(J,nt){for(var rt=-1,Dt=J.length;++rt<Dt&&Ls(nt,J[rt],0)>-1;);return rt}function _f(J,nt){for(var rt=J.length;rt--&&Ls(nt,J[rt],0)>-1;);return rt}function Rm(J,nt){for(var rt=J.length,Dt=0;rt--;)J[rt]===nt&&++Dt;return Dt}var Tm=Oc(j),Fm=Oc(Q);function Um(J){return"\\"+St[J]}function Bm(J,nt){return J==null?e:J[nt]}function qs(J){return La.test(J)}function Lm(J){return cs.test(J)}function qm(J){for(var nt,rt=[];!(nt=J.next()).done;)rt.push(nt.value);return rt}function Fc(J){var nt=-1,rt=Array(J.size);return J.forEach(function(Dt,ee){rt[++nt]=[ee,Dt]}),rt}function Ef(J,nt){return function(rt){return J(nt(rt))}}function Un(J,nt){for(var rt=-1,Dt=J.length,ee=0,Se=[];++rt<Dt;){var ir=J[rt];(ir===nt||ir===w)&&(J[rt]=w,Se[ee++]=rt)}return Se}function za(J){var nt=-1,rt=Array(J.size);return J.forEach(function(Dt){rt[++nt]=Dt}),rt}function jm(J){var nt=-1,rt=Array(J.size);return J.forEach(function(Dt){rt[++nt]=[Dt,Dt]}),rt}function $m(J,nt,rt){for(var Dt=rt-1,ee=J.length;++Dt<ee;)if(J[Dt]===nt)return Dt;return-1}function zm(J,nt,rt){for(var Dt=rt+1;Dt--;)if(J[Dt]===nt)return Dt;return Dt}function js(J){return qs(J)?Hm(J):xm(J)}function Ci(J){return qs(J)?Km(J):Mm(J)}function Af(J){for(var nt=J.length;nt--&&Ce.test(J.charAt(nt)););return nt}var km=Oc(ht);function Hm(J){for(var nt=Bs.lastIndex=0;Bs.test(J);)++nt;return nt}function Km(J){return J.match(Bs)||[]}function Vm(J){return J.match(Ba)||[]}var Gm=function J(nt){nt=nt==null?we:$s.defaults(we.Object(),nt,$s.pick(we,qa));var rt=nt.Array,Dt=nt.Date,ee=nt.Error,Se=nt.Function,ir=nt.Math,qe=nt.Object,Uc=nt.RegExp,Wm=nt.String,fi=nt.TypeError,ka=rt.prototype,Ym=Se.prototype,zs=qe.prototype,Ha=nt["__core-js_shared__"],Ka=Ym.toString,Ne=zs.hasOwnProperty,Qm=0,Sf=function(){var i=/[^.]+$/.exec(Ha&&Ha.keys&&Ha.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),Va=zs.toString,Jm=Ka.call(qe),Xm=we._,Zm=Uc("^"+Ka.call(Ne).replace(xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ga=Fr?nt.Buffer:e,Bn=nt.Symbol,Wa=nt.Uint8Array,If=Ga?Ga.allocUnsafe:e,Ya=Ef(qe.getPrototypeOf,qe),Df=qe.create,xf=zs.propertyIsEnumerable,Qa=ka.splice,Mf=Bn?Bn.isConcatSpreadable:e,Mo=Bn?Bn.iterator:e,ls=Bn?Bn.toStringTag:e,Ja=function(){try{var i=ms(qe,"defineProperty");return i({},"",{}),i}catch{}}(),tv=nt.clearTimeout!==we.clearTimeout&&nt.clearTimeout,ev=Dt&&Dt.now!==we.Date.now&&Dt.now,rv=nt.setTimeout!==we.setTimeout&&nt.setTimeout,Xa=ir.ceil,Za=ir.floor,Bc=qe.getOwnPropertySymbols,iv=Ga?Ga.isBuffer:e,Cf=nt.isFinite,nv=ka.join,sv=Ef(qe.keys,qe),nr=ir.max,vr=ir.min,ov=Dt.now,av=nt.parseInt,Pf=ir.random,uv=ka.reverse,Lc=ms(nt,"DataView"),Co=ms(nt,"Map"),qc=ms(nt,"Promise"),ks=ms(nt,"Set"),Po=ms(nt,"WeakMap"),Oo=ms(qe,"create"),tu=Po&&new Po,Hs={},cv=vs(Lc),hv=vs(Co),lv=vs(qc),fv=vs(ks),dv=vs(Po),eu=Bn?Bn.prototype:e,No=eu?eu.valueOf:e,Of=eu?eu.toString:e;function D(i){if(We(i)&&!ie(i)&&!(i instanceof ge)){if(i instanceof di)return i;if(Ne.call(i,"__wrapped__"))return N0(i)}return new di(i)}var Ks=function(){function i(){}return function(o){if(!Ge(o))return{};if(Df)return Df(o);i.prototype=o;var u=new i;return i.prototype=e,u}}();function ru(){}function di(i,o){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=e}D.templateSettings={escape:De,evaluate:Wt,interpolate:Kt,variable:"",imports:{_:D}},D.prototype=ru.prototype,D.prototype.constructor=D,di.prototype=Ks(ru.prototype),di.prototype.constructor=di;function ge(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=g,this.__views__=[]}function pv(){var i=new ge(this.__wrapped__);return i.__actions__=Ur(this.__actions__),i.__dir__=this.__dir__,i.__filtered__=this.__filtered__,i.__iteratees__=Ur(this.__iteratees__),i.__takeCount__=this.__takeCount__,i.__views__=Ur(this.__views__),i}function gv(){if(this.__filtered__){var i=new ge(this);i.__dir__=-1,i.__filtered__=!0}else i=this.clone(),i.__dir__*=-1;return i}function mv(){var i=this.__wrapped__.value(),o=this.__dir__,u=ie(i),m=o<0,A=u?i.length:0,P=My(0,A,this.__views__),H=P.start,G=P.end,X=G-H,ot=m?G:H-1,ut=this.__iteratees__,dt=ut.length,vt=0,Ft=vr(X,this.__takeCount__);if(!u||!m&&A==X&&Ft==X)return e0(i,this.__actions__);var kt=[];t:for(;X--&&vt<Ft;){ot+=o;for(var ce=-1,Ht=i[ot];++ce<dt;){var fe=ut[ce],be=fe.iteratee,Jr=fe.type,xr=be(Ht);if(Jr==b)Ht=xr;else if(!xr){if(Jr==y)continue t;break t}}kt[vt++]=Ht}return kt}ge.prototype=Ks(ru.prototype),ge.prototype.constructor=ge;function fs(i){var o=-1,u=i==null?0:i.length;for(this.clear();++o<u;){var m=i[o];this.set(m[0],m[1])}}function vv(){this.__data__=Oo?Oo(null):{},this.size=0}function yv(i){var o=this.has(i)&&delete this.__data__[i];return this.size-=o?1:0,o}function wv(i){var o=this.__data__;if(Oo){var u=o[i];return u===d?e:u}return Ne.call(o,i)?o[i]:e}function bv(i){var o=this.__data__;return Oo?o[i]!==e:Ne.call(o,i)}function _v(i,o){var u=this.__data__;return this.size+=this.has(i)?0:1,u[i]=Oo&&o===e?d:o,this}fs.prototype.clear=vv,fs.prototype.delete=yv,fs.prototype.get=wv,fs.prototype.has=bv,fs.prototype.set=_v;function ln(i){var o=-1,u=i==null?0:i.length;for(this.clear();++o<u;){var m=i[o];this.set(m[0],m[1])}}function Ev(){this.__data__=[],this.size=0}function Av(i){var o=this.__data__,u=iu(o,i);if(u<0)return!1;var m=o.length-1;return u==m?o.pop():Qa.call(o,u,1),--this.size,!0}function Sv(i){var o=this.__data__,u=iu(o,i);return u<0?e:o[u][1]}function Iv(i){return iu(this.__data__,i)>-1}function Dv(i,o){var u=this.__data__,m=iu(u,i);return m<0?(++this.size,u.push([i,o])):u[m][1]=o,this}ln.prototype.clear=Ev,ln.prototype.delete=Av,ln.prototype.get=Sv,ln.prototype.has=Iv,ln.prototype.set=Dv;function fn(i){var o=-1,u=i==null?0:i.length;for(this.clear();++o<u;){var m=i[o];this.set(m[0],m[1])}}function xv(){this.size=0,this.__data__={hash:new fs,map:new(Co||ln),string:new fs}}function Mv(i){var o=gu(this,i).delete(i);return this.size-=o?1:0,o}function Cv(i){return gu(this,i).get(i)}function Pv(i){return gu(this,i).has(i)}function Ov(i,o){var u=gu(this,i),m=u.size;return u.set(i,o),this.size+=u.size==m?0:1,this}fn.prototype.clear=xv,fn.prototype.delete=Mv,fn.prototype.get=Cv,fn.prototype.has=Pv,fn.prototype.set=Ov;function ds(i){var o=-1,u=i==null?0:i.length;for(this.__data__=new fn;++o<u;)this.add(i[o])}function Nv(i){return this.__data__.set(i,d),this}function Rv(i){return this.__data__.has(i)}ds.prototype.add=ds.prototype.push=Nv,ds.prototype.has=Rv;function Pi(i){var o=this.__data__=new ln(i);this.size=o.size}function Tv(){this.__data__=new ln,this.size=0}function Fv(i){var o=this.__data__,u=o.delete(i);return this.size=o.size,u}function Uv(i){return this.__data__.get(i)}function Bv(i){return this.__data__.has(i)}function Lv(i,o){var u=this.__data__;if(u instanceof ln){var m=u.__data__;if(!Co||m.length<s-1)return m.push([i,o]),this.size=++u.size,this;u=this.__data__=new fn(m)}return u.set(i,o),this.size=u.size,this}Pi.prototype.clear=Tv,Pi.prototype.delete=Fv,Pi.prototype.get=Uv,Pi.prototype.has=Bv,Pi.prototype.set=Lv;function Nf(i,o){var u=ie(i),m=!u&&ys(i),A=!u&&!m&&zn(i),P=!u&&!m&&!A&&Ys(i),H=u||m||A||P,G=H?Rc(i.length,Wm):[],X=G.length;for(var ot in i)(o||Ne.call(i,ot))&&!(H&&(ot=="length"||A&&(ot=="offset"||ot=="parent")||P&&(ot=="buffer"||ot=="byteLength"||ot=="byteOffset")||mn(ot,X)))&&G.push(ot);return G}function Rf(i){var o=i.length;return o?i[Qc(0,o-1)]:e}function qv(i,o){return mu(Ur(i),ps(o,0,i.length))}function jv(i){return mu(Ur(i))}function jc(i,o,u){(u!==e&&!Oi(i[o],u)||u===e&&!(o in i))&&dn(i,o,u)}function Ro(i,o,u){var m=i[o];(!(Ne.call(i,o)&&Oi(m,u))||u===e&&!(o in i))&&dn(i,o,u)}function iu(i,o){for(var u=i.length;u--;)if(Oi(i[u][0],o))return u;return-1}function $v(i,o,u,m){return Ln(i,function(A,P,H){o(m,A,u(A),H)}),m}function Tf(i,o){return i&&Ki(o,ur(o),i)}function zv(i,o){return i&&Ki(o,Lr(o),i)}function dn(i,o,u){o=="__proto__"&&Ja?Ja(i,o,{configurable:!0,enumerable:!0,value:u,writable:!0}):i[o]=u}function $c(i,o){for(var u=-1,m=o.length,A=rt(m),P=i==null;++u<m;)A[u]=P?e:_h(i,o[u]);return A}function ps(i,o,u){return i===i&&(u!==e&&(i=i<=u?i:u),o!==e&&(i=i>=o?i:o)),i}function pi(i,o,u,m,A,P){var H,G=o&E,X=o&x,ot=o&I;if(u&&(H=A?u(i,m,A,P):u(i)),H!==e)return H;if(!Ge(i))return i;var ut=ie(i);if(ut){if(H=Py(i),!G)return Ur(i,H)}else{var dt=yr(i),vt=dt==et||dt==ct;if(zn(i))return n0(i,G);if(dt==It||dt==_||vt&&!A){if(H=X||vt?{}:A0(i),!G)return X?wy(i,zv(H,i)):yy(i,Tf(H,i))}else{if(!Fe[dt])return A?i:{};H=Oy(i,dt,G)}}P||(P=new Pi);var Ft=P.get(i);if(Ft)return Ft;P.set(i,H),X0(i)?i.forEach(function(Ht){H.add(pi(Ht,o,u,Ht,i,P))}):Q0(i)&&i.forEach(function(Ht,fe){H.set(fe,pi(Ht,o,u,fe,i,P))});var kt=ot?X?ah:oh:X?Lr:ur,ce=ut?e:kt(i);return li(ce||i,function(Ht,fe){ce&&(fe=Ht,Ht=i[fe]),Ro(H,fe,pi(Ht,o,u,fe,i,P))}),H}function kv(i){var o=ur(i);return function(u){return Ff(u,i,o)}}function Ff(i,o,u){var m=u.length;if(i==null)return!m;for(i=qe(i);m--;){var A=u[m],P=o[A],H=i[A];if(H===e&&!(A in i)||!P(H))return!1}return!0}function Uf(i,o,u){if(typeof i!="function")throw new fi(c);return jo(function(){i.apply(e,u)},o)}function To(i,o,u,m){var A=-1,P=ja,H=!0,G=i.length,X=[],ot=o.length;if(!G)return X;u&&(o=ke(o,Wr(u))),m?(P=xc,H=!1):o.length>=s&&(P=xo,H=!1,o=new ds(o));t:for(;++A<G;){var ut=i[A],dt=u==null?ut:u(ut);if(ut=m||ut!==0?ut:0,H&&dt===dt){for(var vt=ot;vt--;)if(o[vt]===dt)continue t;X.push(ut)}else P(o,dt,m)||X.push(ut)}return X}var Ln=c0(Hi),Bf=c0(kc,!0);function Hv(i,o){var u=!0;return Ln(i,function(m,A,P){return u=!!o(m,A,P),u}),u}function nu(i,o,u){for(var m=-1,A=i.length;++m<A;){var P=i[m],H=o(P);if(H!=null&&(G===e?H===H&&!Qr(H):u(H,G)))var G=H,X=P}return X}function Kv(i,o,u,m){var A=i.length;for(u=ae(u),u<0&&(u=-u>A?0:A+u),m=m===e||m>A?A:ae(m),m<0&&(m+=A),m=u>m?0:td(m);u<m;)i[u++]=o;return i}function Lf(i,o){var u=[];return Ln(i,function(m,A,P){o(m,A,P)&&u.push(m)}),u}function fr(i,o,u,m,A){var P=-1,H=i.length;for(u||(u=Ry),A||(A=[]);++P<H;){var G=i[P];o>0&&u(G)?o>1?fr(G,o-1,u,m,A):Fn(A,G):m||(A[A.length]=G)}return A}var zc=h0(),qf=h0(!0);function Hi(i,o){return i&&zc(i,o,ur)}function kc(i,o){return i&&qf(i,o,ur)}function su(i,o){return Tn(o,function(u){return vn(i[u])})}function gs(i,o){o=jn(o,i);for(var u=0,m=o.length;i!=null&&u<m;)i=i[Vi(o[u++])];return u&&u==m?i:e}function jf(i,o,u){var m=o(i);return ie(i)?m:Fn(m,u(i))}function Ir(i){return i==null?i===e?Vt:Pt:ls&&ls in qe(i)?xy(i):jy(i)}function Hc(i,o){return i>o}function Vv(i,o){return i!=null&&Ne.call(i,o)}function Gv(i,o){return i!=null&&o in qe(i)}function Wv(i,o,u){return i>=vr(o,u)&&i<nr(o,u)}function Kc(i,o,u){for(var m=u?xc:ja,A=i[0].length,P=i.length,H=P,G=rt(P),X=1/0,ot=[];H--;){var ut=i[H];H&&o&&(ut=ke(ut,Wr(o))),X=vr(ut.length,X),G[H]=!u&&(o||A>=120&&ut.length>=120)?new ds(H&&ut):e}ut=i[0];var dt=-1,vt=G[0];t:for(;++dt<A&&ot.length<X;){var Ft=ut[dt],kt=o?o(Ft):Ft;if(Ft=u||Ft!==0?Ft:0,!(vt?xo(vt,kt):m(ot,kt,u))){for(H=P;--H;){var ce=G[H];if(!(ce?xo(ce,kt):m(i[H],kt,u)))continue t}vt&&vt.push(kt),ot.push(Ft)}}return ot}function Yv(i,o,u,m){return Hi(i,function(A,P,H){o(m,u(A),P,H)}),m}function Fo(i,o,u){o=jn(o,i),i=x0(i,o);var m=i==null?i:i[Vi(mi(o))];return m==null?e:ar(m,i,u)}function $f(i){return We(i)&&Ir(i)==_}function Qv(i){return We(i)&&Ir(i)==Ut}function Jv(i){return We(i)&&Ir(i)==k}function Uo(i,o,u,m,A){return i===o?!0:i==null||o==null||!We(i)&&!We(o)?i!==i&&o!==o:Xv(i,o,u,m,Uo,A)}function Xv(i,o,u,m,A,P){var H=ie(i),G=ie(o),X=H?Z:yr(i),ot=G?Z:yr(o);X=X==_?It:X,ot=ot==_?It:ot;var ut=X==It,dt=ot==It,vt=X==ot;if(vt&&zn(i)){if(!zn(o))return!1;H=!0,ut=!1}if(vt&&!ut)return P||(P=new Pi),H||Ys(i)?b0(i,o,u,m,A,P):Iy(i,o,X,u,m,A,P);if(!(u&R)){var Ft=ut&&Ne.call(i,"__wrapped__"),kt=dt&&Ne.call(o,"__wrapped__");if(Ft||kt){var ce=Ft?i.value():i,Ht=kt?o.value():o;return P||(P=new Pi),A(ce,Ht,u,m,P)}}return vt?(P||(P=new Pi),Dy(i,o,u,m,A,P)):!1}function Zv(i){return We(i)&&yr(i)==at}function Vc(i,o,u,m){var A=u.length,P=A,H=!m;if(i==null)return!P;for(i=qe(i);A--;){var G=u[A];if(H&&G[2]?G[1]!==i[G[0]]:!(G[0]in i))return!1}for(;++A<P;){G=u[A];var X=G[0],ot=i[X],ut=G[1];if(H&&G[2]){if(ot===e&&!(X in i))return!1}else{var dt=new Pi;if(m)var vt=m(ot,ut,X,i,o,dt);if(!(vt===e?Uo(ut,ot,R|Y,m,dt):vt))return!1}}return!0}function zf(i){if(!Ge(i)||Fy(i))return!1;var o=vn(i)?Zm:ai;return o.test(vs(i))}function ty(i){return We(i)&&Ir(i)==xt}function ey(i){return We(i)&&yr(i)==Bt}function ry(i){return We(i)&&Eu(i.length)&&!!Ue[Ir(i)]}function kf(i){return typeof i=="function"?i:i==null?qr:typeof i=="object"?ie(i)?Vf(i[0],i[1]):Kf(i):ld(i)}function Gc(i){if(!qo(i))return sv(i);var o=[];for(var u in qe(i))Ne.call(i,u)&&u!="constructor"&&o.push(u);return o}function iy(i){if(!Ge(i))return qy(i);var o=qo(i),u=[];for(var m in i)m=="constructor"&&(o||!Ne.call(i,m))||u.push(m);return u}function Wc(i,o){return i<o}function Hf(i,o){var u=-1,m=Br(i)?rt(i.length):[];return Ln(i,function(A,P,H){m[++u]=o(A,P,H)}),m}function Kf(i){var o=ch(i);return o.length==1&&o[0][2]?I0(o[0][0],o[0][1]):function(u){return u===i||Vc(u,i,o)}}function Vf(i,o){return lh(i)&&S0(o)?I0(Vi(i),o):function(u){var m=_h(u,i);return m===e&&m===o?Eh(u,i):Uo(o,m,R|Y)}}function ou(i,o,u,m,A){i!==o&&zc(o,function(P,H){if(A||(A=new Pi),Ge(P))ny(i,o,H,u,ou,m,A);else{var G=m?m(dh(i,H),P,H+"",i,o,A):e;G===e&&(G=P),jc(i,H,G)}},Lr)}function ny(i,o,u,m,A,P,H){var G=dh(i,u),X=dh(o,u),ot=H.get(X);if(ot){jc(i,u,ot);return}var ut=P?P(G,X,u+"",i,o,H):e,dt=ut===e;if(dt){var vt=ie(X),Ft=!vt&&zn(X),kt=!vt&&!Ft&&Ys(X);ut=X,vt||Ft||kt?ie(G)?ut=G:Je(G)?ut=Ur(G):Ft?(dt=!1,ut=n0(X,!0)):kt?(dt=!1,ut=s0(X,!0)):ut=[]:$o(X)||ys(X)?(ut=G,ys(G)?ut=ed(G):(!Ge(G)||vn(G))&&(ut=A0(X))):dt=!1}dt&&(H.set(X,ut),A(ut,X,m,P,H),H.delete(X)),jc(i,u,ut)}function Gf(i,o){var u=i.length;if(u)return o+=o<0?u:0,mn(o,u)?i[o]:e}function Wf(i,o,u){o.length?o=ke(o,function(P){return ie(P)?function(H){return gs(H,P.length===1?P[0]:P)}:P}):o=[qr];var m=-1;o=ke(o,Wr(jt()));var A=Hf(i,function(P,H,G){var X=ke(o,function(ot){return ot(P)});return{criteria:X,index:++m,value:P}});return Om(A,function(P,H){return vy(P,H,u)})}function sy(i,o){return Yf(i,o,function(u,m){return Eh(i,m)})}function Yf(i,o,u){for(var m=-1,A=o.length,P={};++m<A;){var H=o[m],G=gs(i,H);u(G,H)&&Bo(P,jn(H,i),G)}return P}function oy(i){return function(o){return gs(o,i)}}function Yc(i,o,u,m){var A=m?Pm:Ls,P=-1,H=o.length,G=i;for(i===o&&(o=Ur(o)),u&&(G=ke(i,Wr(u)));++P<H;)for(var X=0,ot=o[P],ut=u?u(ot):ot;(X=A(G,ut,X,m))>-1;)G!==i&&Qa.call(G,X,1),Qa.call(i,X,1);return i}function Qf(i,o){for(var u=i?o.length:0,m=u-1;u--;){var A=o[u];if(u==m||A!==P){var P=A;mn(A)?Qa.call(i,A,1):Zc(i,A)}}return i}function Qc(i,o){return i+Za(Pf()*(o-i+1))}function ay(i,o,u,m){for(var A=-1,P=nr(Xa((o-i)/(u||1)),0),H=rt(P);P--;)H[m?P:++A]=i,i+=u;return H}function Jc(i,o){var u="";if(!i||o<1||o>N)return u;do o%2&&(u+=i),o=Za(o/2),o&&(i+=i);while(o);return u}function he(i,o){return ph(D0(i,o,qr),i+"")}function uy(i){return Rf(Qs(i))}function cy(i,o){var u=Qs(i);return mu(u,ps(o,0,u.length))}function Bo(i,o,u,m){if(!Ge(i))return i;o=jn(o,i);for(var A=-1,P=o.length,H=P-1,G=i;G!=null&&++A<P;){var X=Vi(o[A]),ot=u;if(X==="__proto__"||X==="constructor"||X==="prototype")return i;if(A!=H){var ut=G[X];ot=m?m(ut,X,G):e,ot===e&&(ot=Ge(ut)?ut:mn(o[A+1])?[]:{})}Ro(G,X,ot),G=G[X]}return i}var Jf=tu?function(i,o){return tu.set(i,o),i}:qr,hy=Ja?function(i,o){return Ja(i,"toString",{configurable:!0,enumerable:!1,value:Sh(o),writable:!0})}:qr;function ly(i){return mu(Qs(i))}function gi(i,o,u){var m=-1,A=i.length;o<0&&(o=-o>A?0:A+o),u=u>A?A:u,u<0&&(u+=A),A=o>u?0:u-o>>>0,o>>>=0;for(var P=rt(A);++m<A;)P[m]=i[m+o];return P}function fy(i,o){var u;return Ln(i,function(m,A,P){return u=o(m,A,P),!u}),!!u}function au(i,o,u){var m=0,A=i==null?m:i.length;if(typeof o=="number"&&o===o&&A<=it){for(;m<A;){var P=m+A>>>1,H=i[P];H!==null&&!Qr(H)&&(u?H<=o:H<o)?m=P+1:A=P}return A}return Xc(i,o,qr,u)}function Xc(i,o,u,m){var A=0,P=i==null?0:i.length;if(P===0)return 0;o=u(o);for(var H=o!==o,G=o===null,X=Qr(o),ot=o===e;A<P;){var ut=Za((A+P)/2),dt=u(i[ut]),vt=dt!==e,Ft=dt===null,kt=dt===dt,ce=Qr(dt);if(H)var Ht=m||kt;else ot?Ht=kt&&(m||vt):G?Ht=kt&&vt&&(m||!Ft):X?Ht=kt&&vt&&!Ft&&(m||!ce):Ft||ce?Ht=!1:Ht=m?dt<=o:dt<o;Ht?A=ut+1:P=ut}return vr(P,O)}function Xf(i,o){for(var u=-1,m=i.length,A=0,P=[];++u<m;){var H=i[u],G=o?o(H):H;if(!u||!Oi(G,X)){var X=G;P[A++]=H===0?0:H}}return P}function Zf(i){return typeof i=="number"?i:Qr(i)?S:+i}function Yr(i){if(typeof i=="string")return i;if(ie(i))return ke(i,Yr)+"";if(Qr(i))return Of?Of.call(i):"";var o=i+"";return o=="0"&&1/i==-M?"-0":o}function qn(i,o,u){var m=-1,A=ja,P=i.length,H=!0,G=[],X=G;if(u)H=!1,A=xc;else if(P>=s){var ot=o?null:Ay(i);if(ot)return za(ot);H=!1,A=xo,X=new ds}else X=o?[]:G;t:for(;++m<P;){var ut=i[m],dt=o?o(ut):ut;if(ut=u||ut!==0?ut:0,H&&dt===dt){for(var vt=X.length;vt--;)if(X[vt]===dt)continue t;o&&X.push(dt),G.push(ut)}else A(X,dt,u)||(X!==G&&X.push(dt),G.push(ut))}return G}function Zc(i,o){return o=jn(o,i),i=x0(i,o),i==null||delete i[Vi(mi(o))]}function t0(i,o,u,m){return Bo(i,o,u(gs(i,o)),m)}function uu(i,o,u,m){for(var A=i.length,P=m?A:-1;(m?P--:++P<A)&&o(i[P],P,i););return u?gi(i,m?0:P,m?P+1:A):gi(i,m?P+1:0,m?A:P)}function e0(i,o){var u=i;return u instanceof ge&&(u=u.value()),Mc(o,function(m,A){return A.func.apply(A.thisArg,Fn([m],A.args))},u)}function th(i,o,u){var m=i.length;if(m<2)return m?qn(i[0]):[];for(var A=-1,P=rt(m);++A<m;)for(var H=i[A],G=-1;++G<m;)G!=A&&(P[A]=To(P[A]||H,i[G],o,u));return qn(fr(P,1),o,u)}function r0(i,o,u){for(var m=-1,A=i.length,P=o.length,H={};++m<A;){var G=m<P?o[m]:e;u(H,i[m],G)}return H}function eh(i){return Je(i)?i:[]}function rh(i){return typeof i=="function"?i:qr}function jn(i,o){return ie(i)?i:lh(i,o)?[i]:O0(Me(i))}var dy=he;function $n(i,o,u){var m=i.length;return u=u===e?m:u,!o&&u>=m?i:gi(i,o,u)}var i0=tv||function(i){return we.clearTimeout(i)};function n0(i,o){if(o)return i.slice();var u=i.length,m=If?If(u):new i.constructor(u);return i.copy(m),m}function ih(i){var o=new i.constructor(i.byteLength);return new Wa(o).set(new Wa(i)),o}function py(i,o){var u=o?ih(i.buffer):i.buffer;return new i.constructor(u,i.byteOffset,i.byteLength)}function gy(i){var o=new i.constructor(i.source,le.exec(i));return o.lastIndex=i.lastIndex,o}function my(i){return No?qe(No.call(i)):{}}function s0(i,o){var u=o?ih(i.buffer):i.buffer;return new i.constructor(u,i.byteOffset,i.length)}function o0(i,o){if(i!==o){var u=i!==e,m=i===null,A=i===i,P=Qr(i),H=o!==e,G=o===null,X=o===o,ot=Qr(o);if(!G&&!ot&&!P&&i>o||P&&H&&X&&!G&&!ot||m&&H&&X||!u&&X||!A)return 1;if(!m&&!P&&!ot&&i<o||ot&&u&&A&&!m&&!P||G&&u&&A||!H&&A||!X)return-1}return 0}function vy(i,o,u){for(var m=-1,A=i.criteria,P=o.criteria,H=A.length,G=u.length;++m<H;){var X=o0(A[m],P[m]);if(X){if(m>=G)return X;var ot=u[m];return X*(ot=="desc"?-1:1)}}return i.index-o.index}function a0(i,o,u,m){for(var A=-1,P=i.length,H=u.length,G=-1,X=o.length,ot=nr(P-H,0),ut=rt(X+ot),dt=!m;++G<X;)ut[G]=o[G];for(;++A<H;)(dt||A<P)&&(ut[u[A]]=i[A]);for(;ot--;)ut[G++]=i[A++];return ut}function u0(i,o,u,m){for(var A=-1,P=i.length,H=-1,G=u.length,X=-1,ot=o.length,ut=nr(P-G,0),dt=rt(ut+ot),vt=!m;++A<ut;)dt[A]=i[A];for(var Ft=A;++X<ot;)dt[Ft+X]=o[X];for(;++H<G;)(vt||A<P)&&(dt[Ft+u[H]]=i[A++]);return dt}function Ur(i,o){var u=-1,m=i.length;for(o||(o=rt(m));++u<m;)o[u]=i[u];return o}function Ki(i,o,u,m){var A=!u;u||(u={});for(var P=-1,H=o.length;++P<H;){var G=o[P],X=m?m(u[G],i[G],G,u,i):e;X===e&&(X=i[G]),A?dn(u,G,X):Ro(u,G,X)}return u}function yy(i,o){return Ki(i,hh(i),o)}function wy(i,o){return Ki(i,_0(i),o)}function cu(i,o){return function(u,m){var A=ie(u)?Sm:$v,P=o?o():{};return A(u,i,jt(m,2),P)}}function Vs(i){return he(function(o,u){var m=-1,A=u.length,P=A>1?u[A-1]:e,H=A>2?u[2]:e;for(P=i.length>3&&typeof P=="function"?(A--,P):e,H&&Dr(u[0],u[1],H)&&(P=A<3?e:P,A=1),o=qe(o);++m<A;){var G=u[m];G&&i(o,G,m,P)}return o})}function c0(i,o){return function(u,m){if(u==null)return u;if(!Br(u))return i(u,m);for(var A=u.length,P=o?A:-1,H=qe(u);(o?P--:++P<A)&&m(H[P],P,H)!==!1;);return u}}function h0(i){return function(o,u,m){for(var A=-1,P=qe(o),H=m(o),G=H.length;G--;){var X=H[i?G:++A];if(u(P[X],X,P)===!1)break}return o}}function by(i,o,u){var m=o&W,A=Lo(i);function P(){var H=this&&this!==we&&this instanceof P?A:i;return H.apply(m?u:this,arguments)}return P}function l0(i){return function(o){o=Me(o);var u=qs(o)?Ci(o):e,m=u?u[0]:o.charAt(0),A=u?$n(u,1).join(""):o.slice(1);return m[i]()+A}}function Gs(i){return function(o){return Mc(cd(ud(o).replace(Io,"")),i,"")}}function Lo(i){return function(){var o=arguments;switch(o.length){case 0:return new i;case 1:return new i(o[0]);case 2:return new i(o[0],o[1]);case 3:return new i(o[0],o[1],o[2]);case 4:return new i(o[0],o[1],o[2],o[3]);case 5:return new i(o[0],o[1],o[2],o[3],o[4]);case 6:return new i(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new i(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var u=Ks(i.prototype),m=i.apply(u,o);return Ge(m)?m:u}}function _y(i,o,u){var m=Lo(i);function A(){for(var P=arguments.length,H=rt(P),G=P,X=Ws(A);G--;)H[G]=arguments[G];var ot=P<3&&H[0]!==X&&H[P-1]!==X?[]:Un(H,X);if(P-=ot.length,P<u)return m0(i,o,hu,A.placeholder,e,H,ot,e,e,u-P);var ut=this&&this!==we&&this instanceof A?m:i;return ar(ut,this,H)}return A}function f0(i){return function(o,u,m){var A=qe(o);if(!Br(o)){var P=jt(u,3);o=ur(o),u=function(G){return P(A[G],G,A)}}var H=i(o,u,m);return H>-1?A[P?o[H]:H]:e}}function d0(i){return gn(function(o){var u=o.length,m=u,A=di.prototype.thru;for(i&&o.reverse();m--;){var P=o[m];if(typeof P!="function")throw new fi(c);if(A&&!H&&pu(P)=="wrapper")var H=new di([],!0)}for(m=H?m:u;++m<u;){P=o[m];var G=pu(P),X=G=="wrapper"?uh(P):e;X&&fh(X[0])&&X[1]==(v|V|z|T)&&!X[4].length&&X[9]==1?H=H[pu(X[0])].apply(H,X[3]):H=P.length==1&&fh(P)?H[G]():H.thru(P)}return function(){var ot=arguments,ut=ot[0];if(H&&ot.length==1&&ie(ut))return H.plant(ut).value();for(var dt=0,vt=u?o[dt].apply(this,ot):ut;++dt<u;)vt=o[dt].call(this,vt);return vt}})}function hu(i,o,u,m,A,P,H,G,X,ot){var ut=o&v,dt=o&W,vt=o&tt,Ft=o&(V|B),kt=o&st,ce=vt?e:Lo(i);function Ht(){for(var fe=arguments.length,be=rt(fe),Jr=fe;Jr--;)be[Jr]=arguments[Jr];if(Ft)var xr=Ws(Ht),Xr=Rm(be,xr);if(m&&(be=a0(be,m,A,Ft)),P&&(be=u0(be,P,H,Ft)),fe-=Xr,Ft&&fe<ot){var Xe=Un(be,xr);return m0(i,o,hu,Ht.placeholder,u,be,Xe,G,X,ot-fe)}var Ni=dt?u:this,wn=vt?Ni[i]:i;return fe=be.length,G?be=$y(be,G):kt&&fe>1&&be.reverse(),ut&&X<fe&&(be.length=X),this&&this!==we&&this instanceof Ht&&(wn=ce||Lo(wn)),wn.apply(Ni,be)}return Ht}function p0(i,o){return function(u,m){return Yv(u,i,o(m),{})}}function lu(i,o){return function(u,m){var A;if(u===e&&m===e)return o;if(u!==e&&(A=u),m!==e){if(A===e)return m;typeof u=="string"||typeof m=="string"?(u=Yr(u),m=Yr(m)):(u=Zf(u),m=Zf(m)),A=i(u,m)}return A}}function nh(i){return gn(function(o){return o=ke(o,Wr(jt())),he(function(u){var m=this;return i(o,function(A){return ar(A,m,u)})})})}function fu(i,o){o=o===e?" ":Yr(o);var u=o.length;if(u<2)return u?Jc(o,i):o;var m=Jc(o,Xa(i/js(o)));return qs(o)?$n(Ci(m),0,i).join(""):m.slice(0,i)}function Ey(i,o,u,m){var A=o&W,P=Lo(i);function H(){for(var G=-1,X=arguments.length,ot=-1,ut=m.length,dt=rt(ut+X),vt=this&&this!==we&&this instanceof H?P:i;++ot<ut;)dt[ot]=m[ot];for(;X--;)dt[ot++]=arguments[++G];return ar(vt,A?u:this,dt)}return H}function g0(i){return function(o,u,m){return m&&typeof m!="number"&&Dr(o,u,m)&&(u=m=e),o=yn(o),u===e?(u=o,o=0):u=yn(u),m=m===e?o<u?1:-1:yn(m),ay(o,u,m,i)}}function du(i){return function(o,u){return typeof o=="string"&&typeof u=="string"||(o=vi(o),u=vi(u)),i(o,u)}}function m0(i,o,u,m,A,P,H,G,X,ot){var ut=o&V,dt=ut?H:e,vt=ut?e:H,Ft=ut?P:e,kt=ut?e:P;o|=ut?z:$,o&=~(ut?$:z),o&K||(o&=~(W|tt));var ce=[i,o,A,Ft,dt,kt,vt,G,X,ot],Ht=u.apply(e,ce);return fh(i)&&M0(Ht,ce),Ht.placeholder=m,C0(Ht,i,o)}function sh(i){var o=ir[i];return function(u,m){if(u=vi(u),m=m==null?0:vr(ae(m),292),m&&Cf(u)){var A=(Me(u)+"e").split("e"),P=o(A[0]+"e"+(+A[1]+m));return A=(Me(P)+"e").split("e"),+(A[0]+"e"+(+A[1]-m))}return o(u)}}var Ay=ks&&1/za(new ks([,-0]))[1]==M?function(i){return new ks(i)}:xh;function v0(i){return function(o){var u=yr(o);return u==at?Fc(o):u==Bt?jm(o):Nm(o,i(o))}}function pn(i,o,u,m,A,P,H,G){var X=o&tt;if(!X&&typeof i!="function")throw new fi(c);var ot=m?m.length:0;if(ot||(o&=~(z|$),m=A=e),H=H===e?H:nr(ae(H),0),G=G===e?G:ae(G),ot-=A?A.length:0,o&$){var ut=m,dt=A;m=A=e}var vt=X?e:uh(i),Ft=[i,o,u,m,A,ut,dt,P,H,G];if(vt&&Ly(Ft,vt),i=Ft[0],o=Ft[1],u=Ft[2],m=Ft[3],A=Ft[4],G=Ft[9]=Ft[9]===e?X?0:i.length:nr(Ft[9]-ot,0),!G&&o&(V|B)&&(o&=~(V|B)),!o||o==W)var kt=by(i,o,u);else o==V||o==B?kt=_y(i,o,G):(o==z||o==(W|z))&&!A.length?kt=Ey(i,o,u,m):kt=hu.apply(e,Ft);var ce=vt?Jf:M0;return C0(ce(kt,Ft),i,o)}function y0(i,o,u,m){return i===e||Oi(i,zs[u])&&!Ne.call(m,u)?o:i}function w0(i,o,u,m,A,P){return Ge(i)&&Ge(o)&&(P.set(o,i),ou(i,o,e,w0,P),P.delete(o)),i}function Sy(i){return $o(i)?e:i}function b0(i,o,u,m,A,P){var H=u&R,G=i.length,X=o.length;if(G!=X&&!(H&&X>G))return!1;var ot=P.get(i),ut=P.get(o);if(ot&&ut)return ot==o&&ut==i;var dt=-1,vt=!0,Ft=u&Y?new ds:e;for(P.set(i,o),P.set(o,i);++dt<G;){var kt=i[dt],ce=o[dt];if(m)var Ht=H?m(ce,kt,dt,o,i,P):m(kt,ce,dt,i,o,P);if(Ht!==e){if(Ht)continue;vt=!1;break}if(Ft){if(!Cc(o,function(fe,be){if(!xo(Ft,be)&&(kt===fe||A(kt,fe,u,m,P)))return Ft.push(be)})){vt=!1;break}}else if(!(kt===ce||A(kt,ce,u,m,P))){vt=!1;break}}return P.delete(i),P.delete(o),vt}function Iy(i,o,u,m,A,P,H){switch(u){case wt:if(i.byteLength!=o.byteLength||i.byteOffset!=o.byteOffset)return!1;i=i.buffer,o=o.buffer;case Ut:return!(i.byteLength!=o.byteLength||!P(new Wa(i),new Wa(o)));case L:case k:case Mt:return Oi(+i,+o);case F:return i.name==o.name&&i.message==o.message;case xt:case _t:return i==o+"";case at:var G=Fc;case Bt:var X=m&R;if(G||(G=za),i.size!=o.size&&!X)return!1;var ot=H.get(i);if(ot)return ot==o;m|=Y,H.set(i,o);var ut=b0(G(i),G(o),m,A,P,H);return H.delete(i),ut;case Et:if(No)return No.call(i)==No.call(o)}return!1}function Dy(i,o,u,m,A,P){var H=u&R,G=oh(i),X=G.length,ot=oh(o),ut=ot.length;if(X!=ut&&!H)return!1;for(var dt=X;dt--;){var vt=G[dt];if(!(H?vt in o:Ne.call(o,vt)))return!1}var Ft=P.get(i),kt=P.get(o);if(Ft&&kt)return Ft==o&&kt==i;var ce=!0;P.set(i,o),P.set(o,i);for(var Ht=H;++dt<X;){vt=G[dt];var fe=i[vt],be=o[vt];if(m)var Jr=H?m(be,fe,vt,o,i,P):m(fe,be,vt,i,o,P);if(!(Jr===e?fe===be||A(fe,be,u,m,P):Jr)){ce=!1;break}Ht||(Ht=vt=="constructor")}if(ce&&!Ht){var xr=i.constructor,Xr=o.constructor;xr!=Xr&&"constructor"in i&&"constructor"in o&&!(typeof xr=="function"&&xr instanceof xr&&typeof Xr=="function"&&Xr instanceof Xr)&&(ce=!1)}return P.delete(i),P.delete(o),ce}function gn(i){return ph(D0(i,e,F0),i+"")}function oh(i){return jf(i,ur,hh)}function ah(i){return jf(i,Lr,_0)}var uh=tu?function(i){return tu.get(i)}:xh;function pu(i){for(var o=i.name+"",u=Hs[o],m=Ne.call(Hs,o)?u.length:0;m--;){var A=u[m],P=A.func;if(P==null||P==i)return A.name}return o}function Ws(i){var o=Ne.call(D,"placeholder")?D:i;return o.placeholder}function jt(){var i=D.iteratee||Ih;return i=i===Ih?kf:i,arguments.length?i(arguments[0],arguments[1]):i}function gu(i,o){var u=i.__data__;return Ty(o)?u[typeof o=="string"?"string":"hash"]:u.map}function ch(i){for(var o=ur(i),u=o.length;u--;){var m=o[u],A=i[m];o[u]=[m,A,S0(A)]}return o}function ms(i,o){var u=Bm(i,o);return zf(u)?u:e}function xy(i){var o=Ne.call(i,ls),u=i[ls];try{i[ls]=e;var m=!0}catch{}var A=Va.call(i);return m&&(o?i[ls]=u:delete i[ls]),A}var hh=Bc?function(i){return i==null?[]:(i=qe(i),Tn(Bc(i),function(o){return xf.call(i,o)}))}:Mh,_0=Bc?function(i){for(var o=[];i;)Fn(o,hh(i)),i=Ya(i);return o}:Mh,yr=Ir;(Lc&&yr(new Lc(new ArrayBuffer(1)))!=wt||Co&&yr(new Co)!=at||qc&&yr(qc.resolve())!=Ee||ks&&yr(new ks)!=Bt||Po&&yr(new Po)!=yt)&&(yr=function(i){var o=Ir(i),u=o==It?i.constructor:e,m=u?vs(u):"";if(m)switch(m){case cv:return wt;case hv:return at;case lv:return Ee;case fv:return Bt;case dv:return yt}return o});function My(i,o,u){for(var m=-1,A=u.length;++m<A;){var P=u[m],H=P.size;switch(P.type){case"drop":i+=H;break;case"dropRight":o-=H;break;case"take":o=vr(o,i+H);break;case"takeRight":i=nr(i,o-H);break}}return{start:i,end:o}}function Cy(i){var o=i.match(qt);return o?o[1].split(Te):[]}function E0(i,o,u){o=jn(o,i);for(var m=-1,A=o.length,P=!1;++m<A;){var H=Vi(o[m]);if(!(P=i!=null&&u(i,H)))break;i=i[H]}return P||++m!=A?P:(A=i==null?0:i.length,!!A&&Eu(A)&&mn(H,A)&&(ie(i)||ys(i)))}function Py(i){var o=i.length,u=new i.constructor(o);return o&&typeof i[0]=="string"&&Ne.call(i,"index")&&(u.index=i.index,u.input=i.input),u}function A0(i){return typeof i.constructor=="function"&&!qo(i)?Ks(Ya(i)):{}}function Oy(i,o,u){var m=i.constructor;switch(o){case Ut:return ih(i);case L:case k:return new m(+i);case wt:return py(i,u);case Ct:case Lt:case Ot:case Nt:case se:case Tt:case Rt:case Ke:case ue:return s0(i,u);case at:return new m;case Mt:case _t:return new m(i);case xt:return gy(i);case Bt:return new m;case Et:return my(i)}}function Ny(i,o){var u=o.length;if(!u)return i;var m=u-1;return o[m]=(u>1?"& ":"")+o[m],o=o.join(u>2?", ":" "),i.replace(Qt,`{
25
- /* [wrapped with `+o+`] */
26
- `)}function Ry(i){return ie(i)||ys(i)||!!(Mf&&i&&i[Mf])}function mn(i,o){var u=typeof i;return o=o??N,!!o&&(u=="number"||u!="symbol"&&ci.test(i))&&i>-1&&i%1==0&&i<o}function Dr(i,o,u){if(!Ge(u))return!1;var m=typeof o;return(m=="number"?Br(u)&&mn(o,u.length):m=="string"&&o in u)?Oi(u[o],i):!1}function lh(i,o){if(ie(i))return!1;var u=typeof i;return u=="number"||u=="symbol"||u=="boolean"||i==null||Qr(i)?!0:Jt.test(i)||!Ae.test(i)||o!=null&&i in qe(o)}function Ty(i){var o=typeof i;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?i!=="__proto__":i===null}function fh(i){var o=pu(i),u=D[o];if(typeof u!="function"||!(o in ge.prototype))return!1;if(i===u)return!0;var m=uh(u);return!!m&&i===m[0]}function Fy(i){return!!Sf&&Sf in i}var Uy=Ha?vn:Ch;function qo(i){var o=i&&i.constructor,u=typeof o=="function"&&o.prototype||zs;return i===u}function S0(i){return i===i&&!Ge(i)}function I0(i,o){return function(u){return u==null?!1:u[i]===o&&(o!==e||i in qe(u))}}function By(i){var o=bu(i,function(m){return u.size===f&&u.clear(),m}),u=o.cache;return o}function Ly(i,o){var u=i[1],m=o[1],A=u|m,P=A<(W|tt|v),H=m==v&&u==V||m==v&&u==T&&i[7].length<=o[8]||m==(v|T)&&o[7].length<=o[8]&&u==V;if(!(P||H))return i;m&W&&(i[2]=o[2],A|=u&W?0:K);var G=o[3];if(G){var X=i[3];i[3]=X?a0(X,G,o[4]):G,i[4]=X?Un(i[3],w):o[4]}return G=o[5],G&&(X=i[5],i[5]=X?u0(X,G,o[6]):G,i[6]=X?Un(i[5],w):o[6]),G=o[7],G&&(i[7]=G),m&v&&(i[8]=i[8]==null?o[8]:vr(i[8],o[8])),i[9]==null&&(i[9]=o[9]),i[0]=o[0],i[1]=A,i}function qy(i){var o=[];if(i!=null)for(var u in qe(i))o.push(u);return o}function jy(i){return Va.call(i)}function D0(i,o,u){return o=nr(o===e?i.length-1:o,0),function(){for(var m=arguments,A=-1,P=nr(m.length-o,0),H=rt(P);++A<P;)H[A]=m[o+A];A=-1;for(var G=rt(o+1);++A<o;)G[A]=m[A];return G[o]=u(H),ar(i,this,G)}}function x0(i,o){return o.length<2?i:gs(i,gi(o,0,-1))}function $y(i,o){for(var u=i.length,m=vr(o.length,u),A=Ur(i);m--;){var P=o[m];i[m]=mn(P,u)?A[P]:e}return i}function dh(i,o){if(!(o==="constructor"&&typeof i[o]=="function")&&o!="__proto__")return i[o]}var M0=P0(Jf),jo=rv||function(i,o){return we.setTimeout(i,o)},ph=P0(hy);function C0(i,o,u){var m=o+"";return ph(i,Ny(m,zy(Cy(m),u)))}function P0(i){var o=0,u=0;return function(){var m=ov(),A=h-(m-u);if(u=m,A>0){if(++o>=gt)return arguments[0]}else o=0;return i.apply(e,arguments)}}function mu(i,o){var u=-1,m=i.length,A=m-1;for(o=o===e?m:o;++u<o;){var P=Qc(u,A),H=i[P];i[P]=i[u],i[u]=H}return i.length=o,i}var O0=By(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(Xt,function(u,m,A,P){o.push(A?P.replace(xi,"$1"):m||u)}),o});function Vi(i){if(typeof i=="string"||Qr(i))return i;var o=i+"";return o=="0"&&1/i==-M?"-0":o}function vs(i){if(i!=null){try{return Ka.call(i)}catch{}try{return i+""}catch{}}return""}function zy(i,o){return li(lt,function(u){var m="_."+u[0];o&u[1]&&!ja(i,m)&&i.push(m)}),i.sort()}function N0(i){if(i instanceof ge)return i.clone();var o=new di(i.__wrapped__,i.__chain__);return o.__actions__=Ur(i.__actions__),o.__index__=i.__index__,o.__values__=i.__values__,o}function ky(i,o,u){(u?Dr(i,o,u):o===e)?o=1:o=nr(ae(o),0);var m=i==null?0:i.length;if(!m||o<1)return[];for(var A=0,P=0,H=rt(Xa(m/o));A<m;)H[P++]=gi(i,A,A+=o);return H}function Hy(i){for(var o=-1,u=i==null?0:i.length,m=0,A=[];++o<u;){var P=i[o];P&&(A[m++]=P)}return A}function Ky(){var i=arguments.length;if(!i)return[];for(var o=rt(i-1),u=arguments[0],m=i;m--;)o[m-1]=arguments[m];return Fn(ie(u)?Ur(u):[u],fr(o,1))}var Vy=he(function(i,o){return Je(i)?To(i,fr(o,1,Je,!0)):[]}),Gy=he(function(i,o){var u=mi(o);return Je(u)&&(u=e),Je(i)?To(i,fr(o,1,Je,!0),jt(u,2)):[]}),Wy=he(function(i,o){var u=mi(o);return Je(u)&&(u=e),Je(i)?To(i,fr(o,1,Je,!0),e,u):[]});function Yy(i,o,u){var m=i==null?0:i.length;return m?(o=u||o===e?1:ae(o),gi(i,o<0?0:o,m)):[]}function Qy(i,o,u){var m=i==null?0:i.length;return m?(o=u||o===e?1:ae(o),o=m-o,gi(i,0,o<0?0:o)):[]}function Jy(i,o){return i&&i.length?uu(i,jt(o,3),!0,!0):[]}function Xy(i,o){return i&&i.length?uu(i,jt(o,3),!0):[]}function Zy(i,o,u,m){var A=i==null?0:i.length;return A?(u&&typeof u!="number"&&Dr(i,o,u)&&(u=0,m=A),Kv(i,o,u,m)):[]}function R0(i,o,u){var m=i==null?0:i.length;if(!m)return-1;var A=u==null?0:ae(u);return A<0&&(A=nr(m+A,0)),$a(i,jt(o,3),A)}function T0(i,o,u){var m=i==null?0:i.length;if(!m)return-1;var A=m-1;return u!==e&&(A=ae(u),A=u<0?nr(m+A,0):vr(A,m-1)),$a(i,jt(o,3),A,!0)}function F0(i){var o=i==null?0:i.length;return o?fr(i,1):[]}function tw(i){var o=i==null?0:i.length;return o?fr(i,M):[]}function ew(i,o){var u=i==null?0:i.length;return u?(o=o===e?1:ae(o),fr(i,o)):[]}function rw(i){for(var o=-1,u=i==null?0:i.length,m={};++o<u;){var A=i[o];m[A[0]]=A[1]}return m}function U0(i){return i&&i.length?i[0]:e}function iw(i,o,u){var m=i==null?0:i.length;if(!m)return-1;var A=u==null?0:ae(u);return A<0&&(A=nr(m+A,0)),Ls(i,o,A)}function nw(i){var o=i==null?0:i.length;return o?gi(i,0,-1):[]}var sw=he(function(i){var o=ke(i,eh);return o.length&&o[0]===i[0]?Kc(o):[]}),ow=he(function(i){var o=mi(i),u=ke(i,eh);return o===mi(u)?o=e:u.pop(),u.length&&u[0]===i[0]?Kc(u,jt(o,2)):[]}),aw=he(function(i){var o=mi(i),u=ke(i,eh);return o=typeof o=="function"?o:e,o&&u.pop(),u.length&&u[0]===i[0]?Kc(u,e,o):[]});function uw(i,o){return i==null?"":nv.call(i,o)}function mi(i){var o=i==null?0:i.length;return o?i[o-1]:e}function cw(i,o,u){var m=i==null?0:i.length;if(!m)return-1;var A=m;return u!==e&&(A=ae(u),A=A<0?nr(m+A,0):vr(A,m-1)),o===o?zm(i,o,A):$a(i,mf,A,!0)}function hw(i,o){return i&&i.length?Gf(i,ae(o)):e}var lw=he(B0);function B0(i,o){return i&&i.length&&o&&o.length?Yc(i,o):i}function fw(i,o,u){return i&&i.length&&o&&o.length?Yc(i,o,jt(u,2)):i}function dw(i,o,u){return i&&i.length&&o&&o.length?Yc(i,o,e,u):i}var pw=gn(function(i,o){var u=i==null?0:i.length,m=$c(i,o);return Qf(i,ke(o,function(A){return mn(A,u)?+A:A}).sort(o0)),m});function gw(i,o){var u=[];if(!(i&&i.length))return u;var m=-1,A=[],P=i.length;for(o=jt(o,3);++m<P;){var H=i[m];o(H,m,i)&&(u.push(H),A.push(m))}return Qf(i,A),u}function gh(i){return i==null?i:uv.call(i)}function mw(i,o,u){var m=i==null?0:i.length;return m?(u&&typeof u!="number"&&Dr(i,o,u)?(o=0,u=m):(o=o==null?0:ae(o),u=u===e?m:ae(u)),gi(i,o,u)):[]}function vw(i,o){return au(i,o)}function yw(i,o,u){return Xc(i,o,jt(u,2))}function ww(i,o){var u=i==null?0:i.length;if(u){var m=au(i,o);if(m<u&&Oi(i[m],o))return m}return-1}function bw(i,o){return au(i,o,!0)}function _w(i,o,u){return Xc(i,o,jt(u,2),!0)}function Ew(i,o){var u=i==null?0:i.length;if(u){var m=au(i,o,!0)-1;if(Oi(i[m],o))return m}return-1}function Aw(i){return i&&i.length?Xf(i):[]}function Sw(i,o){return i&&i.length?Xf(i,jt(o,2)):[]}function Iw(i){var o=i==null?0:i.length;return o?gi(i,1,o):[]}function Dw(i,o,u){return i&&i.length?(o=u||o===e?1:ae(o),gi(i,0,o<0?0:o)):[]}function xw(i,o,u){var m=i==null?0:i.length;return m?(o=u||o===e?1:ae(o),o=m-o,gi(i,o<0?0:o,m)):[]}function Mw(i,o){return i&&i.length?uu(i,jt(o,3),!1,!0):[]}function Cw(i,o){return i&&i.length?uu(i,jt(o,3)):[]}var Pw=he(function(i){return qn(fr(i,1,Je,!0))}),Ow=he(function(i){var o=mi(i);return Je(o)&&(o=e),qn(fr(i,1,Je,!0),jt(o,2))}),Nw=he(function(i){var o=mi(i);return o=typeof o=="function"?o:e,qn(fr(i,1,Je,!0),e,o)});function Rw(i){return i&&i.length?qn(i):[]}function Tw(i,o){return i&&i.length?qn(i,jt(o,2)):[]}function Fw(i,o){return o=typeof o=="function"?o:e,i&&i.length?qn(i,e,o):[]}function mh(i){if(!(i&&i.length))return[];var o=0;return i=Tn(i,function(u){if(Je(u))return o=nr(u.length,o),!0}),Rc(o,function(u){return ke(i,Pc(u))})}function L0(i,o){if(!(i&&i.length))return[];var u=mh(i);return o==null?u:ke(u,function(m){return ar(o,e,m)})}var Uw=he(function(i,o){return Je(i)?To(i,o):[]}),Bw=he(function(i){return th(Tn(i,Je))}),Lw=he(function(i){var o=mi(i);return Je(o)&&(o=e),th(Tn(i,Je),jt(o,2))}),qw=he(function(i){var o=mi(i);return o=typeof o=="function"?o:e,th(Tn(i,Je),e,o)}),jw=he(mh);function $w(i,o){return r0(i||[],o||[],Ro)}function zw(i,o){return r0(i||[],o||[],Bo)}var kw=he(function(i){var o=i.length,u=o>1?i[o-1]:e;return u=typeof u=="function"?(i.pop(),u):e,L0(i,u)});function q0(i){var o=D(i);return o.__chain__=!0,o}function Hw(i,o){return o(i),i}function vu(i,o){return o(i)}var Kw=gn(function(i){var o=i.length,u=o?i[0]:0,m=this.__wrapped__,A=function(P){return $c(P,i)};return o>1||this.__actions__.length||!(m instanceof ge)||!mn(u)?this.thru(A):(m=m.slice(u,+u+(o?1:0)),m.__actions__.push({func:vu,args:[A],thisArg:e}),new di(m,this.__chain__).thru(function(P){return o&&!P.length&&P.push(e),P}))});function Vw(){return q0(this)}function Gw(){return new di(this.value(),this.__chain__)}function Ww(){this.__values__===e&&(this.__values__=Z0(this.value()));var i=this.__index__>=this.__values__.length,o=i?e:this.__values__[this.__index__++];return{done:i,value:o}}function Yw(){return this}function Qw(i){for(var o,u=this;u instanceof ru;){var m=N0(u);m.__index__=0,m.__values__=e,o?A.__wrapped__=m:o=m;var A=m;u=u.__wrapped__}return A.__wrapped__=i,o}function Jw(){var i=this.__wrapped__;if(i instanceof ge){var o=i;return this.__actions__.length&&(o=new ge(this)),o=o.reverse(),o.__actions__.push({func:vu,args:[gh],thisArg:e}),new di(o,this.__chain__)}return this.thru(gh)}function Xw(){return e0(this.__wrapped__,this.__actions__)}var Zw=cu(function(i,o,u){Ne.call(i,u)?++i[u]:dn(i,u,1)});function tb(i,o,u){var m=ie(i)?pf:Hv;return u&&Dr(i,o,u)&&(o=e),m(i,jt(o,3))}function eb(i,o){var u=ie(i)?Tn:Lf;return u(i,jt(o,3))}var rb=f0(R0),ib=f0(T0);function nb(i,o){return fr(yu(i,o),1)}function sb(i,o){return fr(yu(i,o),M)}function ob(i,o,u){return u=u===e?1:ae(u),fr(yu(i,o),u)}function j0(i,o){var u=ie(i)?li:Ln;return u(i,jt(o,3))}function $0(i,o){var u=ie(i)?Im:Bf;return u(i,jt(o,3))}var ab=cu(function(i,o,u){Ne.call(i,u)?i[u].push(o):dn(i,u,[o])});function ub(i,o,u,m){i=Br(i)?i:Qs(i),u=u&&!m?ae(u):0;var A=i.length;return u<0&&(u=nr(A+u,0)),Au(i)?u<=A&&i.indexOf(o,u)>-1:!!A&&Ls(i,o,u)>-1}var cb=he(function(i,o,u){var m=-1,A=typeof o=="function",P=Br(i)?rt(i.length):[];return Ln(i,function(H){P[++m]=A?ar(o,H,u):Fo(H,o,u)}),P}),hb=cu(function(i,o,u){dn(i,u,o)});function yu(i,o){var u=ie(i)?ke:Hf;return u(i,jt(o,3))}function lb(i,o,u,m){return i==null?[]:(ie(o)||(o=o==null?[]:[o]),u=m?e:u,ie(u)||(u=u==null?[]:[u]),Wf(i,o,u))}var fb=cu(function(i,o,u){i[u?0:1].push(o)},function(){return[[],[]]});function db(i,o,u){var m=ie(i)?Mc:yf,A=arguments.length<3;return m(i,jt(o,4),u,A,Ln)}function pb(i,o,u){var m=ie(i)?Dm:yf,A=arguments.length<3;return m(i,jt(o,4),u,A,Bf)}function gb(i,o){var u=ie(i)?Tn:Lf;return u(i,_u(jt(o,3)))}function mb(i){var o=ie(i)?Rf:uy;return o(i)}function vb(i,o,u){(u?Dr(i,o,u):o===e)?o=1:o=ae(o);var m=ie(i)?qv:cy;return m(i,o)}function yb(i){var o=ie(i)?jv:ly;return o(i)}function wb(i){if(i==null)return 0;if(Br(i))return Au(i)?js(i):i.length;var o=yr(i);return o==at||o==Bt?i.size:Gc(i).length}function bb(i,o,u){var m=ie(i)?Cc:fy;return u&&Dr(i,o,u)&&(o=e),m(i,jt(o,3))}var _b=he(function(i,o){if(i==null)return[];var u=o.length;return u>1&&Dr(i,o[0],o[1])?o=[]:u>2&&Dr(o[0],o[1],o[2])&&(o=[o[0]]),Wf(i,fr(o,1),[])}),wu=ev||function(){return we.Date.now()};function Eb(i,o){if(typeof o!="function")throw new fi(c);return i=ae(i),function(){if(--i<1)return o.apply(this,arguments)}}function z0(i,o,u){return o=u?e:o,o=i&&o==null?i.length:o,pn(i,v,e,e,e,e,o)}function k0(i,o){var u;if(typeof o!="function")throw new fi(c);return i=ae(i),function(){return--i>0&&(u=o.apply(this,arguments)),i<=1&&(o=e),u}}var vh=he(function(i,o,u){var m=W;if(u.length){var A=Un(u,Ws(vh));m|=z}return pn(i,m,o,u,A)}),H0=he(function(i,o,u){var m=W|tt;if(u.length){var A=Un(u,Ws(H0));m|=z}return pn(o,m,i,u,A)});function K0(i,o,u){o=u?e:o;var m=pn(i,V,e,e,e,e,e,o);return m.placeholder=K0.placeholder,m}function V0(i,o,u){o=u?e:o;var m=pn(i,B,e,e,e,e,e,o);return m.placeholder=V0.placeholder,m}function G0(i,o,u){var m,A,P,H,G,X,ot=0,ut=!1,dt=!1,vt=!0;if(typeof i!="function")throw new fi(c);o=vi(o)||0,Ge(u)&&(ut=!!u.leading,dt="maxWait"in u,P=dt?nr(vi(u.maxWait)||0,o):P,vt="trailing"in u?!!u.trailing:vt);function Ft(Xe){var Ni=m,wn=A;return m=A=e,ot=Xe,H=i.apply(wn,Ni),H}function kt(Xe){return ot=Xe,G=jo(fe,o),ut?Ft(Xe):H}function ce(Xe){var Ni=Xe-X,wn=Xe-ot,fd=o-Ni;return dt?vr(fd,P-wn):fd}function Ht(Xe){var Ni=Xe-X,wn=Xe-ot;return X===e||Ni>=o||Ni<0||dt&&wn>=P}function fe(){var Xe=wu();if(Ht(Xe))return be(Xe);G=jo(fe,ce(Xe))}function be(Xe){return G=e,vt&&m?Ft(Xe):(m=A=e,H)}function Jr(){G!==e&&i0(G),ot=0,m=X=A=G=e}function xr(){return G===e?H:be(wu())}function Xr(){var Xe=wu(),Ni=Ht(Xe);if(m=arguments,A=this,X=Xe,Ni){if(G===e)return kt(X);if(dt)return i0(G),G=jo(fe,o),Ft(X)}return G===e&&(G=jo(fe,o)),H}return Xr.cancel=Jr,Xr.flush=xr,Xr}var Ab=he(function(i,o){return Uf(i,1,o)}),Sb=he(function(i,o,u){return Uf(i,vi(o)||0,u)});function Ib(i){return pn(i,st)}function bu(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new fi(c);var u=function(){var m=arguments,A=o?o.apply(this,m):m[0],P=u.cache;if(P.has(A))return P.get(A);var H=i.apply(this,m);return u.cache=P.set(A,H)||P,H};return u.cache=new(bu.Cache||fn),u}bu.Cache=fn;function _u(i){if(typeof i!="function")throw new fi(c);return function(){var o=arguments;switch(o.length){case 0:return!i.call(this);case 1:return!i.call(this,o[0]);case 2:return!i.call(this,o[0],o[1]);case 3:return!i.call(this,o[0],o[1],o[2])}return!i.apply(this,o)}}function Db(i){return k0(2,i)}var xb=dy(function(i,o){o=o.length==1&&ie(o[0])?ke(o[0],Wr(jt())):ke(fr(o,1),Wr(jt()));var u=o.length;return he(function(m){for(var A=-1,P=vr(m.length,u);++A<P;)m[A]=o[A].call(this,m[A]);return ar(i,this,m)})}),yh=he(function(i,o){var u=Un(o,Ws(yh));return pn(i,z,e,o,u)}),W0=he(function(i,o){var u=Un(o,Ws(W0));return pn(i,$,e,o,u)}),Mb=gn(function(i,o){return pn(i,T,e,e,e,o)});function Cb(i,o){if(typeof i!="function")throw new fi(c);return o=o===e?o:ae(o),he(i,o)}function Pb(i,o){if(typeof i!="function")throw new fi(c);return o=o==null?0:nr(ae(o),0),he(function(u){var m=u[o],A=$n(u,0,o);return m&&Fn(A,m),ar(i,this,A)})}function Ob(i,o,u){var m=!0,A=!0;if(typeof i!="function")throw new fi(c);return Ge(u)&&(m="leading"in u?!!u.leading:m,A="trailing"in u?!!u.trailing:A),G0(i,o,{leading:m,maxWait:o,trailing:A})}function Nb(i){return z0(i,1)}function Rb(i,o){return yh(rh(o),i)}function Tb(){if(!arguments.length)return[];var i=arguments[0];return ie(i)?i:[i]}function Fb(i){return pi(i,I)}function Ub(i,o){return o=typeof o=="function"?o:e,pi(i,I,o)}function Bb(i){return pi(i,E|I)}function Lb(i,o){return o=typeof o=="function"?o:e,pi(i,E|I,o)}function qb(i,o){return o==null||Ff(i,o,ur(o))}function Oi(i,o){return i===o||i!==i&&o!==o}var jb=du(Hc),$b=du(function(i,o){return i>=o}),ys=$f(function(){return arguments}())?$f:function(i){return We(i)&&Ne.call(i,"callee")&&!xf.call(i,"callee")},ie=rt.isArray,zb=Sr?Wr(Sr):Qv;function Br(i){return i!=null&&Eu(i.length)&&!vn(i)}function Je(i){return We(i)&&Br(i)}function kb(i){return i===!0||i===!1||We(i)&&Ir(i)==L}var zn=iv||Ch,Hb=Mi?Wr(Mi):Jv;function Kb(i){return We(i)&&i.nodeType===1&&!$o(i)}function Vb(i){if(i==null)return!0;if(Br(i)&&(ie(i)||typeof i=="string"||typeof i.splice=="function"||zn(i)||Ys(i)||ys(i)))return!i.length;var o=yr(i);if(o==at||o==Bt)return!i.size;if(qo(i))return!Gc(i).length;for(var u in i)if(Ne.call(i,u))return!1;return!0}function Gb(i,o){return Uo(i,o)}function Wb(i,o,u){u=typeof u=="function"?u:e;var m=u?u(i,o):e;return m===e?Uo(i,o,e,u):!!m}function wh(i){if(!We(i))return!1;var o=Ir(i);return o==F||o==p||typeof i.message=="string"&&typeof i.name=="string"&&!$o(i)}function Yb(i){return typeof i=="number"&&Cf(i)}function vn(i){if(!Ge(i))return!1;var o=Ir(i);return o==et||o==ct||o==U||o==$t}function Y0(i){return typeof i=="number"&&i==ae(i)}function Eu(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=N}function Ge(i){var o=typeof i;return i!=null&&(o=="object"||o=="function")}function We(i){return i!=null&&typeof i=="object"}var Q0=hi?Wr(hi):Zv;function Qb(i,o){return i===o||Vc(i,o,ch(o))}function Jb(i,o,u){return u=typeof u=="function"?u:e,Vc(i,o,ch(o),u)}function Xb(i){return J0(i)&&i!=+i}function Zb(i){if(Uy(i))throw new ee(a);return zf(i)}function t2(i){return i===null}function e2(i){return i==null}function J0(i){return typeof i=="number"||We(i)&&Ir(i)==Mt}function $o(i){if(!We(i)||Ir(i)!=It)return!1;var o=Ya(i);if(o===null)return!0;var u=Ne.call(o,"constructor")&&o.constructor;return typeof u=="function"&&u instanceof u&&Ka.call(u)==Jm}var bh=ki?Wr(ki):ty;function r2(i){return Y0(i)&&i>=-N&&i<=N}var X0=Do?Wr(Do):ey;function Au(i){return typeof i=="string"||!ie(i)&&We(i)&&Ir(i)==_t}function Qr(i){return typeof i=="symbol"||We(i)&&Ir(i)==Et}var Ys=hs?Wr(hs):ry;function i2(i){return i===e}function n2(i){return We(i)&&yr(i)==yt}function s2(i){return We(i)&&Ir(i)==At}var o2=du(Wc),a2=du(function(i,o){return i<=o});function Z0(i){if(!i)return[];if(Br(i))return Au(i)?Ci(i):Ur(i);if(Mo&&i[Mo])return qm(i[Mo]());var o=yr(i),u=o==at?Fc:o==Bt?za:Qs;return u(i)}function yn(i){if(!i)return i===0?i:0;if(i=vi(i),i===M||i===-M){var o=i<0?-1:1;return o*q}return i===i?i:0}function ae(i){var o=yn(i),u=o%1;return o===o?u?o-u:o:0}function td(i){return i?ps(ae(i),0,g):0}function vi(i){if(typeof i=="number")return i;if(Qr(i))return S;if(Ge(i)){var o=typeof i.valueOf=="function"?i.valueOf():i;i=Ge(o)?o+"":o}if(typeof i!="string")return i===0?i:+i;i=wf(i);var u=oi.test(i);return u||ui.test(i)?re(i.slice(2),u?2:8):si.test(i)?S:+i}function ed(i){return Ki(i,Lr(i))}function u2(i){return i?ps(ae(i),-N,N):i===0?i:0}function Me(i){return i==null?"":Yr(i)}var c2=Vs(function(i,o){if(qo(o)||Br(o)){Ki(o,ur(o),i);return}for(var u in o)Ne.call(o,u)&&Ro(i,u,o[u])}),rd=Vs(function(i,o){Ki(o,Lr(o),i)}),Su=Vs(function(i,o,u,m){Ki(o,Lr(o),i,m)}),h2=Vs(function(i,o,u,m){Ki(o,ur(o),i,m)}),l2=gn($c);function f2(i,o){var u=Ks(i);return o==null?u:Tf(u,o)}var d2=he(function(i,o){i=qe(i);var u=-1,m=o.length,A=m>2?o[2]:e;for(A&&Dr(o[0],o[1],A)&&(m=1);++u<m;)for(var P=o[u],H=Lr(P),G=-1,X=H.length;++G<X;){var ot=H[G],ut=i[ot];(ut===e||Oi(ut,zs[ot])&&!Ne.call(i,ot))&&(i[ot]=P[ot])}return i}),p2=he(function(i){return i.push(e,w0),ar(id,e,i)});function g2(i,o){return gf(i,jt(o,3),Hi)}function m2(i,o){return gf(i,jt(o,3),kc)}function v2(i,o){return i==null?i:zc(i,jt(o,3),Lr)}function y2(i,o){return i==null?i:qf(i,jt(o,3),Lr)}function w2(i,o){return i&&Hi(i,jt(o,3))}function b2(i,o){return i&&kc(i,jt(o,3))}function _2(i){return i==null?[]:su(i,ur(i))}function E2(i){return i==null?[]:su(i,Lr(i))}function _h(i,o,u){var m=i==null?e:gs(i,o);return m===e?u:m}function A2(i,o){return i!=null&&E0(i,o,Vv)}function Eh(i,o){return i!=null&&E0(i,o,Gv)}var S2=p0(function(i,o,u){o!=null&&typeof o.toString!="function"&&(o=Va.call(o)),i[o]=u},Sh(qr)),I2=p0(function(i,o,u){o!=null&&typeof o.toString!="function"&&(o=Va.call(o)),Ne.call(i,o)?i[o].push(u):i[o]=[u]},jt),D2=he(Fo);function ur(i){return Br(i)?Nf(i):Gc(i)}function Lr(i){return Br(i)?Nf(i,!0):iy(i)}function x2(i,o){var u={};return o=jt(o,3),Hi(i,function(m,A,P){dn(u,o(m,A,P),m)}),u}function M2(i,o){var u={};return o=jt(o,3),Hi(i,function(m,A,P){dn(u,A,o(m,A,P))}),u}var C2=Vs(function(i,o,u){ou(i,o,u)}),id=Vs(function(i,o,u,m){ou(i,o,u,m)}),P2=gn(function(i,o){var u={};if(i==null)return u;var m=!1;o=ke(o,function(P){return P=jn(P,i),m||(m=P.length>1),P}),Ki(i,ah(i),u),m&&(u=pi(u,E|x|I,Sy));for(var A=o.length;A--;)Zc(u,o[A]);return u});function O2(i,o){return nd(i,_u(jt(o)))}var N2=gn(function(i,o){return i==null?{}:sy(i,o)});function nd(i,o){if(i==null)return{};var u=ke(ah(i),function(m){return[m]});return o=jt(o),Yf(i,u,function(m,A){return o(m,A[0])})}function R2(i,o,u){o=jn(o,i);var m=-1,A=o.length;for(A||(A=1,i=e);++m<A;){var P=i==null?e:i[Vi(o[m])];P===e&&(m=A,P=u),i=vn(P)?P.call(i):P}return i}function T2(i,o,u){return i==null?i:Bo(i,o,u)}function F2(i,o,u,m){return m=typeof m=="function"?m:e,i==null?i:Bo(i,o,u,m)}var sd=v0(ur),od=v0(Lr);function U2(i,o,u){var m=ie(i),A=m||zn(i)||Ys(i);if(o=jt(o,4),u==null){var P=i&&i.constructor;A?u=m?new P:[]:Ge(i)?u=vn(P)?Ks(Ya(i)):{}:u={}}return(A?li:Hi)(i,function(H,G,X){return o(u,H,G,X)}),u}function B2(i,o){return i==null?!0:Zc(i,o)}function L2(i,o,u){return i==null?i:t0(i,o,rh(u))}function q2(i,o,u,m){return m=typeof m=="function"?m:e,i==null?i:t0(i,o,rh(u),m)}function Qs(i){return i==null?[]:Tc(i,ur(i))}function j2(i){return i==null?[]:Tc(i,Lr(i))}function $2(i,o,u){return u===e&&(u=o,o=e),u!==e&&(u=vi(u),u=u===u?u:0),o!==e&&(o=vi(o),o=o===o?o:0),ps(vi(i),o,u)}function z2(i,o,u){return o=yn(o),u===e?(u=o,o=0):u=yn(u),i=vi(i),Wv(i,o,u)}function k2(i,o,u){if(u&&typeof u!="boolean"&&Dr(i,o,u)&&(o=u=e),u===e&&(typeof o=="boolean"?(u=o,o=e):typeof i=="boolean"&&(u=i,i=e)),i===e&&o===e?(i=0,o=1):(i=yn(i),o===e?(o=i,i=0):o=yn(o)),i>o){var m=i;i=o,o=m}if(u||i%1||o%1){var A=Pf();return vr(i+A*(o-i+Be("1e-"+((A+"").length-1))),o)}return Qc(i,o)}var H2=Gs(function(i,o,u){return o=o.toLowerCase(),i+(u?ad(o):o)});function ad(i){return Ah(Me(i).toLowerCase())}function ud(i){return i=Me(i),i&&i.replace(or,Tm).replace(Ic,"")}function K2(i,o,u){i=Me(i),o=Yr(o);var m=i.length;u=u===e?m:ps(ae(u),0,m);var A=u;return u-=o.length,u>=0&&i.slice(u,A)==o}function V2(i){return i=Me(i),i&&zt.test(i)?i.replace(Er,Fm):i}function G2(i){return i=Me(i),i&&Zt.test(i)?i.replace(xe,"\\$&"):i}var W2=Gs(function(i,o,u){return i+(u?"-":"")+o.toLowerCase()}),Y2=Gs(function(i,o,u){return i+(u?" ":"")+o.toLowerCase()}),Q2=l0("toLowerCase");function J2(i,o,u){i=Me(i),o=ae(o);var m=o?js(i):0;if(!o||m>=o)return i;var A=(o-m)/2;return fu(Za(A),u)+i+fu(Xa(A),u)}function X2(i,o,u){i=Me(i),o=ae(o);var m=o?js(i):0;return o&&m<o?i+fu(o-m,u):i}function Z2(i,o,u){i=Me(i),o=ae(o);var m=o?js(i):0;return o&&m<o?fu(o-m,u)+i:i}function t3(i,o,u){return u||o==null?o=0:o&&(o=+o),av(Me(i).replace(Yt,""),o||0)}function e3(i,o,u){return(u?Dr(i,o,u):o===e)?o=1:o=ae(o),Jc(Me(i),o)}function r3(){var i=arguments,o=Me(i[0]);return i.length<3?o:o.replace(i[1],i[2])}var i3=Gs(function(i,o,u){return i+(u?"_":"")+o.toLowerCase()});function n3(i,o,u){return u&&typeof u!="number"&&Dr(i,o,u)&&(o=u=e),u=u===e?g:u>>>0,u?(i=Me(i),i&&(typeof o=="string"||o!=null&&!bh(o))&&(o=Yr(o),!o&&qs(i))?$n(Ci(i),0,u):i.split(o,u)):[]}var s3=Gs(function(i,o,u){return i+(u?" ":"")+Ah(o)});function o3(i,o,u){return i=Me(i),u=u==null?0:ps(ae(u),0,i.length),o=Yr(o),i.slice(u,u+o.length)==o}function a3(i,o,u){var m=D.templateSettings;u&&Dr(i,o,u)&&(o=e),i=Me(i),o=Su({},o,m,y0);var A=Su({},o.imports,m.imports,y0),P=ur(A),H=Tc(A,P),G,X,ot=0,ut=o.interpolate||qi,dt="__p += '",vt=Uc((o.escape||qi).source+"|"+ut.source+"|"+(ut===Kt?Oe:qi).source+"|"+(o.evaluate||qi).source+"|$","g"),Ft="//# sourceURL="+(Ne.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Dc+"]")+`
27
- `;i.replace(vt,function(Ht,fe,be,Jr,xr,Xr){return be||(be=Jr),dt+=i.slice(ot,Xr).replace(Zn,Um),fe&&(G=!0,dt+=`' +
28
- __e(`+fe+`) +
29
- '`),xr&&(X=!0,dt+=`';
30
- `+xr+`;
31
- __p += '`),be&&(dt+=`' +
32
- ((__t = (`+be+`)) == null ? '' : __t) +
33
- '`),ot=Xr+Ht.length,Ht}),dt+=`';
34
- `;var kt=Ne.call(o,"variable")&&o.variable;if(!kt)dt=`with (obj) {
35
- `+dt+`
36
- }
37
- `;else if(Pe.test(kt))throw new ee(l);dt=(X?dt.replace(pe,""):dt).replace(Ve,"$1").replace(ye,"$1;"),dt="function("+(kt||"obj")+`) {
38
- `+(kt?"":`obj || (obj = {});
39
- `)+"var __t, __p = ''"+(G?", __e = _.escape":"")+(X?`, __j = Array.prototype.join;
40
- function print() { __p += __j.call(arguments, '') }
41
- `:`;
42
- `)+dt+`return __p
43
- }`;var ce=hd(function(){return Se(P,Ft+"return "+dt).apply(e,H)});if(ce.source=dt,wh(ce))throw ce;return ce}function u3(i){return Me(i).toLowerCase()}function c3(i){return Me(i).toUpperCase()}function h3(i,o,u){if(i=Me(i),i&&(u||o===e))return wf(i);if(!i||!(o=Yr(o)))return i;var m=Ci(i),A=Ci(o),P=bf(m,A),H=_f(m,A)+1;return $n(m,P,H).join("")}function l3(i,o,u){if(i=Me(i),i&&(u||o===e))return i.slice(0,Af(i)+1);if(!i||!(o=Yr(o)))return i;var m=Ci(i),A=_f(m,Ci(o))+1;return $n(m,0,A).join("")}function f3(i,o,u){if(i=Me(i),i&&(u||o===e))return i.replace(Yt,"");if(!i||!(o=Yr(o)))return i;var m=Ci(i),A=bf(m,Ci(o));return $n(m,A).join("")}function d3(i,o){var u=ft,m=pt;if(Ge(o)){var A="separator"in o?o.separator:A;u="length"in o?ae(o.length):u,m="omission"in o?Yr(o.omission):m}i=Me(i);var P=i.length;if(qs(i)){var H=Ci(i);P=H.length}if(u>=P)return i;var G=u-js(m);if(G<1)return m;var X=H?$n(H,0,G).join(""):i.slice(0,G);if(A===e)return X+m;if(H&&(G+=X.length-G),bh(A)){if(i.slice(G).search(A)){var ot,ut=X;for(A.global||(A=Uc(A.source,Me(le.exec(A))+"g")),A.lastIndex=0;ot=A.exec(ut);)var dt=ot.index;X=X.slice(0,dt===e?G:dt)}}else if(i.indexOf(Yr(A),G)!=G){var vt=X.lastIndexOf(A);vt>-1&&(X=X.slice(0,vt))}return X+m}function p3(i){return i=Me(i),i&&Gt.test(i)?i.replace(_e,km):i}var g3=Gs(function(i,o,u){return i+(u?" ":"")+o.toUpperCase()}),Ah=l0("toUpperCase");function cd(i,o,u){return i=Me(i),o=u?e:o,o===e?Lm(i)?Vm(i):Cm(i):i.match(o)||[]}var hd=he(function(i,o){try{return ar(i,e,o)}catch(u){return wh(u)?u:new ee(u)}}),m3=gn(function(i,o){return li(o,function(u){u=Vi(u),dn(i,u,vh(i[u],i))}),i});function v3(i){var o=i==null?0:i.length,u=jt();return i=o?ke(i,function(m){if(typeof m[1]!="function")throw new fi(c);return[u(m[0]),m[1]]}):[],he(function(m){for(var A=-1;++A<o;){var P=i[A];if(ar(P[0],this,m))return ar(P[1],this,m)}})}function y3(i){return kv(pi(i,E))}function Sh(i){return function(){return i}}function w3(i,o){return i==null||i!==i?o:i}var b3=d0(),_3=d0(!0);function qr(i){return i}function Ih(i){return kf(typeof i=="function"?i:pi(i,E))}function E3(i){return Kf(pi(i,E))}function A3(i,o){return Vf(i,pi(o,E))}var S3=he(function(i,o){return function(u){return Fo(u,i,o)}}),I3=he(function(i,o){return function(u){return Fo(i,u,o)}});function Dh(i,o,u){var m=ur(o),A=su(o,m);u==null&&!(Ge(o)&&(A.length||!m.length))&&(u=o,o=i,i=this,A=su(o,ur(o)));var P=!(Ge(u)&&"chain"in u)||!!u.chain,H=vn(i);return li(A,function(G){var X=o[G];i[G]=X,H&&(i.prototype[G]=function(){var ot=this.__chain__;if(P||ot){var ut=i(this.__wrapped__),dt=ut.__actions__=Ur(this.__actions__);return dt.push({func:X,args:arguments,thisArg:i}),ut.__chain__=ot,ut}return X.apply(i,Fn([this.value()],arguments))})}),i}function D3(){return we._===this&&(we._=Xm),this}function xh(){}function x3(i){return i=ae(i),he(function(o){return Gf(o,i)})}var M3=nh(ke),C3=nh(pf),P3=nh(Cc);function ld(i){return lh(i)?Pc(Vi(i)):oy(i)}function O3(i){return function(o){return i==null?e:gs(i,o)}}var N3=g0(),R3=g0(!0);function Mh(){return[]}function Ch(){return!1}function T3(){return{}}function F3(){return""}function U3(){return!0}function B3(i,o){if(i=ae(i),i<1||i>N)return[];var u=g,m=vr(i,g);o=jt(o),i-=g;for(var A=Rc(m,o);++u<i;)o(u);return A}function L3(i){return ie(i)?ke(i,Vi):Qr(i)?[i]:Ur(O0(Me(i)))}function q3(i){var o=++Qm;return Me(i)+o}var j3=lu(function(i,o){return i+o},0),$3=sh("ceil"),z3=lu(function(i,o){return i/o},1),k3=sh("floor");function H3(i){return i&&i.length?nu(i,qr,Hc):e}function K3(i,o){return i&&i.length?nu(i,jt(o,2),Hc):e}function V3(i){return vf(i,qr)}function G3(i,o){return vf(i,jt(o,2))}function W3(i){return i&&i.length?nu(i,qr,Wc):e}function Y3(i,o){return i&&i.length?nu(i,jt(o,2),Wc):e}var Q3=lu(function(i,o){return i*o},1),J3=sh("round"),X3=lu(function(i,o){return i-o},0);function Z3(i){return i&&i.length?Nc(i,qr):0}function t6(i,o){return i&&i.length?Nc(i,jt(o,2)):0}return D.after=Eb,D.ary=z0,D.assign=c2,D.assignIn=rd,D.assignInWith=Su,D.assignWith=h2,D.at=l2,D.before=k0,D.bind=vh,D.bindAll=m3,D.bindKey=H0,D.castArray=Tb,D.chain=q0,D.chunk=ky,D.compact=Hy,D.concat=Ky,D.cond=v3,D.conforms=y3,D.constant=Sh,D.countBy=Zw,D.create=f2,D.curry=K0,D.curryRight=V0,D.debounce=G0,D.defaults=d2,D.defaultsDeep=p2,D.defer=Ab,D.delay=Sb,D.difference=Vy,D.differenceBy=Gy,D.differenceWith=Wy,D.drop=Yy,D.dropRight=Qy,D.dropRightWhile=Jy,D.dropWhile=Xy,D.fill=Zy,D.filter=eb,D.flatMap=nb,D.flatMapDeep=sb,D.flatMapDepth=ob,D.flatten=F0,D.flattenDeep=tw,D.flattenDepth=ew,D.flip=Ib,D.flow=b3,D.flowRight=_3,D.fromPairs=rw,D.functions=_2,D.functionsIn=E2,D.groupBy=ab,D.initial=nw,D.intersection=sw,D.intersectionBy=ow,D.intersectionWith=aw,D.invert=S2,D.invertBy=I2,D.invokeMap=cb,D.iteratee=Ih,D.keyBy=hb,D.keys=ur,D.keysIn=Lr,D.map=yu,D.mapKeys=x2,D.mapValues=M2,D.matches=E3,D.matchesProperty=A3,D.memoize=bu,D.merge=C2,D.mergeWith=id,D.method=S3,D.methodOf=I3,D.mixin=Dh,D.negate=_u,D.nthArg=x3,D.omit=P2,D.omitBy=O2,D.once=Db,D.orderBy=lb,D.over=M3,D.overArgs=xb,D.overEvery=C3,D.overSome=P3,D.partial=yh,D.partialRight=W0,D.partition=fb,D.pick=N2,D.pickBy=nd,D.property=ld,D.propertyOf=O3,D.pull=lw,D.pullAll=B0,D.pullAllBy=fw,D.pullAllWith=dw,D.pullAt=pw,D.range=N3,D.rangeRight=R3,D.rearg=Mb,D.reject=gb,D.remove=gw,D.rest=Cb,D.reverse=gh,D.sampleSize=vb,D.set=T2,D.setWith=F2,D.shuffle=yb,D.slice=mw,D.sortBy=_b,D.sortedUniq=Aw,D.sortedUniqBy=Sw,D.split=n3,D.spread=Pb,D.tail=Iw,D.take=Dw,D.takeRight=xw,D.takeRightWhile=Mw,D.takeWhile=Cw,D.tap=Hw,D.throttle=Ob,D.thru=vu,D.toArray=Z0,D.toPairs=sd,D.toPairsIn=od,D.toPath=L3,D.toPlainObject=ed,D.transform=U2,D.unary=Nb,D.union=Pw,D.unionBy=Ow,D.unionWith=Nw,D.uniq=Rw,D.uniqBy=Tw,D.uniqWith=Fw,D.unset=B2,D.unzip=mh,D.unzipWith=L0,D.update=L2,D.updateWith=q2,D.values=Qs,D.valuesIn=j2,D.without=Uw,D.words=cd,D.wrap=Rb,D.xor=Bw,D.xorBy=Lw,D.xorWith=qw,D.zip=jw,D.zipObject=$w,D.zipObjectDeep=zw,D.zipWith=kw,D.entries=sd,D.entriesIn=od,D.extend=rd,D.extendWith=Su,Dh(D,D),D.add=j3,D.attempt=hd,D.camelCase=H2,D.capitalize=ad,D.ceil=$3,D.clamp=$2,D.clone=Fb,D.cloneDeep=Bb,D.cloneDeepWith=Lb,D.cloneWith=Ub,D.conformsTo=qb,D.deburr=ud,D.defaultTo=w3,D.divide=z3,D.endsWith=K2,D.eq=Oi,D.escape=V2,D.escapeRegExp=G2,D.every=tb,D.find=rb,D.findIndex=R0,D.findKey=g2,D.findLast=ib,D.findLastIndex=T0,D.findLastKey=m2,D.floor=k3,D.forEach=j0,D.forEachRight=$0,D.forIn=v2,D.forInRight=y2,D.forOwn=w2,D.forOwnRight=b2,D.get=_h,D.gt=jb,D.gte=$b,D.has=A2,D.hasIn=Eh,D.head=U0,D.identity=qr,D.includes=ub,D.indexOf=iw,D.inRange=z2,D.invoke=D2,D.isArguments=ys,D.isArray=ie,D.isArrayBuffer=zb,D.isArrayLike=Br,D.isArrayLikeObject=Je,D.isBoolean=kb,D.isBuffer=zn,D.isDate=Hb,D.isElement=Kb,D.isEmpty=Vb,D.isEqual=Gb,D.isEqualWith=Wb,D.isError=wh,D.isFinite=Yb,D.isFunction=vn,D.isInteger=Y0,D.isLength=Eu,D.isMap=Q0,D.isMatch=Qb,D.isMatchWith=Jb,D.isNaN=Xb,D.isNative=Zb,D.isNil=e2,D.isNull=t2,D.isNumber=J0,D.isObject=Ge,D.isObjectLike=We,D.isPlainObject=$o,D.isRegExp=bh,D.isSafeInteger=r2,D.isSet=X0,D.isString=Au,D.isSymbol=Qr,D.isTypedArray=Ys,D.isUndefined=i2,D.isWeakMap=n2,D.isWeakSet=s2,D.join=uw,D.kebabCase=W2,D.last=mi,D.lastIndexOf=cw,D.lowerCase=Y2,D.lowerFirst=Q2,D.lt=o2,D.lte=a2,D.max=H3,D.maxBy=K3,D.mean=V3,D.meanBy=G3,D.min=W3,D.minBy=Y3,D.stubArray=Mh,D.stubFalse=Ch,D.stubObject=T3,D.stubString=F3,D.stubTrue=U3,D.multiply=Q3,D.nth=hw,D.noConflict=D3,D.noop=xh,D.now=wu,D.pad=J2,D.padEnd=X2,D.padStart=Z2,D.parseInt=t3,D.random=k2,D.reduce=db,D.reduceRight=pb,D.repeat=e3,D.replace=r3,D.result=R2,D.round=J3,D.runInContext=J,D.sample=mb,D.size=wb,D.snakeCase=i3,D.some=bb,D.sortedIndex=vw,D.sortedIndexBy=yw,D.sortedIndexOf=ww,D.sortedLastIndex=bw,D.sortedLastIndexBy=_w,D.sortedLastIndexOf=Ew,D.startCase=s3,D.startsWith=o3,D.subtract=X3,D.sum=Z3,D.sumBy=t6,D.template=a3,D.times=B3,D.toFinite=yn,D.toInteger=ae,D.toLength=td,D.toLower=u3,D.toNumber=vi,D.toSafeInteger=u2,D.toString=Me,D.toUpper=c3,D.trim=h3,D.trimEnd=l3,D.trimStart=f3,D.truncate=d3,D.unescape=p3,D.uniqueId=q3,D.upperCase=g3,D.upperFirst=Ah,D.each=j0,D.eachRight=$0,D.first=U0,Dh(D,function(){var i={};return Hi(D,function(o,u){Ne.call(D.prototype,u)||(i[u]=o)}),i}(),{chain:!1}),D.VERSION=n,li(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){D[i].placeholder=D}),li(["drop","take"],function(i,o){ge.prototype[i]=function(u){u=u===e?1:nr(ae(u),0);var m=this.__filtered__&&!o?new ge(this):this.clone();return m.__filtered__?m.__takeCount__=vr(u,m.__takeCount__):m.__views__.push({size:vr(u,g),type:i+(m.__dir__<0?"Right":"")}),m},ge.prototype[i+"Right"]=function(u){return this.reverse()[i](u).reverse()}}),li(["filter","map","takeWhile"],function(i,o){var u=o+1,m=u==y||u==C;ge.prototype[i]=function(A){var P=this.clone();return P.__iteratees__.push({iteratee:jt(A,3),type:u}),P.__filtered__=P.__filtered__||m,P}}),li(["head","last"],function(i,o){var u="take"+(o?"Right":"");ge.prototype[i]=function(){return this[u](1).value()[0]}}),li(["initial","tail"],function(i,o){var u="drop"+(o?"":"Right");ge.prototype[i]=function(){return this.__filtered__?new ge(this):this[u](1)}}),ge.prototype.compact=function(){return this.filter(qr)},ge.prototype.find=function(i){return this.filter(i).head()},ge.prototype.findLast=function(i){return this.reverse().find(i)},ge.prototype.invokeMap=he(function(i,o){return typeof i=="function"?new ge(this):this.map(function(u){return Fo(u,i,o)})}),ge.prototype.reject=function(i){return this.filter(_u(jt(i)))},ge.prototype.slice=function(i,o){i=ae(i);var u=this;return u.__filtered__&&(i>0||o<0)?new ge(u):(i<0?u=u.takeRight(-i):i&&(u=u.drop(i)),o!==e&&(o=ae(o),u=o<0?u.dropRight(-o):u.take(o-i)),u)},ge.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},ge.prototype.toArray=function(){return this.take(g)},Hi(ge.prototype,function(i,o){var u=/^(?:filter|find|map|reject)|While$/.test(o),m=/^(?:head|last)$/.test(o),A=D[m?"take"+(o=="last"?"Right":""):o],P=m||/^find/.test(o);A&&(D.prototype[o]=function(){var H=this.__wrapped__,G=m?[1]:arguments,X=H instanceof ge,ot=G[0],ut=X||ie(H),dt=function(fe){var be=A.apply(D,Fn([fe],G));return m&&vt?be[0]:be};ut&&u&&typeof ot=="function"&&ot.length!=1&&(X=ut=!1);var vt=this.__chain__,Ft=!!this.__actions__.length,kt=P&&!vt,ce=X&&!Ft;if(!P&&ut){H=ce?H:new ge(this);var Ht=i.apply(H,G);return Ht.__actions__.push({func:vu,args:[dt],thisArg:e}),new di(Ht,vt)}return kt&&ce?i.apply(this,G):(Ht=this.thru(dt),kt?m?Ht.value()[0]:Ht.value():Ht)})}),li(["pop","push","shift","sort","splice","unshift"],function(i){var o=ka[i],u=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",m=/^(?:pop|shift)$/.test(i);D.prototype[i]=function(){var A=arguments;if(m&&!this.__chain__){var P=this.value();return o.apply(ie(P)?P:[],A)}return this[u](function(H){return o.apply(ie(H)?H:[],A)})}}),Hi(ge.prototype,function(i,o){var u=D[o];if(u){var m=u.name+"";Ne.call(Hs,m)||(Hs[m]=[]),Hs[m].push({name:o,func:u})}}),Hs[hu(e,tt).name]=[{name:"wrapper",func:e}],ge.prototype.clone=pv,ge.prototype.reverse=gv,ge.prototype.value=mv,D.prototype.at=Kw,D.prototype.chain=Vw,D.prototype.commit=Gw,D.prototype.next=Ww,D.prototype.plant=Qw,D.prototype.reverse=Jw,D.prototype.toJSON=D.prototype.valueOf=D.prototype.value=Xw,D.prototype.first=D.prototype.head,Mo&&(D.prototype[Mo]=Yw),D},$s=Gm();Qe?((Qe.exports=$s)._=$s,Le._=$s):we._=$s}).call(Xo)})(Fl,Fl.exports);var r9=Object.defineProperty,i9=Object.defineProperties,n9=Object.getOwnPropertyDescriptors,w1=Object.getOwnPropertySymbols,s9=Object.prototype.hasOwnProperty,o9=Object.prototype.propertyIsEnumerable,b1=(r,t,e)=>t in r?r9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ru=(r,t)=>{for(var e in t||(t={}))s9.call(t,e)&&b1(r,e,t[e]);if(w1)for(var e of w1(t))o9.call(t,e)&&b1(r,e,t[e]);return r},a9=(r,t)=>i9(r,n9(t));function Qn(r,t,e){var n;const s=Uu(r);return((n=t.rpcMap)==null?void 0:n[s.reference])||`${e9}?chainId=${s.namespace}:${s.reference}&projectId=${e}`}function Rs(r){return r.includes(":")?r.split(":")[1]:r}function Em(r){return r.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function u9(r,t){const e=Object.keys(t.namespaces).filter(s=>s.includes(r));if(!e.length)return[];const n=[];return e.forEach(s=>{const a=t.namespaces[s].accounts;n.push(...a)}),n}function ul(r={},t={}){const e=_1(r),n=_1(t);return Fl.exports.merge(e,n)}function _1(r){var t,e,n,s;const a={};if(!ca(r))return a;for(const[c,l]of Object.entries(r)){const d=rf(c)?[c]:l.chains,f=l.methods||[],w=l.events||[],E=l.rpcMap||{},x=ta(c);a[x]=a9(Ru(Ru({},a[x]),l),{chains:Bu(d,(t=a[x])==null?void 0:t.chains),methods:Bu(f,(e=a[x])==null?void 0:e.methods),events:Bu(w,(n=a[x])==null?void 0:n.events),rpcMap:Ru(Ru({},E),(s=a[x])==null?void 0:s.rpcMap)})}return a}function c9(r){return r.includes(":")?r.split(":")[2]:r}function E1(r){const t={};for(const[e,n]of Object.entries(r)){const s=n.methods||[],a=n.events||[],c=n.accounts||[],l=rf(e)?[e]:n.chains?n.chains:Em(n.accounts);t[e]={chains:l,methods:s,events:a,accounts:c}}return t}function cl(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const Am={},He=r=>Am[r],hl=(r,t)=>{Am[r]=t};class h9{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const s=Rs(e);t[s]=this.createHttpProvider(s,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Qn(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}}class l9{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const n=e||Qn(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const s=parseInt(Rs(e));t[s]=this.createHttpProvider(s,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,n;let s=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const a=parseInt(s,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:s}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class f9{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const s=Rs(e);t[s]=this.createHttpProvider(s,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Qn(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}}class d9{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const s=Rs(e);t[s]=this.createHttpProvider(s,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Qn(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}}class p9{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const n=this.getCardanoRPCUrl(e),s=Rs(e);t[s]=this.createHttpProvider(s,n)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||this.getCardanoRPCUrl(t);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}}class g9{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const s=Rs(e);t[s]=this.createHttpProvider(s,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Qn(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}}class m9{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;const s=Rs(e);t[s]=this.createHttpProvider(s,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Qn(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new Cn(new Xn(n,He("disableProviderPing")))}}class v9{constructor(t){this.name="near",this.namespace=t.namespace,this.events=He("events"),this.client=He("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const n=e||Qn(`${this.name}:${t}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.events.emit(Pn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var n;t[e]=this.createHttpProvider(e,(n=this.namespace.rpcMap)==null?void 0:n[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const n=this.createHttpProvider(t,e);n&&(this.httpProviders[t]=n)}createHttpProvider(t,e){const n=e||Qn(t,this.namespace);return typeof n>"u"?void 0:new Cn(new Xn(n,He("disableProviderPing")))}}var y9=Object.defineProperty,w9=Object.defineProperties,b9=Object.getOwnPropertyDescriptors,A1=Object.getOwnPropertySymbols,_9=Object.prototype.hasOwnProperty,E9=Object.prototype.propertyIsEnumerable,S1=(r,t,e)=>t in r?y9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tu=(r,t)=>{for(var e in t||(t={}))_9.call(t,e)&&S1(r,e,t[e]);if(A1)for(var e of A1(t))E9.call(t,e)&&S1(r,e,t[e]);return r},ll=(r,t)=>w9(r,b9(t));class ff{constructor(t){this.events=new jl,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:ba(gc({level:(t==null?void 0:t.logger)||v1})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new ff(t);return await e.initialize(),e}async request(t,e,n){const[s,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Tu({},t),chainId:`${s}:${a}`,topic:this.session.topic,expiry:n})}sendAsync(t,e,n,s){const a=new Date().getTime();this.request(t,n,s).then(c=>e(null,mc(a,c))).catch(c=>e(c,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Re("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:n}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const s=await n();if(this.session=s.session,this.session){const a=E1(this.session.namespaces);this.namespaces=ul(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:s}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await s().then(a=>{this.session=a;const c=E1(a.namespaces);this.namespaces=ul(this.namespaces,c),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==_m)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[n,s]=this.validateChain(t);this.getProvider(n).setDefaultChain(s,e)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(un(e)){for(const n of e)t.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await lf.init({logger:this.providerOpts.logger||v1,relayUrl:this.providerOpts.relayUrl||X7,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>ta(e)))];hl("client",this.client),hl("events",this.events),hl("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const n=u9(e,this.session),s=Em(n),a=ul(this.namespaces,this.optionalNamespaces),c=ll(Tu({},a[e]),{accounts:n,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new l9({namespace:c});break;case"solana":this.rpcProviders[e]=new f9({namespace:c});break;case"cosmos":this.rpcProviders[e]=new d9({namespace:c});break;case"polkadot":this.rpcProviders[e]=new h9({namespace:c});break;case"cip34":this.rpcProviders[e]=new p9({namespace:c});break;case"elrond":this.rpcProviders[e]=new g9({namespace:c});break;case"multiversx":this.rpcProviders[e]=new m9({namespace:c});break;case"near":this.rpcProviders[e]=new v9({namespace:c});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:e}=t,{event:n}=e;if(n.name==="accountsChanged"){const s=n.data;s&&un(s)&&this.events.emit("accountsChanged",s.map(c9))}else if(n.name==="chainChanged"){const s=e.chainId,a=e.event.data,c=ta(s),l=cl(s)!==cl(a)?`${c}:${cl(a)}`:s;this.onChainChanged(l)}else this.events.emit(n.name,n.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var n;const{namespaces:s}=e,a=(n=this.client)==null?void 0:n.session.get(t);this.session=ll(Tu({},a),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",ll(Tu({},Re("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Pn.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:n,sessionProperties:s}=t;e&&Object.keys(e).length&&(this.namespaces=e),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=s,this.persist("namespaces",e),this.persist("optionalNamespaces",n)}validateChain(t){const[e,n]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,n];if(e&&!Object.keys(this.namespaces||{}).map(c=>ta(c)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&n)return[e,n];const s=ta(Object.keys(this.namespaces)[0]),a=this.rpcProviders[s].getDefaultChain();return[s,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[n,s]=this.validateChain(t);s&&(e||this.getProvider(n).setDefaultChain(s),this.namespaces[n]?this.namespaces[n].defaultChain=s:this.namespaces[`${n}:${s}`]?this.namespaces[`${n}:${s}`].defaultChain=s:this.namespaces[`${n}:${s}`]={defaultChain:s},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",s))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,e){this.client.core.storage.setItem(`${y1}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${y1}/${t}`)}}const A9=ff,S9="wc",I9="ethereum_provider",D9=`${S9}@2:${I9}:`,x9="https://rpc.walletconnect.com/v1/",Ul=["eth_sendTransaction","personal_sign"],M9=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Bl=["chainChanged","accountsChanged"],C9=["chainChanged","accountsChanged","message","disconnect","connect"];var P9=Object.defineProperty,O9=Object.defineProperties,N9=Object.getOwnPropertyDescriptors,I1=Object.getOwnPropertySymbols,R9=Object.prototype.hasOwnProperty,T9=Object.prototype.propertyIsEnumerable,D1=(r,t,e)=>t in r?P9(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,no=(r,t)=>{for(var e in t||(t={}))R9.call(t,e)&&D1(r,e,t[e]);if(I1)for(var e of I1(t))T9.call(t,e)&&D1(r,e,t[e]);return r},fl=(r,t)=>O9(r,N9(t));function oc(r){return Number(r[0].split(":")[1])}function Fu(r){return`0x${r.toString(16)}`}function F9(r){const{chains:t,optionalChains:e,methods:n,optionalMethods:s,events:a,optionalEvents:c,rpcMap:l}=r;if(!un(t))throw new Error("Invalid chains");const d={chains:t,methods:n||Ul,events:a||Bl,rpcMap:no({},t.length?{[oc(t)]:l[oc(t)]}:{})},f=a==null?void 0:a.filter(I=>!Bl.includes(I)),w=n==null?void 0:n.filter(I=>!Ul.includes(I));if(!e&&!c&&!s&&!(f!=null&&f.length)&&!(w!=null&&w.length))return{required:t.length?d:void 0};const E=(f==null?void 0:f.length)&&(w==null?void 0:w.length)||!e,x={chains:[...new Set(E?d.chains.concat(e||[]):e)],methods:[...new Set(d.methods.concat(s!=null&&s.length?s:M9))],events:[...new Set(d.events.concat(c!=null&&c.length?c:C9))],rpcMap:l};return{required:t.length?d:void 0,optional:e.length?x:void 0}}class df{constructor(){this.events=new Di.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=D9,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new df;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,n){this.signer.sendAsync(t,e,this.formatChainId(this.chainId),n)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:e,optional:n}=F9(this.rpc);try{const s=await new Promise(async(c,l)=>{var d;this.rpc.showQrModal&&((d=this.modal)==null||d.subscribeModal(f=>{!f.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),l(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(fl(no({namespaces:no({},e&&{[this.namespace]:e})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(f=>{c(f)}).catch(f=>{l(new Error(f.message))})});if(!s)return;const a=Fd(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Fu(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(s,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(fl(no({},t),{chains:this.rpc.chains})).then(l=>{s(l)}).catch(l=>{a(new Error(l.message))})}),n=e.session;if(n){const s=Fd(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:Fu(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:e}=t,{event:n}=e;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Fu(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",fl(no({},Re("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,n;this.rpc.showQrModal&&((e=this.modal)==null||e.closeModal(),(n=this.modal)==null||n.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Fu(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,n,s]=t.split(":");return{chainId:`${e}:${n}`,address:s}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,n;const s=(e=t==null?void 0:t.chains)!=null?e:[],a=(n=t==null?void 0:t.optionalChains)!=null?n:[],c=s.concat(a);if(!c.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const l=s.length?(t==null?void 0:t.methods)||Ul:[],d=s.length?(t==null?void 0:t.events)||Bl:[],f=(t==null?void 0:t.optionalMethods)||[],w=(t==null?void 0:t.optionalEvents)||[],E=(t==null?void 0:t.rpcMap)||this.buildRpcMap(c,t.projectId),x=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(I=>this.formatChainId(I)),optionalChains:a.map(I=>this.formatChainId(I)),methods:l,events:d,optionalMethods:f,optionalEvents:w,rpcMap:E,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:x,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const n={};return t.forEach(s=>{n[s]=this.getRpcUrl(s,e)}),n}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?oc(this.rpc.chains):oc(this.rpc.optionalChains),this.signer=await A9.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:n}=await n6(()=>import("./index-d67429f9.js").then(s=>s.i),["assets/index-d67429f9.js","assets/index-92525cc1.js","assets/index-937baffd.css"]);e=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(no({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:n,rpcMap:s}=t;e&&un(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)})),n&&un(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(a=>this.formatChainId(a)),n.forEach(a=>{this.rpc.rpcMap[a]=(s==null?void 0:s[a])||this.getRpcUrl(a)}))}getRpcUrl(t,e){var n;return((n=this.rpc.rpcMap)==null?void 0:n[t])||`${x9}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(e=>this.parseAccount(e))}}const cM=df;export{cM as EthereumProvider,C9 as OPTIONAL_EVENTS,M9 as OPTIONAL_METHODS,Bl as REQUIRED_EVENTS,Ul as REQUIRED_METHODS,df as default};