metahunt/Assets/WebGLTemplates/Web3GL-2020x/assets/torus.esm-a70aabf5.js
2024-02-11 13:53:18 +05:30

17 lines
122 KiB
JavaScript

import{n as he,aZ as jn,U as Re,a_ as mi,W as Z,V as vi,a$ as mt,b0 as nt,b1 as bi,m as Un,b2 as Wr,b3 as it,b4 as wi,b5 as Xr,b6 as _i}from"./index-f9496d0e.js";function Si(e,t){if(e==null)return{};var r={},n=Object.keys(e),i,o;for(o=0;o<n.length;o++)i=n[o],!(t.indexOf(i)>=0)&&(r[i]=e[i]);return r}function Ei(e,t){if(e==null)return{};var r=Si(e,t),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function me(e){return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},me(e)}function Oi(e,t){if(me(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(me(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xn(e){var t=Oi(e,"string");return me(t)==="symbol"?t:String(t)}function P(e,t,r){return t=xn(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var dt={},Ci={get exports(){return dt},set exports(e){dt=e}};(function(e){(function(t,r){e.exports?e.exports=r():t.log=r()})(he,function(){var t=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function o(_,T){var A=_[T];if(typeof A.bind=="function")return A.bind(_);try{return Function.prototype.bind.call(A,_)}catch{return function(){return Function.prototype.apply.apply(A,[_,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(_){return _==="debug"&&(_="log"),typeof console===r?!1:_==="trace"&&n?a:console[_]!==void 0?o(console,_):console.log!==void 0?o(console,"log"):t}function d(_,T){for(var A=0;A<i.length;A++){var E=i[A];this[E]=A<_?t:this.methodFactory(E,_,T)}this.log=this.debug}function m(_,T,A){return function(){typeof console!==r&&(d.call(this,T,A),this[_].apply(this,arguments))}}function y(_,T,A){return c(_)||m.apply(this,arguments)}function p(_,T,A){var E=this,U;T=T??"WARN";var k="loglevel";typeof _=="string"?k+=":"+_:typeof _=="symbol"&&(k=void 0);function q(L){var G=(i[L]||"silent").toUpperCase();if(!(typeof window===r||!k)){try{window.localStorage[k]=G;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+G+";"}catch{}}}function j(){var L;if(!(typeof window===r||!k)){try{L=window.localStorage[k]}catch{}if(typeof L===r)try{var G=window.document.cookie,H=G.indexOf(encodeURIComponent(k)+"=");H!==-1&&(L=/^([^;]+)/.exec(G.slice(H))[1])}catch{}return E.levels[L]===void 0&&(L=void 0),L}}function V(){if(!(typeof window===r||!k)){try{window.localStorage.removeItem(k);return}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}E.name=_,E.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},E.methodFactory=A||y,E.getLevel=function(){return U},E.setLevel=function(L,G){if(typeof L=="string"&&E.levels[L.toUpperCase()]!==void 0&&(L=E.levels[L.toUpperCase()]),typeof L=="number"&&L>=0&&L<=E.levels.SILENT){if(U=L,G!==!1&&q(L),d.call(E,L,_),typeof console===r&&L<E.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+L},E.setDefaultLevel=function(L){T=L,j()||E.setLevel(L,!1)},E.resetLevel=function(){E.setLevel(T,!1),V()},E.enableAll=function(L){E.setLevel(E.levels.TRACE,L)},E.disableAll=function(L){E.setLevel(E.levels.SILENT,L)};var X=j();X==null&&(X=T),E.setLevel(X,!1)}var h=new p,b={};h.getLogger=function(T){if(typeof T!="symbol"&&typeof T!="string"||T==="")throw new TypeError("You must supply a name when creating a logger.");var A=b[T];return A||(A=b[T]=new p(T,h.getLevel(),h.methodFactory)),A};var O=typeof window!==r?window.log:void 0;return h.noConflict=function(){return typeof window!==r&&window.log===h&&(window.log=O),h},h.getLoggers=function(){return b},h.default=h,h})})(Ci);const Wn=dt;function Jr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Jr(Object(r),!0).forEach(function(n){P(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Jr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const Mr=Wn.getLogger("http-helpers");Mr.setLevel(dt.levels.INFO);let Ir="torus-default";const Ri="x-api-key";function Ai(e){Ir=e}async function Pi(e,t){let r=null;try{r=new URL(e)}catch{}return fetch(e,t)}function Ti(){const e={};return Ir&&(e[Ri]=Ir),e}function Mi(e){Mr.info("Response: ".concat(e.status," ").concat(e.statusText)),Mr.info("Url: ".concat(e.url))}const Hn=async function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const n={mode:"cors",headers:{}};r.useAPIKey&&(n.headers=Zr(Zr({},n.headers),Ti()));const i=jn(n,t,{method:"GET"}),o=await Pi(e,i);if(o.ok)return o.json();throw Mi(o),o};function We(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,xn(n.key),n)}}function He(e,t,r){return t&&Qr(e.prototype,t),r&&Qr(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Q(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ze(e,t){return Ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ze(e,t)}function Fe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ze(e,t)}function $e(e,t){if(t&&(me(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Q(e)}function re(e){return re=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},re(e)}function en(e,t,r,n,i,o,a){try{var c=e[o](a),d=c.value}catch(m){r(m);return}c.done?t(d):Promise.resolve(d).then(n,i)}function _e(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(d){en(o,n,i,a,c,"next",d)}function c(d){en(o,n,i,a,c,"throw",d)}a(void 0)})}}var Dr={},Ii={get exports(){return Dr},set exports(e){Dr=e}},Lr={},Di={get exports(){return Lr},set exports(e){Lr=e}};(function(e){function t(r){return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Di);(function(e){var t=Lr.default;function r(){e.exports=r=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var n={},i=Object.prototype,o=i.hasOwnProperty,a=Object.defineProperty||function(C,v,l){C[v]=l.value},c=typeof Symbol=="function"?Symbol:{},d=c.iterator||"@@iterator",m=c.asyncIterator||"@@asyncIterator",y=c.toStringTag||"@@toStringTag";function p(C,v,l){return Object.defineProperty(C,v,{value:l,enumerable:!0,configurable:!0,writable:!0}),C[v]}try{p({},"")}catch{p=function(l,f,g){return l[f]=g}}function h(C,v,l,f){var g=v&&v.prototype instanceof _?v:_,w=Object.create(g.prototype),M=new ne(f||[]);return a(w,"_invoke",{value:X(C,l,M)}),w}function b(C,v,l){try{return{type:"normal",arg:C.call(v,l)}}catch(f){return{type:"throw",arg:f}}}n.wrap=h;var O={};function _(){}function T(){}function A(){}var E={};p(E,d,function(){return this});var U=Object.getPrototypeOf,k=U&&U(U(se([])));k&&k!==i&&o.call(k,d)&&(E=k);var q=A.prototype=_.prototype=Object.create(E);function j(C){["next","throw","return"].forEach(function(v){p(C,v,function(l){return this._invoke(v,l)})})}function V(C,v){function l(g,w,M,I){var x=b(C[g],C,w);if(x.type!=="throw"){var F=x.arg,z=F.value;return z&&t(z)=="object"&&o.call(z,"__await")?v.resolve(z.__await).then(function(J){l("next",J,M,I)},function(J){l("throw",J,M,I)}):v.resolve(z).then(function(J){F.value=J,M(F)},function(J){return l("throw",J,M,I)})}I(x.arg)}var f;a(this,"_invoke",{value:function(w,M){function I(){return new v(function(x,F){l(w,M,x,F)})}return f=f?f.then(I,I):I()}})}function X(C,v,l){var f="suspendedStart";return function(g,w){if(f==="executing")throw new Error("Generator is already running");if(f==="completed"){if(g==="throw")throw w;return ie()}for(l.method=g,l.arg=w;;){var M=l.delegate;if(M){var I=L(M,l);if(I){if(I===O)continue;return I}}if(l.method==="next")l.sent=l._sent=l.arg;else if(l.method==="throw"){if(f==="suspendedStart")throw f="completed",l.arg;l.dispatchException(l.arg)}else l.method==="return"&&l.abrupt("return",l.arg);f="executing";var x=b(C,v,l);if(x.type==="normal"){if(f=l.done?"completed":"suspendedYield",x.arg===O)continue;return{value:x.arg,done:l.done}}x.type==="throw"&&(f="completed",l.method="throw",l.arg=x.arg)}}}function L(C,v){var l=v.method,f=C.iterator[l];if(f===void 0)return v.delegate=null,l==="throw"&&C.iterator.return&&(v.method="return",v.arg=void 0,L(C,v),v.method==="throw")||l!=="return"&&(v.method="throw",v.arg=new TypeError("The iterator does not provide a '"+l+"' method")),O;var g=b(f,C.iterator,v.arg);if(g.type==="throw")return v.method="throw",v.arg=g.arg,v.delegate=null,O;var w=g.arg;return w?w.done?(v[C.resultName]=w.value,v.next=C.nextLoc,v.method!=="return"&&(v.method="next",v.arg=void 0),v.delegate=null,O):w:(v.method="throw",v.arg=new TypeError("iterator result is not an object"),v.delegate=null,O)}function G(C){var v={tryLoc:C[0]};1 in C&&(v.catchLoc=C[1]),2 in C&&(v.finallyLoc=C[2],v.afterLoc=C[3]),this.tryEntries.push(v)}function H(C){var v=C.completion||{};v.type="normal",delete v.arg,C.completion=v}function ne(C){this.tryEntries=[{tryLoc:"root"}],C.forEach(G,this),this.reset(!0)}function se(C){if(C){var v=C[d];if(v)return v.call(C);if(typeof C.next=="function")return C;if(!isNaN(C.length)){var l=-1,f=function g(){for(;++l<C.length;)if(o.call(C,l))return g.value=C[l],g.done=!1,g;return g.value=void 0,g.done=!0,g};return f.next=f}}return{next:ie}}function ie(){return{value:void 0,done:!0}}return T.prototype=A,a(q,"constructor",{value:A,configurable:!0}),a(A,"constructor",{value:T,configurable:!0}),T.displayName=p(A,y,"GeneratorFunction"),n.isGeneratorFunction=function(C){var v=typeof C=="function"&&C.constructor;return!!v&&(v===T||(v.displayName||v.name)==="GeneratorFunction")},n.mark=function(C){return Object.setPrototypeOf?Object.setPrototypeOf(C,A):(C.__proto__=A,p(C,y,"GeneratorFunction")),C.prototype=Object.create(q),C},n.awrap=function(C){return{__await:C}},j(V.prototype),p(V.prototype,m,function(){return this}),n.AsyncIterator=V,n.async=function(C,v,l,f,g){g===void 0&&(g=Promise);var w=new V(h(C,v,l,f),g);return n.isGeneratorFunction(v)?w:w.next().then(function(M){return M.done?M.value:w.next()})},j(q),p(q,y,"Generator"),p(q,d,function(){return this}),p(q,"toString",function(){return"[object Generator]"}),n.keys=function(C){var v=Object(C),l=[];for(var f in v)l.push(f);return l.reverse(),function g(){for(;l.length;){var w=l.pop();if(w in v)return g.value=w,g.done=!1,g}return g.done=!0,g}},n.values=se,ne.prototype={constructor:ne,reset:function(v){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(H),!v)for(var l in this)l.charAt(0)==="t"&&o.call(this,l)&&!isNaN(+l.slice(1))&&(this[l]=void 0)},stop:function(){this.done=!0;var v=this.tryEntries[0].completion;if(v.type==="throw")throw v.arg;return this.rval},dispatchException:function(v){if(this.done)throw v;var l=this;function f(F,z){return M.type="throw",M.arg=v,l.next=F,z&&(l.method="next",l.arg=void 0),!!z}for(var g=this.tryEntries.length-1;g>=0;--g){var w=this.tryEntries[g],M=w.completion;if(w.tryLoc==="root")return f("end");if(w.tryLoc<=this.prev){var I=o.call(w,"catchLoc"),x=o.call(w,"finallyLoc");if(I&&x){if(this.prev<w.catchLoc)return f(w.catchLoc,!0);if(this.prev<w.finallyLoc)return f(w.finallyLoc)}else if(I){if(this.prev<w.catchLoc)return f(w.catchLoc,!0)}else{if(!x)throw new Error("try statement without catch or finally");if(this.prev<w.finallyLoc)return f(w.finallyLoc)}}}},abrupt:function(v,l){for(var f=this.tryEntries.length-1;f>=0;--f){var g=this.tryEntries[f];if(g.tryLoc<=this.prev&&o.call(g,"finallyLoc")&&this.prev<g.finallyLoc){var w=g;break}}w&&(v==="break"||v==="continue")&&w.tryLoc<=l&&l<=w.finallyLoc&&(w=null);var M=w?w.completion:{};return M.type=v,M.arg=l,w?(this.method="next",this.next=w.finallyLoc,O):this.complete(M)},complete:function(v,l){if(v.type==="throw")throw v.arg;return v.type==="break"||v.type==="continue"?this.next=v.arg:v.type==="return"?(this.rval=this.arg=v.arg,this.method="return",this.next="end"):v.type==="normal"&&l&&(this.next=l),O},finish:function(v){for(var l=this.tryEntries.length-1;l>=0;--l){var f=this.tryEntries[l];if(f.finallyLoc===v)return this.complete(f.completion,f.afterLoc),H(f),O}},catch:function(v){for(var l=this.tryEntries.length-1;l>=0;--l){var f=this.tryEntries[l];if(f.tryLoc===v){var g=f.completion;if(g.type==="throw"){var w=g.arg;H(f)}return w}}throw new Error("illegal catch attempt")},delegateYield:function(v,l,f){return this.delegate={iterator:se(v),resultName:l,nextLoc:f},this.method==="next"&&(this.arg=void 0),O}},n}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports})(Ii);var ut=Dr(),ee=ut;try{regeneratorRuntime=ut}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ut:Function("r","regeneratorRuntime = r")(ut)}function Li(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Ni(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function lt(e,t,r){return Ni()?lt=Reflect.construct.bind():lt=function(i,o,a){var c=[null];c.push.apply(c,o);var d=Function.bind.apply(i,c),m=new d;return a&&Ze(m,a.prototype),m},lt.apply(null,arguments)}function Nr(e){var t=typeof Map=="function"?new Map:void 0;return Nr=function(n){if(n===null||!Li(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return lt(n,arguments,re(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ze(i,n)},Nr(e)}var tn={},ki={get exports(){return tn},set exports(e){tn=e}},Hr={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});function Bi(e){var t=4,r=e.length,n=r%t;if(!n)return e;var i=r,o=t-n,a=r+o,c=Re.Buffer.alloc(a);for(c.write(e);o--;)c.write("=",i++);return c.toString()}Fr.default=Bi;Object.defineProperty(Hr,"__esModule",{value:!0});var ji=Fr;function Fn(e,t){return t===void 0&&(t="utf8"),Re.Buffer.isBuffer(e)?kr(e.toString("base64")):kr(Re.Buffer.from(e,t).toString("base64"))}function Ui(e,t){return t===void 0&&(t="utf8"),Re.Buffer.from($r(e),"base64").toString(t)}function $r(e){return e=e.toString(),ji.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function kr(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function xi(e){return Re.Buffer.from($r(e),"base64")}var qe=Fn;qe.encode=Fn;qe.decode=Ui;qe.toBase64=$r;qe.fromBase64=kr;qe.toBuffer=xi;Hr.default=qe;(function(e){e.exports=Hr.default,e.exports.default=e.exports})(ki);var $n={};const rn=[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];$n.p1600=function(e){for(let t=0;t<24;++t){const r=e[0]^e[10]^e[20]^e[30]^e[40],n=e[1]^e[11]^e[21]^e[31]^e[41],i=e[2]^e[12]^e[22]^e[32]^e[42],o=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],d=e[6]^e[16]^e[26]^e[36]^e[46],m=e[7]^e[17]^e[27]^e[37]^e[47],y=e[8]^e[18]^e[28]^e[38]^e[48],p=e[9]^e[19]^e[29]^e[39]^e[49];let h=y^(i<<1|o>>>31),b=p^(o<<1|i>>>31);const O=e[0]^h,_=e[1]^b,T=e[10]^h,A=e[11]^b,E=e[20]^h,U=e[21]^b,k=e[30]^h,q=e[31]^b,j=e[40]^h,V=e[41]^b;h=r^(a<<1|c>>>31),b=n^(c<<1|a>>>31);const X=e[2]^h,L=e[3]^b,G=e[12]^h,H=e[13]^b,ne=e[22]^h,se=e[23]^b,ie=e[32]^h,C=e[33]^b,v=e[42]^h,l=e[43]^b;h=i^(d<<1|m>>>31),b=o^(m<<1|d>>>31);const f=e[4]^h,g=e[5]^b,w=e[14]^h,M=e[15]^b,I=e[24]^h,x=e[25]^b,F=e[34]^h,z=e[35]^b,J=e[44]^h,s=e[45]^b;h=a^(y<<1|p>>>31),b=c^(p<<1|y>>>31);const u=e[6]^h,S=e[7]^b,R=e[16]^h,B=e[17]^b,D=e[26]^h,N=e[27]^b,we=e[36]^h,Pe=e[37]^b,Ve=e[46]^h,at=e[47]^b;h=d^(r<<1|n>>>31),b=m^(n<<1|r>>>31);const Te=e[8]^h,Ge=e[9]^b,Me=e[18]^h,Ie=e[19]^b,De=e[28]^h,ge=e[29]^b,fe=e[38]^h,ye=e[39]^b,zr=e[48]^h,Yr=e[49]^b,Pt=O,Tt=_,Mt=A<<4|T>>>28,It=T<<4|A>>>28,Dt=E<<3|U>>>29,Lt=U<<3|E>>>29,Nt=q<<9|k>>>23,kt=k<<9|q>>>23,Bt=j<<18|V>>>14,jt=V<<18|j>>>14,Ut=X<<1|L>>>31,xt=L<<1|X>>>31,Wt=H<<12|G>>>20,Ht=G<<12|H>>>20,Ft=ne<<10|se>>>22,$t=se<<10|ne>>>22,qt=C<<13|ie>>>19,Kt=ie<<13|C>>>19,Vt=v<<2|l>>>30,Gt=l<<2|v>>>30,zt=g<<30|f>>>2,Yt=f<<30|g>>>2,Xt=w<<6|M>>>26,Jt=M<<6|w>>>26,Zt=x<<11|I>>>21,Qt=I<<11|x>>>21,er=F<<15|z>>>17,tr=z<<15|F>>>17,rr=s<<29|J>>>3,nr=J<<29|s>>>3,ir=u<<28|S>>>4,or=S<<28|u>>>4,ar=B<<23|R>>>9,sr=R<<23|B>>>9,ur=D<<25|N>>>7,lr=N<<25|D>>>7,cr=we<<21|Pe>>>11,fr=Pe<<21|we>>>11,dr=at<<24|Ve>>>8,hr=Ve<<24|at>>>8,pr=Te<<27|Ge>>>5,gr=Ge<<27|Te>>>5,yr=Me<<20|Ie>>>12,mr=Ie<<20|Me>>>12,vr=ge<<7|De>>>25,br=De<<7|ge>>>25,wr=fe<<8|ye>>>24,_r=ye<<8|fe>>>24,Sr=zr<<14|Yr>>>18,Er=Yr<<14|zr>>>18;e[0]=Pt^~Wt&Zt,e[1]=Tt^~Ht&Qt,e[10]=ir^~yr&Dt,e[11]=or^~mr&Lt,e[20]=Ut^~Xt&ur,e[21]=xt^~Jt&lr,e[30]=pr^~Mt&Ft,e[31]=gr^~It&$t,e[40]=zt^~ar&vr,e[41]=Yt^~sr&br,e[2]=Wt^~Zt&cr,e[3]=Ht^~Qt&fr,e[12]=yr^~Dt&qt,e[13]=mr^~Lt&Kt,e[22]=Xt^~ur&wr,e[23]=Jt^~lr&_r,e[32]=Mt^~Ft&er,e[33]=It^~$t&tr,e[42]=ar^~vr&Nt,e[43]=sr^~br&kt,e[4]=Zt^~cr&Sr,e[5]=Qt^~fr&Er,e[14]=Dt^~qt&rr,e[15]=Lt^~Kt&nr,e[24]=ur^~wr&Bt,e[25]=lr^~_r&jt,e[34]=Ft^~er&dr,e[35]=$t^~tr&hr,e[44]=vr^~Nt&Vt,e[45]=br^~kt&Gt,e[6]=cr^~Sr&Pt,e[7]=fr^~Er&Tt,e[16]=qt^~rr&ir,e[17]=Kt^~nr&or,e[26]=wr^~Bt&Ut,e[27]=_r^~jt&xt,e[36]=er^~dr&pr,e[37]=tr^~hr&gr,e[46]=Nt^~Vt&zt,e[47]=kt^~Gt&Yt,e[8]=Sr^~Pt&Wt,e[9]=Er^~Tt&Ht,e[18]=rr^~ir&yr,e[19]=nr^~or&mr,e[28]=Bt^~Ut&Xt,e[29]=jt^~xt&Jt,e[38]=dr^~pr&Mt,e[39]=hr^~gr&It,e[48]=Vt^~zt&ar,e[49]=Gt^~Yt&sr,e[0]^=rn[t*2],e[1]^=rn[t*2+1]}};const ht=$n;function ot(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}ot.prototype.initialize=function(e,t){for(let r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1};ot.prototype.absorb=function(e){for(let t=0;t<e.length;++t)this.state[~~(this.count/4)]^=e[t]<<8*(this.count%4),this.count+=1,this.count===this.blockSize&&(ht.p1600(this.state),this.count=0)};ot.prototype.absorbLastFewBits=function(e){this.state[~~(this.count/4)]^=e<<8*(this.count%4),e&128&&this.count===this.blockSize-1&&ht.p1600(this.state),this.state[~~((this.blockSize-1)/4)]^=128<<8*((this.blockSize-1)%4),ht.p1600(this.state),this.count=0,this.squeezing=!0};ot.prototype.squeeze=function(e){this.squeezing||this.absorbLastFewBits(1);const t=Re.Buffer.alloc(e);for(let r=0;r<e;++r)t[r]=this.state[~~(this.count/4)]>>>8*(this.count%4)&255,this.count+=1,this.count===this.blockSize&&(ht.p1600(this.state),this.count=0);return t};ot.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing};var Wi=function(){return mi(32).toString("hex")},qn=Qe;Qe.default=Qe;Qe.stable=Gn;Qe.stableStringify=Gn;var pt="[...]",Kn="[Circular]",Ae=[],Ce=[];function Vn(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Qe(e,t,r,n){typeof n>"u"&&(n=Vn()),Br(e,"",0,[],void 0,0,n);var i;try{Ce.length===0?i=JSON.stringify(e,t,r):i=JSON.stringify(e,zn(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ae.length!==0;){var o=Ae.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function Ne(e,t,r,n){var i=Object.getOwnPropertyDescriptor(n,r);i.get!==void 0?i.configurable?(Object.defineProperty(n,r,{value:e}),Ae.push([n,r,t,i])):Ce.push([t,r,e]):(n[r]=e,Ae.push([n,r,t]))}function Br(e,t,r,n,i,o,a){o+=1;var c;if(typeof e=="object"&&e!==null){for(c=0;c<n.length;c++)if(n[c]===e){Ne(Kn,e,t,i);return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){Ne(pt,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){Ne(pt,e,t,i);return}if(n.push(e),Array.isArray(e))for(c=0;c<e.length;c++)Br(e[c],c,c,n,e,o,a);else{var d=Object.keys(e);for(c=0;c<d.length;c++){var m=d[c];Br(e[m],m,c,n,e,o,a)}}n.pop()}}function Hi(e,t){return e<t?-1:e>t?1:0}function Gn(e,t,r,n){typeof n>"u"&&(n=Vn());var i=jr(e,"",0,[],void 0,0,n)||e,o;try{Ce.length===0?o=JSON.stringify(i,t,r):o=JSON.stringify(i,zn(t),r)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Ae.length!==0;){var a=Ae.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function jr(e,t,r,n,i,o,a){o+=1;var c;if(typeof e=="object"&&e!==null){for(c=0;c<n.length;c++)if(n[c]===e){Ne(Kn,e,t,i);return}try{if(typeof e.toJSON=="function")return}catch{return}if(typeof a.depthLimit<"u"&&o>a.depthLimit){Ne(pt,e,t,i);return}if(typeof a.edgesLimit<"u"&&r+1>a.edgesLimit){Ne(pt,e,t,i);return}if(n.push(e),Array.isArray(e))for(c=0;c<e.length;c++)jr(e[c],c,c,n,e,o,a);else{var d={},m=Object.keys(e).sort(Hi);for(c=0;c<m.length;c++){var y=m[c];jr(e[y],y,c,n,e,o,a),d[y]=e[y]}if(typeof i<"u")Ae.push([i,t,e]),i[t]=d;else return d}n.pop()}}function zn(e){return e=typeof e<"u"?e:function(t,r){return r},function(t,r){if(Ce.length>0)for(var n=0;n<Ce.length;n++){var i=Ce[n];if(i[1]===t&&i[0]===r){r=i[2],Ce.splice(n,1);break}}return e.call(this,t,r)}}function Fi(e){if(Array.isArray(e))return e}function $i(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,a,c=[],d=!0,m=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;d=!1}else for(;!(d=(n=o.call(r)).done)&&(c.push(n.value),c.length!==t);d=!0);}catch(y){m=!0,i=y}finally{try{if(!d&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(m)throw i}}return c}}function nn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function qi(e,t){if(e){if(typeof e=="string")return nn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return nn(e,t)}}function Ki(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Or(e,t){return Fi(e)||$i(e,t)||qi(e,t)||Ki()}var de={},ve={};Object.defineProperty(ve,"__esModule",{value:!0});ve.EthereumProviderError=ve.EthereumRpcError=void 0;const Vi=qn;class Yn extends Error{constructor(t,r,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=t,n!==void 0&&(this.data=n)}serialize(){const t={code:this.code,message:this.message};return this.data!==void 0&&(t.data=this.data),this.stack&&(t.stack=this.stack),t}toString(){return Vi.default(this.serialize(),Yi,2)}}ve.EthereumRpcError=Yn;class Gi extends Yn{constructor(t,r,n){if(!zi(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,r,n)}}ve.EthereumProviderError=Gi;function zi(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}function Yi(e,t){if(t!=="[Circular]")return t}var qr={},be={};Object.defineProperty(be,"__esModule",{value:!0});be.errorValues=be.errorCodes=void 0;be.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};be.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=be,r=ve,n=t.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",o={code:n,message:a(n)};e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.";function a(h,b=i){if(Number.isInteger(h)){const O=h.toString();if(p(t.errorValues,O))return t.errorValues[O].message;if(m(h))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return b}e.getMessageFromCode=a;function c(h){if(!Number.isInteger(h))return!1;const b=h.toString();return!!(t.errorValues[b]||m(h))}e.isValidCode=c;function d(h,{fallbackError:b=o,shouldIncludeStack:O=!1}={}){var _,T;if(!b||!Number.isInteger(b.code)||typeof b.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(h instanceof r.EthereumRpcError)return h.serialize();const A={};if(h&&typeof h=="object"&&!Array.isArray(h)&&p(h,"code")&&c(h.code)){const U=h;A.code=U.code,U.message&&typeof U.message=="string"?(A.message=U.message,p(U,"data")&&(A.data=U.data)):(A.message=a(A.code),A.data={originalError:y(h)})}else{A.code=b.code;const U=(_=h)===null||_===void 0?void 0:_.message;A.message=U&&typeof U=="string"?U:b.message,A.data={originalError:y(h)}}const E=(T=h)===null||T===void 0?void 0:T.stack;return O&&h&&E&&typeof E=="string"&&(A.stack=E),A}e.serializeError=d;function m(h){return h>=-32099&&h<=-32e3}function y(h){return h&&typeof h=="object"&&!Array.isArray(h)?Object.assign({},h):h}function p(h,b){return Object.prototype.hasOwnProperty.call(h,b)}})(qr);var vt={};Object.defineProperty(vt,"__esModule",{value:!0});vt.ethErrors=void 0;const Kr=ve,Xn=qr,te=be;vt.ethErrors={rpc:{parse:e=>oe(te.errorCodes.rpc.parse,e),invalidRequest:e=>oe(te.errorCodes.rpc.invalidRequest,e),invalidParams:e=>oe(te.errorCodes.rpc.invalidParams,e),methodNotFound:e=>oe(te.errorCodes.rpc.methodNotFound,e),internal:e=>oe(te.errorCodes.rpc.internal,e),server:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return oe(t,e)},invalidInput:e=>oe(te.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>oe(te.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>oe(te.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>oe(te.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>oe(te.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>oe(te.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>ze(te.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>ze(te.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>ze(te.errorCodes.provider.unsupportedMethod,e),disconnected:e=>ze(te.errorCodes.provider.disconnected,e),chainDisconnected:e=>ze(te.errorCodes.provider.chainDisconnected,e),custom:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:r,data:n}=e;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new Kr.EthereumProviderError(t,r,n)}}};function oe(e,t){const[r,n]=Jn(t);return new Kr.EthereumRpcError(e,r||Xn.getMessageFromCode(e),n)}function ze(e,t){const[r,n]=Jn(t);return new Kr.EthereumProviderError(e,r||Xn.getMessageFromCode(e),n)}function Jn(e){if(e){if(typeof e=="string")return[e];if(typeof e=="object"&&!Array.isArray(e)){const{message:t,data:r}=e;if(t&&typeof t!="string")throw new Error("Must specify string message.");return[t||void 0,r]}}return[]}(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;const t=ve;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});const r=qr;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=vt;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=be;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(de);var ke={},Xi={get exports(){return ke},set exports(e){ke=e}},Ji=Zn;function Zn(e,t){if(e&&t)return Zn(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){r[n]=e[n]}),r;function r(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];var o=e.apply(this,n),a=n[n.length-1];return typeof o=="function"&&o!==a&&Object.keys(a).forEach(function(c){o[c]=a[c]}),o}}var Qn=Ji;Xi.exports=Qn(ct);ke.strict=Qn(ei);ct.proto=ct(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return ct(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return ei(this)},configurable:!0})});function ct(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function ei(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}var Zi=ke,Qi=function(){},eo=function(e){return e.setHeader&&typeof e.abort=="function"},to=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3},ti=function(e,t,r){if(typeof t=="function")return ti(e,null,t);t||(t={}),r=Zi(r||Qi);var n=e._writableState,i=e._readableState,o=t.readable||t.readable!==!1&&e.readable,a=t.writable||t.writable!==!1&&e.writable,c=!1,d=function(){e.writable||m()},m=function(){a=!1,o||r.call(e)},y=function(){o=!1,a||r.call(e)},p=function(T){r.call(e,T?new Error("exited with error code: "+T):null)},h=function(T){r.call(e,T)},b=function(){Z.nextTick(O)},O=function(){if(!c){if(o&&!(i&&i.ended&&!i.destroyed))return r.call(e,new Error("premature close"));if(a&&!(n&&n.ended&&!n.destroyed))return r.call(e,new Error("premature close"))}},_=function(){e.req.on("finish",m)};return eo(e)?(e.on("complete",m),e.on("abort",b),e.req?_():e.on("request",_)):a&&!n&&(e.on("end",d),e.on("close",d)),to(e)&&e.on("exit",p),e.on("end",y),e.on("finish",m),t.error!==!1&&e.on("error",h),e.on("close",b),function(){c=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",_),e.req&&e.req.removeListener("finish",m),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("exit",p),e.removeListener("end",y),e.removeListener("error",h),e.removeListener("close",b)}},Ur=ti,ro=null;const no=Object.freeze(Object.defineProperty({__proto__:null,default:ro},Symbol.toStringTag,{value:"Module"})),io=vi(no);var oo=ke,ao=Ur,Cr=io,et=function(){},so=/^v?\.0/.test(Z.version),bt=function(e){return typeof e=="function"},uo=function(e){return!so||!Cr?!1:(e instanceof(Cr.ReadStream||et)||e instanceof(Cr.WriteStream||et))&&bt(e.close)},lo=function(e){return e.setHeader&&bt(e.abort)},co=function(e,t,r,n){n=oo(n);var i=!1;e.on("close",function(){i=!0}),ao(e,{readable:t,writable:r},function(a){if(a)return n(a);i=!0,n()});var o=!1;return function(a){if(!i&&!o){if(o=!0,uo(e))return e.close(et);if(lo(e))return e.abort();if(bt(e.destroy))return e.destroy();n(a||new Error("stream was destroyed"))}}},on=function(e){e()},fo=function(e,t){return e.pipe(t)},ho=function(){var e=Array.prototype.slice.call(arguments),t=bt(e[e.length-1]||et)&&e.pop()||et;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error("pump requires two streams per minimum");var r,n=e.map(function(i,o){var a=o<e.length-1,c=o>0;return co(i,a,c,function(d){r||(r=d),d&&n.forEach(on),!a&&(n.forEach(on),t(r))})});return e.reduce(fo)},ft=ho;function po(e){var t=go();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return $e(this,i)}}function go(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function st(){}var an="SYN",Rr="ACK",sn="BRK",un=function(e){Fe(r,e);var t=po(r);function r(n){var i,o=n.name,a=n.target,c=n.targetWindow,d=c===void 0?window:c,m=n.targetOrigin,y=m===void 0?"*":m;if(We(this,r),i=t.call(this,{objectMode:!0}),P(Q(i),"_init",void 0),P(Q(i),"_haveSyn",void 0),P(Q(i),"_name",void 0),P(Q(i),"_target",void 0),P(Q(i),"_targetWindow",void 0),P(Q(i),"_targetOrigin",void 0),P(Q(i),"_onMessage",void 0),P(Q(i),"_synIntervalId",void 0),!o||!a)throw new Error("Invalid input.");return i._init=!1,i._haveSyn=!1,i._name=o,i._target=a,i._targetWindow=d,i._targetOrigin=y,i._onMessage=i.onMessage.bind(Q(i)),i._synIntervalId=null,window.addEventListener("message",i._onMessage,!1),i._handShake(),i}return He(r,[{key:"_break",value:function(){this.cork(),this._write(sn,null,st),this._haveSyn=!1,this._init=!1}},{key:"_handShake",value:function(){this._write(an,null,st),this.cork()}},{key:"_onData",value:function(i){if(!this._init)i===an?(this._haveSyn=!0,this._write(Rr,null,st)):i===Rr&&(this._init=!0,this._haveSyn||this._write(Rr,null,st),this.uncork());else if(i===sn)this._break();else try{this.push(i)}catch(o){this.emit("error",o)}}},{key:"_postMessage",value:function(i){var o=this._targetOrigin;this._targetWindow.postMessage({target:this._target,data:i},o)}},{key:"onMessage",value:function(i){var o=i.data;this._targetOrigin!=="*"&&i.origin!==this._targetOrigin||i.source!==this._targetWindow||me(o)!=="object"||o.target!==this._name||!o.data||this._onData(o.data)}},{key:"_read",value:function(){}},{key:"_write",value:function(i,o,a){this._postMessage(i),a()}},{key:"_destroy",value:function(){window.removeEventListener("message",this._onMessage,!1)}}]),r}(mt.Duplex);function yo(e){var t=mo();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return $e(this,i)}}function mo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ln(e,t,r){try{Reflect.apply(e,t,r)}catch(n){setTimeout(function(){throw n})}}function vo(e){for(var t=e.length,r=new Array(t),n=0;n<t;n+=1)r[n]=e[n];return r}var wt=function(e){Fe(r,e);var t=yo(r);function r(){return We(this,r),t.apply(this,arguments)}return He(r,[{key:"emit",value:function(i){var o=i==="error",a=this._events;if(a!==void 0)o=o&&a.error===void 0;else if(!o)return!1;for(var c=arguments.length,d=new Array(c>1?c-1:0),m=1;m<c;m++)d[m-1]=arguments[m];if(o){var y;if(d.length>0&&(y=d[0]),y instanceof Error)throw y;var p=new Error("Unhandled error.".concat(y?" (".concat(y.message,")"):""));throw p.context=y,p}var h=a[i];if(h===void 0)return!1;if(typeof h=="function")ln(h,this,d);else for(var b=h.length,O=vo(h),_=0;_<b;_+=1)ln(O[_],this,d);return!0}}]),r}(nt.EventEmitter);function bo(e){var t=wo();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return $e(this,i)}}function wo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=function(e){Fe(r,e);var t=bo(r);function r(n){var i,o=n.code,a=n.message,c=n.data;if(We(this,r),!Number.isInteger(o))throw new Error("code must be an integer");if(!a||typeof a!="string")throw new Error("message must be string");return i=t.call(this,a),P(Q(i),"code",void 0),P(Q(i),"data",void 0),i.code=o,c!==void 0&&(i.data=c),i}return He(r,[{key:"toString",value:function(){return qn({code:this.code,message:this.message,data:this.data,stack:this.stack})}}]),r}(Nr(Error));function _o(){var e={};function t(){return!1}var r=new wt;function n(d){var m=e[d.id];if(!m)throw new Error('StreamMiddleware - Unknown response id "'.concat(d.id,'"'));delete e[d.id],Object.assign(m.res,d),setTimeout(m.end)}function i(d){r.emit("notification",d)}function o(d,m,y){var p;try{var h=!d.id;h?i(d):n(d)}catch(b){p=b}y(p)}var a=new mt.Duplex({objectMode:!0,read:t,write:o}),c=function(m,y,p,h){a.push(m),e[m.id]={req:m,res:y,next:p,end:h}};return{events:r,middleware:c,stream:a}}function So(){return function(e,t,r,n){var i=e.id,o=Wi();e.id=o,t.id=o,r(function(a){e.id=i,t.id=i,a()})}}function cn(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Eo(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(m){throw m},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,c;return{s:function(){r=r.call(e)},n:function(){var m=r.next();return o=m.done,m},e:function(m){a=!0,c=m},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(a)throw c}}}}function Eo(e,t){if(e){if(typeof e=="string")return fn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fn(e,t)}}function fn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function dn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Oo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dn(Object(r),!0).forEach(function(n){P(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Co(e){var t=Ro();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return $e(this,i)}}function Ro(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ao=function(e){Fe(r,e);var t=Co(r);function r(){var n;return We(this,r),n=t.call(this),P(Q(n),"_middleware",void 0),n._middleware=[],n}return He(r,[{key:"push",value:function(i){this._middleware.push(i)}},{key:"handle",value:function(i,o){if(o&&typeof o!="function")throw new Error('"callback" must be a function if provided.');return Array.isArray(i)?o?this._handleBatch(i,o):this._handleBatch(i):o?this._handle(i,o):this._promiseHandle(i)}},{key:"asMiddleware",value:function(){var i=this;return function(){var o=_e(ee.mark(function a(c,d,m,y){var p,h,b,O,_;return ee.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.prev=0,A.next=3,r._runAllMiddleware(c,d,i._middleware);case 3:if(p=A.sent,h=Or(p,3),b=h[0],O=h[1],_=h[2],!O){A.next=12;break}return A.next=11,r._runReturnHandlers(_);case 11:return A.abrupt("return",y(b));case 12:return A.abrupt("return",m(function(){var E=_e(ee.mark(function U(k){return ee.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return j.prev=0,j.next=3,r._runReturnHandlers(_);case 3:j.next=8;break;case 5:return j.prev=5,j.t0=j.catch(0),j.abrupt("return",k(j.t0));case 8:return j.abrupt("return",k());case 9:case"end":return j.stop()}},U,null,[[0,5]])}));return function(U){return E.apply(this,arguments)}}()));case 15:return A.prev=15,A.t0=A.catch(0),A.abrupt("return",y(A.t0));case 18:case"end":return A.stop()}},a,null,[[0,15]])}));return function(a,c,d,m){return o.apply(this,arguments)}}()}},{key:"_handleBatch",value:function(){var n=_e(ee.mark(function o(a,c){var d;return ee.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.prev=0,y.next=3,Promise.all(a.map(this._promiseHandle.bind(this)));case 3:if(d=y.sent,!c){y.next=6;break}return y.abrupt("return",c(null,d));case 6:return y.abrupt("return",d);case 9:if(y.prev=9,y.t0=y.catch(0),!c){y.next=13;break}return y.abrupt("return",c(y.t0));case 13:throw y.t0;case 14:case"end":return y.stop()}},o,this,[[0,9]])}));function i(o,a){return n.apply(this,arguments)}return i}()},{key:"_promiseHandle",value:function(i){var o=this;return new Promise(function(a){o._handle(i,function(c,d){a(d)})})}},{key:"_handle",value:function(){var n=_e(ee.mark(function o(a,c){var d,m,y,p,h;return ee.wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(!(!a||Array.isArray(a)||me(a)!=="object")){O.next=3;break}return d=new Ye({code:-32603,message:"request must be plain object"}),O.abrupt("return",c(d,{id:void 0,jsonrpc:"2.0",error:d}));case 3:if(typeof a.method=="string"){O.next=6;break}return m=new Ye({code:-32603,message:"method must be string"}),O.abrupt("return",c(m,{id:a.id,jsonrpc:"2.0",error:m}));case 6:return y=Oo({},a),p={id:y.id,jsonrpc:y.jsonrpc},h=null,O.prev=9,O.next=12,this._processRequest(y,p);case 12:O.next=17;break;case 14:O.prev=14,O.t0=O.catch(9),h=O.t0;case 17:return h&&(delete p.result,p.error||(p.error=de.serializeError(h))),O.abrupt("return",c(h,p));case 19:case"end":return O.stop()}},o,this,[[9,14]])}));function i(o,a){return n.apply(this,arguments)}return i}()},{key:"_processRequest",value:function(){var n=_e(ee.mark(function o(a,c){var d,m,y,p,h;return ee.wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return O.next=2,r._runAllMiddleware(a,c,this._middleware);case 2:return d=O.sent,m=Or(d,3),y=m[0],p=m[1],h=m[2],r._checkForCompletion(a,c,p),O.next=10,r._runReturnHandlers(h);case 10:if(!y){O.next=12;break}throw y;case 12:case"end":return O.stop()}},o,this)}));function i(o,a){return n.apply(this,arguments)}return i}()}],[{key:"_runAllMiddleware",value:function(){var n=_e(ee.mark(function o(a,c,d){var m,y,p,h,b,O,_,T;return ee.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:m=[],y=null,p=!1,h=cn(d),E.prev=4,h.s();case 6:if((b=h.n()).done){E.next=18;break}return O=b.value,E.next=10,r._runMiddleware(a,c,O,m);case 10:if(_=E.sent,T=Or(_,2),y=T[0],p=T[1],!p){E.next=16;break}return E.abrupt("break",18);case 16:E.next=6;break;case 18:E.next=23;break;case 20:E.prev=20,E.t0=E.catch(4),h.e(E.t0);case 23:return E.prev=23,h.f(),E.finish(23);case 26:return E.abrupt("return",[y,p,m.reverse()]);case 27:case"end":return E.stop()}},o,null,[[4,20,23,26]])}));function i(o,a,c){return n.apply(this,arguments)}return i}()},{key:"_runMiddleware",value:function(i,o,a,c){return new Promise(function(d){var m=function(h){var b=h||o.error;b&&(o.error=de.serializeError(b)),d([b,!0])},y=function(h){o.error?m(o.error):(h&&(typeof h!="function"&&m(new Ye({code:-32603,message:"JRPCEngine: 'next' return handlers must be functions"})),c.push(h)),d([null,!1]))};try{a(i,o,y,m)}catch(p){m(p)}})}},{key:"_runReturnHandlers",value:function(){var n=_e(ee.mark(function o(a){var c,d,m;return ee.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:c=cn(a),p.prev=1,m=ee.mark(function h(){var b;return ee.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return b=d.value,_.next=3,new Promise(function(T,A){b(function(E){return E?A(E):T()})});case 3:case"end":return _.stop()}},h)}),c.s();case 4:if((d=c.n()).done){p.next=8;break}return p.delegateYield(m(),"t0",6);case 6:p.next=4;break;case 8:p.next=13;break;case 10:p.prev=10,p.t1=p.catch(1),c.e(p.t1);case 13:return p.prev=13,c.f(),p.finish(13);case 16:case"end":return p.stop()}},o,null,[[1,10,13,16]])}));function i(o){return n.apply(this,arguments)}return i}()},{key:"_checkForCompletion",value:function(i,o,a){if(!("result"in o)&&!("error"in o))throw new Ye({code:-32603,message:"Response has no error or result for request"});if(!a)throw new Ye({code:-32603,message:"Nothing ended request"})}}]),r}(wt);function Po(e){var t=To();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return $e(this,i)}}function To(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Mo=function(e){Fe(r,e);var t=Po(r);function r(n){var i,o=n.parent,a=n.name;return We(this,r),i=t.call(this,{objectMode:!0}),P(Q(i),"_parent",void 0),P(Q(i),"_name",void 0),i._parent=o,i._name=a,i}return He(r,[{key:"_read",value:function(){}},{key:"_write",value:function(i,o,a){this._parent.push({name:this._name,data:i}),a()}}]),r}(mt.Duplex);function hn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function pn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?hn(Object(r),!0).forEach(function(n){P(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Io(e){var t=Do();return function(){var n=re(e),i;if(t){var o=re(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return $e(this,i)}}function Do(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var gn=Symbol("IGNORE_SUBSTREAM"),ri=function(e){Fe(r,e);var t=Io(r);function r(){var n,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return We(this,r),n=t.call(this,pn(pn({},i),{},{objectMode:!0})),P(Q(n),"_substreams",void 0),P(Q(n),"getStream",void 0),n._substreams={},n}return He(r,[{key:"createStream",value:function(i){if(!i)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[i])throw new Error('ObjectMultiplex - Substream for name "'.concat(i,'" already exists'));var o=new Mo({parent:this,name:i});return this._substreams[i]=o,Lo(this,function(a){return o.destroy(a||void 0)}),o}},{key:"ignoreStream",value:function(i){if(!i)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[i])throw new Error('ObjectMultiplex - Substream for name "'.concat(i,'" already exists'));this._substreams[i]=gn}},{key:"_read",value:function(){}},{key:"_write",value:function(i,o,a){var c=i.name,d=i.data;if(!c)return window.console.warn('ObjectMultiplex - malformed chunk without name "'.concat(i,'"')),a();var m=this._substreams[c];return m?(m!==gn&&m.push(d),a()):(window.console.warn('ObjectMultiplex - orphaned data for stream "'.concat(c,'"')),a())}}]),r}(mt.Duplex);function Lo(e,t){var r=ke(t);Ur(e,{readable:!1},r),Ur(e,{writable:!1},r)}function No(e){var t=new ri;return t.getStream=function(n){return this._substreams[n]?this._substreams[n]:this.createStream(n)},ft(e,t,e,function(r){r&&window.console.error(r)}),t}var xr={},_t={};Object.defineProperty(_t,"__esModule",{value:!0});_t.storeAsStream=void 0;const ko=bi;class Bo extends ko.Duplex{constructor(t){super({objectMode:!0}),this.resume(),this.handler=r=>this.push(r),this.obsStore=t,this.obsStore.subscribe(this.handler)}pipe(t,r){const n=super.pipe(t,r);return t.write(this.obsStore.getState()),n}_write(t,r,n){this.obsStore.putState(t),n()}_read(t){}_destroy(t,r){this.obsStore.unsubscribe(this.handler),super._destroy(t,r)}}function jo(e){return new Bo(e)}_t.storeAsStream=jo;var St={},Ke={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});const Uo=nt;function yn(e,t,r){try{Reflect.apply(e,t,r)}catch(n){setTimeout(()=>{throw n})}}function xo(e){const t=e.length,r=new Array(t);for(let n=0;n<t;n+=1)r[n]=e[n];return r}class Wo extends Uo.EventEmitter{emit(t,...r){let n=t==="error";const i=this._events;if(i!==void 0)n=n&&i.error===void 0;else if(!n)return!1;if(n){let a;if(r.length>0&&([a]=r),a instanceof Error)throw a;const c=new Error(`Unhandled error.${a?` (${a.message})`:""}`);throw c.context=a,c}const o=i[t];if(o===void 0)return!1;if(typeof o=="function")yn(o,this,r);else{const a=o.length,c=xo(o);for(let d=0;d<a;d+=1)yn(c[d],this,r)}return!0}}Vr.default=Wo;var Ho=he&&he.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.ObservableStore=void 0;const Fo=Ho(Vr);class $o extends Fo.default{constructor(t){super(),t?this._state=t:this._state={}}getState(){return this._getState()}putState(t){this._putState(t),this.emit("update",t)}updateState(t){if(t&&typeof t=="object"){const r=this.getState();this.putState(Object.assign(Object.assign({},r),t))}else this.putState(t)}subscribe(t){this.on("update",t)}unsubscribe(t){this.removeListener("update",t)}_getState(){return this._state}_putState(t){this._state=t}}Ke.ObservableStore=$o;Object.defineProperty(St,"__esModule",{value:!0});St.ComposedStore=void 0;const qo=Ke;class Ko extends qo.ObservableStore{constructor(t){super({}),this._children=t||{},Object.keys(this._children).forEach(r=>{const n=this._children[r];this._addChild(r,n)})}_addChild(t,r){const n=i=>{const o=this.getState();o[t]=i,this.putState(o)};r.subscribe(n),n(r.getState())}}St.ComposedStore=Ko;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.MergedStore=void 0;const Vo=Ke;class Go extends Vo.ObservableStore{constructor(t=[]){super({}),this._children=t,t.forEach(r=>this._addChild(r)),this._updateWholeState()}_addChild(t){t.subscribe(()=>this._updateWholeState())}_updateWholeState(){const t=this._children.map(n=>n.getState()),r=Object.assign({},...t);this.putState(r)}}Et.MergedStore=Go;var Ot={},tt={},zo={get exports(){return tt},set exports(e){tt=e}},gt={},Yo={get exports(){return gt},set exports(e){gt=e}},Be={},mn={get exports(){return Be},set exports(e){Be=e}};typeof Z>"u"||!Z.version||Z.version.indexOf("v0.")===0||Z.version.indexOf("v1.")===0&&Z.version.indexOf("v1.8.")!==0?mn.exports={nextTick:Xo}:mn.exports=Z;function Xo(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,a;switch(i){case 0:case 1:return Z.nextTick(e);case 2:return Z.nextTick(function(){e.call(null,t)});case 3:return Z.nextTick(function(){e.call(null,t,r)});case 4:return Z.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),a=0;a<o.length;)o[a++]=arguments[a];return Z.nextTick(function(){e.apply(null,o)})}}var Jo={}.toString,Zo=Array.isArray||function(e){return Jo.call(e)=="[object Array]"},ni=nt.EventEmitter,je={},Qo={get exports(){return je},set exports(e){je=e}};(function(e,t){var r=Un(),n=r.Buffer;function i(a,c){for(var d in a)c[d]=a[d]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o);function o(a,c,d){return n(a,c,d)}i(n,o),o.from=function(a,c,d){if(typeof a=="number")throw new TypeError("Argument must not be a number");return n(a,c,d)},o.alloc=function(a,c,d){if(typeof a!="number")throw new TypeError("Argument must be a number");var m=n(a);return c!==void 0?typeof d=="string"?m.fill(c,d):m.fill(c):m.fill(0),m},o.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return n(a)},o.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(a)}})(Qo,je);var K={};function ea(e){return Array.isArray?Array.isArray(e):Ct(e)==="[object Array]"}K.isArray=ea;function ta(e){return typeof e=="boolean"}K.isBoolean=ta;function ra(e){return e===null}K.isNull=ra;function na(e){return e==null}K.isNullOrUndefined=na;function ia(e){return typeof e=="number"}K.isNumber=ia;function oa(e){return typeof e=="string"}K.isString=oa;function aa(e){return typeof e=="symbol"}K.isSymbol=aa;function sa(e){return e===void 0}K.isUndefined=sa;function ua(e){return Ct(e)==="[object RegExp]"}K.isRegExp=ua;function la(e){return typeof e=="object"&&e!==null}K.isObject=la;function ca(e){return Ct(e)==="[object Date]"}K.isDate=ca;function fa(e){return Ct(e)==="[object Error]"||e instanceof Error}K.isError=fa;function da(e){return typeof e=="function"}K.isFunction=da;function ha(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}K.isPrimitive=ha;K.isBuffer=Un().Buffer.isBuffer;function Ct(e){return Object.prototype.toString.call(e)}var yt={},pa={get exports(){return yt},set exports(e){yt=e}},vn;function ga(){return vn||(vn=1,function(e){function t(o,a){if(!(o instanceof a))throw new TypeError("Cannot call a class as a function")}var r=je.Buffer,n=Wr;function i(o,a,c){o.copy(a,c)}e.exports=function(){function o(){t(this,o),this.head=null,this.tail=null,this.length=0}return o.prototype.push=function(c){var d={data:c,next:null};this.length>0?this.tail.next=d:this.head=d,this.tail=d,++this.length},o.prototype.unshift=function(c){var d={data:c,next:this.head};this.length===0&&(this.tail=d),this.head=d,++this.length},o.prototype.shift=function(){if(this.length!==0){var c=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,c}},o.prototype.clear=function(){this.head=this.tail=null,this.length=0},o.prototype.join=function(c){if(this.length===0)return"";for(var d=this.head,m=""+d.data;d=d.next;)m+=c+d.data;return m},o.prototype.concat=function(c){if(this.length===0)return r.alloc(0);if(this.length===1)return this.head.data;for(var d=r.allocUnsafe(c>>>0),m=this.head,y=0;m;)i(m.data,d,y),y+=m.data.length,m=m.next;return d},o}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var o=n.inspect({length:this.length});return this.constructor.name+" "+o})}(pa)),yt}var bn=Be;function ya(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(!this._writableState||!this._writableState.errorEmitted)&&bn.nextTick(wn,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?(bn.nextTick(wn,r,o),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(o)}),this)}function ma(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function wn(e,t){e.emit("error",t)}var ii={destroy:ya,undestroy:ma},Ar,_n;function oi(){if(_n)return Ar;_n=1;var e=Be;Ar=_;function t(l){var f=this;this.next=null,this.entry=null,this.finish=function(){v(f,l)}}var r=!Z.browser&&["v0.10","v0.9."].indexOf(Z.version.slice(0,5))>-1?setImmediate:e.nextTick,n;_.WritableState=b;var i=Object.create(K);i.inherits=it;var o={deprecate:wi},a=ni,c=je.Buffer,d=he.Uint8Array||function(){};function m(l){return c.from(l)}function y(l){return c.isBuffer(l)||l instanceof d}var p=ii;i.inherits(_,a);function h(){}function b(l,f){n=n||Ue(),l=l||{};var g=f instanceof n;this.objectMode=!!l.objectMode,g&&(this.objectMode=this.objectMode||!!l.writableObjectMode);var w=l.highWaterMark,M=l.writableHighWaterMark,I=this.objectMode?16:16*1024;w||w===0?this.highWaterMark=w:g&&(M||M===0)?this.highWaterMark=M:this.highWaterMark=I,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var x=l.decodeStrings===!1;this.decodeStrings=!x,this.defaultEncoding=l.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(F){V(f,F)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}b.prototype.getBuffer=function(){for(var f=this.bufferedRequest,g=[];f;)g.push(f),f=f.next;return g},function(){try{Object.defineProperty(b.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var O;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(O=Function.prototype[Symbol.hasInstance],Object.defineProperty(_,Symbol.hasInstance,{value:function(l){return O.call(this,l)?!0:this!==_?!1:l&&l._writableState instanceof b}})):O=function(l){return l instanceof this};function _(l){if(n=n||Ue(),!O.call(_,this)&&!(this instanceof n))return new _(l);this._writableState=new b(l,this),this.writable=!0,l&&(typeof l.write=="function"&&(this._write=l.write),typeof l.writev=="function"&&(this._writev=l.writev),typeof l.destroy=="function"&&(this._destroy=l.destroy),typeof l.final=="function"&&(this._final=l.final)),a.call(this)}_.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function T(l,f){var g=new Error("write after end");l.emit("error",g),e.nextTick(f,g)}function A(l,f,g,w){var M=!0,I=!1;return g===null?I=new TypeError("May not write null values to stream"):typeof g!="string"&&g!==void 0&&!f.objectMode&&(I=new TypeError("Invalid non-string/buffer chunk")),I&&(l.emit("error",I),e.nextTick(w,I),M=!1),M}_.prototype.write=function(l,f,g){var w=this._writableState,M=!1,I=!w.objectMode&&y(l);return I&&!c.isBuffer(l)&&(l=m(l)),typeof f=="function"&&(g=f,f=null),I?f="buffer":f||(f=w.defaultEncoding),typeof g!="function"&&(g=h),w.ended?T(this,g):(I||A(this,w,l,g))&&(w.pendingcb++,M=U(this,w,I,l,f,g)),M},_.prototype.cork=function(){var l=this._writableState;l.corked++},_.prototype.uncork=function(){var l=this._writableState;l.corked&&(l.corked--,!l.writing&&!l.corked&&!l.finished&&!l.bufferProcessing&&l.bufferedRequest&&G(this,l))},_.prototype.setDefaultEncoding=function(f){if(typeof f=="string"&&(f=f.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((f+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+f);return this._writableState.defaultEncoding=f,this};function E(l,f,g){return!l.objectMode&&l.decodeStrings!==!1&&typeof f=="string"&&(f=c.from(f,g)),f}Object.defineProperty(_.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function U(l,f,g,w,M,I){if(!g){var x=E(f,w,M);w!==x&&(g=!0,M="buffer",w=x)}var F=f.objectMode?1:w.length;f.length+=F;var z=f.length<f.highWaterMark;if(z||(f.needDrain=!0),f.writing||f.corked){var J=f.lastBufferedRequest;f.lastBufferedRequest={chunk:w,encoding:M,isBuf:g,callback:I,next:null},J?J.next=f.lastBufferedRequest:f.bufferedRequest=f.lastBufferedRequest,f.bufferedRequestCount+=1}else k(l,f,!1,F,w,M,I);return z}function k(l,f,g,w,M,I,x){f.writelen=w,f.writecb=x,f.writing=!0,f.sync=!0,g?l._writev(M,f.onwrite):l._write(M,I,f.onwrite),f.sync=!1}function q(l,f,g,w,M){--f.pendingcb,g?(e.nextTick(M,w),e.nextTick(ie,l,f),l._writableState.errorEmitted=!0,l.emit("error",w)):(M(w),l._writableState.errorEmitted=!0,l.emit("error",w),ie(l,f))}function j(l){l.writing=!1,l.writecb=null,l.length-=l.writelen,l.writelen=0}function V(l,f){var g=l._writableState,w=g.sync,M=g.writecb;if(j(g),f)q(l,g,w,f,M);else{var I=H(g);!I&&!g.corked&&!g.bufferProcessing&&g.bufferedRequest&&G(l,g),w?r(X,l,g,I,M):X(l,g,I,M)}}function X(l,f,g,w){g||L(l,f),f.pendingcb--,w(),ie(l,f)}function L(l,f){f.length===0&&f.needDrain&&(f.needDrain=!1,l.emit("drain"))}function G(l,f){f.bufferProcessing=!0;var g=f.bufferedRequest;if(l._writev&&g&&g.next){var w=f.bufferedRequestCount,M=new Array(w),I=f.corkedRequestsFree;I.entry=g;for(var x=0,F=!0;g;)M[x]=g,g.isBuf||(F=!1),g=g.next,x+=1;M.allBuffers=F,k(l,f,!0,f.length,M,"",I.finish),f.pendingcb++,f.lastBufferedRequest=null,I.next?(f.corkedRequestsFree=I.next,I.next=null):f.corkedRequestsFree=new t(f),f.bufferedRequestCount=0}else{for(;g;){var z=g.chunk,J=g.encoding,s=g.callback,u=f.objectMode?1:z.length;if(k(l,f,!1,u,z,J,s),g=g.next,f.bufferedRequestCount--,f.writing)break}g===null&&(f.lastBufferedRequest=null)}f.bufferedRequest=g,f.bufferProcessing=!1}_.prototype._write=function(l,f,g){g(new Error("_write() is not implemented"))},_.prototype._writev=null,_.prototype.end=function(l,f,g){var w=this._writableState;typeof l=="function"?(g=l,l=null,f=null):typeof f=="function"&&(g=f,f=null),l!=null&&this.write(l,f),w.corked&&(w.corked=1,this.uncork()),!w.ending&&!w.finished&&C(this,w,g)};function H(l){return l.ending&&l.length===0&&l.bufferedRequest===null&&!l.finished&&!l.writing}function ne(l,f){l._final(function(g){f.pendingcb--,g&&l.emit("error",g),f.prefinished=!0,l.emit("prefinish"),ie(l,f)})}function se(l,f){!f.prefinished&&!f.finalCalled&&(typeof l._final=="function"?(f.pendingcb++,f.finalCalled=!0,e.nextTick(ne,l,f)):(f.prefinished=!0,l.emit("prefinish")))}function ie(l,f){var g=H(f);return g&&(se(l,f),f.pendingcb===0&&(f.finished=!0,l.emit("finish"))),g}function C(l,f,g){f.ending=!0,ie(l,f),g&&(f.finished?e.nextTick(g):l.once("finish",g)),f.ended=!0,l.writable=!1}function v(l,f,g){var w=l.entry;for(l.entry=null;w;){var M=w.callback;f.pendingcb--,M(g),w=w.next}f.corkedRequestsFree?f.corkedRequestsFree.next=l:f.corkedRequestsFree=l}return Object.defineProperty(_.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(l){this._writableState&&(this._writableState.destroyed=l)}}),_.prototype.destroy=p.destroy,_.prototype._undestroy=p.undestroy,_.prototype._destroy=function(l,f){this.end(),f(l)},Ar}var Pr,Sn;function Ue(){if(Sn)return Pr;Sn=1;var e=Be,t=Object.keys||function(p){var h=[];for(var b in p)h.push(b);return h};Pr=d;var r=Object.create(K);r.inherits=it;var n=ai(),i=oi();r.inherits(d,n);for(var o=t(i.prototype),a=0;a<o.length;a++){var c=o[a];d.prototype[c]||(d.prototype[c]=i.prototype[c])}function d(p){if(!(this instanceof d))return new d(p);n.call(this,p),i.call(this,p),p&&p.readable===!1&&(this.readable=!1),p&&p.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,p&&p.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",m)}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function m(){this.allowHalfOpen||this._writableState.ended||e.nextTick(y,this)}function y(p){p.end()}return Object.defineProperty(d.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(p){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=p,this._writableState.destroyed=p)}}),d.prototype._destroy=function(p,h){this.push(null),this.end(),e.nextTick(h,p)},Pr}var Tr,En;function ai(){if(En)return Tr;En=1;var e=Be;Tr=E;var t=Zo,r;E.ReadableState=A,nt.EventEmitter;var n=function(s,u){return s.listeners(u).length},i=ni,o=je.Buffer,a=he.Uint8Array||function(){};function c(s){return o.from(s)}function d(s){return o.isBuffer(s)||s instanceof a}var m=Object.create(K);m.inherits=it;var y=Wr,p=void 0;y&&y.debuglog?p=y.debuglog("stream"):p=function(){};var h=ga(),b=ii,O;m.inherits(E,i);var _=["error","close","destroy","pause","resume"];function T(s,u,S){if(typeof s.prependListener=="function")return s.prependListener(u,S);!s._events||!s._events[u]?s.on(u,S):t(s._events[u])?s._events[u].unshift(S):s._events[u]=[S,s._events[u]]}function A(s,u){r=r||Ue(),s=s||{};var S=u instanceof r;this.objectMode=!!s.objectMode,S&&(this.objectMode=this.objectMode||!!s.readableObjectMode);var R=s.highWaterMark,B=s.readableHighWaterMark,D=this.objectMode?16:16*1024;R||R===0?this.highWaterMark=R:S&&(B||B===0)?this.highWaterMark=B:this.highWaterMark=D,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new h,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=s.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,s.encoding&&(O||(O=Xr.StringDecoder),this.decoder=new O(s.encoding),this.encoding=s.encoding)}function E(s){if(r=r||Ue(),!(this instanceof E))return new E(s);this._readableState=new A(s,this),this.readable=!0,s&&(typeof s.read=="function"&&(this._read=s.read),typeof s.destroy=="function"&&(this._destroy=s.destroy)),i.call(this)}Object.defineProperty(E.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(s){this._readableState&&(this._readableState.destroyed=s)}}),E.prototype.destroy=b.destroy,E.prototype._undestroy=b.undestroy,E.prototype._destroy=function(s,u){this.push(null),u(s)},E.prototype.push=function(s,u){var S=this._readableState,R;return S.objectMode?R=!0:typeof s=="string"&&(u=u||S.defaultEncoding,u!==S.encoding&&(s=o.from(s,u),u=""),R=!0),U(this,s,u,!1,R)},E.prototype.unshift=function(s){return U(this,s,null,!0,!1)};function U(s,u,S,R,B){var D=s._readableState;if(u===null)D.reading=!1,G(s,D);else{var N;B||(N=q(D,u)),N?s.emit("error",N):D.objectMode||u&&u.length>0?(typeof u!="string"&&!D.objectMode&&Object.getPrototypeOf(u)!==o.prototype&&(u=c(u)),R?D.endEmitted?s.emit("error",new Error("stream.unshift() after end event")):k(s,D,u,!0):D.ended?s.emit("error",new Error("stream.push() after EOF")):(D.reading=!1,D.decoder&&!S?(u=D.decoder.write(u),D.objectMode||u.length!==0?k(s,D,u,!1):se(s,D)):k(s,D,u,!1))):R||(D.reading=!1)}return j(D)}function k(s,u,S,R){u.flowing&&u.length===0&&!u.sync?(s.emit("data",S),s.read(0)):(u.length+=u.objectMode?1:S.length,R?u.buffer.unshift(S):u.buffer.push(S),u.needReadable&&H(s)),se(s,u)}function q(s,u){var S;return!d(u)&&typeof u!="string"&&u!==void 0&&!s.objectMode&&(S=new TypeError("Invalid non-string/buffer chunk")),S}function j(s){return!s.ended&&(s.needReadable||s.length<s.highWaterMark||s.length===0)}E.prototype.isPaused=function(){return this._readableState.flowing===!1},E.prototype.setEncoding=function(s){return O||(O=Xr.StringDecoder),this._readableState.decoder=new O(s),this._readableState.encoding=s,this};var V=8388608;function X(s){return s>=V?s=V:(s--,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s++),s}function L(s,u){return s<=0||u.length===0&&u.ended?0:u.objectMode?1:s!==s?u.flowing&&u.length?u.buffer.head.data.length:u.length:(s>u.highWaterMark&&(u.highWaterMark=X(s)),s<=u.length?s:u.ended?u.length:(u.needReadable=!0,0))}E.prototype.read=function(s){p("read",s),s=parseInt(s,10);var u=this._readableState,S=s;if(s!==0&&(u.emittedReadable=!1),s===0&&u.needReadable&&(u.length>=u.highWaterMark||u.ended))return p("read: emitReadable",u.length,u.ended),u.length===0&&u.ended?F(this):H(this),null;if(s=L(s,u),s===0&&u.ended)return u.length===0&&F(this),null;var R=u.needReadable;p("need readable",R),(u.length===0||u.length-s<u.highWaterMark)&&(R=!0,p("length less than watermark",R)),u.ended||u.reading?(R=!1,p("reading or ended",R)):R&&(p("do read"),u.reading=!0,u.sync=!0,u.length===0&&(u.needReadable=!0),this._read(u.highWaterMark),u.sync=!1,u.reading||(s=L(S,u)));var B;return s>0?B=w(s,u):B=null,B===null?(u.needReadable=!0,s=0):u.length-=s,u.length===0&&(u.ended||(u.needReadable=!0),S!==s&&u.ended&&F(this)),B!==null&&this.emit("data",B),B};function G(s,u){if(!u.ended){if(u.decoder){var S=u.decoder.end();S&&S.length&&(u.buffer.push(S),u.length+=u.objectMode?1:S.length)}u.ended=!0,H(s)}}function H(s){var u=s._readableState;u.needReadable=!1,u.emittedReadable||(p("emitReadable",u.flowing),u.emittedReadable=!0,u.sync?e.nextTick(ne,s):ne(s))}function ne(s){p("emit readable"),s.emit("readable"),g(s)}function se(s,u){u.readingMore||(u.readingMore=!0,e.nextTick(ie,s,u))}function ie(s,u){for(var S=u.length;!u.reading&&!u.flowing&&!u.ended&&u.length<u.highWaterMark&&(p("maybeReadMore read 0"),s.read(0),S!==u.length);)S=u.length;u.readingMore=!1}E.prototype._read=function(s){this.emit("error",new Error("_read() is not implemented"))},E.prototype.pipe=function(s,u){var S=this,R=this._readableState;switch(R.pipesCount){case 0:R.pipes=s;break;case 1:R.pipes=[R.pipes,s];break;default:R.pipes.push(s);break}R.pipesCount+=1,p("pipe count=%d opts=%j",R.pipesCount,u);var B=(!u||u.end!==!1)&&s!==Z.stdout&&s!==Z.stderr,D=B?we:ge;R.endEmitted?e.nextTick(D):S.once("end",D),s.on("unpipe",N);function N(fe,ye){p("onunpipe"),fe===S&&ye&&ye.hasUnpiped===!1&&(ye.hasUnpiped=!0,at())}function we(){p("onend"),s.end()}var Pe=C(S);s.on("drain",Pe);var Ve=!1;function at(){p("cleanup"),s.removeListener("close",Ie),s.removeListener("finish",De),s.removeListener("drain",Pe),s.removeListener("error",Me),s.removeListener("unpipe",N),S.removeListener("end",we),S.removeListener("end",ge),S.removeListener("data",Ge),Ve=!0,R.awaitDrain&&(!s._writableState||s._writableState.needDrain)&&Pe()}var Te=!1;S.on("data",Ge);function Ge(fe){p("ondata"),Te=!1;var ye=s.write(fe);ye===!1&&!Te&&((R.pipesCount===1&&R.pipes===s||R.pipesCount>1&&J(R.pipes,s)!==-1)&&!Ve&&(p("false write response, pause",S._readableState.awaitDrain),S._readableState.awaitDrain++,Te=!0),S.pause())}function Me(fe){p("onerror",fe),ge(),s.removeListener("error",Me),n(s,"error")===0&&s.emit("error",fe)}T(s,"error",Me);function Ie(){s.removeListener("finish",De),ge()}s.once("close",Ie);function De(){p("onfinish"),s.removeListener("close",Ie),ge()}s.once("finish",De);function ge(){p("unpipe"),S.unpipe(s)}return s.emit("pipe",S),R.flowing||(p("pipe resume"),S.resume()),s};function C(s){return function(){var u=s._readableState;p("pipeOnDrain",u.awaitDrain),u.awaitDrain&&u.awaitDrain--,u.awaitDrain===0&&n(s,"data")&&(u.flowing=!0,g(s))}}E.prototype.unpipe=function(s){var u=this._readableState,S={hasUnpiped:!1};if(u.pipesCount===0)return this;if(u.pipesCount===1)return s&&s!==u.pipes?this:(s||(s=u.pipes),u.pipes=null,u.pipesCount=0,u.flowing=!1,s&&s.emit("unpipe",this,S),this);if(!s){var R=u.pipes,B=u.pipesCount;u.pipes=null,u.pipesCount=0,u.flowing=!1;for(var D=0;D<B;D++)R[D].emit("unpipe",this,S);return this}var N=J(u.pipes,s);return N===-1?this:(u.pipes.splice(N,1),u.pipesCount-=1,u.pipesCount===1&&(u.pipes=u.pipes[0]),s.emit("unpipe",this,S),this)},E.prototype.on=function(s,u){var S=i.prototype.on.call(this,s,u);if(s==="data")this._readableState.flowing!==!1&&this.resume();else if(s==="readable"){var R=this._readableState;!R.endEmitted&&!R.readableListening&&(R.readableListening=R.needReadable=!0,R.emittedReadable=!1,R.reading?R.length&&H(this):e.nextTick(v,this))}return S},E.prototype.addListener=E.prototype.on;function v(s){p("readable nexttick read 0"),s.read(0)}E.prototype.resume=function(){var s=this._readableState;return s.flowing||(p("resume"),s.flowing=!0,l(this,s)),this};function l(s,u){u.resumeScheduled||(u.resumeScheduled=!0,e.nextTick(f,s,u))}function f(s,u){u.reading||(p("resume read 0"),s.read(0)),u.resumeScheduled=!1,u.awaitDrain=0,s.emit("resume"),g(s),u.flowing&&!u.reading&&s.read(0)}E.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function g(s){var u=s._readableState;for(p("flow",u.flowing);u.flowing&&s.read()!==null;);}E.prototype.wrap=function(s){var u=this,S=this._readableState,R=!1;s.on("end",function(){if(p("wrapped end"),S.decoder&&!S.ended){var N=S.decoder.end();N&&N.length&&u.push(N)}u.push(null)}),s.on("data",function(N){if(p("wrapped data"),S.decoder&&(N=S.decoder.write(N)),!(S.objectMode&&N==null)&&!(!S.objectMode&&(!N||!N.length))){var we=u.push(N);we||(R=!0,s.pause())}});for(var B in s)this[B]===void 0&&typeof s[B]=="function"&&(this[B]=function(N){return function(){return s[N].apply(s,arguments)}}(B));for(var D=0;D<_.length;D++)s.on(_[D],this.emit.bind(this,_[D]));return this._read=function(N){p("wrapped _read",N),R&&(R=!1,s.resume())},this},Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),E._fromList=w;function w(s,u){if(u.length===0)return null;var S;return u.objectMode?S=u.buffer.shift():!s||s>=u.length?(u.decoder?S=u.buffer.join(""):u.buffer.length===1?S=u.buffer.head.data:S=u.buffer.concat(u.length),u.buffer.clear()):S=M(s,u.buffer,u.decoder),S}function M(s,u,S){var R;return s<u.head.data.length?(R=u.head.data.slice(0,s),u.head.data=u.head.data.slice(s)):s===u.head.data.length?R=u.shift():R=S?I(s,u):x(s,u),R}function I(s,u){var S=u.head,R=1,B=S.data;for(s-=B.length;S=S.next;){var D=S.data,N=s>D.length?D.length:s;if(N===D.length?B+=D:B+=D.slice(0,s),s-=N,s===0){N===D.length?(++R,S.next?u.head=S.next:u.head=u.tail=null):(u.head=S,S.data=D.slice(N));break}++R}return u.length-=R,B}function x(s,u){var S=o.allocUnsafe(s),R=u.head,B=1;for(R.data.copy(S),s-=R.data.length;R=R.next;){var D=R.data,N=s>D.length?D.length:s;if(D.copy(S,S.length-s,0,N),s-=N,s===0){N===D.length?(++B,R.next?u.head=R.next:u.head=u.tail=null):(u.head=R,R.data=D.slice(N));break}++B}return u.length-=B,S}function F(s){var u=s._readableState;if(u.length>0)throw new Error('"endReadable()" called on non-empty stream');u.endEmitted||(u.ended=!0,e.nextTick(z,u,s))}function z(s,u){!s.endEmitted&&s.length===0&&(s.endEmitted=!0,u.readable=!1,u.emit("end"))}function J(s,u){for(var S=0,R=s.length;S<R;S++)if(s[S]===u)return S;return-1}return Tr}var si=pe,Rt=Ue(),ui=Object.create(K);ui.inherits=it;ui.inherits(pe,Rt);function va(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function pe(e){if(!(this instanceof pe))return new pe(e);Rt.call(this,e),this._transformState={afterTransform:va.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",ba)}function ba(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){On(e,t,r)}):On(this,null,null)}pe.prototype.push=function(e,t){return this._transformState.needTransform=!1,Rt.prototype.push.call(this,e,t)};pe.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};pe.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};pe.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};pe.prototype._destroy=function(e,t){var r=this;Rt.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function On(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}var wa=rt,li=si,ci=Object.create(K);ci.inherits=it;ci.inherits(rt,li);function rt(e){if(!(this instanceof rt))return new rt(e);li.call(this,e)}rt.prototype._transform=function(e,t,r){r(null,e)};(function(e,t){t=e.exports=ai(),t.Stream=t,t.Readable=t,t.Writable=oi(),t.Duplex=Ue(),t.Transform=si,t.PassThrough=wa})(Yo,gt);var _a=Ea,Sa=Object.prototype.hasOwnProperty;function Ea(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var n in r)Sa.call(r,n)&&(e[n]=r[n])}return e}var fi=gt.Transform,di=Wr.inherits,hi=_a;function xe(e){fi.call(this,e),this._destroyed=!1}di(xe,fi);xe.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var t=this;Z.nextTick(function(){e&&t.emit("error",e),t.emit("close")})}};function Oa(e,t,r){r(null,e)}function Gr(e){return function(t,r,n){return typeof t=="function"&&(n=r,r=t,t={}),typeof r!="function"&&(r=Oa),typeof n!="function"&&(n=null),e(t,r,n)}}zo.exports=Gr(function(e,t,r){var n=new xe(e);return n._transform=t,r&&(n._flush=r),n});tt.ctor=Gr(function(e,t,r){function n(i){if(!(this instanceof n))return new n(i);this.options=hi(e,i),xe.call(this,this.options)}return di(n,xe),n.prototype._transform=t,r&&(n.prototype._flush=r),n});tt.obj=Gr(function(e,t,r){var n=new xe(hi({objectMode:!0,highWaterMark:16},e));return n._transform=t,r&&(n._flush=r),n});Object.defineProperty(Ot,"__esModule",{value:!0});Ot.storeTransformStream=void 0;const Ca=tt;function Ra(e){return Ca.obj((t,r,n)=>{try{const i=e(t);n(null,i);return}catch(i){n(i);return}})}Ot.storeTransformStream=Ra;(function(e){var t=he&&he.__createBinding||(Object.create?function(n,i,o,a){a===void 0&&(a=o),Object.defineProperty(n,a,{enumerable:!0,get:function(){return i[o]}})}:function(n,i,o,a){a===void 0&&(a=o),n[a]=i[o]}),r=he&&he.__exportStar||function(n,i){for(var o in n)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&t(i,n,o)};Object.defineProperty(e,"__esModule",{value:!0}),r(_t,e),r(St,e),r(Et,e),r(Ke,e),r(Ot,e)})(xr);var Aa=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!e(t[i],r[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var a=o[i];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r};const ce=e=>e!==null&&typeof e=="object"&&typeof e.pipe=="function";ce.writable=e=>ce(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object";ce.readable=e=>ce(e)&&e.readable!==!1&&typeof e._read=="function"&&typeof e._readableState=="object";ce.duplex=e=>ce.writable(e)&&ce.readable(e);ce.transform=e=>ce.duplex(e)&&typeof e._transform=="function";var Pa=ce;const Xe={GOOGLE:"google",FACEBOOK:"facebook",TWITCH:"twitch",REDDIT:"reddit",DISCORD:"discord"},Ee={GOOGLE:"google",FACEBOOK:"facebook",TWITCH:"twitch",REDDIT:"reddit",DISCORD:"discord",EMAIL_PASSWORDLESS:"torus-auth0-email-passwordless"},Cn={[Ee.GOOGLE]:"tkey-google",[Ee.FACEBOOK]:"tkey-facebook",[Ee.TWITCH]:"tkey-twitch",[Ee.REDDIT]:"tkey-reddit",[Ee.DISCORD]:"tkey-discord",[Ee.EMAIL_PASSWORDLESS]:"tkey-auth0-email-passwordless"},$={MOONPAY:"moonpay",WYRE:"wyre",RAMPNETWORK:"rampnetwork",XANPOOL:"xanpool",MERCURYO:"mercuryo",TRANSAK:"transak",BANXA:"banxa"},Y={MAINNET:"mainnet",MATIC:"matic",BSC_MAINNET:"bsc_mainnet",AVALANCHE_MAINNET:"avalanche_mainnet",XDAI:"xdai"},Ta={PRODUCTION:"production",DEVELOPMENT:"development",BINANCE:"binance",TESTING:"testing",LRC:"lrc",BETA:"beta",BNB:"bnb",POLYGON:"polygon"},Le={BOTTOM_LEFT:"bottom-left",TOP_LEFT:"top-left",BOTTOM_RIGHT:"bottom-right",TOP_RIGHT:"top-right"},Ma=["ETH","USDT","USDC","TUSD","EOSDT","USD","DAI","GUSD","DKKT","PAX","ILS","RUB","BYN","EUR","GBP","JPY","KRW","PLN","MXN","AUD","BRL","CAD","CHF","KPW","LAK","LBP","LKR","XOF","CNHT","DOGE","UAH","TRY","HKD","XJP","SGD","USC","NZD","NGN","RUR","COP","GHS","EGP","IDR","BHD","CRC","PEN","AED","DOP","PKR","HUF","VND","XAR","LTC","RON","OMR","MYR","DKK","UGX","ZMW","SAR","SEK","GEL","RWF","IRR","TZS","CNY","VEF","BDT","HRK","CLP","THB","XAF","ARS","UYU","SZL","KZT","NOK","KES","PAB","INR","CZK","MAD","TWD","PHP","ZAR","BOB","CDF","DASH","VES","ISK","MWK","BAM","TTD","XRP","JOD","RSD","HNL","BGN","GTQ","BWP","XMR","MMK","QAR","AOA","KWD","MUR","WUSD","WEUR","WAVES","WTRY","LRD","LSL","LYD","AWG","MDL","BTO","EURS","CHFT","MKD","MNT","MOP","MRO","MVR","VOLLAR","CKUSD","KHR","VUV","BITCNY","QC","BBD","NAD","NPR","PGK","PYG","BIF","BMD","BND","XLM","BNB","SCR","BAT","CRO","HT","KCS","LEO","LINK","MKR","NPXS","OMG","REP","ZB","ZIL","ZRX","BCH","BZD","CUP","CVE","DJF","DZD","ERN","ETB","FJD","FKP","BUSD","ANCT","ALL","AMD","ANG","CNYX","IQD","UZS","TND","GGP","XAU","KGS","GIP","JMD","ZEC","USDP","BSV","EMC2","SNT","GTO","POWR","EUSD","EURT","BCY","BTS","ATM","BLOCKPAY","ARDR","AMP","B2X","BITGOLD","BITEUR","ATB","BITUSD","AGRS","DFXT","HIKEN","BIX","KNC","EOS","COB","COSS","BMH","NANO","BDG","BNT","XVG","LKK1Y","LKK","USDK","EURN","NZDT","JSE","GMD","GNF","GYD","YER","XPF","HTG","SLL","SOS","WST","SVC","SYP","NEO","KMF","JUMP","AYA","BLAST","WGR","BCN","BTG","URALS","INN","USDQ","CNH","HUSD","BKRW","NZDX","EURX","CADX","USDEX","JPYX","AUDX","VNDC","EON","GBPX","CHFX","USDJ","IDRT","USDS","USDN","BIDR","IDK","BSD","BTN","KYD","NIO","SBD","SDG","SHP","TOP","XCD","XCHF","CNYT","GYEN","ZUSD","GOLD","TRX","TRYB","PLATC","STRAX","UST","GLM","VAI","BRZ","DDRST","XAUT","MIM"],Ia={[$.MOONPAY]:["AUD","BGN","BRL","CAD","CHF","CNY","COP","CZK","DKK","DOP","EGP","EUR","GBP","HKD","HRK","IDR","ILS","JPY","JOD","KES","KRW","KWD","LKR","MAD","MXN","MYR","NGN","NOK","NZD","OMR","PEN","PKR","PLN","RON","RUB","SEK","SGD","THB","TRY","TWD","USD","VND","ZAR"],[$.WYRE]:["USD","EUR","GBP","AUD","CAD","NZD","ARS","BRL","CHF","CLP","COP","CZK","DKK","HKD","ILS","INR","ISK","JPY","KRW","MXN","MYR","NOK","PHP","PLN","SEK","THB","VND","ZAR"],[$.RAMPNETWORK]:["USD","EUR","GBP"],[$.XANPOOL]:["SGD","HKD","THB","PHP","INR","IDR","MYR","AUD","NZD","KRW"],[$.MERCURYO]:["EUR","USD","GBP","TRY","JPY","BRL","NGN","VND","MXN","KRW"],[$.TRANSAK]:["ARS","AUD","BBD","BGN","BMD","BRL","CAD","CHF","CLP","CRC","CZK","DKK","DOP","EUR","FJD","FKP","GBP","GIP","HRK","HUF","IDR","ILS","ISK","JMD","JPY","KES","KRW","MDL","MXN","MYR","NOK","NZD","PEN","PHP","PLN","PYG","RON","SEK","SGD","THB","TRY","TZS","USD","ZAR"],[$.BANXA]:["EUR","GBP","USD"]},Da=new Set(Ma);function Se(e){return Ia[e].filter(r=>Da.has(r))}const La={[$.MOONPAY]:{line1:"Credit/ Debit Card/ Apple Pay",line2:"4.5% or 5 USD",line3:"2,000€/day, 10,000€/mo",supportPage:"https://help.moonpay.io/en/",minOrderValue:24.99,maxOrderValue:5e4,validCurrencies:Se($.MOONPAY),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"aave",display:"AAVE"},{value:"bat",display:"BAT"},{value:"dai",display:"DAI"},{value:"eth",display:"ETH"},{value:"mkr",display:"MKR"},{value:"matic",display:"MATIC"},{value:"usdt",display:"USDT"},{value:"usdc",display:"USDC"}],[Y.MATIC]:[{value:"eth_polygon",display:"ETH"},{value:"matic_polygon",display:"MATIC"},{value:"usdc_polygon",display:"USDC"}],[Y.BSC_MAINNET]:[{value:"bnb_bsc",display:"BNB"},{value:"busd_bsc",display:"BUSD"}],[Y.AVALANCHE_MAINNET]:[{value:"avax_cchain",display:"AVAX"}]},includeFees:!0,api:!0,enforceMax:!1},[$.WYRE]:{line1:"Apple Pay/ Debit/ Credit Card",line2:"4.9% + 30¢ or 5 USD",line3:"$250/day",supportPage:"https://support.sendwyre.com/en/",minOrderValue:5,maxOrderValue:500,validCurrencies:Se($.WYRE),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"AAVE",display:"AAVE"},{value:"BAT",display:"BAT"},{value:"BUSD",display:"BUSD"},{value:"DAI",display:"DAI"},{value:"ETH",display:"ETH"},{value:"MKR",display:"MKR"},{value:"UNI",display:"UNI"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"}],[Y.MATIC]:[{value:"MUSDC",display:"USDC"}],[Y.AVALANCHE_MAINNET]:[{value:"AVAXC",display:"AVAXC"}]},includeFees:!1,api:!0,enforceMax:!1},[$.RAMPNETWORK]:{line1:"Debit Card/ <br>Apple Pay/ Bank transfer",line2:"0.49% - 2.9%",line3:"5,000€/purchase, 20,000€/mo",supportPage:"https://instant.ramp.network/",minOrderValue:50,maxOrderValue:2e4,validCurrencies:Se($.RAMPNETWORK),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"ETH",display:"ETH"},{value:"DAI",display:"DAI"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"}],[Y.MATIC]:[{value:"MATIC_DAI",display:"DAI"},{value:"MATIC_MATIC",display:"MATIC"},{value:"MATIC_USDC",display:"USDC"}],[Y.AVALANCHE_MAINNET]:[{value:"AVAX",display:"AVAX"}]},includeFees:!0,api:!0,receiveHint:"walletTopUp.receiveHintRamp",enforceMax:!1},[$.XANPOOL]:{line1:"PayNow/ InstaPay/ FPS/ GoJekPay/ UPI/ PromptPay/ <br>ViettelPay/ DuitNow",line2:"2.5% buying, 3% selling",line3:"$2,500 / day",supportPage:"mailto:support@xanpool.com",minOrderValue:100,maxOrderValue:2500,validCurrencies:Se($.XANPOOL),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"ETH",display:"ETH"},{value:"USDT",display:"USDT"}]},includeFees:!0,api:!0,sell:!0,enforceMax:!1},[$.MERCURYO]:{line1:"Credit/ Debit Card/ Apple Pay",line2:"3.95% or 4 USD",line3:"10,000€/day, 25,000€/mo",supportPage:"mailto:support@mercuryo.io",minOrderValue:30,maxOrderValue:5e3,validCurrencies:Se($.MERCURYO),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"ETH",display:"ETH"},{value:"BAT",display:"BAT"},{value:"USDT",display:"USDT"},{value:"DAI",display:"DAI"}],[Y.BSC_MAINNET]:[{value:"BNB",display:"BNB"},{value:"BUSD",display:"BUSD"},{value:"1INCH",display:"1INCH"}]},includeFees:!0,api:!0,enforceMax:!1},[$.TRANSAK]:{line1:"Apple & Google Pay / Credit/Debit Card<br/>Bangkok Bank Mobile & iPay<br/>Bank Transfer (sepa/gbp) / SCB Mobile & Easy",line2:"0.99% - 5.5% or 5 USD",line3:"$5,000/day, $28,000/mo",supportPage:"https://support.transak.com/hc/en-US",minOrderValue:30,maxOrderValue:500,validCurrencies:Se($.TRANSAK),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"AAVE",display:"AAVE"},{value:"DAI",display:"DAI"},{value:"ETH",display:"ETH"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"}],[Y.MATIC]:[{value:"AAVE",display:"AAVE"},{value:"DAI",display:"DAI"},{value:"MATIC",display:"MATIC"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"},{value:"WETH",display:"WETH"}],[Y.BSC_MAINNET]:[{value:"BNB",display:"BNB"},{value:"BUSD",display:"BUSD"}],[Y.AVALANCHE_MAINNET]:[{value:"AVAX",display:"AVAX"}]},includeFees:!0,enforceMax:!0},[$.BANXA]:{line1:"Debit Card/ <br>Apple Pay/ Bank transfer",line2:"0.49% - 2.9%",line3:"5,000€/purchase, 20,000€/mo",supportPage:"https://support.banxa.com",minOrderValue:20,maxOrderValue:15e3,validCurrencies:Se($.BANXA),validCryptoCurrenciesByChain:{[Y.MAINNET]:[{value:"ETH",display:"ETH"},{value:"USDT",display:"USDT"},{value:"BUSD",display:"BUSD"},{value:"LINK",display:"LINK"},{value:"USDC",display:"USDC"},{value:"CHZ",display:"CHZ"},{value:"BAT",display:"BAT"},{value:"MANA",display:"MANA"},{value:"AAVE",display:"AAVE"},{value:"COMP",display:"COMP"},{value:"ENJ",display:"ENJ"}],[Y.MATIC]:[{value:"MATIC",display:"MATIC"}]},includeFees:!0,enforceMax:!0}},Na={en:{embed:{continue:"Continue",actionRequired:"Authorization required",pendingAction:"Click continue to proceed with your request in a popup",cookiesRequired:"Cookies Required",enableCookies:"Please enable cookies in your browser preferences to access Torus",clickHere:"More Info"}},de:{embed:{continue:"Fortsetzen",actionRequired:"Autorisierung erforderlich",pendingAction:"Klicken Sie in einem Popup auf Weiter, um mit Ihrer Anfrage fortzufahren",cookiesRequired:"Cookies benötigt",enableCookies:"Bitte aktivieren Sie Cookies in Ihren Browsereinstellungen, um auf Torus zuzugreifen",clickHere:"Mehr Info"}},ja:{embed:{continue:"継続する",actionRequired:"認証が必要です",pendingAction:"続行をクリックして、ポップアップでリクエストを続行します",cookiesRequired:"必要なクッキー",enableCookies:"Torusにアクセスするには、ブラウザの設定でCookieを有効にしてください。",clickHere:"詳しくは"}},ko:{embed:{continue:"계속하다",actionRequired:"승인 필요",pendingAction:"팝업에서 요청을 진행하려면 계속을 클릭하십시오.",cookiesRequired:"쿠키 필요",enableCookies:"브라우저 환경 설정에서 쿠키를 활성화하여 Torus에 액세스하십시오.",clickHere:"더 많은 정보"}},zh:{embed:{continue:"继续",actionRequired:"需要授权",pendingAction:"单击继续以在弹出窗口中继续您的请求",cookiesRequired:"必填Cookie",enableCookies:"请在您的浏览器首选项中启用cookie以访问Torus。",clickHere:"更多信息"}}};var le={supportedVerifierList:Object.values(Ee),paymentProviders:La,api:"https://api.tor.us",translations:Na,prodTorusUrl:"",localStorageKeyPrefix:"torus-"};const Rn=e=>new Promise((t,r)=>{window.document.body!=null?Promise.resolve(e()).then(t).catch(r):window.document.addEventListener("DOMContentLoaded",()=>{Promise.resolve(e()).then(t).catch(r)})}),Je=e=>{const t=window.document.createElement("template"),r=e.trim();return t.innerHTML=r,t.content.firstChild},ka=function(e,t,r){for(var n=arguments.length,i=new Array(n>3?n-3:0),o=3;o<n;o++)i[o-3]=arguments[o];const a=()=>{r(...i),e.removeEventListener(t,a)};e.addEventListener(t,a)},ue=(e,t,r)=>{const n=i=>{r(i),e.removeListener(t,n)};e.on(t,n)};async function Ba(){return new Promise(e=>{document.readyState!=="loading"?e():ka(document,"DOMContentLoaded",e)})}var W=Wn.getLogger("torus-embed"),ae={errors:{disconnected:()=>"Torus: Lost connection to Torus.",permanentlyDisconnected:()=>"Torus: Disconnected from iframe. Page reload required.",sendSiteMetadata:()=>"Torus: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:e=>`Torus: The Torus Ethereum provider does not support synchronous methods like ${e} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidOptions:(e,t)=>`Invalid options. Received: { maxEventListeners: ${e}, shouldSendMetadata: ${t} }`,invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:e=>`'args.logger' must include required method '${e}'.`},info:{connected:e=>`Torus: Connected to chain with ID "${e}".`},warnings:{enableDeprecation:'Torus: ""ethereum.enable()" is deprecated and may be removed in the future. Please use "ethereum.send("eth_requestAccounts")" instead. For more information, see: https://eips.ethereum.org/EIPS/eip-1102',sendDeprecation:`Torus: "ethereum.send(...)" is deprecated and may be removed in the future. Please use "ethereum.sendAsync(...)" or "ethereum.request(...)" instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193`,events:{close:`Torus: The event "close" is deprecated and may be removed in the future. Please use "disconnect" instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193`,data:`Torus: The event "data" is deprecated and will be removed in the future.Use "message" instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`,networkChanged:`Torus: The event "networkChanged" is deprecated and may be removed in the future. Please use "chainChanged" instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193`,notification:`Torus: The event "notification" is deprecated and may be removed in the future. Please use "message" instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193`},publicConfigStore:'Torus: The property "publicConfigStore" is deprecated and WILL be removed in the future.'}};const{paymentProviders:An}=le,ja=(e,t)=>{const r={};if(!e)return{errors:r,isValid:!0};if(e&&!An[e])return r.provider="Invalid Provider",{errors:r,isValid:Object.keys(r).length===0};const n=An[e],i=t||{};if(i.fiatValue){const o=+parseFloat(i.fiatValue.toString())||0;o<n.minOrderValue&&(r.fiatValue="Requested amount is lower than supported"),o>n.maxOrderValue&&n.enforceMax&&(r.fiatValue="Requested amount is higher than supported")}if(i.selectedCurrency&&!n.validCurrencies.includes(i.selectedCurrency)&&(r.selectedCurrency="Unsupported currency"),i.selectedCryptoCurrency){const o=Object.values(n.validCryptoCurrenciesByChain).flat().map(c=>c.value),a=e===$.MOONPAY?i.selectedCryptoCurrency.toLowerCase():i.selectedCryptoCurrency;o&&!o.includes(a)&&(r.selectedCryptoCurrency="Unsupported cryptoCurrency")}return{errors:r,isValid:Object.keys(r).length===0}};function Ua(){return(e,t,r)=>{(typeof e.method!="string"||!e.method)&&(t.error=de.ethErrors.rpc.invalidRequest({message:"The request 'method' must be a non-empty string.",data:e})),r(n=>{const{error:i}=t;return i&&W.error(`MetaMask - RPC Error: ${i.message}`,i),n()})}}function Pn(e,t,r){let n=`MetaMask: Lost connection to "${e}".`;t!=null&&t.stack&&(n+=`
${t.stack}`),W.warn(n),r&&r.listenerCount("error")>0&&r.emit("error",n)}const Oe=()=>Math.random().toString(36).slice(2),pi=async(e,t)=>{let r,n;const i="1.38.2";let o=t.version||i;try{if((e==="binance"||e==="production")&&!t.version){let a;le.prodTorusUrl?a={data:le.prodTorusUrl}:a=await Hn(`${le.api}/latestversion?name=@toruslabs/torus-embed&version=${i}`,{},{useAPIKey:!0}),o=a.data,le.prodTorusUrl=a.data}}catch(a){W.error(a,"unable to fetch latest version")}switch(W.info("version used: ",o),e){case"binance":r=`https://binance.tor.us/v${o}`,n="info";break;case"testing":r="https://testing.tor.us",n="debug";break;case"bnb":r="https://bnb.tor.us",n="error";break;case"polygon":r="https://polygon.tor.us",n="error";break;case"lrc":r="https://lrc.tor.us",n="debug";break;case"beta":r="https://beta.tor.us",n="debug";break;case"development":r="http://localhost:4050",n="debug";break;default:r=`https://app.tor.us/v${o}`,n="error";break}return{torusUrl:r,logLevel:n}},Tn=()=>{let e=window.navigator.language||"en-US";const t=e.split("-");return e=Object.prototype.hasOwnProperty.call(le.translations,t[0])?t[0]:"en",e},xa=["eth_subscription"],gi=()=>{},Mn="directories=0,titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=660,width=375",Wa="directories=0,titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=740,width=1315",In="directories=0,titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=700,width=450";function Ha(){const e=window.screenLeft!==void 0?window.screenLeft:window.screenX,t=window.screenTop!==void 0?window.screenTop:window.screenY,r=1200,n=700,i=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,o=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height,a=1,c=Math.abs((i-r)/2/a+e),d=Math.abs((o-n)/2/a+t);return`titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${n/a},width=${r/a},top=${d},left=${c}`}function Dn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Fa(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Dn(Object(r),!0).forEach(function(n){P(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Dn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}wt.defaultMaxListeners=100;const Ln=function(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return(n,i)=>n||i.error?t(n||i.error):!r||Array.isArray(i)?e(i):e(i.result)};class At extends wt{constructor(t){let{maxEventListeners:r=100,shouldSendMetadata:n=!0,jsonRpcStreamName:i="provider"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(super(),P(this,"chainId",void 0),P(this,"selectedAddress",void 0),P(this,"_rpcEngine",void 0),P(this,"networkVersion",void 0),P(this,"shouldSendMetadata",void 0),P(this,"isTorus",void 0),P(this,"_publicConfigStore",void 0),P(this,"tryPreopenHandle",void 0),P(this,"enable",void 0),P(this,"_state",void 0),P(this,"_jsonRpcConnection",void 0),P(this,"_sentWarnings",{enable:!1,experimentalMethods:!1,send:!1,publicConfigStore:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}}),!Pa.duplex(t))throw new Error(ae.errors.invalidDuplexStream());this.isTorus=!0,this.setMaxListeners(r),this._state=Fa({},At._defaultState),this.selectedAddress=null,this.networkVersion=null,this.chainId=null,this.shouldSendMetadata=n,this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this),this._sendSync=this._sendSync.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._initializeState=this._initializeState.bind(this),this.request=this.request.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this);const o=new ri;ft(t,o,t,this._handleStreamDisconnect.bind(this,"MetaMask")),this._publicConfigStore=new xr.ObservableStore({storageKey:"Metamask-Config"}),ft(o.createStream("publicConfig"),xr.storeAsStream(this._publicConfigStore),Pn.bind(this,"MetaMask PublicConfigStore")),o.ignoreStream("phishing"),this.on("connect",()=>{this._state.isConnected=!0});const a=_o();ft(a.stream,o.createStream(i),a.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider"));const c=new Ao;c.push(So()),c.push(Ua()),c.push(a.middleware),this._rpcEngine=c,a.events.on("notification",d=>{const{method:m,params:y}=d;m==="wallet_accountsChanged"?this._handleAccountsChanged(y):m==="wallet_unlockStateChanged"?this._handleUnlockStateChanged(y):m==="wallet_chainChanged"?this._handleChainChanged(y):xa.includes(d.method)&&(this.emit("data",d),this.emit("notification",y.result),this.emit("message",{type:m,data:y}))})}get publicConfigStore(){return this._sentWarnings.publicConfigStore||(W.warn(ae.warnings.publicConfigStore),this._sentWarnings.publicConfigStore=!0),this._publicConfigStore}isConnected(){return this._state.isConnected}async request(t){if(!t||typeof t!="object"||Array.isArray(t))throw de.ethErrors.rpc.invalidRequest({message:ae.errors.invalidRequestArgs(),data:t});const{method:r,params:n}=t;if(typeof r!="string"||r.length===0)throw de.ethErrors.rpc.invalidRequest({message:ae.errors.invalidRequestMethod(),data:t});if(n!==void 0&&!Array.isArray(n)&&(typeof n!="object"||n===null))throw de.ethErrors.rpc.invalidRequest({message:ae.errors.invalidRequestParams(),data:t});return new Promise((i,o)=>{this._rpcRequest({method:r,params:n},Ln(i,o))})}sendAsync(t,r){this._rpcRequest(t,r)}addListener(t,r){return this._warnOfDeprecation(t),super.addListener(t,r)}on(t,r){return this._warnOfDeprecation(t),super.on(t,r)}once(t,r){return this._warnOfDeprecation(t),super.once(t,r)}prependListener(t,r){return this._warnOfDeprecation(t),super.prependListener(t,r)}prependOnceListener(t,r){return this._warnOfDeprecation(t),super.prependOnceListener(t,r)}async _initializeState(){try{const{accounts:t,chainId:r,isUnlocked:n,networkVersion:i}=await this.request({method:"wallet_getProviderState"});this.emit("connect",{chainId:r}),this._handleChainChanged({chainId:r,networkVersion:i}),this._handleUnlockStateChanged({accounts:t,isUnlocked:n}),this._handleAccountsChanged(t)}catch(t){W.error("MetaMask: Failed to get initial state. Please report this bug.",t)}finally{W.info("initialized state"),this._state.initialized=!0,this.emit("_initialized")}}_rpcRequest(t,r){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=r;const o=t;if(!Array.isArray(o)){if(o.jsonrpc||(o.jsonrpc="2.0"),o.method==="eth_accounts"||o.method==="eth_requestAccounts")i=(a,c)=>{this._handleAccountsChanged(c.result||[],o.method==="eth_accounts",n),r(a,c)};else if(o.method==="wallet_getProviderState"){this._rpcEngine.handle(t,i);return}}this.tryPreopenHandle(o,i)}send(t,r){return this._sentWarnings.send||(W.warn(ae.warnings.sendDeprecation),this._sentWarnings.send=!0),typeof t=="string"&&(!r||Array.isArray(r))?new Promise((n,i)=>{try{this._rpcRequest({method:t,params:r},Ln(n,i,!1))}catch(o){i(o)}}):t&&typeof t=="object"&&typeof r=="function"?this._rpcRequest(t,r):this._sendSync(t)}_sendSync(t){let r;switch(t.method){case"eth_accounts":r=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":r=this.selectedAddress||null;break;case"eth_uninstallFilter":this._rpcRequest(t,gi),r=!0;break;case"net_version":r=this.networkVersion||null;break;default:throw new Error(ae.errors.unsupportedSync(t.method))}return{id:t.id,jsonrpc:t.jsonrpc,result:r}}_handleConnect(t){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:t}),W.debug(ae.info.connected(t)))}_handleDisconnect(t,r){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!t){this._state.isConnected=!1;let n;t?(n=new de.EthereumRpcError(1013,r||ae.errors.disconnected()),W.debug(n)):(n=new de.EthereumRpcError(1011,r||ae.errors.permanentlyDisconnected()),W.error(n),this.chainId=null,this._state.accounts=null,this.selectedAddress=null,this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",n)}}_handleStreamDisconnect(t,r){Pn(t,r,this),this._handleDisconnect(!1,r?r.message:void 0)}_handleAccountsChanged(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=t;Array.isArray(i)||(W.error("MetaMask: Received non-array accounts parameter. Please report this bug.",i),i=[]);for(const o of t)if(typeof o!="string"){W.error("MetaMask: Received non-string account. Please report this bug.",t),i=[];break}Aa(this._state.accounts,i)||(r&&Array.isArray(this._state.accounts)&&this._state.accounts.length>0&&!n&&W.error('MetaMask: "eth_accounts" unexpectedly updated accounts. Please report this bug.',i),this._state.accounts=i,this.emit("accountsChanged",i)),this.selectedAddress!==i[0]&&(this.selectedAddress=i[0]||null)}_handleChainChanged(){let{chainId:t,networkVersion:r}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!t||!r){W.error("MetaMask: Received invalid network parameters. Please report this bug.",{chainId:t,networkVersion:r});return}r==="loading"?this._handleDisconnect(!0):(this._handleConnect(t),t!==this.chainId&&(this.chainId=t,this._state.initialized&&this.emit("chainChanged",this.chainId)))}_handleUnlockStateChanged(){let{accounts:t,isUnlocked:r}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(typeof r!="boolean"){W.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.",{isUnlocked:r});return}r!==this._state.isUnlocked&&(this._state.isUnlocked=r,this._handleAccountsChanged(t||[]))}_warnOfDeprecation(t){this._sentWarnings.events[t]===!1&&(W.warn(ae.warnings.events[t]),this._sentWarnings.events[t]=!0)}}P(At,"_defaultState",{accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1,hasEmittedConnection:!1});const $a=e=>({algorithms:e.algorithms||["sha256"],delimiter:e.delimiter||" ",full:e.full||!1}),qa=(e,t)=>{const r={};return e.algorithms.forEach(n=>{r[n]=_i(n).update(t,"utf8").digest("base64")}),r},Ka=(e,t)=>{let r="";return r+=Object.keys(t.hashes).map(n=>`${n}-${t.hashes[n]}`).join(e.delimiter),r},Va=(e,t)=>{const r=$a(e),n={hashes:qa(r,t),integrity:void 0};return n.integrity=Ka(r,n),r.full?n:n.integrity};class Nn extends nt.EventEmitter{constructor(t){let{url:r,target:n,features:i}=t;super(),P(this,"url",void 0),P(this,"target",void 0),P(this,"features",void 0),P(this,"window",void 0),P(this,"windowTimer",void 0),P(this,"iClosedWindow",void 0),this.url=r,this.target=n||"_blank",this.features=i||Ha(),this.window=void 0,this.windowTimer=void 0,this.iClosedWindow=!1,this._setupTimer()}_setupTimer(){this.windowTimer=Number(setInterval(()=>{this.window&&this.window.closed&&(clearInterval(this.windowTimer),this.iClosedWindow||this.emit("close"),this.iClosedWindow=!1,this.window=void 0),this.window===void 0&&clearInterval(this.windowTimer)},500))}open(){var t;return this.window=window.open(this.url.href,this.target,this.features),(t=this.window)!==null&&t!==void 0&&t.focus&&this.window.focus(),Promise.resolve()}close(){this.iClosedWindow=!0,this.window&&this.window.close()}redirect(t){t?window.location.replace(this.url.href):window.location.href=this.url.href}}function kn(e){return new Promise((t,r)=>{try{const n=document.createElement("img");n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e}catch(n){r(n)}})}const Ga=e=>{const{document:t}=e,r=t.querySelector('head > meta[property="og:site_name"]');if(r)return r.content;const n=t.querySelector('head > meta[name="title"]');return n?n.content:t.title&&t.title.length>0?t.title:e.location.hostname};async function za(e){const{document:t}=e;let r=t.querySelector('head > link[rel="shortcut icon"]');return r&&await kn(r.href)||(r=Array.from(t.querySelectorAll('head > link[rel="icon"]')).find(n=>Boolean(n.href)),r&&await kn(r.href))?r.href:null}const Ya=async()=>({name:Ga(window),icon:await za(window)});async function Xa(e){try{const t=await Ya();e.handle({jsonrpc:"2.0",id:Oe(),method:"wallet_sendDomainMetadata",params:t},gi)}catch(t){W.error({message:ae.errors.sendSiteMetadata(),originalError:t})}}const Ja=["host","chainId","networkName"];function Bn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Za(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Bn(Object(r),!0).forEach(function(n){P(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Bn(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const Qa={[Xe.GOOGLE]:!0,[Xe.FACEBOOK]:!0,[Xe.REDDIT]:!0,[Xe.TWITCH]:!0,[Xe.DISCORD]:!0},yi="sha384-CtXpgmTZsK+NAtIX8tWrMn+8s/fTjkftnUPkLV3Hnhe7kj5CH5E92MqqBD46kp/0",es="max-age=3600",ts=["eth_sendTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","personal_sign","eth_getEncryptionPublicKey","eth_decrypt"];(async function(){try{if(typeof document>"u")return;const t=document.createElement("link"),{torusUrl:r}=await pi("production",{check:!1,hash:yi,version:""});t.href=`${r}/popup`,t.crossOrigin="anonymous",t.type="text/html",t.rel="prefetch",t.relList&&t.relList.supports&&t.relList.supports("prefetch")&&document.head.appendChild(t)}catch(t){W.warn(t)}})();class ns{constructor(){let{buttonPosition:t=Le.BOTTOM_LEFT,buttonSize:r=56,modalZIndex:n=99999,apiKey:i="torus-default"}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};P(this,"buttonPosition",Le.BOTTOM_LEFT),P(this,"buttonSize",void 0),P(this,"torusUrl",void 0),P(this,"torusIframe",void 0),P(this,"styleLink",void 0),P(this,"isLoggedIn",void 0),P(this,"isInitialized",void 0),P(this,"torusWidgetVisibility",void 0),P(this,"torusAlert",void 0),P(this,"apiKey",void 0),P(this,"modalZIndex",void 0),P(this,"alertZIndex",void 0),P(this,"torusAlertContainer",void 0),P(this,"isIframeFullScreen",void 0),P(this,"whiteLabel",void 0),P(this,"requestedVerifier",void 0),P(this,"currentVerifier",void 0),P(this,"embedTranslations",void 0),P(this,"ethereum",void 0),P(this,"provider",void 0),P(this,"communicationMux",void 0),P(this,"isLoginCallback",void 0),P(this,"paymentProviders",le.paymentProviders),P(this,"loginHint",""),P(this,"useWalletConnect",void 0),P(this,"isCustomLogin",!1),this.buttonPosition=t,this.buttonSize=r,this.torusUrl="",this.isLoggedIn=!1,this.isInitialized=!1,this.torusWidgetVisibility=!0,this.requestedVerifier="",this.currentVerifier="",this.apiKey=i,Ai(i),this.modalZIndex=n,this.alertZIndex=n+1e3,this.isIframeFullScreen=!1}async init(){let{buildEnv:t=Ta.PRODUCTION,enableLogging:r=!1,enabledVerifiers:n=Qa,network:i={host:"mainnet",chainId:null,networkName:"",blockExplorer:"",ticker:"",tickerName:""},loginConfig:o={},showTorusButton:a=!0,integrity:c={check:!1,hash:yi,version:""},whiteLabel:d,skipTKey:m=!1,useWalletConnect:y=!1,mfaLevel:p="default"}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.isInitialized)throw new Error("Already initialized");const{torusUrl:h,logLevel:b}=await pi(t,c);W.info(h,"url loaded"),this.torusUrl=h,this.whiteLabel=d,this.useWalletConnect=y,this.isCustomLogin=!!(o&&Object.keys(o).length>0)||!!(d&&Object.keys(d).length>0),W.setDefaultLevel(b),r?W.enableAll():W.disableAll(),this.torusWidgetVisibility=a;const O=new URL(h);O.pathname.endsWith("/")?O.pathname+="popup":O.pathname+="/popup",O.hash=`#isCustomLogin=${this.isCustomLogin}`,this.torusIframe=Je(`<iframe
id="torusIframe"
allow=${y?"camera":""}
class="torusIframe"
src="${O.href}"
style="display: none; position: fixed; top: 0; right: 0; width: 100%; color-scheme: none;
height: 100%; border: none; border-radius: 0; z-index: ${this.modalZIndex}"
></iframe>`),this.torusAlertContainer=Je('<div id="torusAlertContainer"></div>'),this.torusAlertContainer.style.display="none",this.torusAlertContainer.style.setProperty("z-index",this.alertZIndex.toString());const _=window.document.createElement("link");_.setAttribute("rel","stylesheet"),_.setAttribute("type","text/css"),_.setAttribute("href",`${h}/css/widget.css`),this.styleLink=_;const{defaultLanguage:T=Tn(),customTranslations:A={}}=this.whiteLabel||{},U=jn(le.translations,A)[T]||le.translations[Tn()];this.embedTranslations=U.embed;const k=async()=>(await Ba(),new Promise((q,j)=>{this.torusIframe.onload=async()=>{this._setupWeb3();const V=this.communicationMux.getStream("init_stream");V.on("data",X=>{const{name:L,data:G,error:H}=X;L==="init_complete"&&G.success?(this.isInitialized=!0,this._displayIframe(this.isIframeFullScreen),q(void 0)):H&&j(new Error(H))}),V.write({name:"init_stream",data:{enabledVerifiers:n,loginConfig:o,whiteLabel:this.whiteLabel,buttonPosition:this.buttonPosition,buttonSize:this.buttonSize,torusWidgetVisibility:this.torusWidgetVisibility,apiKey:this.apiKey,skipTKey:m,network:i,mfaLevel:p}})},window.document.head.appendChild(this.styleLink),window.document.body.appendChild(this.torusIframe),window.document.body.appendChild(this.torusAlertContainer)}));if(t==="production"&&c.check){const q=`${h}/popup`,j=await fetch(q,{cache:"reload"});if(j.headers.get("Cache-Control")!==es)throw new Error(`Unexpected Cache-Control headers, got ${j.headers.get("Cache-Control")}`);const V=await j.text(),X=Va({algorithms:["sha384"]},V);if(W.info(X,"integrity"),X===c.hash)await k();else throw this.clearInit(),new Error("Integrity check failed")}else await k()}login(){let{verifier:t="",login_hint:r=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.isInitialized)throw new Error("Call init() first");return this.requestedVerifier=t,this.loginHint=r,this.ethereum.enable()}logout(){return new Promise((t,r)=>{if(!this.isLoggedIn){r(new Error("User has not logged in yet"));return}this.communicationMux.getStream("logout").write({name:"logOut"});const i=this.communicationMux.getStream("status");ue(i,"data",a=>{a.loggedIn?r(new Error("Some Error Occured")):(this.isLoggedIn=!1,this.currentVerifier="",this.requestedVerifier="",t())})})}async cleanUp(){this.isLoggedIn&&await this.logout(),this.clearInit()}clearInit(){function t(r){return r instanceof Element||r instanceof HTMLDocument}t(this.styleLink)&&window.document.body.contains(this.styleLink)&&(this.styleLink.remove(),this.styleLink=void 0),t(this.torusIframe)&&window.document.body.contains(this.torusIframe)&&(this.torusIframe.remove(),this.torusIframe=void 0),t(this.torusAlertContainer)&&window.document.body.contains(this.torusAlertContainer)&&(this.torusAlert=void 0,this.torusAlertContainer.remove(),this.torusAlertContainer=void 0),this.isInitialized=!1}hideTorusButton(){this.torusWidgetVisibility=!1,this._sendWidgetVisibilityStatus(!1),this._displayIframe()}showTorusButton(){this.torusWidgetVisibility=!0,this._sendWidgetVisibilityStatus(!0),this._displayIframe()}setProvider(t){let{host:r="mainnet",chainId:n=null,networkName:i=""}=t,o=Ei(t,Ja);return new Promise((a,c)=>{const d=this.communicationMux.getStream("provider_change");ue(d,"data",p=>{const{err:h,success:b}=p.data;W.info(p),h?c(h):b?a():c(new Error("some error occured"))});const y=Oe();this._handleWindow(y,{target:"_blank",features:Mn}),d.write({name:"show_provider_change",data:{network:Za({host:r,chainId:n,networkName:i},o),preopenInstanceId:y,override:!1}})})}showWallet(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=this.communicationMux.getStream("show_wallet"),i=t?`/${t}`:"";n.write({name:"show_wallet",data:{path:i}}),ue(n,"data",a=>{if(a.name==="show_wallet_instance"){const{instanceId:c}=a.data,d=new URL(`${this.torusUrl}/wallet${i}`);d.searchParams.append("integrity","true"),d.searchParams.append("instanceId",c),Object.keys(r).forEach(y=>{d.searchParams.append(y,r[y])}),d.hash=`#isCustomLogin=${this.isCustomLogin}`,new Nn({url:d,features:Wa}).open()}})}async getPublicAddress(t){let{verifier:r,verifierId:n,isExtended:i=!1}=t;if(!le.supportedVerifierList.includes(r)||!Cn[r])throw new Error("Unsupported verifier");const o=r,a=Cn[r],c=new URL("https://api.tor.us/lookup/torus");return c.searchParams.append("verifier",a),c.searchParams.append("verifierId",n),c.searchParams.append("walletVerifier",o),c.searchParams.append("network","mainnet"),c.searchParams.append("isExtended",i.toString()),Hn(c.href,{headers:{"Content-Type":"application/json; charset=utf-8"}},{useAPIKey:!0})}getUserInfo(t){return new Promise((r,n)=>{if(this.isLoggedIn){const i=this.communicationMux.getStream("user_info_access");i.write({name:"user_info_access_request"}),ue(i,"data",a=>{const{name:c,data:{approved:d,payload:m,rejected:y,newRequest:p}}=a;if(c==="user_info_access_response"){if(d)r(m);else if(y)n(new Error("User rejected the request"));else if(p){const h=this.communicationMux.getStream("user_info");ue(h,"data",_=>{_.name==="user_info_response"&&(_.data.approved?r(_.data.payload):n(new Error("User rejected the request")))});const O=Oe();this._handleWindow(O,{target:"_blank",features:Mn}),h.write({name:"user_info_request",data:{message:t,preopenInstanceId:O}})}}})}else n(new Error("User has not logged in yet"))})}initiateTopup(t,r){return new Promise((n,i)=>{if(this.isInitialized){const{errors:o,isValid:a}=ja(t,r);if(!a){i(new Error(JSON.stringify(o)));return}const c=this.communicationMux.getStream("topup");ue(c,"data",y=>{y.name==="topup_response"&&(y.data.success?n(y.data.success):i(new Error(y.data.error)))});const m=Oe();this._handleWindow(m),c.write({name:"topup_request",data:{provider:t,params:r,preopenInstanceId:m}})}else i(new Error("Torus is not initialized yet"))})}async loginWithPrivateKey(t){const{privateKey:r,userInfo:n}=t;return new Promise((i,o)=>{if(this.isInitialized){if(Re.Buffer.from(r,"hex").length!==32){o(new Error("Invalid private key, Please provide a 32 byte valid secp25k1 private key"));return}const a=this.communicationMux.getStream("login_with_private_key");ue(a,"data",d=>{d.name==="login_with_private_key_response"&&(d.data.success?i(d.data.success):o(new Error(d.data.error)))}),a.write({name:"login_with_private_key_request",data:{privateKey:r,userInfo:n}})}else o(new Error("Torus is not initialized yet"))})}async showWalletConnectScanner(){if(!this.useWalletConnect)throw new Error("Set `useWalletConnect` as true in init function options to use wallet connect scanner");return new Promise((t,r)=>{if(this.isLoggedIn){const n=this.communicationMux.getStream("wallet_connect_stream");ue(n,"data",o=>{o.name==="wallet_connect_stream_res"&&(o.data.success?t(o.data.success):r(new Error(o.data.error)),this._displayIframe())}),n.write({name:"wallet_connect_stream_req"}),this._displayIframe(!0)}else r(new Error("User has not logged in yet"))})}_handleWindow(t){let{url:r,target:n,features:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t){const o=this.communicationMux.getStream("window"),a=new URL(r||`${this.torusUrl}/redirect?preopenInstanceId=${t}`);a.hash?a.hash+=`&isCustomLogin=${this.isCustomLogin}`:a.hash=`#isCustomLogin=${this.isCustomLogin}`;const c=new Nn({url:a,target:n,features:i});if(c.open(),!c.window){this._createPopupBlockAlert(t,a.href);return}o.write({name:"opened_window",data:{preopenInstanceId:t}});const d=m=>{let{preopenInstanceId:y,close:p}=m;y===t&&p&&(c.close(),o.removeListener("data",d))};o.on("data",d),c.once("close",()=>{o.write({data:{preopenInstanceId:t,closed:!0}}),o.removeListener("data",d)})}}_setEmbedWhiteLabel(t){const{theme:r}=this.whiteLabel||{};if(r){const{isDark:n=!1,colors:i={}}=r;n&&t.classList.add("torus-dark"),i.torusBrand1&&t.style.setProperty("--torus-brand-1",i.torusBrand1),i.torusGray2&&t.style.setProperty("--torus-gray-2",i.torusGray2)}}_getLogoUrl(){var t,r;let n=`${this.torusUrl}/images/torus_icon-blue.svg`;if((t=this.whiteLabel)!==null&&t!==void 0&&(r=t.theme)!==null&&r!==void 0&&r.isDark){var i;n=((i=this.whiteLabel)===null||i===void 0?void 0:i.logoLight)||n}else{var o;n=((o=this.whiteLabel)===null||o===void 0?void 0:o.logoDark)||n}return n}_sendWidgetVisibilityStatus(t){this.communicationMux.getStream("torus-widget-visibility").write({data:t})}_displayIframe(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;const r={},n=this.buttonSize+14;if(t)r.display="block",r.width="100%",r.height="100%",r.top="0px",r.right="0px",r.left="0px",r.bottom="0px";else switch(r.display=this.torusWidgetVisibility?"block":"none",r.height=`${n}px`,r.width=`${n}px`,this.buttonPosition){case Le.TOP_LEFT:r.top="0px",r.left="0px",r.right="auto",r.bottom="auto";break;case Le.TOP_RIGHT:r.top="0px",r.right="0px",r.left="auto",r.bottom="auto";break;case Le.BOTTOM_RIGHT:r.bottom="0px",r.right="0px",r.top="auto",r.left="auto";break;case Le.BOTTOM_LEFT:default:r.bottom="0px",r.left="0px",r.top="auto",r.right="auto";break}Object.assign(this.torusIframe.style,r),this.isIframeFullScreen=t}_setupWeb3(){W.info("setupWeb3 running");const t=new un({name:"embed_metamask",target:"iframe_metamask",targetWindow:this.torusIframe.contentWindow,targetOrigin:new URL(this.torusUrl).origin}),r=new un({name:"embed_comm",target:"iframe_comm",targetWindow:this.torusIframe.contentWindow,targetOrigin:new URL(this.torusUrl).origin}),n=new At(t),i=y=>{const p=n[y];n[y]=function(b){if(b&&b==="eth_requestAccounts")return n.enable();for(var O=arguments.length,_=new Array(O>1?O-1:0),T=1;T<O;T++)_[T-1]=arguments[T];return p.apply(this,[b,..._])}};i("send"),i("sendAsync"),n.enable=()=>new Promise((y,p)=>{n.sendAsync({jsonrpc:"2.0",id:Oe(),method:"eth_requestAccounts",params:[]},(h,b)=>{const{result:O}=b||{};if(h)setTimeout(()=>{p(h)},50);else if(Array.isArray(O)&&O.length>0){const _=()=>{if(this.requestedVerifier!==""&&this.currentVerifier!==this.requestedVerifier){const{requestedVerifier:T}=this;this.logout().then(A=>{this.requestedVerifier=T,this._showLoginPopup(!0,y,p)}).catch(A=>p(A))}else y(O)};this.isLoggedIn?_():this.isLoginCallback=_}else this._showLoginPopup(!0,y,p)})}),n.tryPreopenHandle=(y,p)=>{const h=y;if(!Array.isArray(h)&&ts.includes(h.method)){const b=Oe();this._handleWindow(b,{target:"_blank",features:In}),h.preopenInstanceId=b}n._rpcEngine.handle(h,p)};const o=new Proxy(n,{deleteProperty:()=>!0});this.ethereum=o;const a=No(r);this.communicationMux=a,a.getStream("window").on("data",y=>{y.name==="create_window"&&this._createPopupBlockAlert(y.data.preopenInstanceId,y.data.url)}),a.getStream("widget").on("data",y=>{const{data:p}=y;this._displayIframe(p)}),a.getStream("status").on("data",y=>{y.loggedIn?(this.isLoggedIn=y.loggedIn,this.currentVerifier=y.verifier):this._displayIframe(),this.isLoginCallback&&(this.isLoginCallback(),delete this.isLoginCallback)}),this.provider=o,this.provider.shouldSendMetadata&&Xa(this.provider._rpcEngine),n._initializeState(),W.debug("Torus - injected provider")}_showLoginPopup(t,r,n){const i=a=>{const{err:c,selectedAddress:d}=a;c?(W.error(c),n&&n(c)):r&&r([d]),this.isIframeFullScreen&&this._displayIframe()},o=this.communicationMux.getStream("oauth");if(!this.requestedVerifier)this._displayIframe(!0),ue(o,"data",i),o.write({name:"oauth_modal",data:{calledFromEmbed:t}});else{ue(o,"data",i);const a=Oe();this._handleWindow(a),o.write({name:"oauth",data:{calledFromEmbed:t,verifier:this.requestedVerifier,preopenInstanceId:a,login_hint:this.loginHint}})}}_createPopupBlockAlert(t,r){const n=this._getLogoUrl(),i=Je(`<div id="torusAlert" class="torus-alert--v2"><div id="torusAlert__logo"><img src="${n}" /></div><div><h1 id="torusAlert__title">${this.embedTranslations.actionRequired}</h1><p id="torusAlert__desc">${this.embedTranslations.pendingAction}</p></div></div>`),o=Je(`<div><a id="torusAlert__btn">${this.embedTranslations.continue}</a></div>`),a=Je('<div id="torusAlert__btn-container"></div>');a.appendChild(o),i.appendChild(a);const c=()=>{o.addEventListener("click",()=>{this._handleWindow(t,{url:r,target:"_blank",features:In}),i.remove(),this.torusAlertContainer.children.length===0&&(this.torusAlertContainer.style.display="none")})};this._setEmbedWhiteLabel(i),Rn(()=>{this.torusAlertContainer.style.display="block",this.torusAlertContainer.appendChild(i)}),Rn(c)}}export{Le as BUTTON_POSITION,Xe as LOGIN_PROVIDER,$ as PAYMENT_PROVIDER,Y as SUPPORTED_PAYMENT_NETWORK,Ta as TORUS_BUILD_ENV,At as TorusInpageProvider,Cn as WALLET_OPENLOGIN_VERIFIER_MAP,Ee as WALLET_VERIFIERS,ns as default};