@bitte-ai/chat
Version:
Bitte AI chat component
1 lines • 244 kB
JavaScript
'use strict';var ai=require('ai'),Ne=require('react'),react=require('@ai-sdk/react'),jotai=require('jotai'),jsxRuntime=require('react/jsx-runtime'),jn=require('swr'),clsx=require('clsx'),format_js=require('near-api-js/lib/utils/format.js'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),Ut=require('@radix-ui/react-dialog'),vaul=require('vaul'),vo=require('@radix-ui/react-label'),M0=require('fast-deep-equal'),framerMotion=require('framer-motion'),Rc=require('react-markdown'),Ic=require('rehype-highlight'),Ec=require('rehype-raw'),Pc=require('remark-gfm'),Li=require('recharts'),viem=require('viem'),nearSafe=require('near-safe'),utils=require('jotai/utils'),ne=require('@radix-ui/react-accordion'),transactions=require('@mysten/sui/transactions'),getLatestGasPrice_js=require('@mintbase-js/rpc/lib/methods/getLatestGasPrice.js'),ve=require('numeral');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Ne__namespace=/*#__PURE__*/_interopNamespace(Ne);var jn__default=/*#__PURE__*/_interopDefault(jn);var Ut__namespace=/*#__PURE__*/_interopNamespace(Ut);var vo__namespace=/*#__PURE__*/_interopNamespace(vo);var M0__default=/*#__PURE__*/_interopDefault(M0);var Rc__default=/*#__PURE__*/_interopDefault(Rc);var Ic__default=/*#__PURE__*/_interopDefault(Ic);var Ec__default=/*#__PURE__*/_interopDefault(Ec);var Pc__default=/*#__PURE__*/_interopDefault(Pc);var Li__namespace=/*#__PURE__*/_interopNamespace(Li);var ne__namespace=/*#__PURE__*/_interopNamespace(ne);var ve__default=/*#__PURE__*/_interopDefault(ve);var bl=Object.create;var Dn=Object.defineProperty;var fl=Object.getOwnPropertyDescriptor;var pl=Object.getOwnPropertyNames;var hl=Object.getPrototypeOf,gl=Object.prototype.hasOwnProperty;var vl=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var xl=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var yl=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pl(e))!gl.call(t,o)&&o!==r&&Dn(t,o,{get:()=>e[o],enumerable:!(s=fl(e,o))||s.enumerable});return t};var er=(t,e,r)=>(r=t!=null?bl(hl(t)):{},yl(!t||!t.__esModule?Dn(r,"default",{value:t,enumerable:true}):r,t));var ki=xl((Yn,oo)=>{(function(t,e){function r(f,i){if(!f)throw new Error(i||"Assertion failed")}function s(f,i){f.super_=i;var a=function(){};a.prototype=i.prototype,f.prototype=new a,f.prototype.constructor=f;}function o(f,i,a){if(o.isBN(f))return f;this.negative=0,this.words=null,this.length=0,this.red=null,f!==null&&((i==="le"||i==="be")&&(a=i,i=10),this._init(f||0,i||10,a||"be"));}typeof t=="object"?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=vl("buffer").Buffer;}catch{}o.isBN=function(i){return i instanceof o?true:i!==null&&typeof i=="object"&&i.constructor.wordSize===o.wordSize&&Array.isArray(i.words)},o.max=function(i,a){return i.cmp(a)>0?i:a},o.min=function(i,a){return i.cmp(a)<0?i:a},o.prototype._init=function(i,a,l){if(typeof i=="number")return this._initNumber(i,a,l);if(typeof i=="object")return this._initArray(i,a,l);a==="hex"&&(a=16),r(a===(a|0)&&a>=2&&a<=36),i=i.toString().replace(/\s+/g,"");var d=0;i[0]==="-"&&(d++,this.negative=1),d<i.length&&(a===16?this._parseHex(i,d,l):(this._parseBase(i,a,d),l==="le"&&this._initArray(this.toArray(),a,l)));},o.prototype._initNumber=function(i,a,l){i<0&&(this.negative=1,i=-i),i<67108864?(this.words=[i&67108863],this.length=1):i<4503599627370496?(this.words=[i&67108863,i/67108864&67108863],this.length=2):(r(i<9007199254740992),this.words=[i&67108863,i/67108864&67108863,1],this.length=3),l==="le"&&this._initArray(this.toArray(),a,l);},o.prototype._initArray=function(i,a,l){if(r(typeof i.length=="number"),i.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(i.length/3),this.words=new Array(this.length);for(var d=0;d<this.length;d++)this.words[d]=0;var u,g,y=0;if(l==="be")for(d=i.length-1,u=0;d>=0;d-=3)g=i[d]|i[d-1]<<8|i[d-2]<<16,this.words[u]|=g<<y&67108863,this.words[u+1]=g>>>26-y&67108863,y+=24,y>=26&&(y-=26,u++);else if(l==="le")for(d=0,u=0;d<i.length;d+=3)g=i[d]|i[d+1]<<8|i[d+2]<<16,this.words[u]|=g<<y&67108863,this.words[u+1]=g>>>26-y&67108863,y+=24,y>=26&&(y-=26,u++);return this._strip()};function c(f,i){var a=f.charCodeAt(i);if(a>=48&&a<=57)return a-48;if(a>=65&&a<=70)return a-55;if(a>=97&&a<=102)return a-87;r(false,"Invalid character in "+f);}function h(f,i,a){var l=c(f,a);return a-1>=i&&(l|=c(f,a-1)<<4),l}o.prototype._parseHex=function(i,a,l){this.length=Math.ceil((i.length-a)/6),this.words=new Array(this.length);for(var d=0;d<this.length;d++)this.words[d]=0;var u=0,g=0,y;if(l==="be")for(d=i.length-1;d>=a;d-=2)y=h(i,a,d)<<u,this.words[g]|=y&67108863,u>=18?(u-=18,g+=1,this.words[g]|=y>>>26):u+=8;else {var b=i.length-a;for(d=b%2===0?a+1:a;d<i.length;d+=2)y=h(i,a,d)<<u,this.words[g]|=y&67108863,u>=18?(u-=18,g+=1,this.words[g]|=y>>>26):u+=8;}this._strip();};function x(f,i,a,l){for(var d=0,u=0,g=Math.min(f.length,a),y=i;y<g;y++){var b=f.charCodeAt(y)-48;d*=l,b>=49?u=b-49+10:b>=17?u=b-17+10:u=b,r(b>=0&&u<l,"Invalid character"),d+=u;}return d}o.prototype._parseBase=function(i,a,l){this.words=[0],this.length=1;for(var d=0,u=1;u<=67108863;u*=a)d++;d--,u=u/a|0;for(var g=i.length-l,y=g%d,b=Math.min(g,g-y)+l,n=0,p=l;p<b;p+=d)n=x(i,p,p+d,a),this.imuln(u),this.words[0]+n<67108864?this.words[0]+=n:this._iaddn(n);if(y!==0){var F=1;for(n=x(i,p,i.length,a),p=0;p<y;p++)F*=a;this.imuln(F),this.words[0]+n<67108864?this.words[0]+=n:this._iaddn(n);}this._strip();},o.prototype.copy=function(i){i.words=new Array(this.length);for(var a=0;a<this.length;a++)i.words[a]=this.words[a];i.length=this.length,i.negative=this.negative,i.red=this.red;};function v(f,i){f.words=i.words,f.length=i.length,f.negative=i.negative,f.red=i.red;}if(o.prototype._move=function(i){v(i,this);},o.prototype.clone=function(){var i=new o(null);return this.copy(i),i},o.prototype._expand=function(i){for(;this.length<i;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=C;}catch{o.prototype.inspect=C;}else o.prototype.inspect=C;function C(){return (this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var w=["","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"],k=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],R=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(i,a){i=i||10,a=a|0||1;var l;if(i===16||i==="hex"){l="";for(var d=0,u=0,g=0;g<this.length;g++){var y=this.words[g],b=((y<<d|u)&16777215).toString(16);u=y>>>24-d&16777215,d+=2,d>=26&&(d-=26,g--),u!==0||g!==this.length-1?l=w[6-b.length]+b+l:l=b+l;}for(u!==0&&(l=u.toString(16)+l);l.length%a!==0;)l="0"+l;return this.negative!==0&&(l="-"+l),l}if(i===(i|0)&&i>=2&&i<=36){var n=k[i],p=R[i];l="";var F=this.clone();for(F.negative=0;!F.isZero();){var D=F.modrn(p).toString(i);F=F.idivn(p),F.isZero()?l=D+l:l=w[n-D.length]+D+l;}for(this.isZero()&&(l="0"+l);l.length%a!==0;)l="0"+l;return this.negative!==0&&(l="-"+l),l}r(false,"Base should be between 2 and 36");},o.prototype.toNumber=function(){var i=this.words[0];return this.length===2?i+=this.words[1]*67108864:this.length===3&&this.words[2]===1?i+=4503599627370496+this.words[1]*67108864:this.length>2&&r(false,"Number can only safely store up to 53 bits"),this.negative!==0?-i:i},o.prototype.toJSON=function(){return this.toString(16,2)},m&&(o.prototype.toBuffer=function(i,a){return this.toArrayLike(m,i,a)}),o.prototype.toArray=function(i,a){return this.toArrayLike(Array,i,a)};var M=function(i,a){return i.allocUnsafe?i.allocUnsafe(a):new i(a)};o.prototype.toArrayLike=function(i,a,l){this._strip();var d=this.byteLength(),u=l||Math.max(1,d);r(d<=u,"byte array longer than desired length"),r(u>0,"Requested array length <= 0");var g=M(i,u),y=a==="le"?"LE":"BE";return this["_toArrayLike"+y](g,d),g},o.prototype._toArrayLikeLE=function(i,a){for(var l=0,d=0,u=0,g=0;u<this.length;u++){var y=this.words[u]<<g|d;i[l++]=y&255,l<i.length&&(i[l++]=y>>8&255),l<i.length&&(i[l++]=y>>16&255),g===6?(l<i.length&&(i[l++]=y>>24&255),d=0,g=0):(d=y>>>24,g+=2);}if(l<i.length)for(i[l++]=d;l<i.length;)i[l++]=0;},o.prototype._toArrayLikeBE=function(i,a){for(var l=i.length-1,d=0,u=0,g=0;u<this.length;u++){var y=this.words[u]<<g|d;i[l--]=y&255,l>=0&&(i[l--]=y>>8&255),l>=0&&(i[l--]=y>>16&255),g===6?(l>=0&&(i[l--]=y>>24&255),d=0,g=0):(d=y>>>24,g+=2);}if(l>=0)for(i[l--]=d;l>=0;)i[l--]=0;},Math.clz32?o.prototype._countBits=function(i){return 32-Math.clz32(i)}:o.prototype._countBits=function(i){var a=i,l=0;return a>=4096&&(l+=13,a>>>=13),a>=64&&(l+=7,a>>>=7),a>=8&&(l+=4,a>>>=4),a>=2&&(l+=2,a>>>=2),l+a},o.prototype._zeroBits=function(i){if(i===0)return 26;var a=i,l=0;return (a&8191)===0&&(l+=13,a>>>=13),(a&127)===0&&(l+=7,a>>>=7),(a&15)===0&&(l+=4,a>>>=4),(a&3)===0&&(l+=2,a>>>=2),(a&1)===0&&l++,l},o.prototype.bitLength=function(){var i=this.words[this.length-1],a=this._countBits(i);return (this.length-1)*26+a};function A(f){for(var i=new Array(f.bitLength()),a=0;a<i.length;a++){var l=a/26|0,d=a%26;i[a]=f.words[l]>>>d&1;}return i}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var i=0,a=0;a<this.length;a++){var l=this._zeroBits(this.words[a]);if(i+=l,l!==26)break}return i},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(i){return this.negative!==0?this.abs().inotn(i).iaddn(1):this.clone()},o.prototype.fromTwos=function(i){return this.testn(i-1)?this.notn(i).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(i){for(;this.length<i.length;)this.words[this.length++]=0;for(var a=0;a<i.length;a++)this.words[a]=this.words[a]|i.words[a];return this._strip()},o.prototype.ior=function(i){return r((this.negative|i.negative)===0),this.iuor(i)},o.prototype.or=function(i){return this.length>i.length?this.clone().ior(i):i.clone().ior(this)},o.prototype.uor=function(i){return this.length>i.length?this.clone().iuor(i):i.clone().iuor(this)},o.prototype.iuand=function(i){var a;this.length>i.length?a=i:a=this;for(var l=0;l<a.length;l++)this.words[l]=this.words[l]&i.words[l];return this.length=a.length,this._strip()},o.prototype.iand=function(i){return r((this.negative|i.negative)===0),this.iuand(i)},o.prototype.and=function(i){return this.length>i.length?this.clone().iand(i):i.clone().iand(this)},o.prototype.uand=function(i){return this.length>i.length?this.clone().iuand(i):i.clone().iuand(this)},o.prototype.iuxor=function(i){var a,l;this.length>i.length?(a=this,l=i):(a=i,l=this);for(var d=0;d<l.length;d++)this.words[d]=a.words[d]^l.words[d];if(this!==a)for(;d<a.length;d++)this.words[d]=a.words[d];return this.length=a.length,this._strip()},o.prototype.ixor=function(i){return r((this.negative|i.negative)===0),this.iuxor(i)},o.prototype.xor=function(i){return this.length>i.length?this.clone().ixor(i):i.clone().ixor(this)},o.prototype.uxor=function(i){return this.length>i.length?this.clone().iuxor(i):i.clone().iuxor(this)},o.prototype.inotn=function(i){r(typeof i=="number"&&i>=0);var a=Math.ceil(i/26)|0,l=i%26;this._expand(a),l>0&&a--;for(var d=0;d<a;d++)this.words[d]=~this.words[d]&67108863;return l>0&&(this.words[d]=~this.words[d]&67108863>>26-l),this._strip()},o.prototype.notn=function(i){return this.clone().inotn(i)},o.prototype.setn=function(i,a){r(typeof i=="number"&&i>=0);var l=i/26|0,d=i%26;return this._expand(l+1),a?this.words[l]=this.words[l]|1<<d:this.words[l]=this.words[l]&~(1<<d),this._strip()},o.prototype.iadd=function(i){var a;if(this.negative!==0&&i.negative===0)return this.negative=0,a=this.isub(i),this.negative^=1,this._normSign();if(this.negative===0&&i.negative!==0)return i.negative=0,a=this.isub(i),i.negative=1,a._normSign();var l,d;this.length>i.length?(l=this,d=i):(l=i,d=this);for(var u=0,g=0;g<d.length;g++)a=(l.words[g]|0)+(d.words[g]|0)+u,this.words[g]=a&67108863,u=a>>>26;for(;u!==0&&g<l.length;g++)a=(l.words[g]|0)+u,this.words[g]=a&67108863,u=a>>>26;if(this.length=l.length,u!==0)this.words[this.length]=u,this.length++;else if(l!==this)for(;g<l.length;g++)this.words[g]=l.words[g];return this},o.prototype.add=function(i){var a;return i.negative!==0&&this.negative===0?(i.negative=0,a=this.sub(i),i.negative^=1,a):i.negative===0&&this.negative!==0?(this.negative=0,a=i.sub(this),this.negative=1,a):this.length>i.length?this.clone().iadd(i):i.clone().iadd(this)},o.prototype.isub=function(i){if(i.negative!==0){i.negative=0;var a=this.iadd(i);return i.negative=1,a._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(i),this.negative=1,this._normSign();var l=this.cmp(i);if(l===0)return this.negative=0,this.length=1,this.words[0]=0,this;var d,u;l>0?(d=this,u=i):(d=i,u=this);for(var g=0,y=0;y<u.length;y++)a=(d.words[y]|0)-(u.words[y]|0)+g,g=a>>26,this.words[y]=a&67108863;for(;g!==0&&y<d.length;y++)a=(d.words[y]|0)+g,g=a>>26,this.words[y]=a&67108863;if(g===0&&y<d.length&&d!==this)for(;y<d.length;y++)this.words[y]=d.words[y];return this.length=Math.max(this.length,y),d!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(i){return this.clone().isub(i)};function E(f,i,a){a.negative=i.negative^f.negative;var l=f.length+i.length|0;a.length=l,l=l-1|0;var d=f.words[0]|0,u=i.words[0]|0,g=d*u,y=g&67108863,b=g/67108864|0;a.words[0]=y;for(var n=1;n<l;n++){for(var p=b>>>26,F=b&67108863,D=Math.min(n,i.length-1),$=Math.max(0,n-f.length+1);$<=D;$++){var U=n-$|0;d=f.words[U]|0,u=i.words[$]|0,g=d*u+F,p+=g/67108864|0,F=g&67108863;}a.words[n]=F|0,b=p|0;}return b!==0?a.words[n]=b|0:a.length--,a._strip()}var S=function(i,a,l){var d=i.words,u=a.words,g=l.words,y=0,b,n,p,F=d[0]|0,D=F&8191,$=F>>>13,U=d[1]|0,Z=U&8191,Q=U>>>13,be=d[2]|0,tt=be&8191,it=be>>>13,tr=d[3]|0,st=tr&8191,rt=tr>>>13,si=d[4]|0,dt=si&8191,mt=si>>>13,vn=d[5]|0,ut=vn&8191,bt=vn>>>13,xn=d[6]|0,ft=xn&8191,pt=xn>>>13,yn=d[7]|0,ht=yn&8191,gt=yn>>>13,wn=d[8]|0,vt=wn&8191,xt=wn>>>13,Cn=d[9]|0,yt=Cn&8191,wt=Cn>>>13,Tn=u[0]|0,Ct=Tn&8191,Tt=Tn>>>13,Nn=u[1]|0,Nt=Nn&8191,Mt=Nn>>>13,Mn=u[2]|0,kt=Mn&8191,At=Mn>>>13,kn=u[3]|0,St=kn&8191,Rt=kn>>>13,An=u[4]|0,It=An&8191,Et=An>>>13,Sn=u[5]|0,Pt=Sn&8191,Dt=Sn>>>13,Rn=u[6]|0,Lt=Rn&8191,Bt=Rn>>>13,In=u[7]|0,_t=In&8191,Ft=In>>>13,En=u[8]|0,$t=En&8191,Ht=En>>>13,Pn=u[9]|0,Ot=Pn&8191,Vt=Pn>>>13;l.negative=i.negative^a.negative,l.length=19,b=Math.imul(D,Ct),n=Math.imul(D,Tt),n=n+Math.imul($,Ct)|0,p=Math.imul($,Tt);var Fr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Fr>>>26)|0,Fr&=67108863,b=Math.imul(Z,Ct),n=Math.imul(Z,Tt),n=n+Math.imul(Q,Ct)|0,p=Math.imul(Q,Tt),b=b+Math.imul(D,Nt)|0,n=n+Math.imul(D,Mt)|0,n=n+Math.imul($,Nt)|0,p=p+Math.imul($,Mt)|0;var $r=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+($r>>>26)|0,$r&=67108863,b=Math.imul(tt,Ct),n=Math.imul(tt,Tt),n=n+Math.imul(it,Ct)|0,p=Math.imul(it,Tt),b=b+Math.imul(Z,Nt)|0,n=n+Math.imul(Z,Mt)|0,n=n+Math.imul(Q,Nt)|0,p=p+Math.imul(Q,Mt)|0,b=b+Math.imul(D,kt)|0,n=n+Math.imul(D,At)|0,n=n+Math.imul($,kt)|0,p=p+Math.imul($,At)|0;var Hr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Hr>>>26)|0,Hr&=67108863,b=Math.imul(st,Ct),n=Math.imul(st,Tt),n=n+Math.imul(rt,Ct)|0,p=Math.imul(rt,Tt),b=b+Math.imul(tt,Nt)|0,n=n+Math.imul(tt,Mt)|0,n=n+Math.imul(it,Nt)|0,p=p+Math.imul(it,Mt)|0,b=b+Math.imul(Z,kt)|0,n=n+Math.imul(Z,At)|0,n=n+Math.imul(Q,kt)|0,p=p+Math.imul(Q,At)|0,b=b+Math.imul(D,St)|0,n=n+Math.imul(D,Rt)|0,n=n+Math.imul($,St)|0,p=p+Math.imul($,Rt)|0;var Or=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Or>>>26)|0,Or&=67108863,b=Math.imul(dt,Ct),n=Math.imul(dt,Tt),n=n+Math.imul(mt,Ct)|0,p=Math.imul(mt,Tt),b=b+Math.imul(st,Nt)|0,n=n+Math.imul(st,Mt)|0,n=n+Math.imul(rt,Nt)|0,p=p+Math.imul(rt,Mt)|0,b=b+Math.imul(tt,kt)|0,n=n+Math.imul(tt,At)|0,n=n+Math.imul(it,kt)|0,p=p+Math.imul(it,At)|0,b=b+Math.imul(Z,St)|0,n=n+Math.imul(Z,Rt)|0,n=n+Math.imul(Q,St)|0,p=p+Math.imul(Q,Rt)|0,b=b+Math.imul(D,It)|0,n=n+Math.imul(D,Et)|0,n=n+Math.imul($,It)|0,p=p+Math.imul($,Et)|0;var Vr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Vr>>>26)|0,Vr&=67108863,b=Math.imul(ut,Ct),n=Math.imul(ut,Tt),n=n+Math.imul(bt,Ct)|0,p=Math.imul(bt,Tt),b=b+Math.imul(dt,Nt)|0,n=n+Math.imul(dt,Mt)|0,n=n+Math.imul(mt,Nt)|0,p=p+Math.imul(mt,Mt)|0,b=b+Math.imul(st,kt)|0,n=n+Math.imul(st,At)|0,n=n+Math.imul(rt,kt)|0,p=p+Math.imul(rt,At)|0,b=b+Math.imul(tt,St)|0,n=n+Math.imul(tt,Rt)|0,n=n+Math.imul(it,St)|0,p=p+Math.imul(it,Rt)|0,b=b+Math.imul(Z,It)|0,n=n+Math.imul(Z,Et)|0,n=n+Math.imul(Q,It)|0,p=p+Math.imul(Q,Et)|0,b=b+Math.imul(D,Pt)|0,n=n+Math.imul(D,Dt)|0,n=n+Math.imul($,Pt)|0,p=p+Math.imul($,Dt)|0;var Ur=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,b=Math.imul(ft,Ct),n=Math.imul(ft,Tt),n=n+Math.imul(pt,Ct)|0,p=Math.imul(pt,Tt),b=b+Math.imul(ut,Nt)|0,n=n+Math.imul(ut,Mt)|0,n=n+Math.imul(bt,Nt)|0,p=p+Math.imul(bt,Mt)|0,b=b+Math.imul(dt,kt)|0,n=n+Math.imul(dt,At)|0,n=n+Math.imul(mt,kt)|0,p=p+Math.imul(mt,At)|0,b=b+Math.imul(st,St)|0,n=n+Math.imul(st,Rt)|0,n=n+Math.imul(rt,St)|0,p=p+Math.imul(rt,Rt)|0,b=b+Math.imul(tt,It)|0,n=n+Math.imul(tt,Et)|0,n=n+Math.imul(it,It)|0,p=p+Math.imul(it,Et)|0,b=b+Math.imul(Z,Pt)|0,n=n+Math.imul(Z,Dt)|0,n=n+Math.imul(Q,Pt)|0,p=p+Math.imul(Q,Dt)|0,b=b+Math.imul(D,Lt)|0,n=n+Math.imul(D,Bt)|0,n=n+Math.imul($,Lt)|0,p=p+Math.imul($,Bt)|0;var Wr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,b=Math.imul(ht,Ct),n=Math.imul(ht,Tt),n=n+Math.imul(gt,Ct)|0,p=Math.imul(gt,Tt),b=b+Math.imul(ft,Nt)|0,n=n+Math.imul(ft,Mt)|0,n=n+Math.imul(pt,Nt)|0,p=p+Math.imul(pt,Mt)|0,b=b+Math.imul(ut,kt)|0,n=n+Math.imul(ut,At)|0,n=n+Math.imul(bt,kt)|0,p=p+Math.imul(bt,At)|0,b=b+Math.imul(dt,St)|0,n=n+Math.imul(dt,Rt)|0,n=n+Math.imul(mt,St)|0,p=p+Math.imul(mt,Rt)|0,b=b+Math.imul(st,It)|0,n=n+Math.imul(st,Et)|0,n=n+Math.imul(rt,It)|0,p=p+Math.imul(rt,Et)|0,b=b+Math.imul(tt,Pt)|0,n=n+Math.imul(tt,Dt)|0,n=n+Math.imul(it,Pt)|0,p=p+Math.imul(it,Dt)|0,b=b+Math.imul(Z,Lt)|0,n=n+Math.imul(Z,Bt)|0,n=n+Math.imul(Q,Lt)|0,p=p+Math.imul(Q,Bt)|0,b=b+Math.imul(D,_t)|0,n=n+Math.imul(D,Ft)|0,n=n+Math.imul($,_t)|0,p=p+Math.imul($,Ft)|0;var qr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(qr>>>26)|0,qr&=67108863,b=Math.imul(vt,Ct),n=Math.imul(vt,Tt),n=n+Math.imul(xt,Ct)|0,p=Math.imul(xt,Tt),b=b+Math.imul(ht,Nt)|0,n=n+Math.imul(ht,Mt)|0,n=n+Math.imul(gt,Nt)|0,p=p+Math.imul(gt,Mt)|0,b=b+Math.imul(ft,kt)|0,n=n+Math.imul(ft,At)|0,n=n+Math.imul(pt,kt)|0,p=p+Math.imul(pt,At)|0,b=b+Math.imul(ut,St)|0,n=n+Math.imul(ut,Rt)|0,n=n+Math.imul(bt,St)|0,p=p+Math.imul(bt,Rt)|0,b=b+Math.imul(dt,It)|0,n=n+Math.imul(dt,Et)|0,n=n+Math.imul(mt,It)|0,p=p+Math.imul(mt,Et)|0,b=b+Math.imul(st,Pt)|0,n=n+Math.imul(st,Dt)|0,n=n+Math.imul(rt,Pt)|0,p=p+Math.imul(rt,Dt)|0,b=b+Math.imul(tt,Lt)|0,n=n+Math.imul(tt,Bt)|0,n=n+Math.imul(it,Lt)|0,p=p+Math.imul(it,Bt)|0,b=b+Math.imul(Z,_t)|0,n=n+Math.imul(Z,Ft)|0,n=n+Math.imul(Q,_t)|0,p=p+Math.imul(Q,Ft)|0,b=b+Math.imul(D,$t)|0,n=n+Math.imul(D,Ht)|0,n=n+Math.imul($,$t)|0,p=p+Math.imul($,Ht)|0;var zr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(zr>>>26)|0,zr&=67108863,b=Math.imul(yt,Ct),n=Math.imul(yt,Tt),n=n+Math.imul(wt,Ct)|0,p=Math.imul(wt,Tt),b=b+Math.imul(vt,Nt)|0,n=n+Math.imul(vt,Mt)|0,n=n+Math.imul(xt,Nt)|0,p=p+Math.imul(xt,Mt)|0,b=b+Math.imul(ht,kt)|0,n=n+Math.imul(ht,At)|0,n=n+Math.imul(gt,kt)|0,p=p+Math.imul(gt,At)|0,b=b+Math.imul(ft,St)|0,n=n+Math.imul(ft,Rt)|0,n=n+Math.imul(pt,St)|0,p=p+Math.imul(pt,Rt)|0,b=b+Math.imul(ut,It)|0,n=n+Math.imul(ut,Et)|0,n=n+Math.imul(bt,It)|0,p=p+Math.imul(bt,Et)|0,b=b+Math.imul(dt,Pt)|0,n=n+Math.imul(dt,Dt)|0,n=n+Math.imul(mt,Pt)|0,p=p+Math.imul(mt,Dt)|0,b=b+Math.imul(st,Lt)|0,n=n+Math.imul(st,Bt)|0,n=n+Math.imul(rt,Lt)|0,p=p+Math.imul(rt,Bt)|0,b=b+Math.imul(tt,_t)|0,n=n+Math.imul(tt,Ft)|0,n=n+Math.imul(it,_t)|0,p=p+Math.imul(it,Ft)|0,b=b+Math.imul(Z,$t)|0,n=n+Math.imul(Z,Ht)|0,n=n+Math.imul(Q,$t)|0,p=p+Math.imul(Q,Ht)|0,b=b+Math.imul(D,Ot)|0,n=n+Math.imul(D,Vt)|0,n=n+Math.imul($,Ot)|0,p=p+Math.imul($,Vt)|0;var Gr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,b=Math.imul(yt,Nt),n=Math.imul(yt,Mt),n=n+Math.imul(wt,Nt)|0,p=Math.imul(wt,Mt),b=b+Math.imul(vt,kt)|0,n=n+Math.imul(vt,At)|0,n=n+Math.imul(xt,kt)|0,p=p+Math.imul(xt,At)|0,b=b+Math.imul(ht,St)|0,n=n+Math.imul(ht,Rt)|0,n=n+Math.imul(gt,St)|0,p=p+Math.imul(gt,Rt)|0,b=b+Math.imul(ft,It)|0,n=n+Math.imul(ft,Et)|0,n=n+Math.imul(pt,It)|0,p=p+Math.imul(pt,Et)|0,b=b+Math.imul(ut,Pt)|0,n=n+Math.imul(ut,Dt)|0,n=n+Math.imul(bt,Pt)|0,p=p+Math.imul(bt,Dt)|0,b=b+Math.imul(dt,Lt)|0,n=n+Math.imul(dt,Bt)|0,n=n+Math.imul(mt,Lt)|0,p=p+Math.imul(mt,Bt)|0,b=b+Math.imul(st,_t)|0,n=n+Math.imul(st,Ft)|0,n=n+Math.imul(rt,_t)|0,p=p+Math.imul(rt,Ft)|0,b=b+Math.imul(tt,$t)|0,n=n+Math.imul(tt,Ht)|0,n=n+Math.imul(it,$t)|0,p=p+Math.imul(it,Ht)|0,b=b+Math.imul(Z,Ot)|0,n=n+Math.imul(Z,Vt)|0,n=n+Math.imul(Q,Ot)|0,p=p+Math.imul(Q,Vt)|0;var Kr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Kr>>>26)|0,Kr&=67108863,b=Math.imul(yt,kt),n=Math.imul(yt,At),n=n+Math.imul(wt,kt)|0,p=Math.imul(wt,At),b=b+Math.imul(vt,St)|0,n=n+Math.imul(vt,Rt)|0,n=n+Math.imul(xt,St)|0,p=p+Math.imul(xt,Rt)|0,b=b+Math.imul(ht,It)|0,n=n+Math.imul(ht,Et)|0,n=n+Math.imul(gt,It)|0,p=p+Math.imul(gt,Et)|0,b=b+Math.imul(ft,Pt)|0,n=n+Math.imul(ft,Dt)|0,n=n+Math.imul(pt,Pt)|0,p=p+Math.imul(pt,Dt)|0,b=b+Math.imul(ut,Lt)|0,n=n+Math.imul(ut,Bt)|0,n=n+Math.imul(bt,Lt)|0,p=p+Math.imul(bt,Bt)|0,b=b+Math.imul(dt,_t)|0,n=n+Math.imul(dt,Ft)|0,n=n+Math.imul(mt,_t)|0,p=p+Math.imul(mt,Ft)|0,b=b+Math.imul(st,$t)|0,n=n+Math.imul(st,Ht)|0,n=n+Math.imul(rt,$t)|0,p=p+Math.imul(rt,Ht)|0,b=b+Math.imul(tt,Ot)|0,n=n+Math.imul(tt,Vt)|0,n=n+Math.imul(it,Ot)|0,p=p+Math.imul(it,Vt)|0;var Jr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Jr>>>26)|0,Jr&=67108863,b=Math.imul(yt,St),n=Math.imul(yt,Rt),n=n+Math.imul(wt,St)|0,p=Math.imul(wt,Rt),b=b+Math.imul(vt,It)|0,n=n+Math.imul(vt,Et)|0,n=n+Math.imul(xt,It)|0,p=p+Math.imul(xt,Et)|0,b=b+Math.imul(ht,Pt)|0,n=n+Math.imul(ht,Dt)|0,n=n+Math.imul(gt,Pt)|0,p=p+Math.imul(gt,Dt)|0,b=b+Math.imul(ft,Lt)|0,n=n+Math.imul(ft,Bt)|0,n=n+Math.imul(pt,Lt)|0,p=p+Math.imul(pt,Bt)|0,b=b+Math.imul(ut,_t)|0,n=n+Math.imul(ut,Ft)|0,n=n+Math.imul(bt,_t)|0,p=p+Math.imul(bt,Ft)|0,b=b+Math.imul(dt,$t)|0,n=n+Math.imul(dt,Ht)|0,n=n+Math.imul(mt,$t)|0,p=p+Math.imul(mt,Ht)|0,b=b+Math.imul(st,Ot)|0,n=n+Math.imul(st,Vt)|0,n=n+Math.imul(rt,Ot)|0,p=p+Math.imul(rt,Vt)|0;var Zr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,b=Math.imul(yt,It),n=Math.imul(yt,Et),n=n+Math.imul(wt,It)|0,p=Math.imul(wt,Et),b=b+Math.imul(vt,Pt)|0,n=n+Math.imul(vt,Dt)|0,n=n+Math.imul(xt,Pt)|0,p=p+Math.imul(xt,Dt)|0,b=b+Math.imul(ht,Lt)|0,n=n+Math.imul(ht,Bt)|0,n=n+Math.imul(gt,Lt)|0,p=p+Math.imul(gt,Bt)|0,b=b+Math.imul(ft,_t)|0,n=n+Math.imul(ft,Ft)|0,n=n+Math.imul(pt,_t)|0,p=p+Math.imul(pt,Ft)|0,b=b+Math.imul(ut,$t)|0,n=n+Math.imul(ut,Ht)|0,n=n+Math.imul(bt,$t)|0,p=p+Math.imul(bt,Ht)|0,b=b+Math.imul(dt,Ot)|0,n=n+Math.imul(dt,Vt)|0,n=n+Math.imul(mt,Ot)|0,p=p+Math.imul(mt,Vt)|0;var jr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(jr>>>26)|0,jr&=67108863,b=Math.imul(yt,Pt),n=Math.imul(yt,Dt),n=n+Math.imul(wt,Pt)|0,p=Math.imul(wt,Dt),b=b+Math.imul(vt,Lt)|0,n=n+Math.imul(vt,Bt)|0,n=n+Math.imul(xt,Lt)|0,p=p+Math.imul(xt,Bt)|0,b=b+Math.imul(ht,_t)|0,n=n+Math.imul(ht,Ft)|0,n=n+Math.imul(gt,_t)|0,p=p+Math.imul(gt,Ft)|0,b=b+Math.imul(ft,$t)|0,n=n+Math.imul(ft,Ht)|0,n=n+Math.imul(pt,$t)|0,p=p+Math.imul(pt,Ht)|0,b=b+Math.imul(ut,Ot)|0,n=n+Math.imul(ut,Vt)|0,n=n+Math.imul(bt,Ot)|0,p=p+Math.imul(bt,Vt)|0;var Xr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,b=Math.imul(yt,Lt),n=Math.imul(yt,Bt),n=n+Math.imul(wt,Lt)|0,p=Math.imul(wt,Bt),b=b+Math.imul(vt,_t)|0,n=n+Math.imul(vt,Ft)|0,n=n+Math.imul(xt,_t)|0,p=p+Math.imul(xt,Ft)|0,b=b+Math.imul(ht,$t)|0,n=n+Math.imul(ht,Ht)|0,n=n+Math.imul(gt,$t)|0,p=p+Math.imul(gt,Ht)|0,b=b+Math.imul(ft,Ot)|0,n=n+Math.imul(ft,Vt)|0,n=n+Math.imul(pt,Ot)|0,p=p+Math.imul(pt,Vt)|0;var Qr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Qr>>>26)|0,Qr&=67108863,b=Math.imul(yt,_t),n=Math.imul(yt,Ft),n=n+Math.imul(wt,_t)|0,p=Math.imul(wt,Ft),b=b+Math.imul(vt,$t)|0,n=n+Math.imul(vt,Ht)|0,n=n+Math.imul(xt,$t)|0,p=p+Math.imul(xt,Ht)|0,b=b+Math.imul(ht,Ot)|0,n=n+Math.imul(ht,Vt)|0,n=n+Math.imul(gt,Ot)|0,p=p+Math.imul(gt,Vt)|0;var Yr=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(Yr>>>26)|0,Yr&=67108863,b=Math.imul(yt,$t),n=Math.imul(yt,Ht),n=n+Math.imul(wt,$t)|0,p=Math.imul(wt,Ht),b=b+Math.imul(vt,Ot)|0,n=n+Math.imul(vt,Vt)|0,n=n+Math.imul(xt,Ot)|0,p=p+Math.imul(xt,Vt)|0;var to=(y+b|0)+((n&8191)<<13)|0;y=(p+(n>>>13)|0)+(to>>>26)|0,to&=67108863,b=Math.imul(yt,Ot),n=Math.imul(yt,Vt),n=n+Math.imul(wt,Ot)|0,p=Math.imul(wt,Vt);var eo=(y+b|0)+((n&8191)<<13)|0;return y=(p+(n>>>13)|0)+(eo>>>26)|0,eo&=67108863,g[0]=Fr,g[1]=$r,g[2]=Hr,g[3]=Or,g[4]=Vr,g[5]=Ur,g[6]=Wr,g[7]=qr,g[8]=zr,g[9]=Gr,g[10]=Kr,g[11]=Jr,g[12]=Zr,g[13]=jr,g[14]=Xr,g[15]=Qr,g[16]=Yr,g[17]=to,g[18]=eo,y!==0&&(g[19]=y,l.length++),l};Math.imul||(S=E);function N(f,i,a){a.negative=i.negative^f.negative,a.length=f.length+i.length;for(var l=0,d=0,u=0;u<a.length-1;u++){var g=d;d=0;for(var y=l&67108863,b=Math.min(u,i.length-1),n=Math.max(0,u-f.length+1);n<=b;n++){var p=u-n,F=f.words[p]|0,D=i.words[n]|0,$=F*D,U=$&67108863;g=g+($/67108864|0)|0,U=U+y|0,y=U&67108863,g=g+(U>>>26)|0,d+=g>>>26,g&=67108863;}a.words[u]=y,l=g,g=d;}return l!==0?a.words[u]=l:a.length--,a._strip()}function _(f,i,a){return N(f,i,a)}o.prototype.mulTo=function(i,a){var l,d=this.length+i.length;return this.length===10&&i.length===10?l=S(this,i,a):d<63?l=E(this,i,a):d<1024?l=N(this,i,a):l=_(this,i,a),l};o.prototype.mul=function(i){var a=new o(null);return a.words=new Array(this.length+i.length),this.mulTo(i,a)},o.prototype.mulf=function(i){var a=new o(null);return a.words=new Array(this.length+i.length),_(this,i,a)},o.prototype.imul=function(i){return this.clone().mulTo(i,this)},o.prototype.imuln=function(i){var a=i<0;a&&(i=-i),r(typeof i=="number"),r(i<67108864);for(var l=0,d=0;d<this.length;d++){var u=(this.words[d]|0)*i,g=(u&67108863)+(l&67108863);l>>=26,l+=u/67108864|0,l+=g>>>26,this.words[d]=g&67108863;}return l!==0&&(this.words[d]=l,this.length++),a?this.ineg():this},o.prototype.muln=function(i){return this.clone().imuln(i)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(i){var a=A(i);if(a.length===0)return new o(1);for(var l=this,d=0;d<a.length&&a[d]===0;d++,l=l.sqr());if(++d<a.length)for(var u=l.sqr();d<a.length;d++,u=u.sqr())a[d]!==0&&(l=l.mul(u));return l},o.prototype.iushln=function(i){r(typeof i=="number"&&i>=0);var a=i%26,l=(i-a)/26,d=67108863>>>26-a<<26-a,u;if(a!==0){var g=0;for(u=0;u<this.length;u++){var y=this.words[u]&d,b=(this.words[u]|0)-y<<a;this.words[u]=b|g,g=y>>>26-a;}g&&(this.words[u]=g,this.length++);}if(l!==0){for(u=this.length-1;u>=0;u--)this.words[u+l]=this.words[u];for(u=0;u<l;u++)this.words[u]=0;this.length+=l;}return this._strip()},o.prototype.ishln=function(i){return r(this.negative===0),this.iushln(i)},o.prototype.iushrn=function(i,a,l){r(typeof i=="number"&&i>=0);var d;a?d=(a-a%26)/26:d=0;var u=i%26,g=Math.min((i-u)/26,this.length),y=67108863^67108863>>>u<<u,b=l;if(d-=g,d=Math.max(0,d),b){for(var n=0;n<g;n++)b.words[n]=this.words[n];b.length=g;}if(g!==0)if(this.length>g)for(this.length-=g,n=0;n<this.length;n++)this.words[n]=this.words[n+g];else this.words[0]=0,this.length=1;var p=0;for(n=this.length-1;n>=0&&(p!==0||n>=d);n--){var F=this.words[n]|0;this.words[n]=p<<26-u|F>>>u,p=F&y;}return b&&p!==0&&(b.words[b.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(i,a,l){return r(this.negative===0),this.iushrn(i,a,l)},o.prototype.shln=function(i){return this.clone().ishln(i)},o.prototype.ushln=function(i){return this.clone().iushln(i)},o.prototype.shrn=function(i){return this.clone().ishrn(i)},o.prototype.ushrn=function(i){return this.clone().iushrn(i)},o.prototype.testn=function(i){r(typeof i=="number"&&i>=0);var a=i%26,l=(i-a)/26,d=1<<a;if(this.length<=l)return false;var u=this.words[l];return !!(u&d)},o.prototype.imaskn=function(i){r(typeof i=="number"&&i>=0);var a=i%26,l=(i-a)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=l)return this;if(a!==0&&l++,this.length=Math.min(l,this.length),a!==0){var d=67108863^67108863>>>a<<a;this.words[this.length-1]&=d;}return this._strip()},o.prototype.maskn=function(i){return this.clone().imaskn(i)},o.prototype.iaddn=function(i){return r(typeof i=="number"),r(i<67108864),i<0?this.isubn(-i):this.negative!==0?this.length===1&&(this.words[0]|0)<=i?(this.words[0]=i-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(i),this.negative=1,this):this._iaddn(i)},o.prototype._iaddn=function(i){this.words[0]+=i;for(var a=0;a<this.length&&this.words[a]>=67108864;a++)this.words[a]-=67108864,a===this.length-1?this.words[a+1]=1:this.words[a+1]++;return this.length=Math.max(this.length,a+1),this},o.prototype.isubn=function(i){if(r(typeof i=="number"),r(i<67108864),i<0)return this.iaddn(-i);if(this.negative!==0)return this.negative=0,this.iaddn(i),this.negative=1,this;if(this.words[0]-=i,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var a=0;a<this.length&&this.words[a]<0;a++)this.words[a]+=67108864,this.words[a+1]-=1;return this._strip()},o.prototype.addn=function(i){return this.clone().iaddn(i)},o.prototype.subn=function(i){return this.clone().isubn(i)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(i,a,l){var d=i.length+l,u;this._expand(d);var g,y=0;for(u=0;u<i.length;u++){g=(this.words[u+l]|0)+y;var b=(i.words[u]|0)*a;g-=b&67108863,y=(g>>26)-(b/67108864|0),this.words[u+l]=g&67108863;}for(;u<this.length-l;u++)g=(this.words[u+l]|0)+y,y=g>>26,this.words[u+l]=g&67108863;if(y===0)return this._strip();for(r(y===-1),y=0,u=0;u<this.length;u++)g=-(this.words[u]|0)+y,y=g>>26,this.words[u]=g&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(i,a){var l=this.length-i.length,d=this.clone(),u=i,g=u.words[u.length-1]|0,y=this._countBits(g);l=26-y,l!==0&&(u=u.ushln(l),d.iushln(l),g=u.words[u.length-1]|0);var b=d.length-u.length,n;if(a!=="mod"){n=new o(null),n.length=b+1,n.words=new Array(n.length);for(var p=0;p<n.length;p++)n.words[p]=0;}var F=d.clone()._ishlnsubmul(u,1,b);F.negative===0&&(d=F,n&&(n.words[b]=1));for(var D=b-1;D>=0;D--){var $=(d.words[u.length+D]|0)*67108864+(d.words[u.length+D-1]|0);for($=Math.min($/g|0,67108863),d._ishlnsubmul(u,$,D);d.negative!==0;)$--,d.negative=0,d._ishlnsubmul(u,1,D),d.isZero()||(d.negative^=1);n&&(n.words[D]=$);}return n&&n._strip(),d._strip(),a!=="div"&&l!==0&&d.iushrn(l),{div:n||null,mod:d}},o.prototype.divmod=function(i,a,l){if(r(!i.isZero()),this.isZero())return {div:new o(0),mod:new o(0)};var d,u,g;return this.negative!==0&&i.negative===0?(g=this.neg().divmod(i,a),a!=="mod"&&(d=g.div.neg()),a!=="div"&&(u=g.mod.neg(),l&&u.negative!==0&&u.iadd(i)),{div:d,mod:u}):this.negative===0&&i.negative!==0?(g=this.divmod(i.neg(),a),a!=="mod"&&(d=g.div.neg()),{div:d,mod:g.mod}):(this.negative&i.negative)!==0?(g=this.neg().divmod(i.neg(),a),a!=="div"&&(u=g.mod.neg(),l&&u.negative!==0&&u.isub(i)),{div:g.div,mod:u}):i.length>this.length||this.cmp(i)<0?{div:new o(0),mod:this}:i.length===1?a==="div"?{div:this.divn(i.words[0]),mod:null}:a==="mod"?{div:null,mod:new o(this.modrn(i.words[0]))}:{div:this.divn(i.words[0]),mod:new o(this.modrn(i.words[0]))}:this._wordDiv(i,a)},o.prototype.div=function(i){return this.divmod(i,"div",false).div},o.prototype.mod=function(i){return this.divmod(i,"mod",false).mod},o.prototype.umod=function(i){return this.divmod(i,"mod",true).mod},o.prototype.divRound=function(i){var a=this.divmod(i);if(a.mod.isZero())return a.div;var l=a.div.negative!==0?a.mod.isub(i):a.mod,d=i.ushrn(1),u=i.andln(1),g=l.cmp(d);return g<0||u===1&&g===0?a.div:a.div.negative!==0?a.div.isubn(1):a.div.iaddn(1)},o.prototype.modrn=function(i){var a=i<0;a&&(i=-i),r(i<=67108863);for(var l=(1<<26)%i,d=0,u=this.length-1;u>=0;u--)d=(l*d+(this.words[u]|0))%i;return a?-d:d},o.prototype.modn=function(i){return this.modrn(i)},o.prototype.idivn=function(i){var a=i<0;a&&(i=-i),r(i<=67108863);for(var l=0,d=this.length-1;d>=0;d--){var u=(this.words[d]|0)+l*67108864;this.words[d]=u/i|0,l=u%i;}return this._strip(),a?this.ineg():this},o.prototype.divn=function(i){return this.clone().idivn(i)},o.prototype.egcd=function(i){r(i.negative===0),r(!i.isZero());var a=this,l=i.clone();a.negative!==0?a=a.umod(i):a=a.clone();for(var d=new o(1),u=new o(0),g=new o(0),y=new o(1),b=0;a.isEven()&&l.isEven();)a.iushrn(1),l.iushrn(1),++b;for(var n=l.clone(),p=a.clone();!a.isZero();){for(var F=0,D=1;(a.words[0]&D)===0&&F<26;++F,D<<=1);if(F>0)for(a.iushrn(F);F-- >0;)(d.isOdd()||u.isOdd())&&(d.iadd(n),u.isub(p)),d.iushrn(1),u.iushrn(1);for(var $=0,U=1;(l.words[0]&U)===0&&$<26;++$,U<<=1);if($>0)for(l.iushrn($);$-- >0;)(g.isOdd()||y.isOdd())&&(g.iadd(n),y.isub(p)),g.iushrn(1),y.iushrn(1);a.cmp(l)>=0?(a.isub(l),d.isub(g),u.isub(y)):(l.isub(a),g.isub(d),y.isub(u));}return {a:g,b:y,gcd:l.iushln(b)}},o.prototype._invmp=function(i){r(i.negative===0),r(!i.isZero());var a=this,l=i.clone();a.negative!==0?a=a.umod(i):a=a.clone();for(var d=new o(1),u=new o(0),g=l.clone();a.cmpn(1)>0&&l.cmpn(1)>0;){for(var y=0,b=1;(a.words[0]&b)===0&&y<26;++y,b<<=1);if(y>0)for(a.iushrn(y);y-- >0;)d.isOdd()&&d.iadd(g),d.iushrn(1);for(var n=0,p=1;(l.words[0]&p)===0&&n<26;++n,p<<=1);if(n>0)for(l.iushrn(n);n-- >0;)u.isOdd()&&u.iadd(g),u.iushrn(1);a.cmp(l)>=0?(a.isub(l),d.isub(u)):(l.isub(a),u.isub(d));}var F;return a.cmpn(1)===0?F=d:F=u,F.cmpn(0)<0&&F.iadd(i),F},o.prototype.gcd=function(i){if(this.isZero())return i.abs();if(i.isZero())return this.abs();var a=this.clone(),l=i.clone();a.negative=0,l.negative=0;for(var d=0;a.isEven()&&l.isEven();d++)a.iushrn(1),l.iushrn(1);do{for(;a.isEven();)a.iushrn(1);for(;l.isEven();)l.iushrn(1);var u=a.cmp(l);if(u<0){var g=a;a=l,l=g;}else if(u===0||l.cmpn(1)===0)break;a.isub(l);}while(true);return l.iushln(d)},o.prototype.invm=function(i){return this.egcd(i).a.umod(i)},o.prototype.isEven=function(){return (this.words[0]&1)===0},o.prototype.isOdd=function(){return (this.words[0]&1)===1},o.prototype.andln=function(i){return this.words[0]&i},o.prototype.bincn=function(i){r(typeof i=="number");var a=i%26,l=(i-a)/26,d=1<<a;if(this.length<=l)return this._expand(l+1),this.words[l]|=d,this;for(var u=d,g=l;u!==0&&g<this.length;g++){var y=this.words[g]|0;y+=u,u=y>>>26,y&=67108863,this.words[g]=y;}return u!==0&&(this.words[g]=u,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(i){var a=i<0;if(this.negative!==0&&!a)return -1;if(this.negative===0&&a)return 1;this._strip();var l;if(this.length>1)l=1;else {a&&(i=-i),r(i<=67108863,"Number is too big");var d=this.words[0]|0;l=d===i?0:d<i?-1:1;}return this.negative!==0?-l|0:l},o.prototype.cmp=function(i){if(this.negative!==0&&i.negative===0)return -1;if(this.negative===0&&i.negative!==0)return 1;var a=this.ucmp(i);return this.negative!==0?-a|0:a},o.prototype.ucmp=function(i){if(this.length>i.length)return 1;if(this.length<i.length)return -1;for(var a=0,l=this.length-1;l>=0;l--){var d=this.words[l]|0,u=i.words[l]|0;if(d!==u){d<u?a=-1:d>u&&(a=1);break}}return a},o.prototype.gtn=function(i){return this.cmpn(i)===1},o.prototype.gt=function(i){return this.cmp(i)===1},o.prototype.gten=function(i){return this.cmpn(i)>=0},o.prototype.gte=function(i){return this.cmp(i)>=0},o.prototype.ltn=function(i){return this.cmpn(i)===-1},o.prototype.lt=function(i){return this.cmp(i)===-1},o.prototype.lten=function(i){return this.cmpn(i)<=0},o.prototype.lte=function(i){return this.cmp(i)<=0},o.prototype.eqn=function(i){return this.cmpn(i)===0},o.prototype.eq=function(i){return this.cmp(i)===0},o.red=function(i){return new G(i)},o.prototype.toRed=function(i){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),i.convertTo(this)._forceRed(i)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(i){return this.red=i,this},o.prototype.forceRed=function(i){return r(!this.red,"Already a number in reduction context"),this._forceRed(i)},o.prototype.redAdd=function(i){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,i)},o.prototype.redIAdd=function(i){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,i)},o.prototype.redSub=function(i){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,i)},o.prototype.redISub=function(i){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,i)},o.prototype.redShl=function(i){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,i)},o.prototype.redMul=function(i){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,i),this.red.mul(this,i)},o.prototype.redIMul=function(i){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,i),this.red.imul(this,i)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(i){return r(this.red&&!i.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,i)};var B={k256:null,p224:null,p192:null,p25519:null};function L(f,i){this.name=f,this.p=new o(i,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp();}L.prototype._tmp=function(){var i=new o(null);return i.words=new Array(Math.ceil(this.n/13)),i},L.prototype.ireduce=function(i){var a=i,l;do this.split(a,this.tmp),a=this.imulK(a),a=a.iadd(this.tmp),l=a.bitLength();while(l>this.n);var d=l<this.n?-1:a.ucmp(this.p);return d===0?(a.words[0]=0,a.length=1):d>0?a.isub(this.p):a.strip!==void 0?a.strip():a._strip(),a},L.prototype.split=function(i,a){i.iushrn(this.n,0,a);},L.prototype.imulK=function(i){return i.imul(this.k)};function P(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f");}s(P,L),P.prototype.split=function(i,a){for(var l=4194303,d=Math.min(i.length,9),u=0;u<d;u++)a.words[u]=i.words[u];if(a.length=d,i.length<=9){i.words[0]=0,i.length=1;return}var g=i.words[9];for(a.words[a.length++]=g&l,u=10;u<i.length;u++){var y=i.words[u]|0;i.words[u-10]=(y&l)<<4|g>>>22,g=y;}g>>>=22,i.words[u-10]=g,g===0&&i.length>10?i.length-=10:i.length-=9;},P.prototype.imulK=function(i){i.words[i.length]=0,i.words[i.length+1]=0,i.length+=2;for(var a=0,l=0;l<i.length;l++){var d=i.words[l]|0;a+=d*977,i.words[l]=a&67108863,a=d*64+(a/67108864|0);}return i.words[i.length-1]===0&&(i.length--,i.words[i.length-1]===0&&i.length--),i};function z(){L.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001");}s(z,L);function q(){L.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff");}s(q,L);function H(){L.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed");}s(H,L),H.prototype.imulK=function(i){for(var a=0,l=0;l<i.length;l++){var d=(i.words[l]|0)*19+a,u=d&67108863;d>>>=26,i.words[l]=u,a=d;}return a!==0&&(i.words[i.length++]=a),i},o._prime=function(i){if(B[i])return B[i];var a;if(i==="k256")a=new P;else if(i==="p224")a=new z;else if(i==="p192")a=new q;else if(i==="p25519")a=new H;else throw new Error("Unknown prime "+i);return B[i]=a,a};function G(f){if(typeof f=="string"){var i=o._prime(f);this.m=i.p,this.prime=i;}else r(f.gtn(1),"modulus must be greater than 1"),this.m=f,this.prime=null;}G.prototype._verify1=function(i){r(i.negative===0,"red works only with positives"),r(i.red,"red works only with red numbers");},G.prototype._verify2=function(i,a){r((i.negative|a.negative)===0,"red works only with positives"),r(i.red&&i.red===a.red,"red works only with red numbers");},G.prototype.imod=function(i){return this.prime?this.prime.ireduce(i)._forceRed(this):(v(i,i.umod(this.m)._forceRed(this)),i)},G.prototype.neg=function(i){return i.isZero()?i.clone():this.m.sub(i)._forceRed(this)},G.prototype.add=function(i,a){this._verify2(i,a);var l=i.add(a);return l.cmp(this.m)>=0&&l.isub(this.m),l._forceRed(this)},G.prototype.iadd=function(i,a){this._verify2(i,a);var l=i.iadd(a);return l.cmp(this.m)>=0&&l.isub(this.m),l},G.prototype.sub=function(i,a){this._verify2(i,a);var l=i.sub(a);return l.cmpn(0)<0&&l.iadd(this.m),l._forceRed(this)},G.prototype.isub=function(i,a){this._verify2(i,a);var l=i.isub(a);return l.cmpn(0)<0&&l.iadd(this.m),l},G.prototype.shl=function(i,a){return this._verify1(i),this.imod(i.ushln(a))},G.prototype.imul=function(i,a){return this._verify2(i,a),this.imod(i.imul(a))},G.prototype.mul=function(i,a){return this._verify2(i,a),this.imod(i.mul(a))},G.prototype.isqr=function(i){return this.imul(i,i.clone())},G.prototype.sqr=function(i){return this.mul(i,i)},G.prototype.sqrt=function(i){if(i.isZero())return i.clone();var a=this.m.andln(3);if(r(a%2===1),a===3){var l=this.m.add(new o(1)).iushrn(2);return this.pow(i,l)}for(var d=this.m.subn(1),u=0;!d.isZero()&&d.andln(1)===0;)u++,d.iushrn(1);r(!d.isZero());var g=new o(1).toRed(this),y=g.redNeg(),b=this.m.subn(1).iushrn(1),n=this.m.bitLength();for(n=new o(2*n*n).toRed(this);this.pow(n,b).cmp(y)!==0;)n.redIAdd(y);for(var p=this.pow(n,d),F=this.pow(i,d.addn(1).iushrn(1)),D=this.pow(i,d),$=u;D.cmp(g)!==0;){for(var U=D,Z=0;U.cmp(g)!==0;Z++)U=U.redSqr();r(Z<$);var Q=this.pow(p,new o(1).iushln($-Z-1));F=F.redMul(Q),p=Q.redSqr(),D=D.redMul(p),$=Z;}return F},G.prototype.invm=function(i){var a=i._invmp(this.m);return a.negative!==0?(a.negative=0,this.imod(a).redNeg()):this.imod(a)},G.prototype.pow=function(i,a){if(a.isZero())return new o(1).toRed(this);if(a.cmpn(1)===0)return i.clone();var l=4,d=new Array(1<<l);d[0]=new o(1).toRed(this),d[1]=i;for(var u=2;u<d.length;u++)d[u]=this.mul(d[u-1],i);var g=d[0],y=0,b=0,n=a.bitLength()%26;for(n===0&&(n=26),u=a.length-1;u>=0;u--){for(var p=a.words[u],F=n-1;F>=0;F--){var D=p>>F&1;if(g!==d[0]&&(g=this.sqr(g)),D===0&&y===0){b=0;continue}y<<=1,y|=D,b++,!(b!==l&&(u!==0||F!==0))&&(g=this.mul(g,d[y]),b=0,y=0);}n=26;}return g},G.prototype.convertTo=function(i){var a=i.umod(this.m);return a===i?a.clone():a},G.prototype.convertFrom=function(i){var a=i.clone();return a.red=null,a},o.mont=function(i){return new Y(i)};function Y(f){G.call(this,f),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv);}s(Y,G),Y.prototype.convertTo=function(i){return this.imod(i.ushln(this.shift))},Y.prototype.convertFrom=function(i){var a=this.imod(i.mul(this.rinv));return a.red=null,a},Y.prototype.imul=function(i,a){if(i.isZero()||a.isZero())return i.words[0]=0,i.length=1,i;var l=i.imul(a),d=l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=l.isub(d).iushrn(this.shift),g=u;return u.cmp(this.m)>=0?g=u.isub(this.m):u.cmpn(0)<0&&(g=u.iadd(this.m)),g._forceRed(this)},Y.prototype.mul=function(i,a){if(i.isZero()||a.isZero())return new o(0)._forceRed(this);var l=i.mul(a),d=l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=l.isub(d).iushrn(this.shift),g=u;return u.cmp(this.m)>=0?g=u.isub(this.m):u.cmpn(0)<0&&(g=u.iadd(this.m)),g._forceRed(this)},Y.prototype.invm=function(i){var a=this.imod(i._invmp(this.m).mul(this.r2));return a._forceRed(this)};})(typeof oo>"u"||oo,Yn);});var Ln=t=>{let{annotations:e}=t,r=e?.[0];if(r&&typeof r=="object"&&"agentId"in r&&typeof r.agentId=="string")return r.agentId};function Cl({toolMessage:t,messages:e}){return e.map(r=>r.parts?{...r,parts:r.parts.map(s=>{if(s.type==="tool-invocation"){let o=typeof t.content=="string"?null:Array.isArray(t.content)?t.content.find(m=>m.toolCallId===s.toolInvocation.toolCallId):null;return o?{...s,state:"result",result:o.result}:s}return s}),annotations:r.agentId?[{agentId:r.agentId}]:void 0}:r)}function Bn(t){return t.reduce((e,r)=>{let s=r.agentId?[{agentId:r.agentId}]:void 0;if(r.role==="tool"||r.role==="function")return Cl({toolMessage:r,messages:e});let o="",m=[];if(typeof r.content=="string")o=r.content;else if(Array.isArray(r.content))for(let x of r.content)x.type==="text"?o+=x.text:x.type==="tool-call"&&m.push({state:"call",toolCallId:x.toolCallId,toolName:x.toolName,args:x.args});let h=["user","assistant","system","data"].includes(r.role)?r.role:"user";return e.push({id:r.id||ai.generateId(),role:h,content:o,toolInvocations:m,annotations:s,parts:r.parts}),e},[])}var _n=t=>t.replace(".vercel.app","");var Fn=async(t,e)=>{try{let r=await fetch(`${e}?id=${t}`,{method:"GET",headers:{"Content-Type":"application/json"}});return r.ok?await r.json():(console.error("Failed to fetch chat history:",r.statusText),null)}catch(r){return console.error("Error fetching chat history:",r),null}};var $n="https://rpc.mainnet.near.org";var Hn="bitte-assistant";var On={generalBackground:"#18181A",messageBackground:"#0A0A0A",textColor:"#FAFAFA",buttonColor:"#000000",borderColor:"#334155"};var Vn={DEBUG:"debug"};var Un=async({localAgent:t,toolCall:e,metadata:r})=>{let s=t.spec.servers?.[0]?.url;if(!s)return;let{toolPath:o,httpMethod:m}=Tl(t,e.toolName);if(!o||!m){console.error("Tool path or method not found for:",e.toolName);return}try{let c=e.args?JSON.parse(JSON.stringify(e.args)):{},{url:h,remainingArgs:x}=Nl(s,o,c),{options:v}=Ml({httpMethod:m,remainingArgs:x,metadata:r}),C=m==="GET"?kl(h,x):h,w=await fetch(C,v);if(!w.ok)throw new Error(`HTTP error during tool execution: ${w.status} ${w.statusText}`);return {data:{result:await Al(w)}}}catch(c){let h=c instanceof Error?c.message:"Unknown error";return console.error("Error executing tool call:",h),{error:h}}},Tl=(t,e)=>{let r,s;return Object.entries(t.spec.paths).forEach(([o,m])=>{Object.entries(m).forEach(([c,h])=>{h.operationId===e&&(r=o,s=c.toUpperCase());});}),{toolPath:r,httpMethod:s}},Nl=(t,e,r)=>{let s=`${t}${e}`,o={...r};return s=s.replace(/\{(\w+)\}/g,(m,c)=>{if(o[c]===void 0)throw new Error(`Missing required path parameter: ${c}`);let h=o[c];return delete o[c],encodeURIComponent(String(h))}),{url:s,remainingArgs:o}},Ml=({httpMethod:t,remainingArgs:e,metadata:r})=>{let s={"Content-Type":"application/json",...r?{"mb-metadata":JSON.stringify(r)}:{}},o={method:t,headers:s};return t!=="GET"&&(o.body=JSON.stringify(e)),{options:o}},kl=(t,e)=>{if(Object.keys(e).length===0)return t;let r=new URLSearchParams;Object.entries(e).filter(([o,m])=>m!=null).forEach(([o,m])=>r.append(o,String(m)));let s=r.toString();return s&&(t+=(t.includes("?")?"&":"?")+s),t},Al=async t=>{let e=t.headers.get("Content-Type")||"";return e.includes("application/json")?t.json():e.includes("text")?t.text():t.blob()};var Wn=jotai.atom({wallet:void 0,nearWalletId:void 0,account:void 0,accountId:null,evmWallet:void 0,evmAddress:void 0,chainId:void 0,suiWallet:void 0,suiAddress:void 0});function Jt(){return jotai.useAtomValue(Wn)}function qn(){let t=jotai.useSetAtom(Wn);return async(e={})=>{let{near:r,evm:s,sui:o}=e;function m(){t({wallet:r?.wallet,account:r?.account,nearWalletId:r?.nearWalletId||void 0,accountId:r?.accountId||null,evmWallet:s,evmAddress:s?.address,chainId:s?.chainId,suiWallet:o?.wallet,suiAddress:o?.wallet?.address});}m(),!r?.account&&!r?.wallet&&!s&&!o?.wallet&&console.warn("No wallet or account configured - users will not be able to send transactions");}}var ro=jotai.atom({chatId:"",apiUrl:"",apiKey:"",agentId:"",initialMessages:[],localAgent:void 0,mcpServerUrl:"",format:"plaintext"}),Gn=jotai.atom(null);jotai.atom(t=>t(ro).chatId);var li=()=>{let t=jotai.useAtomValue(Gn);return t||{messages:[],isLoading:true,status:"ready",input:"",handleInputChange:()=>{},handleSubmit:()=>{}