@bonfida/spl-name-service
Advanced tools
Comparing version 0.1.63 to 0.1.64
@@ -1,1 +0,1 @@ | ||
"use strict";var t=require("@solana/web3.js"),i=require("@ethersproject/sha2"),e=require("borsh"),r=require("@solana/spl-token"),n=require("@bonfida/name-offers"),s=require("tweetnacl"),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a={};!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function r(t,i){t.super_=i;var e=function(){};e.prototype=i.prototype,t.prototype=new e,t.prototype.constructor=t}function n(t,i,e){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(e=i,i=10),this._init(t||0,i||10,e||"be"))}var s;"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function o(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void e(!1,"Invalid character in "+t)}function a(t,i,e){var r=o(t,e);return e-1>=i&&(r|=o(t,e-1)<<4),r}function h(t,i,r,n){for(var s=0,o=0,a=Math.min(t.length,r),h=i;h<a;h++){var u=t.charCodeAt(h)-48;s*=n,o=u>=49?u-49+10:u>=17?u-17+10:u,e(u>=0&&o<n,"Invalid character"),s+=o}return s}function u(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},n.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},n.prototype._initArray=function(t,i,r){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if("be"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},n.prototype._parseHex=function(t,i,e){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,s=0,o=0;if("be"===e)for(r=t.length-1;r>=i;r-=2)n=a(t,i,r)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(r=(t.length-i)%2==0?i+1:i;r<t.length;r+=2)n=a(t,i,r)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},n.prototype._parseBase=function(t,i,e){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=i)r++;r--,n=n/i|0;for(var s=t.length-e,o=s%r,a=Math.min(s,s-o)+e,u=0,l=e;l<a;l+=r)u=h(t,l,l+r,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var f=1;for(u=h(t,l,t.length,i),l=0;l<o;l++)f*=i;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,i,e){e.negative=i.negative^t.negative;var r=t.length+i.length|0;e.length=r,r=r-1|0;var n=0|t.words[0],s=0|i.words[0],o=n*s,a=67108863&o,h=o/67108864|0;e.words[0]=a;for(var u=1;u<r;u++){for(var l=h>>>26,f=67108863&h,m=Math.min(u,i.length-1),c=Math.max(0,u-t.length+1);c<=m;c++){var d=u-c|0;l+=(o=(n=0|t.words[d])*(s=0|i.words[c])+f)/67108864|0,f=67108863&o}e.words[u]=0|f,h=0|l}return 0!==h?e.words[u]=0|h:e.length--,e._strip()}n.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);r=0!=(s=a>>>24-n&16777215)||o!==this.length-1?f[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=m[t],l=c[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modrn(l).toString(t);r=(d=d.idivn(l)).isZero()?p+r:f[u-p.length]+p+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}e(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(t,i){return this.toArrayLike(s,t,i)}),n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);e(n<=s,"byte array longer than desired length"),e(s>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,s);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},n.prototype._toArrayLikeLE=function(t,i){for(var e=0,r=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|r;t[e++]=255&o,e<t.length&&(t[e++]=o>>8&255),e<t.length&&(t[e++]=o>>16&255),6===s?(e<t.length&&(t[e++]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(e<t.length)for(t[e++]=r;e<t.length;)t[e++]=0},n.prototype._toArrayLikeBE=function(t,i){for(var e=t.length-1,r=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|r;t[e--]=255&o,e>=0&&(t[e--]=o>>8&255),e>=0&&(t[e--]=o>>16&255),6===s?(e>=0&&(t[e--]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(e>=0)for(t[e--]=r;e>=0;)t[e--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var i=t,e=0;return i>=4096&&(e+=13,i>>>=13),i>=64&&(e+=7,i>>>=7),i>=8&&(e+=4,i>>>=4),i>=2&&(e+=2,i>>>=2),e+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,e=0;return 0==(8191&i)&&(e+=13,i>>>=13),0==(127&i)&&(e+=7,i>>>=7),0==(15&i)&&(e+=4,i>>>=4),0==(3&i)&&(e+=2,i>>>=2),0==(1&i)&&e++,e},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var e=this._zeroBits(this.words[i]);if(t+=e,26!==e)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},n.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var e=0;e<i.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=i.length,this._strip()},n.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var r=0;r<e.length;r++)this.words[r]=i.words[r]^e.words[r];if(this!==i)for(;r<i.length;r++)this.words[r]=i.words[r];return this.length=i.length,this._strip()},n.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var i,e,r;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0,s=0;s<r.length;s++)i=(0|e.words[s])+(0|r.words[s])+n,this.words[s]=67108863&i,n=i>>>26;for(;0!==n&&s<e.length;s++)i=(0|e.words[s])+n,this.words[s]=67108863&i,n=i>>>26;if(this.length=e.length,0!==n)this.words[this.length]=n,this.length++;else if(e!==this)for(;s<e.length;s++)this.words[s]=e.words[s];return this},n.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(e=this,r=t):(e=t,r=this);for(var s=0,o=0;o<r.length;o++)s=(i=(0|e.words[o])-(0|r.words[o])+s)>>26,this.words[o]=67108863&i;for(;0!==s&&o<e.length;o++)s=(i=(0|e.words[o])+s)>>26,this.words[o]=67108863&i;if(0===s&&o<e.length&&e!==this)for(;o<e.length;o++)this.words[o]=e.words[o];return this.length=Math.max(this.length,o),e!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,i,e){var r,n,s,o=t.words,a=i.words,h=e.words,u=0,l=0|o[0],f=8191&l,m=l>>>13,c=0|o[1],d=8191&c,p=c>>>13,g=0|o[2],w=8191&g,y=g>>>13,v=0|o[3],M=8191&v,b=v>>>13,R=0|o[4],_=8191&R,x=R>>>13,S=0|o[5],k=8191&S,B=S>>>13,E=0|o[6],A=8191&E,I=E>>>13,P=0|o[7],T=8191&P,N=P>>>13,K=0|o[8],D=8191&K,W=K>>>13,L=0|o[9],O=8191&L,H=L>>>13,q=0|a[0],z=8191&q,Z=q>>>13,F=0|a[1],U=8191&F,C=F>>>13,j=0|a[2],V=8191&j,G=j>>>13,Y=0|a[3],X=8191&Y,J=Y>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,it=0|a[5],et=8191&it,rt=it>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,mt=lt>>>13,ct=0|a[9],dt=8191&ct,pt=ct>>>13;e.negative=t.negative^i.negative,e.length=19;var gt=(u+(r=Math.imul(f,z))|0)+((8191&(n=(n=Math.imul(f,Z))+Math.imul(m,z)|0))<<13)|0;u=((s=Math.imul(m,Z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(d,z),n=(n=Math.imul(d,Z))+Math.imul(p,z)|0,s=Math.imul(p,Z);var wt=(u+(r=r+Math.imul(f,U)|0)|0)+((8191&(n=(n=n+Math.imul(f,C)|0)+Math.imul(m,U)|0))<<13)|0;u=((s=s+Math.imul(m,C)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(w,z),n=(n=Math.imul(w,Z))+Math.imul(y,z)|0,s=Math.imul(y,Z),r=r+Math.imul(d,U)|0,n=(n=n+Math.imul(d,C)|0)+Math.imul(p,U)|0,s=s+Math.imul(p,C)|0;var yt=(u+(r=r+Math.imul(f,V)|0)|0)+((8191&(n=(n=n+Math.imul(f,G)|0)+Math.imul(m,V)|0))<<13)|0;u=((s=s+Math.imul(m,G)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,Z))+Math.imul(b,z)|0,s=Math.imul(b,Z),r=r+Math.imul(w,U)|0,n=(n=n+Math.imul(w,C)|0)+Math.imul(y,U)|0,s=s+Math.imul(y,C)|0,r=r+Math.imul(d,V)|0,n=(n=n+Math.imul(d,G)|0)+Math.imul(p,V)|0,s=s+Math.imul(p,G)|0;var vt=(u+(r=r+Math.imul(f,X)|0)|0)+((8191&(n=(n=n+Math.imul(f,J)|0)+Math.imul(m,X)|0))<<13)|0;u=((s=s+Math.imul(m,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(_,z),n=(n=Math.imul(_,Z))+Math.imul(x,z)|0,s=Math.imul(x,Z),r=r+Math.imul(M,U)|0,n=(n=n+Math.imul(M,C)|0)+Math.imul(b,U)|0,s=s+Math.imul(b,C)|0,r=r+Math.imul(w,V)|0,n=(n=n+Math.imul(w,G)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,G)|0,r=r+Math.imul(d,X)|0,n=(n=n+Math.imul(d,J)|0)+Math.imul(p,X)|0,s=s+Math.imul(p,J)|0;var Mt=(u+(r=r+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(m,$)|0))<<13)|0;u=((s=s+Math.imul(m,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(k,z),n=(n=Math.imul(k,Z))+Math.imul(B,z)|0,s=Math.imul(B,Z),r=r+Math.imul(_,U)|0,n=(n=n+Math.imul(_,C)|0)+Math.imul(x,U)|0,s=s+Math.imul(x,C)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,G)|0)+Math.imul(b,V)|0,s=s+Math.imul(b,G)|0,r=r+Math.imul(w,X)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,J)|0,r=r+Math.imul(d,$)|0,n=(n=n+Math.imul(d,tt)|0)+Math.imul(p,$)|0,s=s+Math.imul(p,tt)|0;var bt=(u+(r=r+Math.imul(f,et)|0)|0)+((8191&(n=(n=n+Math.imul(f,rt)|0)+Math.imul(m,et)|0))<<13)|0;u=((s=s+Math.imul(m,rt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(A,z),n=(n=Math.imul(A,Z))+Math.imul(I,z)|0,s=Math.imul(I,Z),r=r+Math.imul(k,U)|0,n=(n=n+Math.imul(k,C)|0)+Math.imul(B,U)|0,s=s+Math.imul(B,C)|0,r=r+Math.imul(_,V)|0,n=(n=n+Math.imul(_,G)|0)+Math.imul(x,V)|0,s=s+Math.imul(x,G)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(b,X)|0,s=s+Math.imul(b,J)|0,r=r+Math.imul(w,$)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(y,$)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(d,et)|0,n=(n=n+Math.imul(d,rt)|0)+Math.imul(p,et)|0,s=s+Math.imul(p,rt)|0;var Rt=(u+(r=r+Math.imul(f,st)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(m,st)|0))<<13)|0;u=((s=s+Math.imul(m,ot)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,Z))+Math.imul(N,z)|0,s=Math.imul(N,Z),r=r+Math.imul(A,U)|0,n=(n=n+Math.imul(A,C)|0)+Math.imul(I,U)|0,s=s+Math.imul(I,C)|0,r=r+Math.imul(k,V)|0,n=(n=n+Math.imul(k,G)|0)+Math.imul(B,V)|0,s=s+Math.imul(B,G)|0,r=r+Math.imul(_,X)|0,n=(n=n+Math.imul(_,J)|0)+Math.imul(x,X)|0,s=s+Math.imul(x,J)|0,r=r+Math.imul(M,$)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(b,$)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(w,et)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(y,et)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(d,st)|0,n=(n=n+Math.imul(d,ot)|0)+Math.imul(p,st)|0,s=s+Math.imul(p,ot)|0;var _t=(u+(r=r+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(m,ht)|0))<<13)|0;u=((s=s+Math.imul(m,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(D,z),n=(n=Math.imul(D,Z))+Math.imul(W,z)|0,s=Math.imul(W,Z),r=r+Math.imul(T,U)|0,n=(n=n+Math.imul(T,C)|0)+Math.imul(N,U)|0,s=s+Math.imul(N,C)|0,r=r+Math.imul(A,V)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,G)|0,r=r+Math.imul(k,X)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(B,X)|0,s=s+Math.imul(B,J)|0,r=r+Math.imul(_,$)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(x,$)|0,s=s+Math.imul(x,tt)|0,r=r+Math.imul(M,et)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(b,et)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(d,ht)|0,n=(n=n+Math.imul(d,ut)|0)+Math.imul(p,ht)|0,s=s+Math.imul(p,ut)|0;var xt=(u+(r=r+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(m,ft)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(O,z),n=(n=Math.imul(O,Z))+Math.imul(H,z)|0,s=Math.imul(H,Z),r=r+Math.imul(D,U)|0,n=(n=n+Math.imul(D,C)|0)+Math.imul(W,U)|0,s=s+Math.imul(W,C)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(N,V)|0,s=s+Math.imul(N,G)|0,r=r+Math.imul(A,X)|0,n=(n=n+Math.imul(A,J)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,J)|0,r=r+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(B,$)|0,s=s+Math.imul(B,tt)|0,r=r+Math.imul(_,et)|0,n=(n=n+Math.imul(_,rt)|0)+Math.imul(x,et)|0,s=s+Math.imul(x,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(y,ht)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(d,ft)|0,n=(n=n+Math.imul(d,mt)|0)+Math.imul(p,ft)|0,s=s+Math.imul(p,mt)|0;var St=(u+(r=r+Math.imul(f,dt)|0)|0)+((8191&(n=(n=n+Math.imul(f,pt)|0)+Math.imul(m,dt)|0))<<13)|0;u=((s=s+Math.imul(m,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(O,U),n=(n=Math.imul(O,C))+Math.imul(H,U)|0,s=Math.imul(H,C),r=r+Math.imul(D,V)|0,n=(n=n+Math.imul(D,G)|0)+Math.imul(W,V)|0,s=s+Math.imul(W,G)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,J)|0,r=r+Math.imul(A,$)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(k,et)|0,n=(n=n+Math.imul(k,rt)|0)+Math.imul(B,et)|0,s=s+Math.imul(B,rt)|0,r=r+Math.imul(_,st)|0,n=(n=n+Math.imul(_,ot)|0)+Math.imul(x,st)|0,s=s+Math.imul(x,ot)|0,r=r+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,mt)|0)+Math.imul(y,ft)|0,s=s+Math.imul(y,mt)|0;var kt=(u+(r=r+Math.imul(d,dt)|0)|0)+((8191&(n=(n=n+Math.imul(d,pt)|0)+Math.imul(p,dt)|0))<<13)|0;u=((s=s+Math.imul(p,pt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,G))+Math.imul(H,V)|0,s=Math.imul(H,G),r=r+Math.imul(D,X)|0,n=(n=n+Math.imul(D,J)|0)+Math.imul(W,X)|0,s=s+Math.imul(W,J)|0,r=r+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,tt)|0,r=r+Math.imul(A,et)|0,n=(n=n+Math.imul(A,rt)|0)+Math.imul(I,et)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(k,st)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(B,st)|0,s=s+Math.imul(B,ot)|0,r=r+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(x,ht)|0,s=s+Math.imul(x,ut)|0,r=r+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,mt)|0)+Math.imul(b,ft)|0,s=s+Math.imul(b,mt)|0;var Bt=(u+(r=r+Math.imul(w,dt)|0)|0)+((8191&(n=(n=n+Math.imul(w,pt)|0)+Math.imul(y,dt)|0))<<13)|0;u=((s=s+Math.imul(y,pt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(O,X),n=(n=Math.imul(O,J))+Math.imul(H,X)|0,s=Math.imul(H,J),r=r+Math.imul(D,$)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(W,$)|0,s=s+Math.imul(W,tt)|0,r=r+Math.imul(T,et)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(N,et)|0,s=s+Math.imul(N,rt)|0,r=r+Math.imul(A,st)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,ut)|0)+Math.imul(B,ht)|0,s=s+Math.imul(B,ut)|0,r=r+Math.imul(_,ft)|0,n=(n=n+Math.imul(_,mt)|0)+Math.imul(x,ft)|0,s=s+Math.imul(x,mt)|0;var Et=(u+(r=r+Math.imul(M,dt)|0)|0)+((8191&(n=(n=n+Math.imul(M,pt)|0)+Math.imul(b,dt)|0))<<13)|0;u=((s=s+Math.imul(b,pt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(O,$),n=(n=Math.imul(O,tt))+Math.imul(H,$)|0,s=Math.imul(H,tt),r=r+Math.imul(D,et)|0,n=(n=n+Math.imul(D,rt)|0)+Math.imul(W,et)|0,s=s+Math.imul(W,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,r=r+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(k,ft)|0,n=(n=n+Math.imul(k,mt)|0)+Math.imul(B,ft)|0,s=s+Math.imul(B,mt)|0;var At=(u+(r=r+Math.imul(_,dt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(x,dt)|0))<<13)|0;u=((s=s+Math.imul(x,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(O,et),n=(n=Math.imul(O,rt))+Math.imul(H,et)|0,s=Math.imul(H,rt),r=r+Math.imul(D,st)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(W,st)|0,s=s+Math.imul(W,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,r=r+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,ft)|0,s=s+Math.imul(I,mt)|0;var It=(u+(r=r+Math.imul(k,dt)|0)|0)+((8191&(n=(n=n+Math.imul(k,pt)|0)+Math.imul(B,dt)|0))<<13)|0;u=((s=s+Math.imul(B,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(O,st),n=(n=Math.imul(O,ot))+Math.imul(H,st)|0,s=Math.imul(H,ot),r=r+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(W,ht)|0,s=s+Math.imul(W,ut)|0,r=r+Math.imul(T,ft)|0,n=(n=n+Math.imul(T,mt)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,mt)|0;var Pt=(u+(r=r+Math.imul(A,dt)|0)|0)+((8191&(n=(n=n+Math.imul(A,pt)|0)+Math.imul(I,dt)|0))<<13)|0;u=((s=s+Math.imul(I,pt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(H,ht)|0,s=Math.imul(H,ut),r=r+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,mt)|0)+Math.imul(W,ft)|0,s=s+Math.imul(W,mt)|0;var Tt=(u+(r=r+Math.imul(T,dt)|0)|0)+((8191&(n=(n=n+Math.imul(T,pt)|0)+Math.imul(N,dt)|0))<<13)|0;u=((s=s+Math.imul(N,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(O,ft),n=(n=Math.imul(O,mt))+Math.imul(H,ft)|0,s=Math.imul(H,mt);var Nt=(u+(r=r+Math.imul(D,dt)|0)|0)+((8191&(n=(n=n+Math.imul(D,pt)|0)+Math.imul(W,dt)|0))<<13)|0;u=((s=s+Math.imul(W,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Kt=(u+(r=Math.imul(O,dt))|0)+((8191&(n=(n=Math.imul(O,pt))+Math.imul(H,dt)|0))<<13)|0;return u=((s=Math.imul(H,pt))+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,h[0]=gt,h[1]=wt,h[2]=yt,h[3]=vt,h[4]=Mt,h[5]=bt,h[6]=Rt,h[7]=_t,h[8]=xt,h[9]=St,h[10]=kt,h[11]=Bt,h[12]=Et,h[13]=At,h[14]=It,h[15]=Pt,h[16]=Tt,h[17]=Nt,h[18]=Kt,0!==u&&(h[19]=u,e.length++),e};function g(t,i,e){e.negative=i.negative^t.negative,e.length=t.length+i.length;for(var r=0,n=0,s=0;s<e.length-1;s++){var o=n;n=0;for(var a=67108863&r,h=Math.min(s,i.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var l=s-u,f=(0|t.words[l])*(0|i.words[u]),m=67108863&f;a=67108863&(m=m+a|0),n+=(o=(o=o+(f/67108864|0)|0)+(m>>>26)|0)>>>26,o&=67108863}e.words[s]=a,r=o,o=n}return 0!==r?e.words[s]=r:e.length--,e._strip()}function w(t,i,e){return g(t,i,e)}Math.imul||(p=d),n.prototype.mulTo=function(t,i){var e=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,i):e<63?d(this,t,i):e<1024?g(this,t,i):w(this,t,i)},n.prototype.mul=function(t){var i=new n(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},n.prototype.mulf=function(t){var i=new n(null);return i.words=new Array(this.length+t.length),w(this,t,i)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var i=t<0;i&&(t=-t),e("number"==typeof t),e(t<67108864);for(var r=0,n=0;n<this.length;n++){var s=(0|this.words[n])*t,o=(67108863&s)+(67108863&r);r>>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),e=0;e<i.length;e++){var r=e/26|0,n=e%26;i[e]=t.words[r]>>>n&1}return i}(t);if(0===i.length)return new n(1);for(var e=this,r=0;r<i.length&&0===i[r];r++,e=e.sqr());if(++r<i.length)for(var s=e.sqr();r<i.length;r++,s=s.sqr())0!==i[r]&&(e=e.mul(s));return e},n.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var a=this.words[i]&s,h=(0|this.words[i])-a<<r;this.words[i]=h|o,o=a>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,i,r){var n;e("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-s|f>>>s,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,i,r){return e(0===this.negative),this.iushrn(t,i,r)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},n.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,i,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*i;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(e(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,i){var e=(this.length,t.length),r=this.clone(),s=t,o=0|s.words[s.length-1];0!=(e=26-this._countBits(o))&&(s=s.ushln(e),r.iushln(e),o=0|s.words[s.length-1]);var a,h=r.length-s.length;if("mod"!==i){(a=new n(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=r.clone()._ishlnsubmul(s,1,h);0===l.negative&&(r=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var m=67108864*(0|r.words[s.length+f])+(0|r.words[s.length+f-1]);for(m=Math.min(m/o|0,67108863),r._ishlnsubmul(s,m,f);0!==r.negative;)m--,r.negative=0,r._ishlnsubmul(s,1,f),r.isZero()||(r.negative^=1);a&&(a.words[f]=m)}return a&&a._strip(),r._strip(),"div"!==i&&0!==e&&r.iushrn(e),{div:a||null,mod:r}},n.prototype.divmod=function(t,i,r){return e(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,i),"mod"!==i&&(s=a.div.neg()),"div"!==i&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:s,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),i),"mod"!==i&&(s=a.div.neg()),{div:s,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),i),"div"!==i&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,i);var s,o,a},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var e=0!==i.div.negative?i.mod.isub(t):i.mod,r=t.ushrn(1),n=t.andln(1),s=e.cmp(r);return s<0||1===n&&0===s?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modrn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%t;return i?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/t|0,r=s%t}return this._strip(),i?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var s=new n(1),o=new n(0),a=new n(0),h=new n(1),u=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),f=i.clone();!i.isZero();){for(var m=0,c=1;0==(i.words[0]&c)&&m<26;++m,c<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||o.isOdd())&&(s.iadd(l),o.isub(f)),s.iushrn(1),o.iushrn(1);for(var d=0,p=1;0==(r.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);i.cmp(r)>=0?(i.isub(r),s.isub(a),o.isub(h)):(r.isub(i),a.isub(s),h.isub(o))}return{a:a,b:h,gcd:r.iushln(u)}},n.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var s,o=new n(1),a=new n(0),h=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,m=1;0==(r.words[0]&m)&&f<26;++f,m<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(a)):(r.isub(i),a.isub(o))}return(s=0===i.cmpn(1)?o:a).cmpn(0)<0&&s.iadd(t),s},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),e=t.clone();i.negative=0,e.negative=0;for(var r=0;i.isEven()&&e.isEven();r++)i.iushrn(1),e.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;e.isEven();)e.iushrn(1);var n=i.cmp(e);if(n<0){var s=i;i=e,e=s}else if(0===n||0===e.cmpn(1))break;i.isub(e)}return e.iushln(r)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),e(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,e=this.length-1;e>=0;e--){var r=0|this.words[e],n=0|t.words[e];if(r!==n){r<n?i=-1:r>n&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new x(t)},n.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function R(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){x.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,e=t;do{this.split(e,this.tmp),i=(e=(e=this.imulK(e)).iadd(this.tmp)).bitLength()}while(i>this.n);var r=i<this.n?-1:e.ucmp(this.p);return 0===r?(e.words[0]=0,e.length=1):r>0?e.isub(this.p):void 0!==e.strip?e.strip():e._strip(),e},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},r(M,v),M.prototype.split=function(t,i){for(var e=4194303,r=Math.min(t.length,9),n=0;n<r;n++)i.words[n]=t.words[n];if(i.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(i.words[i.length++]=s&e,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&e)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},M.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,e=0;e<t.length;e++){var r=0|t.words[e];i+=977*r,t.words[e]=67108863&i,i=64*r+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},r(b,v),r(R,v),r(_,v),_.prototype.imulK=function(t){for(var i=0,e=0;e<t.length;e++){var r=19*(0|t.words[e])+i,n=67108863&r;r>>>=26,t.words[e]=n,i=r}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(y[t])return y[t];var i;if("k256"===t)i=new M;else if("p224"===t)i=new b;else if("p192"===t)i=new R;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new _}return y[t]=i,i},x.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,i){this._verify2(t,i);var e=t.add(i);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},x.prototype.iadd=function(t,i){this._verify2(t,i);var e=t.iadd(i);return e.cmp(this.m)>=0&&e.isub(this.m),e},x.prototype.sub=function(t,i){this._verify2(t,i);var e=t.sub(i);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},x.prototype.isub=function(t,i){this._verify2(t,i);var e=t.isub(i);return e.cmpn(0)<0&&e.iadd(this.m),e},x.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},x.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},x.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var r=this.m.add(new n(1)).iushrn(2);return this.pow(t,r)}for(var s=this.m.subn(1),o=0;!s.isZero()&&0===s.andln(1);)o++,s.iushrn(1);e(!s.isZero());var a=new n(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,s),m=this.pow(t,s.addn(1).iushrn(1)),c=this.pow(t,s),d=o;0!==c.cmp(a);){for(var p=c,g=0;0!==p.cmp(a);g++)p=p.redSqr();e(g<d);var w=this.pow(f,new n(1).iushln(d-g-1));m=m.redMul(w),f=w.redSqr(),c=c.redMul(f),d=g}return m},x.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},x.prototype.pow=function(t,i){if(i.isZero())return new n(1).toRed(this);if(0===i.cmpn(1))return t.clone();var e=new Array(16);e[0]=new n(1).toRed(this),e[1]=t;for(var r=2;r<e.length;r++)e[r]=this.mul(e[r-1],t);var s=e[0],o=0,a=0,h=i.bitLength()%26;for(0===h&&(h=26),r=i.length-1;r>=0;r--){for(var u=i.words[r],l=h-1;l>=0;l--){var f=u>>l&1;s!==e[0]&&(s=this.sqr(s)),0!==f||0!==o?(o<<=1,o|=f,(4==++a||0===r&&0===l)&&(s=this.mul(s,e[o]),a=0,o=0)):a=0}h=26}return s},x.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},x.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new S(t)},r(S,x),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},S.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(i),r=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=e.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},S.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var e=t.mul(i),r=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=e.isub(r).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}({get exports(){return a},set exports(t){a=t}},o);const h=new t.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),u="SPL Name Service",l=new t.PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),f=new t.PublicKey("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),m=new t.PublicKey("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),c=new t.PublicKey("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),d=new t.PublicKey("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),p=new t.PublicKey("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),g=new t.PublicKey("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),w=new t.PublicKey("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),y=new t.PublicKey("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),v=Buffer.from("tokenized_name"),M=async(i,e)=>{try{const[n]=await t.PublicKey.findProgramAddress([v,e.toBuffer()],y);if("0"===(await r.getMint(i,n)).supply.toString())return;const s=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],o=await i.getProgramAccounts(r.TOKEN_PROGRAM_ID,{filters:s});if(1!=o.length)return;return new t.PublicKey(o[0].account.data.slice(32,64))}catch{return}};class b{constructor(i){this.parentName=new t.PublicKey(i.parentName),this.owner=new t.PublicKey(i.owner),this.class=new t.PublicKey(i.class)}static async retrieve(t,i){var r;const n=await t.getAccountInfo(i);if(!n)throw new Error("Invalid name account provided");let s=e.deserializeUnchecked(this.schema,b,n.data);s.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:s,nftOwner:await M(t,i)}}static async _retrieveBatch(t,i){const r=await t.getMultipleAccountsInfo(i),n=t=>{if(!t)return;const i=e.deserializeUnchecked(this.schema,b,t);return i.data=null==t?void 0:t.slice(this.HEADER_LEN),i};return r.map((t=>n(null==t?void 0:t.data)))}static async retrieveBatch(t,i){let e=[];for(;i.length>0;)e.push(...await this._retrieveBatch(t,i.splice(0,100)));return e}}b.HEADER_LEN=96,b.schema=new Map([[b,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);class R{constructor(t){this.name=t.name,this.ticker=t.ticker,this.mint=t.mint,this.decimals=t.decimals,this.website=null==t?void 0:t.website,this.logoUri=null==t?void 0:t.logoUri}serialize(){return e.serialize(R.schema,this)}static deserialize(t){return e.deserializeUnchecked(R.schema,R,t)}}R.schema=new Map([[R,{kind:"struct",fields:[["name","string"],["ticker","string"],["mint",[32]],["decimals","u8"],["website",{kind:"option",type:"string"}],["logoUri",{kind:"option",type:"string"}]]}]]);class _{constructor(t){this.mint=t.mint}serialize(){return e.serialize(_.schema,this)}static deserialize(t){return e.deserializeUnchecked(_.schema,_,t)}}async function x(t,i){if(!await t.getAccountInfo(i))throw new Error("Unable to find the given account.");return b.retrieve(t,i)}async function S(t){const e=u+t,r=i.sha256(Buffer.from(e,"utf8")).slice(2);return Buffer.from(r,"hex")}async function k(i,e,r){const n=[i];e?n.push(e.toBuffer()):n.push(Buffer.alloc(32)),r?n.push(r.toBuffer()):n.push(Buffer.alloc(32));const[s]=await t.PublicKey.findProgramAddress(n,h);return s}async function B(t,i){const e=await S(i.toBase58()),r=await k(e,d),{registry:n}=await b.retrieve(t,r);if(!n.data)throw"Could not retrieve name data";const s=new a(n.data.slice(0,4),"le").toNumber();return n.data.slice(4,4+s).toString()}_.schema=new Map([[_,{kind:"struct",fields:[["mint",[32]]]}]]);const E=async(t,i=l)=>{let e=await S(t);return{pubkey:await k(e,void 0,i),hashed:e}},A=async(t,i=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const e=t.split(".");if(2===e.length){const t=Buffer.from([i?1:0]).toString().concat(e[0]),{pubkey:r}=await E(e[1]);return{...await E(t,r),isSub:!0,parent:r}}if(3===e.length&&i){const{pubkey:t}=await E(e[2]),{pubkey:i}=await E("\0".concat(e[1]),t),r=Buffer.from([1]).toString();return{...await E(r.concat(e[0]),i),isSub:!0,parent:t,isSubRecord:!0}}if(e.length>=3)throw new Error("Invalid derivation input");return{...await E(t,l),isSub:!1,parent:void 0}};class I extends a{toBuffer(){const t=super.toArray().reverse(),i=Buffer.from(t);if(4===i.length)return i;if(i.length>4)throw new Error("Numberu32 too large");const e=Buffer.alloc(4);return i.copy(e),e}static fromBuffer(t){if(4!==t.length)throw new Error(`Invalid buffer length: ${t.length}`);return new a([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}class P extends a{toBuffer(){const t=super.toArray().reverse(),i=Buffer.from(t);if(8===i.length)return i;if(i.length>8)throw new Error("Numberu64 too large");const e=Buffer.alloc(8);return i.copy(e),e}static fromBuffer(t){if(8!==t.length)throw new Error(`Invalid buffer length: ${t.length}`);return new a([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}function T(i,e,r,n,s,o,a,h,u,l,f){const m=[Buffer.from(Int8Array.from([0])),new I(o.length).toBuffer(),o,a.toBuffer(),h.toBuffer()],c=Buffer.concat(m),d=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1}];return u?d.push({pubkey:u,isSigner:!0,isWritable:!1}):d.push({pubkey:new t.PublicKey(Buffer.alloc(32)),isSigner:!1,isWritable:!1}),l?d.push({pubkey:l,isSigner:!1,isWritable:!1}):d.push({pubkey:new t.PublicKey(Buffer.alloc(32)),isSigner:!1,isWritable:!1}),f&&d.push({pubkey:f,isSigner:!0,isWritable:!1}),new t.TransactionInstruction({keys:d,programId:i,data:c})}function N(i,e,r,n,s){const o=[Buffer.from(Int8Array.from([1])),r.toBuffer(),new I(n.length).toBuffer(),n],a=Buffer.concat(o),h=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new t.TransactionInstruction({keys:h,programId:i,data:a})}function K(i,e,r,n,s,o,a){const h=[Buffer.from(Int8Array.from([2])),r.toBuffer()],u=Buffer.concat(h),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a||n,isSigner:!0,isWritable:!1}];return s&&l.push({pubkey:s,isSigner:!0,isWritable:!1}),a&&o&&(s||l.push({pubkey:t.PublicKey.default,isSigner:!1,isWritable:!1}),l.push({pubkey:o,isSigner:!1,isWritable:!1})),new t.TransactionInstruction({keys:l,programId:i,data:u})}function D(i,e,r,n){const s=[Buffer.from(Int8Array.from([3]))],o=Buffer.concat(s),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0}];return new t.TransactionInstruction({keys:a,programId:i,data:o})}class W{constructor(t){this.tag=9,this.name=t.name,this.space=t.space}serialize(){return e.serialize(W.schema,this)}getInstruction(i,e,n,s,o,a,h,u,l,f,m){const c=Buffer.from(this.serialize()),d=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:t.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:h,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!0,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:f,isSigner:!1,isWritable:!0},{pubkey:r.TOKEN_PROGRAM_ID,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1}];return new t.TransactionInstruction({keys:d,programId:i,data:c})}}W.schema=new Map([[W,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class L{constructor(t){this.tag=5,this.name=t.name}serialize(){return e.serialize(L.schema,this)}getInstruction(i,e,r,n,s,o,a,h,u){const l=Buffer.from(this.serialize());let f=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:t.PublicKey.default,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!0,isWritable:!0}];if(h){if(!u)throw new Error("Missing parent name owner");f.push({pubkey:h,isSigner:!1,isWritable:!0}),f.push({pubkey:u,isSigner:!0,isWritable:!1})}return new t.TransactionInstruction({keys:f,programId:i,data:l})}}async function O(t,i,e,r,n){const s=await S(i),o=await k(s,r,n);let a;a=r||(await b.retrieve(t,o)).registry.owner;return D(h,o,e,a)}L.schema=new Map([[L,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class H{constructor(t){this.twitterRegistryKey=t.twitterRegistryKey,this.twitterHandle=t.twitterHandle}static async retrieve(t,i){let r=await t.getAccountInfo(i,"processed");if(!r)throw new Error("Invalid reverse Twitter account provided");return e.deserializeUnchecked(this.schema,H,r.data.slice(b.HEADER_LEN))}}async function q(i,r,n,s,o){const a=await S(s.toString()),u=await k(a,p,g);let l=e.serialize(H.schema,new H({twitterRegistryKey:n.toBytes(),twitterHandle:r}));return[T(h,t.SystemProgram.programId,u,s,o,a,new P(await i.getMinimumBalanceForRentExemption(l.length+b.HEADER_LEN)),new I(l.length),p,g,p),N(h,u,new I(0),Buffer.from(l),p)]}H.schema=new Map([[H,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const z=new t.PublicKey("6NSu2tci4apRKQtt257bAVcvqYjB3zV2H1dWo56vgpa6"),Z=async(t,i)=>{const e=await k(await S(i.toBase58()),void 0,z),{registry:r}=await b.retrieve(t,e);if(!r.data)throw new Error("Invalid account data");return R.deserialize(r.data)};var F;exports.Record=void 0,(F=exports.Record||(exports.Record={})).IPFS="IPFS",F.ARWV="ARWV",F.SOL="SOL",F.ETH="ETH",F.BTC="BTC",F.LTC="LTC",F.DOGE="DOGE",F.Email="email",F.Url="url",F.Discord="discord",F.Github="github",F.Reddit="reddit",F.Twitter="twitter",F.Telegram="telegram",F.Pic="pic",F.SHDW="SHDW",F.POINT="POINT",F.BSC="BSC",F.Injective="INJECT";const U=async(t,i,e)=>{var r,n;const{pubkey:s}=await A(e+"."+i,!0);let{registry:o}=await b.retrieve(t,s);const a=e===exports.Record.SOL?96:null===(r=o.data)||void 0===r?void 0:r.indexOf(0);return o.data=null===(n=o.data)||void 0===n?void 0:n.slice(0,a),o},C=async(t,i)=>await U(t,i,exports.Record.SOL),j=(t,i,e)=>s.sign.detached.verify(t,i,e.toBytes());exports.BONFIDA_FIDA_BNB=c,exports.BONFIDA_USDC_BNB=w,exports.HASH_PREFIX=u,exports.MINT_PREFIX=v,exports.Mint=_,exports.NAME_PROGRAM_ID=h,exports.NAME_TOKENIZER_ID=y,exports.NameRegistryState=b,exports.Numberu32=I,exports.Numberu64=P,exports.PYTH_FIDDA_PRICE_ACC=m,exports.REGISTER_PROGRAM_ID=f,exports.REVERSE_LOOKUP_CLASS=d,exports.ROOT_DOMAIN_ACCOUNT=l,exports.ReverseTwitterRegistryState=H,exports.SOL_RECORD_SIG_LEN=96,exports.TOKEN_TLD=z,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=g,exports.TWITTER_VERIFICATION_AUTHORITY=p,exports.TokenData=R,exports.changeTwitterRegistryData=async function(t,i,e,r){const n=await S(t),s=await k(n,void 0,g);return[N(h,s,new I(e),r,i)]},exports.changeVerifiedPubkey=async function(t,i,e,r,n){const s=await S(i),o=await k(s,void 0,g);let a=[K(h,o,r,e,void 0)];const u=await S(e.toString());return await k(u,p,void 0),a.push(await O(t,e.toString(),n,p,g)),a=a.concat(await q(t,i,o,r,n)),a},exports.checkSolRecord=j,exports.createInstruction=T,exports.createNameRegistry=async function(i,e,r,n,s,o,a,u){const l=await S(e),f=await k(l,a,u),m=o||await i.getMinimumBalanceForRentExemption(r);let c;if(u){const{registry:t}=await x(i,u);c=t.owner}return T(h,t.SystemProgram.programId,f,s,n,l,new P(m),new I(r),a,u,c)},exports.createReverseInstruction=L,exports.createReverseName=async(i,e,r,n,s)=>{let[o]=await t.PublicKey.findProgramAddress([f.toBuffer()],f),a=await S(i.toBase58()),u=await k(a,o,n);return[[],[new L({name:e}).getInstruction(f,t.SYSVAR_RENT_PUBKEY,h,l,u,o,r,n,s)]]},exports.createReverseTwitterRegistry=q,exports.createV2Instruction=W,exports.createVerifiedTwitterRegistry=async function(i,e,r,n,s){const o=await S(e),a=await k(o,void 0,g),u=await i.getMinimumBalanceForRentExemption(n+b.HEADER_LEN);let l=[T(h,t.SystemProgram.programId,a,r,s,o,new P(u),new I(n),void 0,g,p)];return l=l.concat(await q(i,e,a,r,s)),l},exports.deleteInstruction=D,exports.deleteNameRegistry=O,exports.deleteTwitterRegistry=async function(t,i){const e=await S(t),r=await k(e,void 0,g),n=await S(i.toString()),s=await k(n,p,g);return[D(h,r,i,i),D(h,s,i,i)]},exports.findSubdomains=async(t,i)=>{const e=[{memcmp:{offset:0,bytes:i.toBase58()}},{memcmp:{offset:64,bytes:d.toBase58()}}];return(await t.getProgramAccounts(h,{filters:e})).map((t=>{var i;return null===(i=t.account.data.slice(97).toString("utf-8"))||void 0===i?void 0:i.split("\0").join("")}))},exports.getAllDomains=async function(t,i){const e=[{memcmp:{offset:32,bytes:i.toBase58()}},{memcmp:{offset:0,bytes:l.toBase58()}}];return(await t.getProgramAccounts(h,{filters:e})).map((t=>t.pubkey))},exports.getAllRegisteredDomains=async t=>{const i=[{memcmp:{offset:0,bytes:l.toBase58()}}];return await t.getProgramAccounts(h,{dataSlice:{offset:32,length:32},filters:i})},exports.getArweaveRecord=async(t,i)=>await U(t,i,exports.Record.ARWV),exports.getBscRecord=async(t,i)=>await U(t,i,exports.Record.BSC),exports.getBtcRecord=async(t,i)=>await U(t,i,exports.Record.BTC),exports.getDNSRecordAddress=async function(t,i){const e=await S("\0".concat(i));return await k(e,void 0,t)},exports.getDiscordRecord=async(t,i)=>await U(t,i,exports.Record.Discord),exports.getDogeRecord=async(t,i)=>await U(t,i,exports.Record.DOGE),exports.getDomainKey=A,exports.getEmailRecord=async(t,i)=>await U(t,i,exports.Record.Email),exports.getEthRecord=async(t,i)=>await U(t,i,exports.Record.ETH),exports.getFavoriteDomain=async(i,e)=>{const[r]=await n.FavouriteDomain.getKey(n.NAME_OFFERS_ID,new t.PublicKey(e)),s=await n.FavouriteDomain.retrieve(i,r),o=await B(i,s.nameAccount);return{domain:s.nameAccount,reverse:o}},exports.getGithubRecord=async(t,i)=>await U(t,i,exports.Record.Github),exports.getHandleAndRegistryKey=async function(i,e){const r=await S(e.toString()),n=await k(r,p,g);let s=await H.retrieve(i,n);return[s.twitterHandle,new t.PublicKey(s.twitterRegistryKey)]},exports.getHashedName=S,exports.getInjectiveRecord=async(t,i)=>await U(t,i,exports.Record.Injective),exports.getIpfsRecord=async(t,i)=>await U(t,i,exports.Record.IPFS),exports.getLtcRecord=async(t,i)=>await U(t,i,exports.Record.LTC),exports.getNameAccountKey=k,exports.getNameOwner=x,exports.getPicRecord=async(t,i)=>await U(t,i,exports.Record.Pic),exports.getPointRecord=async(t,i)=>await U(t,i,exports.Record.POINT),exports.getRecord=U,exports.getRedditRecord=async(t,i)=>await U(t,i,exports.Record.Reddit),exports.getReverseKey=async(t,i)=>{const{pubkey:e,parent:r}=await A(t),n=await S(e.toBase58());return await k(n,d,i?r:void 0)},exports.getShdwRecord=async(t,i)=>await U(t,i,exports.Record.SHDW),exports.getSolRecord=C,exports.getTelegramRecord=async(t,i)=>await U(t,i,exports.Record.Telegram),exports.getTokenInfoFromMint=Z,exports.getTokenInfoFromName=async(i,e)=>{const r=await k(await S(e),void 0,z),{registry:n}=await b.retrieve(i,r);if(!n.data)throw new Error("Invalid account data");const s=new t.PublicKey(_.deserialize(n.data).mint);return await Z(i,s)},exports.getTwitterHandleandRegistryKeyViaFilters=async function(i,r){const n=[{memcmp:{offset:0,bytes:g.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:p.toBase58()}}],s=await i.getProgramAccounts(h,{filters:n});for(const i of s)if(i.account.data.length>b.HEADER_LEN+32){let r=i.account.data.slice(b.HEADER_LEN),n=e.deserializeUnchecked(H.schema,H,r);return[n.twitterHandle,new t.PublicKey(n.twitterRegistryKey)]}throw new Error("Registry not found.")},exports.getTwitterRecord=async(t,i)=>await U(t,i,exports.Record.Twitter),exports.getTwitterRegistry=async function(t,i){const e=await S(i),r=await k(e,void 0,g),{registry:n}=await b.retrieve(t,r);return n},exports.getTwitterRegistryData=async function(i,e){const r=[{memcmp:{offset:0,bytes:g.toBase58()}},{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:new t.PublicKey(Buffer.alloc(32,0)).toBase58()}}],n=await i.getProgramAccounts(h,{filters:r});if(n.length>1)throw new Error("Found more than one registry.");return n[0].account.data.slice(b.HEADER_LEN)},exports.getTwitterRegistryKey=async function(t){const i=await S(t);return await k(i,void 0,g)},exports.getUrlRecord=async(t,i)=>await U(t,i,exports.Record.Url),exports.performReverseLookup=B,exports.performReverseLookupBatch=async function(t,i){let e=[];for(let t of i){const i=await S(t.toBase58()),r=await k(i,d);e.push(r)}return(await b.retrieveBatch(t,e)).map((t=>{if(void 0===t||void 0===t.data)return;let i=new a(t.data.slice(0,4),"le").toNumber();return t.data.slice(4,4+i).toString()}))},exports.registerDomainName=async(i,e,r,n)=>{const[s]=await t.PublicKey.findProgramAddress([f.toBuffer()],f),o=await S(i),a=await k(o,void 0,l),u=await S(a.toBase58()),m=await k(u,s),[c]=await t.PublicKey.findProgramAddress([a.toBuffer()],f);return[[],[new W({name:i,space:e}).getInstruction(f,t.SYSVAR_RENT_PUBKEY,h,l,a,m,s,r,n,w,c)]]},exports.resolve=async(i,e)=>{const{pubkey:r}=await A(e),{registry:n,nftOwner:s}=await b.retrieve(i,r);if(s)return s;try{const r=await A(exports.Record.SOL+"."+e,!0),s=await C(i,e);if(!s.data)throw new Error("Invalid SOL record data");const o=new TextEncoder,a=Buffer.concat([s.data.slice(0,32),r.pubkey.toBuffer()]),h=o.encode(a.toString("hex"));if(!j(h,s.data.slice(32),n.owner))throw new Error("Signature invalid");return new t.PublicKey(s.data.slice(0,32))}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t;console.log(t)}return n.owner},exports.retrieveNftOwner=M,exports.retrieveNfts=async i=>{const e=await i.getProgramAccounts(y,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return e.map((i=>new t.PublicKey(i.account.data.slice(66,98))))},exports.transferInstruction=K,exports.transferNameOwnership=async function(t,i,e,r,n,s){const o=await S(i),a=await k(o,r,n);let u;return u=r||(await b.retrieve(t,a)).registry.owner,K(h,a,e,u,r,n,s)},exports.updateInstruction=N,exports.updateNameRegistryData=async function(t,i,e,r,n,s){const o=await S(i),a=await k(o,n,s);let u;return u=n||(await b.retrieve(t,a)).registry.owner,N(h,a,new I(e),r,u)}; | ||
"use strict";var t=require("@solana/web3.js"),i=require("@ethersproject/sha2"),e=require("borsh"),r=require("@solana/spl-token"),n=require("@bonfida/name-offers"),s=require("tweetnacl"),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a={};!function(t,i){function e(t,i){if(!t)throw new Error(i||"Assertion failed")}function r(t,i){t.super_=i;var e=function(){};e.prototype=i.prototype,t.prototype=new e,t.prototype.constructor=t}function n(t,i,e){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(e=i,i=10),this._init(t||0,i||10,e||"be"))}var s;"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:require("buffer").Buffer}catch(t){}function o(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void e(!1,"Invalid character in "+t)}function a(t,i,e){var r=o(t,e);return e-1>=i&&(r|=o(t,e-1)<<4),r}function h(t,i,r,n){for(var s=0,o=0,a=Math.min(t.length,r),h=i;h<a;h++){var u=t.charCodeAt(h)-48;s*=n,o=u>=49?u-49+10:u>=17?u-17+10:u,e(u>=0&&o<n,"Invalid character"),s+=o}return s}function u(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),e(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},n.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},n.prototype._initArray=function(t,i,r){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var s,o,a=0;if("be"===r)for(n=t.length-1,s=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},n.prototype._parseHex=function(t,i,e){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,s=0,o=0;if("be"===e)for(r=t.length-1;r>=i;r-=2)n=a(t,i,r)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(r=(t.length-i)%2==0?i+1:i;r<t.length;r+=2)n=a(t,i,r)<<s,this.words[o]|=67108863&n,s>=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this._strip()},n.prototype._parseBase=function(t,i,e){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=i)r++;r--,n=n/i|0;for(var s=t.length-e,o=s%r,a=Math.min(s,s-o)+e,u=0,l=e;l<a;l+=r)u=h(t,l,l+r,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var f=1;for(u=h(t,l,t.length,i),l=0;l<o;l++)f*=i;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],m=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,i,e){e.negative=i.negative^t.negative;var r=t.length+i.length|0;e.length=r,r=r-1|0;var n=0|t.words[0],s=0|i.words[0],o=n*s,a=67108863&o,h=o/67108864|0;e.words[0]=a;for(var u=1;u<r;u++){for(var l=h>>>26,f=67108863&h,m=Math.min(u,i.length-1),c=Math.max(0,u-t.length+1);c<=m;c++){var d=u-c|0;l+=(o=(n=0|t.words[d])*(s=0|i.words[c])+f)/67108864|0,f=67108863&o}e.words[u]=0|f,h=0|l}return 0!==h?e.words[u]=0|h:e.length--,e._strip()}n.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,s=0,o=0;o<this.length;o++){var a=this.words[o],h=(16777215&(a<<n|s)).toString(16);r=0!=(s=a>>>24-n&16777215)||o!==this.length-1?f[6-h.length]+h+r:h+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var u=m[t],l=c[t];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modrn(l).toString(t);r=(d=d.idivn(l)).isZero()?p+r:f[u-p.length]+p+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}e(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(t,i){return this.toArrayLike(s,t,i)}),n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),s=r||Math.max(1,n);e(n<=s,"byte array longer than desired length"),e(s>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,s);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},n.prototype._toArrayLikeLE=function(t,i){for(var e=0,r=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|r;t[e++]=255&o,e<t.length&&(t[e++]=o>>8&255),e<t.length&&(t[e++]=o>>16&255),6===s?(e<t.length&&(t[e++]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(e<t.length)for(t[e++]=r;e<t.length;)t[e++]=0},n.prototype._toArrayLikeBE=function(t,i){for(var e=t.length-1,r=0,n=0,s=0;n<this.length;n++){var o=this.words[n]<<s|r;t[e--]=255&o,e>=0&&(t[e--]=o>>8&255),e>=0&&(t[e--]=o>>16&255),6===s?(e>=0&&(t[e--]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(e>=0)for(t[e--]=r;e>=0;)t[e--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var i=t,e=0;return i>=4096&&(e+=13,i>>>=13),i>=64&&(e+=7,i>>>=7),i>=8&&(e+=4,i>>>=4),i>=2&&(e+=2,i>>>=2),e+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,e=0;return 0==(8191&i)&&(e+=13,i>>>=13),0==(127&i)&&(e+=7,i>>>=7),0==(15&i)&&(e+=4,i>>>=4),0==(3&i)&&(e+=2,i>>>=2),0==(1&i)&&e++,e},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var e=this._zeroBits(this.words[i]);if(t+=e,26!==e)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},n.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var e=0;e<i.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=i.length,this._strip()},n.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,e;this.length>t.length?(i=this,e=t):(i=t,e=this);for(var r=0;r<e.length;r++)this.words[r]=i.words[r]^e.words[r];if(this!==i)for(;r<i.length;r++)this.words[r]=i.words[r];return this.length=i.length,this._strip()},n.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){e("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var i,e,r;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0,s=0;s<r.length;s++)i=(0|e.words[s])+(0|r.words[s])+n,this.words[s]=67108863&i,n=i>>>26;for(;0!==n&&s<e.length;s++)i=(0|e.words[s])+n,this.words[s]=67108863&i,n=i>>>26;if(this.length=e.length,0!==n)this.words[this.length]=n,this.length++;else if(e!==this)for(;s<e.length;s++)this.words[s]=e.words[s];return this},n.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(e=this,r=t):(e=t,r=this);for(var s=0,o=0;o<r.length;o++)s=(i=(0|e.words[o])-(0|r.words[o])+s)>>26,this.words[o]=67108863&i;for(;0!==s&&o<e.length;o++)s=(i=(0|e.words[o])+s)>>26,this.words[o]=67108863&i;if(0===s&&o<e.length&&e!==this)for(;o<e.length;o++)this.words[o]=e.words[o];return this.length=Math.max(this.length,o),e!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,i,e){var r,n,s,o=t.words,a=i.words,h=e.words,u=0,l=0|o[0],f=8191&l,m=l>>>13,c=0|o[1],d=8191&c,p=c>>>13,g=0|o[2],w=8191&g,y=g>>>13,v=0|o[3],M=8191&v,b=v>>>13,R=0|o[4],_=8191&R,x=R>>>13,S=0|o[5],k=8191&S,B=S>>>13,E=0|o[6],A=8191&E,I=E>>>13,P=0|o[7],T=8191&P,N=P>>>13,K=0|o[8],W=8191&K,D=K>>>13,L=0|o[9],O=8191&L,H=L>>>13,q=0|a[0],z=8191&q,Z=q>>>13,F=0|a[1],U=8191&F,C=F>>>13,j=0|a[2],V=8191&j,G=j>>>13,Y=0|a[3],X=8191&Y,J=Y>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,it=0|a[5],et=8191&it,rt=it>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,mt=lt>>>13,ct=0|a[9],dt=8191&ct,pt=ct>>>13;e.negative=t.negative^i.negative,e.length=19;var gt=(u+(r=Math.imul(f,z))|0)+((8191&(n=(n=Math.imul(f,Z))+Math.imul(m,z)|0))<<13)|0;u=((s=Math.imul(m,Z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(d,z),n=(n=Math.imul(d,Z))+Math.imul(p,z)|0,s=Math.imul(p,Z);var wt=(u+(r=r+Math.imul(f,U)|0)|0)+((8191&(n=(n=n+Math.imul(f,C)|0)+Math.imul(m,U)|0))<<13)|0;u=((s=s+Math.imul(m,C)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(w,z),n=(n=Math.imul(w,Z))+Math.imul(y,z)|0,s=Math.imul(y,Z),r=r+Math.imul(d,U)|0,n=(n=n+Math.imul(d,C)|0)+Math.imul(p,U)|0,s=s+Math.imul(p,C)|0;var yt=(u+(r=r+Math.imul(f,V)|0)|0)+((8191&(n=(n=n+Math.imul(f,G)|0)+Math.imul(m,V)|0))<<13)|0;u=((s=s+Math.imul(m,G)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,Z))+Math.imul(b,z)|0,s=Math.imul(b,Z),r=r+Math.imul(w,U)|0,n=(n=n+Math.imul(w,C)|0)+Math.imul(y,U)|0,s=s+Math.imul(y,C)|0,r=r+Math.imul(d,V)|0,n=(n=n+Math.imul(d,G)|0)+Math.imul(p,V)|0,s=s+Math.imul(p,G)|0;var vt=(u+(r=r+Math.imul(f,X)|0)|0)+((8191&(n=(n=n+Math.imul(f,J)|0)+Math.imul(m,X)|0))<<13)|0;u=((s=s+Math.imul(m,J)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(_,z),n=(n=Math.imul(_,Z))+Math.imul(x,z)|0,s=Math.imul(x,Z),r=r+Math.imul(M,U)|0,n=(n=n+Math.imul(M,C)|0)+Math.imul(b,U)|0,s=s+Math.imul(b,C)|0,r=r+Math.imul(w,V)|0,n=(n=n+Math.imul(w,G)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,G)|0,r=r+Math.imul(d,X)|0,n=(n=n+Math.imul(d,J)|0)+Math.imul(p,X)|0,s=s+Math.imul(p,J)|0;var Mt=(u+(r=r+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(m,$)|0))<<13)|0;u=((s=s+Math.imul(m,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(k,z),n=(n=Math.imul(k,Z))+Math.imul(B,z)|0,s=Math.imul(B,Z),r=r+Math.imul(_,U)|0,n=(n=n+Math.imul(_,C)|0)+Math.imul(x,U)|0,s=s+Math.imul(x,C)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,G)|0)+Math.imul(b,V)|0,s=s+Math.imul(b,G)|0,r=r+Math.imul(w,X)|0,n=(n=n+Math.imul(w,J)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,J)|0,r=r+Math.imul(d,$)|0,n=(n=n+Math.imul(d,tt)|0)+Math.imul(p,$)|0,s=s+Math.imul(p,tt)|0;var bt=(u+(r=r+Math.imul(f,et)|0)|0)+((8191&(n=(n=n+Math.imul(f,rt)|0)+Math.imul(m,et)|0))<<13)|0;u=((s=s+Math.imul(m,rt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(A,z),n=(n=Math.imul(A,Z))+Math.imul(I,z)|0,s=Math.imul(I,Z),r=r+Math.imul(k,U)|0,n=(n=n+Math.imul(k,C)|0)+Math.imul(B,U)|0,s=s+Math.imul(B,C)|0,r=r+Math.imul(_,V)|0,n=(n=n+Math.imul(_,G)|0)+Math.imul(x,V)|0,s=s+Math.imul(x,G)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(b,X)|0,s=s+Math.imul(b,J)|0,r=r+Math.imul(w,$)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(y,$)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(d,et)|0,n=(n=n+Math.imul(d,rt)|0)+Math.imul(p,et)|0,s=s+Math.imul(p,rt)|0;var Rt=(u+(r=r+Math.imul(f,st)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(m,st)|0))<<13)|0;u=((s=s+Math.imul(m,ot)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,Z))+Math.imul(N,z)|0,s=Math.imul(N,Z),r=r+Math.imul(A,U)|0,n=(n=n+Math.imul(A,C)|0)+Math.imul(I,U)|0,s=s+Math.imul(I,C)|0,r=r+Math.imul(k,V)|0,n=(n=n+Math.imul(k,G)|0)+Math.imul(B,V)|0,s=s+Math.imul(B,G)|0,r=r+Math.imul(_,X)|0,n=(n=n+Math.imul(_,J)|0)+Math.imul(x,X)|0,s=s+Math.imul(x,J)|0,r=r+Math.imul(M,$)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(b,$)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(w,et)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(y,et)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(d,st)|0,n=(n=n+Math.imul(d,ot)|0)+Math.imul(p,st)|0,s=s+Math.imul(p,ot)|0;var _t=(u+(r=r+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(m,ht)|0))<<13)|0;u=((s=s+Math.imul(m,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(W,z),n=(n=Math.imul(W,Z))+Math.imul(D,z)|0,s=Math.imul(D,Z),r=r+Math.imul(T,U)|0,n=(n=n+Math.imul(T,C)|0)+Math.imul(N,U)|0,s=s+Math.imul(N,C)|0,r=r+Math.imul(A,V)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,G)|0,r=r+Math.imul(k,X)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(B,X)|0,s=s+Math.imul(B,J)|0,r=r+Math.imul(_,$)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(x,$)|0,s=s+Math.imul(x,tt)|0,r=r+Math.imul(M,et)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(b,et)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(d,ht)|0,n=(n=n+Math.imul(d,ut)|0)+Math.imul(p,ht)|0,s=s+Math.imul(p,ut)|0;var xt=(u+(r=r+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(m,ft)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(O,z),n=(n=Math.imul(O,Z))+Math.imul(H,z)|0,s=Math.imul(H,Z),r=r+Math.imul(W,U)|0,n=(n=n+Math.imul(W,C)|0)+Math.imul(D,U)|0,s=s+Math.imul(D,C)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,G)|0)+Math.imul(N,V)|0,s=s+Math.imul(N,G)|0,r=r+Math.imul(A,X)|0,n=(n=n+Math.imul(A,J)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,J)|0,r=r+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(B,$)|0,s=s+Math.imul(B,tt)|0,r=r+Math.imul(_,et)|0,n=(n=n+Math.imul(_,rt)|0)+Math.imul(x,et)|0,s=s+Math.imul(x,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(y,ht)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(d,ft)|0,n=(n=n+Math.imul(d,mt)|0)+Math.imul(p,ft)|0,s=s+Math.imul(p,mt)|0;var St=(u+(r=r+Math.imul(f,dt)|0)|0)+((8191&(n=(n=n+Math.imul(f,pt)|0)+Math.imul(m,dt)|0))<<13)|0;u=((s=s+Math.imul(m,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(O,U),n=(n=Math.imul(O,C))+Math.imul(H,U)|0,s=Math.imul(H,C),r=r+Math.imul(W,V)|0,n=(n=n+Math.imul(W,G)|0)+Math.imul(D,V)|0,s=s+Math.imul(D,G)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,J)|0,r=r+Math.imul(A,$)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(k,et)|0,n=(n=n+Math.imul(k,rt)|0)+Math.imul(B,et)|0,s=s+Math.imul(B,rt)|0,r=r+Math.imul(_,st)|0,n=(n=n+Math.imul(_,ot)|0)+Math.imul(x,st)|0,s=s+Math.imul(x,ot)|0,r=r+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,mt)|0)+Math.imul(y,ft)|0,s=s+Math.imul(y,mt)|0;var kt=(u+(r=r+Math.imul(d,dt)|0)|0)+((8191&(n=(n=n+Math.imul(d,pt)|0)+Math.imul(p,dt)|0))<<13)|0;u=((s=s+Math.imul(p,pt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(O,V),n=(n=Math.imul(O,G))+Math.imul(H,V)|0,s=Math.imul(H,G),r=r+Math.imul(W,X)|0,n=(n=n+Math.imul(W,J)|0)+Math.imul(D,X)|0,s=s+Math.imul(D,J)|0,r=r+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,tt)|0,r=r+Math.imul(A,et)|0,n=(n=n+Math.imul(A,rt)|0)+Math.imul(I,et)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(k,st)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(B,st)|0,s=s+Math.imul(B,ot)|0,r=r+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(x,ht)|0,s=s+Math.imul(x,ut)|0,r=r+Math.imul(M,ft)|0,n=(n=n+Math.imul(M,mt)|0)+Math.imul(b,ft)|0,s=s+Math.imul(b,mt)|0;var Bt=(u+(r=r+Math.imul(w,dt)|0)|0)+((8191&(n=(n=n+Math.imul(w,pt)|0)+Math.imul(y,dt)|0))<<13)|0;u=((s=s+Math.imul(y,pt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(O,X),n=(n=Math.imul(O,J))+Math.imul(H,X)|0,s=Math.imul(H,J),r=r+Math.imul(W,$)|0,n=(n=n+Math.imul(W,tt)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,tt)|0,r=r+Math.imul(T,et)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(N,et)|0,s=s+Math.imul(N,rt)|0,r=r+Math.imul(A,st)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,ut)|0)+Math.imul(B,ht)|0,s=s+Math.imul(B,ut)|0,r=r+Math.imul(_,ft)|0,n=(n=n+Math.imul(_,mt)|0)+Math.imul(x,ft)|0,s=s+Math.imul(x,mt)|0;var Et=(u+(r=r+Math.imul(M,dt)|0)|0)+((8191&(n=(n=n+Math.imul(M,pt)|0)+Math.imul(b,dt)|0))<<13)|0;u=((s=s+Math.imul(b,pt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(O,$),n=(n=Math.imul(O,tt))+Math.imul(H,$)|0,s=Math.imul(H,tt),r=r+Math.imul(W,et)|0,n=(n=n+Math.imul(W,rt)|0)+Math.imul(D,et)|0,s=s+Math.imul(D,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,r=r+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(k,ft)|0,n=(n=n+Math.imul(k,mt)|0)+Math.imul(B,ft)|0,s=s+Math.imul(B,mt)|0;var At=(u+(r=r+Math.imul(_,dt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(x,dt)|0))<<13)|0;u=((s=s+Math.imul(x,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(O,et),n=(n=Math.imul(O,rt))+Math.imul(H,et)|0,s=Math.imul(H,rt),r=r+Math.imul(W,st)|0,n=(n=n+Math.imul(W,ot)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,ut)|0,r=r+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,ft)|0,s=s+Math.imul(I,mt)|0;var It=(u+(r=r+Math.imul(k,dt)|0)|0)+((8191&(n=(n=n+Math.imul(k,pt)|0)+Math.imul(B,dt)|0))<<13)|0;u=((s=s+Math.imul(B,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(O,st),n=(n=Math.imul(O,ot))+Math.imul(H,st)|0,s=Math.imul(H,ot),r=r+Math.imul(W,ht)|0,n=(n=n+Math.imul(W,ut)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,ut)|0,r=r+Math.imul(T,ft)|0,n=(n=n+Math.imul(T,mt)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,mt)|0;var Pt=(u+(r=r+Math.imul(A,dt)|0)|0)+((8191&(n=(n=n+Math.imul(A,pt)|0)+Math.imul(I,dt)|0))<<13)|0;u=((s=s+Math.imul(I,pt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(H,ht)|0,s=Math.imul(H,ut),r=r+Math.imul(W,ft)|0,n=(n=n+Math.imul(W,mt)|0)+Math.imul(D,ft)|0,s=s+Math.imul(D,mt)|0;var Tt=(u+(r=r+Math.imul(T,dt)|0)|0)+((8191&(n=(n=n+Math.imul(T,pt)|0)+Math.imul(N,dt)|0))<<13)|0;u=((s=s+Math.imul(N,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(O,ft),n=(n=Math.imul(O,mt))+Math.imul(H,ft)|0,s=Math.imul(H,mt);var Nt=(u+(r=r+Math.imul(W,dt)|0)|0)+((8191&(n=(n=n+Math.imul(W,pt)|0)+Math.imul(D,dt)|0))<<13)|0;u=((s=s+Math.imul(D,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Kt=(u+(r=Math.imul(O,dt))|0)+((8191&(n=(n=Math.imul(O,pt))+Math.imul(H,dt)|0))<<13)|0;return u=((s=Math.imul(H,pt))+(n>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,h[0]=gt,h[1]=wt,h[2]=yt,h[3]=vt,h[4]=Mt,h[5]=bt,h[6]=Rt,h[7]=_t,h[8]=xt,h[9]=St,h[10]=kt,h[11]=Bt,h[12]=Et,h[13]=At,h[14]=It,h[15]=Pt,h[16]=Tt,h[17]=Nt,h[18]=Kt,0!==u&&(h[19]=u,e.length++),e};function g(t,i,e){e.negative=i.negative^t.negative,e.length=t.length+i.length;for(var r=0,n=0,s=0;s<e.length-1;s++){var o=n;n=0;for(var a=67108863&r,h=Math.min(s,i.length-1),u=Math.max(0,s-t.length+1);u<=h;u++){var l=s-u,f=(0|t.words[l])*(0|i.words[u]),m=67108863&f;a=67108863&(m=m+a|0),n+=(o=(o=o+(f/67108864|0)|0)+(m>>>26)|0)>>>26,o&=67108863}e.words[s]=a,r=o,o=n}return 0!==r?e.words[s]=r:e.length--,e._strip()}function w(t,i,e){return g(t,i,e)}Math.imul||(p=d),n.prototype.mulTo=function(t,i){var e=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,i):e<63?d(this,t,i):e<1024?g(this,t,i):w(this,t,i)},n.prototype.mul=function(t){var i=new n(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},n.prototype.mulf=function(t){var i=new n(null);return i.words=new Array(this.length+t.length),w(this,t,i)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var i=t<0;i&&(t=-t),e("number"==typeof t),e(t<67108864);for(var r=0,n=0;n<this.length;n++){var s=(0|this.words[n])*t,o=(67108863&s)+(67108863&r);r>>=26,r+=s/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),e=0;e<i.length;e++){var r=e/26|0,n=e%26;i[e]=t.words[r]>>>n&1}return i}(t);if(0===i.length)return new n(1);for(var e=this,r=0;r<i.length&&0===i[r];r++,e=e.sqr());if(++r<i.length)for(var s=e.sqr();r<i.length;r++,s=s.sqr())0!==i[r]&&(e=e.mul(s));return e},n.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var a=this.words[i]&s,h=(0|this.words[i])-a<<r;this.words[i]=h|o,o=a>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,i,r){var n;e("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,h=r;if(n-=o,n=Math.max(0,n),h){for(var u=0;u<o;u++)h.words[u]=this.words[u];h.length=o}if(0===o);else if(this.length>o)for(this.length-=o,u=0;u<this.length;u++)this.words[u]=this.words[u+o];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-s|f>>>s,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,i,r){return e(0===this.negative),this.iushrn(t,i,r)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},n.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,i,r){var n,s,o=t.length+r;this._expand(o);var a=0;for(n=0;n<t.length;n++){s=(0|this.words[n+r])+a;var h=(0|t.words[n])*i;a=((s-=67108863&h)>>26)-(h/67108864|0),this.words[n+r]=67108863&s}for(;n<this.length-r;n++)a=(s=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&s;if(0===a)return this._strip();for(e(-1===a),a=0,n=0;n<this.length;n++)a=(s=-(0|this.words[n])+a)>>26,this.words[n]=67108863&s;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,i){var e=(this.length,t.length),r=this.clone(),s=t,o=0|s.words[s.length-1];0!=(e=26-this._countBits(o))&&(s=s.ushln(e),r.iushln(e),o=0|s.words[s.length-1]);var a,h=r.length-s.length;if("mod"!==i){(a=new n(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=r.clone()._ishlnsubmul(s,1,h);0===l.negative&&(r=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var m=67108864*(0|r.words[s.length+f])+(0|r.words[s.length+f-1]);for(m=Math.min(m/o|0,67108863),r._ishlnsubmul(s,m,f);0!==r.negative;)m--,r.negative=0,r._ishlnsubmul(s,1,f),r.isZero()||(r.negative^=1);a&&(a.words[f]=m)}return a&&a._strip(),r._strip(),"div"!==i&&0!==e&&r.iushrn(e),{div:a||null,mod:r}},n.prototype.divmod=function(t,i,r){return e(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,i),"mod"!==i&&(s=a.div.neg()),"div"!==i&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:s,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),i),"mod"!==i&&(s=a.div.neg()),{div:s,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),i),"div"!==i&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,i);var s,o,a},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var e=0!==i.div.negative?i.mod.isub(t):i.mod,r=t.ushrn(1),n=t.andln(1),s=e.cmp(r);return s<0||1===n&&0===s?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modrn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(r*n+(0|this.words[s]))%t;return i?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var i=t<0;i&&(t=-t),e(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*r;this.words[n]=s/t|0,r=s%t}return this._strip(),i?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var s=new n(1),o=new n(0),a=new n(0),h=new n(1),u=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),f=i.clone();!i.isZero();){for(var m=0,c=1;0==(i.words[0]&c)&&m<26;++m,c<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||o.isOdd())&&(s.iadd(l),o.isub(f)),s.iushrn(1),o.iushrn(1);for(var d=0,p=1;0==(r.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);i.cmp(r)>=0?(i.isub(r),s.isub(a),o.isub(h)):(r.isub(i),a.isub(s),h.isub(o))}return{a:a,b:h,gcd:r.iushln(u)}},n.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var s,o=new n(1),a=new n(0),h=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,m=1;0==(r.words[0]&m)&&f<26;++f,m<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(a)):(r.isub(i),a.isub(o))}return(s=0===i.cmpn(1)?o:a).cmpn(0)<0&&s.iadd(t),s},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),e=t.clone();i.negative=0,e.negative=0;for(var r=0;i.isEven()&&e.isEven();r++)i.iushrn(1),e.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;e.isEven();)e.iushrn(1);var n=i.cmp(e);if(n<0){var s=i;i=e,e=s}else if(0===n||0===e.cmpn(1))break;i.isub(e)}return e.iushln(r)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){e("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var s=n,o=r;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),e(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,e=this.length-1;e>=0;e--){var r=0|this.words[e],n=0|t.words[e];if(r!==n){r<n?i=-1:r>n&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new x(t)},n.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function R(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){x.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,e=t;do{this.split(e,this.tmp),i=(e=(e=this.imulK(e)).iadd(this.tmp)).bitLength()}while(i>this.n);var r=i<this.n?-1:e.ucmp(this.p);return 0===r?(e.words[0]=0,e.length=1):r>0?e.isub(this.p):void 0!==e.strip?e.strip():e._strip(),e},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},r(M,v),M.prototype.split=function(t,i){for(var e=4194303,r=Math.min(t.length,9),n=0;n<r;n++)i.words[n]=t.words[n];if(i.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var s=t.words[9];for(i.words[i.length++]=s&e,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&e)<<4|s>>>22,s=o}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},M.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,e=0;e<t.length;e++){var r=0|t.words[e];i+=977*r,t.words[e]=67108863&i,i=64*r+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},r(b,v),r(R,v),r(_,v),_.prototype.imulK=function(t){for(var i=0,e=0;e<t.length;e++){var r=19*(0|t.words[e])+i,n=67108863&r;r>>>=26,t.words[e]=n,i=r}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(y[t])return y[t];var i;if("k256"===t)i=new M;else if("p224"===t)i=new b;else if("p192"===t)i=new R;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new _}return y[t]=i,i},x.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,i){e(0==(t.negative|i.negative),"red works only with positives"),e(t.red&&t.red===i.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,i){this._verify2(t,i);var e=t.add(i);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},x.prototype.iadd=function(t,i){this._verify2(t,i);var e=t.iadd(i);return e.cmp(this.m)>=0&&e.isub(this.m),e},x.prototype.sub=function(t,i){this._verify2(t,i);var e=t.sub(i);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},x.prototype.isub=function(t,i){this._verify2(t,i);var e=t.isub(i);return e.cmpn(0)<0&&e.iadd(this.m),e},x.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},x.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},x.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(e(i%2==1),3===i){var r=this.m.add(new n(1)).iushrn(2);return this.pow(t,r)}for(var s=this.m.subn(1),o=0;!s.isZero()&&0===s.andln(1);)o++,s.iushrn(1);e(!s.isZero());var a=new n(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,s),m=this.pow(t,s.addn(1).iushrn(1)),c=this.pow(t,s),d=o;0!==c.cmp(a);){for(var p=c,g=0;0!==p.cmp(a);g++)p=p.redSqr();e(g<d);var w=this.pow(f,new n(1).iushln(d-g-1));m=m.redMul(w),f=w.redSqr(),c=c.redMul(f),d=g}return m},x.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},x.prototype.pow=function(t,i){if(i.isZero())return new n(1).toRed(this);if(0===i.cmpn(1))return t.clone();var e=new Array(16);e[0]=new n(1).toRed(this),e[1]=t;for(var r=2;r<e.length;r++)e[r]=this.mul(e[r-1],t);var s=e[0],o=0,a=0,h=i.bitLength()%26;for(0===h&&(h=26),r=i.length-1;r>=0;r--){for(var u=i.words[r],l=h-1;l>=0;l--){var f=u>>l&1;s!==e[0]&&(s=this.sqr(s)),0!==f||0!==o?(o<<=1,o|=f,(4==++a||0===r&&0===l)&&(s=this.mul(s,e[o]),a=0,o=0)):a=0}h=26}return s},x.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},x.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new S(t)},r(S,x),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},S.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(i),r=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=e.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},S.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var e=t.mul(i),r=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=e.isub(r).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}({get exports(){return a},set exports(t){a=t}},o);const h=new t.PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),u="SPL Name Service",l=new t.PublicKey("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),f=new t.PublicKey("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),m=new t.PublicKey("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),c=new t.PublicKey("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),d=new t.PublicKey("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),p=new t.PublicKey("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),g=new t.PublicKey("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),w=new t.PublicKey("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),y=new t.PublicKey("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),v=Buffer.from("tokenized_name"),M=async(i,e)=>{try{const[n]=await t.PublicKey.findProgramAddress([v,e.toBuffer()],y);if("0"===(await r.getMint(i,n)).supply.toString())return;const s=[{memcmp:{offset:0,bytes:n.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],o=await i.getProgramAccounts(r.TOKEN_PROGRAM_ID,{filters:s});if(1!=o.length)return;return new t.PublicKey(o[0].account.data.slice(32,64))}catch{return}};class b{constructor(i){this.parentName=new t.PublicKey(i.parentName),this.owner=new t.PublicKey(i.owner),this.class=new t.PublicKey(i.class)}static async retrieve(t,i){var r;const n=await t.getAccountInfo(i);if(!n)throw new Error("Invalid name account provided");let s=e.deserializeUnchecked(this.schema,b,n.data);s.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:s,nftOwner:await M(t,i)}}static async _retrieveBatch(t,i){const r=await t.getMultipleAccountsInfo(i),n=t=>{if(!t)return;const i=e.deserializeUnchecked(this.schema,b,t);return i.data=null==t?void 0:t.slice(this.HEADER_LEN),i};return r.map((t=>n(null==t?void 0:t.data)))}static async retrieveBatch(t,i){let e=[];for(;i.length>0;)e.push(...await this._retrieveBatch(t,i.splice(0,100)));return e}}b.HEADER_LEN=96,b.schema=new Map([[b,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);class R{constructor(t){this.name=t.name,this.ticker=t.ticker,this.mint=t.mint,this.decimals=t.decimals,this.website=null==t?void 0:t.website,this.logoUri=null==t?void 0:t.logoUri}serialize(){return e.serialize(R.schema,this)}static deserialize(t){return e.deserializeUnchecked(R.schema,R,t)}}R.schema=new Map([[R,{kind:"struct",fields:[["name","string"],["ticker","string"],["mint",[32]],["decimals","u8"],["website",{kind:"option",type:"string"}],["logoUri",{kind:"option",type:"string"}]]}]]);class _{constructor(t){this.mint=t.mint}serialize(){return e.serialize(_.schema,this)}static deserialize(t){return e.deserializeUnchecked(_.schema,_,t)}}async function x(t,i){if(!await t.getAccountInfo(i))throw new Error("Unable to find the given account.");return b.retrieve(t,i)}async function S(t){const e=u+t,r=i.sha256(Buffer.from(e,"utf8")).slice(2);return Buffer.from(r,"hex")}async function k(i,e,r){const n=[i];e?n.push(e.toBuffer()):n.push(Buffer.alloc(32)),r?n.push(r.toBuffer()):n.push(Buffer.alloc(32));const[s]=await t.PublicKey.findProgramAddress(n,h);return s}async function B(t,i){const e=await S(i.toBase58()),r=await k(e,d),{registry:n}=await b.retrieve(t,r);if(!n.data)throw"Could not retrieve name data";const s=new a(n.data.slice(0,4),"le").toNumber();return n.data.slice(4,4+s).toString()}_.schema=new Map([[_,{kind:"struct",fields:[["mint",[32]]]}]]);const E=async(t,i=l)=>{let e=await S(t);return{pubkey:await k(e,void 0,i),hashed:e}},A=async(t,i=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const e=t.split(".");if(2===e.length){const t=Buffer.from([i?1:0]).toString().concat(e[0]),{pubkey:r}=await E(e[1]);return{...await E(t,r),isSub:!0,parent:r}}if(3===e.length&&i){const{pubkey:t}=await E(e[2]),{pubkey:i}=await E("\0".concat(e[1]),t),r=Buffer.from([1]).toString();return{...await E(r.concat(e[0]),i),isSub:!0,parent:t,isSubRecord:!0}}if(e.length>=3)throw new Error("Invalid derivation input");return{...await E(t,l),isSub:!1,parent:void 0}};class I extends a{toBuffer(){const t=super.toArray().reverse(),i=Buffer.from(t);if(4===i.length)return i;if(i.length>4)throw new Error("Numberu32 too large");const e=Buffer.alloc(4);return i.copy(e),e}static fromBuffer(t){if(4!==t.length)throw new Error(`Invalid buffer length: ${t.length}`);return new a([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}class P extends a{toBuffer(){const t=super.toArray().reverse(),i=Buffer.from(t);if(8===i.length)return i;if(i.length>8)throw new Error("Numberu64 too large");const e=Buffer.alloc(8);return i.copy(e),e}static fromBuffer(t){if(8!==t.length)throw new Error(`Invalid buffer length: ${t.length}`);return new a([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}function T(i,e,r,n,s,o,a,h,u,l,f){const m=[Buffer.from(Int8Array.from([0])),new I(o.length).toBuffer(),o,a.toBuffer(),h.toBuffer()],c=Buffer.concat(m),d=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1}];return u?d.push({pubkey:u,isSigner:!0,isWritable:!1}):d.push({pubkey:new t.PublicKey(Buffer.alloc(32)),isSigner:!1,isWritable:!1}),l?d.push({pubkey:l,isSigner:!1,isWritable:!1}):d.push({pubkey:new t.PublicKey(Buffer.alloc(32)),isSigner:!1,isWritable:!1}),f&&d.push({pubkey:f,isSigner:!0,isWritable:!1}),new t.TransactionInstruction({keys:d,programId:i,data:c})}function N(i,e,r,n,s){const o=[Buffer.from(Int8Array.from([1])),r.toBuffer(),new I(n.length).toBuffer(),n],a=Buffer.concat(o),h=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1}];return new t.TransactionInstruction({keys:h,programId:i,data:a})}function K(i,e,r,n,s,o,a){const h=[Buffer.from(Int8Array.from([2])),r.toBuffer()],u=Buffer.concat(h),l=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a||n,isSigner:!0,isWritable:!1}];return s&&l.push({pubkey:s,isSigner:!0,isWritable:!1}),a&&o&&(s||l.push({pubkey:t.PublicKey.default,isSigner:!1,isWritable:!1}),l.push({pubkey:o,isSigner:!1,isWritable:!1})),new t.TransactionInstruction({keys:l,programId:i,data:u})}function W(i,e,r,n){const s=[Buffer.from(Int8Array.from([3]))],o=Buffer.concat(s),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0}];return new t.TransactionInstruction({keys:a,programId:i,data:o})}class D{constructor(t){this.tag=9,this.name=t.name,this.space=t.space}serialize(){return e.serialize(D.schema,this)}getInstruction(i,e,n,s,o,a,h,u,l,f,m){const c=Buffer.from(this.serialize()),d=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:t.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:h,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!0,isWritable:!0},{pubkey:l,isSigner:!1,isWritable:!0},{pubkey:f,isSigner:!1,isWritable:!0},{pubkey:r.TOKEN_PROGRAM_ID,isSigner:!1,isWritable:!1},{pubkey:m,isSigner:!1,isWritable:!1}];return new t.TransactionInstruction({keys:d,programId:i,data:c})}}D.schema=new Map([[D,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class L{constructor(t){this.tag=5,this.name=t.name}serialize(){return e.serialize(L.schema,this)}getInstruction(i,e,r,n,s,o,a,h,u){const l=Buffer.from(this.serialize());let f=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:t.PublicKey.default,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!0,isWritable:!0}];if(h){if(!u)throw new Error("Missing parent name owner");f.push({pubkey:h,isSigner:!1,isWritable:!0}),f.push({pubkey:u,isSigner:!0,isWritable:!1})}return new t.TransactionInstruction({keys:f,programId:i,data:l})}}async function O(t,i,e,r,n){const s=await S(i),o=await k(s,r,n);let a;a=r||(await b.retrieve(t,o)).registry.owner;return W(h,o,e,a)}L.schema=new Map([[L,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class H{constructor(t){this.twitterRegistryKey=t.twitterRegistryKey,this.twitterHandle=t.twitterHandle}static async retrieve(t,i){let r=await t.getAccountInfo(i,"processed");if(!r)throw new Error("Invalid reverse Twitter account provided");return e.deserializeUnchecked(this.schema,H,r.data.slice(b.HEADER_LEN))}}async function q(i,r,n,s,o){const a=await S(s.toString()),u=await k(a,p,g);let l=e.serialize(H.schema,new H({twitterRegistryKey:n.toBytes(),twitterHandle:r}));return[T(h,t.SystemProgram.programId,u,s,o,a,new P(await i.getMinimumBalanceForRentExemption(l.length+b.HEADER_LEN)),new I(l.length),p,g,p),N(h,u,new I(0),Buffer.from(l),p)]}H.schema=new Map([[H,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const z=new t.PublicKey("6NSu2tci4apRKQtt257bAVcvqYjB3zV2H1dWo56vgpa6"),Z=async(t,i)=>{const e=await k(await S(i.toBase58()),void 0,z),{registry:r}=await b.retrieve(t,e);if(!r.data)throw new Error("Invalid account data");return R.deserialize(r.data)};var F;exports.Record=void 0,(F=exports.Record||(exports.Record={})).IPFS="IPFS",F.ARWV="ARWV",F.SOL="SOL",F.ETH="ETH",F.BTC="BTC",F.LTC="LTC",F.DOGE="DOGE",F.Email="email",F.Url="url",F.Discord="discord",F.Github="github",F.Reddit="reddit",F.Twitter="twitter",F.Telegram="telegram",F.Pic="pic",F.SHDW="SHDW",F.POINT="POINT",F.BSC="BSC",F.Injective="INJECT";const U=async(t,i)=>{const{pubkey:e}=await A(i+"."+t,!0);return e},C=async(t,i,e)=>{var r,n;const s=await U(i,e);let{registry:o}=await b.retrieve(t,s);const a=e===exports.Record.SOL?96:null===(r=o.data)||void 0===r?void 0:r.indexOf(0);return o.data=null===(n=o.data)||void 0===n?void 0:n.slice(0,a),o},j=async(t,i)=>await C(t,i,exports.Record.SOL),V=(t,i,e)=>s.sign.detached.verify(t,i,e.toBytes());exports.BONFIDA_FIDA_BNB=c,exports.BONFIDA_USDC_BNB=w,exports.HASH_PREFIX=u,exports.MINT_PREFIX=v,exports.Mint=_,exports.NAME_PROGRAM_ID=h,exports.NAME_TOKENIZER_ID=y,exports.NameRegistryState=b,exports.Numberu32=I,exports.Numberu64=P,exports.PYTH_FIDDA_PRICE_ACC=m,exports.REGISTER_PROGRAM_ID=f,exports.REVERSE_LOOKUP_CLASS=d,exports.ROOT_DOMAIN_ACCOUNT=l,exports.ReverseTwitterRegistryState=H,exports.SOL_RECORD_SIG_LEN=96,exports.TOKEN_TLD=z,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=g,exports.TWITTER_VERIFICATION_AUTHORITY=p,exports.TokenData=R,exports.changeTwitterRegistryData=async function(t,i,e,r){const n=await S(t),s=await k(n,void 0,g);return[N(h,s,new I(e),r,i)]},exports.changeVerifiedPubkey=async function(t,i,e,r,n){const s=await S(i),o=await k(s,void 0,g);let a=[K(h,o,r,e,void 0)];const u=await S(e.toString());return await k(u,p,void 0),a.push(await O(t,e.toString(),n,p,g)),a=a.concat(await q(t,i,o,r,n)),a},exports.checkSolRecord=V,exports.createInstruction=T,exports.createNameRegistry=async function(i,e,r,n,s,o,a,u){const l=await S(e),f=await k(l,a,u),m=o||await i.getMinimumBalanceForRentExemption(r);let c;if(u){const{registry:t}=await x(i,u);c=t.owner}return T(h,t.SystemProgram.programId,f,s,n,l,new P(m),new I(r),a,u,c)},exports.createReverseInstruction=L,exports.createReverseName=async(i,e,r,n,s)=>{let[o]=await t.PublicKey.findProgramAddress([f.toBuffer()],f),a=await S(i.toBase58()),u=await k(a,o,n);return[[],[new L({name:e}).getInstruction(f,t.SYSVAR_RENT_PUBKEY,h,l,u,o,r,n,s)]]},exports.createReverseTwitterRegistry=q,exports.createV2Instruction=D,exports.createVerifiedTwitterRegistry=async function(i,e,r,n,s){const o=await S(e),a=await k(o,void 0,g),u=await i.getMinimumBalanceForRentExemption(n+b.HEADER_LEN);let l=[T(h,t.SystemProgram.programId,a,r,s,o,new P(u),new I(n),void 0,g,p)];return l=l.concat(await q(i,e,a,r,s)),l},exports.deleteInstruction=W,exports.deleteNameRegistry=O,exports.deleteTwitterRegistry=async function(t,i){const e=await S(t),r=await k(e,void 0,g),n=await S(i.toString()),s=await k(n,p,g);return[W(h,r,i,i),W(h,s,i,i)]},exports.findSubdomains=async(t,i)=>{const e=[{memcmp:{offset:0,bytes:i.toBase58()}},{memcmp:{offset:64,bytes:d.toBase58()}}];return(await t.getProgramAccounts(h,{filters:e})).map((t=>{var i;return null===(i=t.account.data.slice(97).toString("utf-8"))||void 0===i?void 0:i.split("\0").join("")}))},exports.getAllDomains=async function(t,i){const e=[{memcmp:{offset:32,bytes:i.toBase58()}},{memcmp:{offset:0,bytes:l.toBase58()}}];return(await t.getProgramAccounts(h,{filters:e})).map((t=>t.pubkey))},exports.getAllRegisteredDomains=async t=>{const i=[{memcmp:{offset:0,bytes:l.toBase58()}}];return await t.getProgramAccounts(h,{dataSlice:{offset:32,length:32},filters:i})},exports.getArweaveRecord=async(t,i)=>await C(t,i,exports.Record.ARWV),exports.getBscRecord=async(t,i)=>await C(t,i,exports.Record.BSC),exports.getBtcRecord=async(t,i)=>await C(t,i,exports.Record.BTC),exports.getDiscordRecord=async(t,i)=>await C(t,i,exports.Record.Discord),exports.getDogeRecord=async(t,i)=>await C(t,i,exports.Record.DOGE),exports.getDomainKey=A,exports.getEmailRecord=async(t,i)=>await C(t,i,exports.Record.Email),exports.getEthRecord=async(t,i)=>await C(t,i,exports.Record.ETH),exports.getFavoriteDomain=async(i,e)=>{const[r]=await n.FavouriteDomain.getKey(n.NAME_OFFERS_ID,new t.PublicKey(e)),s=await n.FavouriteDomain.retrieve(i,r),o=await B(i,s.nameAccount);return{domain:s.nameAccount,reverse:o}},exports.getGithubRecord=async(t,i)=>await C(t,i,exports.Record.Github),exports.getHandleAndRegistryKey=async function(i,e){const r=await S(e.toString()),n=await k(r,p,g);let s=await H.retrieve(i,n);return[s.twitterHandle,new t.PublicKey(s.twitterRegistryKey)]},exports.getHashedName=S,exports.getInjectiveRecord=async(t,i)=>await C(t,i,exports.Record.Injective),exports.getIpfsRecord=async(t,i)=>await C(t,i,exports.Record.IPFS),exports.getLtcRecord=async(t,i)=>await C(t,i,exports.Record.LTC),exports.getNameAccountKey=k,exports.getNameOwner=x,exports.getPicRecord=async(t,i)=>await C(t,i,exports.Record.Pic),exports.getPointRecord=async(t,i)=>await C(t,i,exports.Record.POINT),exports.getRecord=C,exports.getRecordKey=U,exports.getRedditRecord=async(t,i)=>await C(t,i,exports.Record.Reddit),exports.getReverseKey=async(t,i)=>{const{pubkey:e,parent:r}=await A(t),n=await S(e.toBase58());return await k(n,d,i?r:void 0)},exports.getShdwRecord=async(t,i)=>await C(t,i,exports.Record.SHDW),exports.getSolRecord=j,exports.getTelegramRecord=async(t,i)=>await C(t,i,exports.Record.Telegram),exports.getTokenInfoFromMint=Z,exports.getTokenInfoFromName=async(i,e)=>{const r=await k(await S(e),void 0,z),{registry:n}=await b.retrieve(i,r);if(!n.data)throw new Error("Invalid account data");const s=new t.PublicKey(_.deserialize(n.data).mint);return await Z(i,s)},exports.getTwitterHandleandRegistryKeyViaFilters=async function(i,r){const n=[{memcmp:{offset:0,bytes:g.toBase58()}},{memcmp:{offset:32,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:p.toBase58()}}],s=await i.getProgramAccounts(h,{filters:n});for(const i of s)if(i.account.data.length>b.HEADER_LEN+32){let r=i.account.data.slice(b.HEADER_LEN),n=e.deserializeUnchecked(H.schema,H,r);return[n.twitterHandle,new t.PublicKey(n.twitterRegistryKey)]}throw new Error("Registry not found.")},exports.getTwitterRecord=async(t,i)=>await C(t,i,exports.Record.Twitter),exports.getTwitterRegistry=async function(t,i){const e=await S(i),r=await k(e,void 0,g),{registry:n}=await b.retrieve(t,r);return n},exports.getTwitterRegistryData=async function(i,e){const r=[{memcmp:{offset:0,bytes:g.toBase58()}},{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:new t.PublicKey(Buffer.alloc(32,0)).toBase58()}}],n=await i.getProgramAccounts(h,{filters:r});if(n.length>1)throw new Error("Found more than one registry.");return n[0].account.data.slice(b.HEADER_LEN)},exports.getTwitterRegistryKey=async function(t){const i=await S(t);return await k(i,void 0,g)},exports.getUrlRecord=async(t,i)=>await C(t,i,exports.Record.Url),exports.performReverseLookup=B,exports.performReverseLookupBatch=async function(t,i){let e=[];for(let t of i){const i=await S(t.toBase58()),r=await k(i,d);e.push(r)}return(await b.retrieveBatch(t,e)).map((t=>{if(void 0===t||void 0===t.data)return;let i=new a(t.data.slice(0,4),"le").toNumber();return t.data.slice(4,4+i).toString()}))},exports.registerDomainName=async(i,e,r,n)=>{const[s]=await t.PublicKey.findProgramAddress([f.toBuffer()],f),o=await S(i),a=await k(o,void 0,l),u=await S(a.toBase58()),m=await k(u,s),[c]=await t.PublicKey.findProgramAddress([a.toBuffer()],f);return[[],[new D({name:i,space:e}).getInstruction(f,t.SYSVAR_RENT_PUBKEY,h,l,a,m,s,r,n,w,c)]]},exports.resolve=async(i,e)=>{const{pubkey:r}=await A(e),{registry:n,nftOwner:s}=await b.retrieve(i,r);if(s)return s;try{const r=await A(exports.Record.SOL+"."+e,!0),s=await j(i,e);if(!s.data)throw new Error("Invalid SOL record data");const o=new TextEncoder,a=Buffer.concat([s.data.slice(0,32),r.pubkey.toBuffer()]),h=o.encode(a.toString("hex"));if(!V(h,s.data.slice(32),n.owner))throw new Error("Signature invalid");return new t.PublicKey(s.data.slice(0,32))}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t;console.log(t)}return n.owner},exports.retrieveNftOwner=M,exports.retrieveNfts=async i=>{const e=await i.getProgramAccounts(y,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return e.map((i=>new t.PublicKey(i.account.data.slice(66,98))))},exports.transferInstruction=K,exports.transferNameOwnership=async function(t,i,e,r,n,s){const o=await S(i),a=await k(o,r,n);let u;return u=r||(await b.retrieve(t,a)).registry.owner,K(h,a,e,u,r,n,s)},exports.updateInstruction=N,exports.updateNameRegistryData=async function(t,i,e,r,n,s){const o=await S(i),a=await k(o,n,s);let u;return u=n||(await b.retrieve(t,a)).registry.owner,N(h,a,new I(e),r,u)}; |
@@ -5,2 +5,9 @@ import { Record } from "./types/record"; | ||
/** | ||
* This function can be used to derive a record key | ||
* @param domain The .sol domain name | ||
* @param record The record to derive the key for | ||
* @returns | ||
*/ | ||
export declare const getRecordKey: (domain: string, record: Record) => Promise<import("@solana/web3.js").PublicKey>; | ||
/** | ||
* This function can be used to retrieve a specified record for the given domain name | ||
@@ -7,0 +14,0 @@ * @param connection The Solana RPC connection object |
@@ -11,3 +11,2 @@ /// <reference types="node" /> | ||
export declare function performReverseLookup(connection: Connection, nameAccount: PublicKey): Promise<string>; | ||
export declare function getDNSRecordAddress(nameAccount: PublicKey, type: string): Promise<PublicKey>; | ||
export declare function performReverseLookupBatch(connection: Connection, nameAccounts: PublicKey[]): Promise<(string | undefined)[]>; | ||
@@ -14,0 +13,0 @@ /** |
{ | ||
"name": "@bonfida/spl-name-service", | ||
"version": "0.1.63", | ||
"version": "0.1.64", | ||
"license": "MIT", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"repository": { | ||
@@ -6,0 +10,0 @@ "type": "git", |
@@ -8,2 +8,13 @@ import { Record } from "./types/record"; | ||
/** | ||
* This function can be used to derive a record key | ||
* @param domain The .sol domain name | ||
* @param record The record to derive the key for | ||
* @returns | ||
*/ | ||
export const getRecordKey = async (domain: string, record: Record) => { | ||
const { pubkey } = await getDomainKey(record + "." + domain, true); | ||
return pubkey; | ||
}; | ||
/** | ||
* This function can be used to retrieve a specified record for the given domain name | ||
@@ -20,3 +31,3 @@ * @param connection The Solana RPC connection object | ||
) => { | ||
const { pubkey } = await getDomainKey(record + "." + domain, true); | ||
const pubkey = await getRecordKey(domain, record); | ||
let { registry } = await NameRegistryState.retrieve(connection, pubkey); | ||
@@ -23,0 +34,0 @@ |
@@ -69,15 +69,2 @@ import { Connection, PublicKey, MemcmpFilter } from "@solana/web3.js"; | ||
export async function getDNSRecordAddress( | ||
nameAccount: PublicKey, | ||
type: string | ||
) { | ||
const hashedName = await getHashedName("\0".concat(type)); | ||
const recordAccount = await getNameAccountKey( | ||
hashedName, | ||
undefined, | ||
nameAccount | ||
); | ||
return recordAccount; | ||
} | ||
export async function performReverseLookupBatch( | ||
@@ -84,0 +71,0 @@ connection: Connection, |
142780
31
2875