//>>built
define("dojox/math/BigInteger",["dojo","dojox","dojo/has"],function(t,z,n){function k(a,b,c){null!=a&&("number"==typeof a?this._fromNumber(a,b,c):b||"string"==typeof a?this._fromString(a,b):this._fromString(a,256))}function m(){return new k(null)}function F(a,b,c,d,f,e){for(;0<=--e;){var g=b*this[a++]+c[d]+f;f=Math.floor(g/67108864);c[d++]=g&67108863}return f}function G(a,b,c,d,f,e){var g=b&32767;for(b>>=15;0<=--e;){var h=this[a]&32767,q=this[a++]>>15,v=b*h+q*g;h=g*h+((v&32767)<<15)+c[d]+(f&1073741823);
f=(h>>>30)+(v>>>15)+b*q+(f>>>30);c[d++]=h&1073741823}return f}function D(a,b){var c=w[a.charCodeAt(b)];return null==c?-1:c}function A(a){var b=m();b._fromInt(a);return b}function x(a){var b=1,c;if(c=a>>>16)a=c,b+=16;if(c=a>>8)a=c,b+=8;if(c=a>>4)a=c,b+=4;if(c=a>>2)a=c,b+=2;if(c=a>>1)a=c,b+=1;return b}function E(a){this.m=a}function B(a){this.m=a;this.mp=a._invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<a._DB-15)-1;this.mt2=2*a.t}t.getObject("math.BigInteger",!0,z);t.experimental("dojox.math.BigInteger");
n("ie")?(k.prototype.am=G,n=30):(k.prototype.am=F,n=26);var w=[],l;var u=48;for(l=0;9>=l;++l)w[u++]=l;u=97;for(l=10;36>l;++l)w[u++]=l;u=65;for(l=10;36>l;++l)w[u++]=l;t.extend(E,{convert:function(a){return 0>a.s||0<=a.compareTo(this.m)?a.mod(this.m):a},revert:function(a){return a},reduce:function(a){a._divRemTo(this.m,null,a)},mulTo:function(a,b,c){a._multiplyTo(b,c);this.reduce(c)},sqrTo:function(a,b){a._squareTo(b);this.reduce(b)}});t.extend(B,{convert:function(a){var b=m();a.abs()._dlShiftTo(this.m.t,
b);b._divRemTo(this.m,null,b);0>a.s&&0<b.compareTo(k.ZERO)&&this.m._subTo(b,b);return b},revert:function(a){var b=m();a._copyTo(b);this.reduce(b);return b},reduce:function(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=a[b]&32767,d=c*this.mpl+((c*this.mph+(a[b]>>15)*this.mpl&this.um)<<15)&a._DM;c=b+this.m.t;for(a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a._DV;)a[c]-=a._DV,a[++c]++}a._clamp();a._drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a._subTo(this.m,a)},mulTo:function(a,
b,c){a._multiplyTo(b,c);this.reduce(c)},sqrTo:function(a,b){a._squareTo(b);this.reduce(b)}});t.extend(k,{_DB:n,_DM:(1<<n)-1,_DV:1<<n,_FV:Math.pow(2,52),_F1:52-n,_F2:2*n-52,_copyTo:function(a){for(var b=this.t-1;0<=b;--b)a[b]=this[b];a.t=this.t;a.s=this.s},_fromInt:function(a){this.t=1;this.s=0>a?-1:0;0<a?this[0]=a:-1>a?this[0]=a+_DV:this.t=0},_fromString:function(a,b){if(16==b)var c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else if(4==b)c=2;else{this._fromRadix(a,b);
return}this.s=this.t=0;for(var d=a.length,f=!1,e=0;0<=--d;){var g=8==c?a[d]&255:D(a,d);0>g?"-"==a.charAt(d)&&(f=!0):(f=!1,0==e?this[this.t++]=g:e+c>this._DB?(this[this.t-1]|=(g&(1<<this._DB-e)-1)<<e,this[this.t++]=g>>this._DB-e):this[this.t-1]|=g<<e,e+=c,e>=this._DB&&(e-=this._DB))}8==c&&0!=(a[0]&128)&&(this.s=-1,0<e&&(this[this.t-1]|=(1<<this._DB-e)-1<<e));this._clamp();f&&k.ZERO._subTo(this,this)},_clamp:function(){for(var a=this.s&this._DM;0<this.t&&this[this.t-1]==a;)--this.t;this.t=0===this.t?
1:this.t},_dlShiftTo:function(a,b){var c;for(c=this.t-1;0<=c;--c)b[c+a]=this[c];for(c=a-1;0<=c;--c)b[c]=0;b.t=this.t+a;b.s=this.s},_drShiftTo:function(a,b){for(var c=a;c<this.t;++c)b[c-a]=this[c];b.t=Math.max(this.t-a,0);b.s=this.s},_lShiftTo:function(a,b){var c=a%this._DB,d=this._DB-c,f=(1<<d)-1,e=Math.floor(a/this._DB),g=this.s<<c&this._DM,h;for(h=this.t-1;0<=h;--h)b[h+e+1]=this[h]>>d|g,g=(this[h]&f)<<c;for(h=e-1;0<=h;--h)b[h]=0;b[e]=g;b.t=this.t+e+1;b.s=this.s;b._clamp()},_rShiftTo:function(a,
b){b.s=this.s;var c=Math.floor(a/this._DB);if(c>=this.t)b.t=0;else{var d=a%this._DB,f=this._DB-d,e=(1<<d)-1;b[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)b[g-c-1]|=(this[g]&e)<<f,b[g-c]=this[g]>>d;0<d&&(b[this.t-c-1]|=(this.s&e)<<f);b.t=this.t-c;b._clamp()}},_subTo:function(a,b){for(var c=0,d=0,f=Math.min(a.t,this.t);c<f;)d+=this[c]-a[c],b[c++]=d&this._DM,d>>=this._DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this[c],b[c++]=d&this._DM,d>>=this._DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a[c],b[c++]=d&this._DM,
d>>=this._DB;d-=a.s}b.s=0>d?-1:0;-1>d?b[c++]=this._DV+d:0<d&&(b[c++]=d);b.t=c;b._clamp()},_multiplyTo:function(a,b){var c=this.abs(),d=a.abs(),f=c.t;for(b.t=f+d.t;0<=--f;)b[f]=0;for(f=0;f<d.t;++f)b[f+c.t]=c.am(0,d[f],b,f,0,c.t);b.s=0;b._clamp();this.s!=a.s&&k.ZERO._subTo(b,b)},_squareTo:function(a){for(var b=this.abs(),c=a.t=2*b.t;0<=--c;)a[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b[c],a,2*c,0,1);(a[c+b.t]+=b.am(c+1,2*b[c],a,2*c+1,d,b.t-c-1))>=b._DV&&(a[c+b.t]-=b._DV,a[c+b.t+1]=1)}0<a.t&&(a[a.t-1]+=
b.am(c,b[c],a,2*c,0,1));a.s=0;a._clamp()},_divRemTo:function(a,b,c){var d=a.abs();if(!(0>=d.t)){var f=this.abs();if(f.t<d.t)null!=b&&b._fromInt(0),null!=c&&this._copyTo(c);else{null==c&&(c=m());var e=m(),g=this.s;a=a.s;var h=this._DB-x(d[d.t-1]);0<h?(d._lShiftTo(h,e),f._lShiftTo(h,c)):(d._copyTo(e),f._copyTo(c));d=e.t;f=e[d-1];if(0!=f){var q=f*(1<<this._F1)+(1<d?e[d-2]>>this._F2:0),v=this._FV/q;q=(1<<this._F1)/q;var H=1<<this._F2,r=c.t,y=r-d,p=null==b?m():b;e._dlShiftTo(y,p);0<=c.compareTo(p)&&(c[c.t++]=
1,c._subTo(p,c));k.ONE._dlShiftTo(d,p);for(p._subTo(e,e);e.t<d;)e[e.t++]=0;for(;0<=--y;){var C=c[--r]==f?this._DM:Math.floor(c[r]*v+(c[r-1]+H)*q);if((c[r]+=e.am(0,C,c,y,0,d))<C)for(e._dlShiftTo(y,p),c._subTo(p,c);c[r]<--C;)c._subTo(p,c)}null!=b&&(c._drShiftTo(d,b),g!=a&&k.ZERO._subTo(b,b));c.t=d;c._clamp();0<h&&c._rShiftTo(h,c);0>g&&k.ZERO._subTo(c,c)}}}},_invDigit:function(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var b=a&3;b=b*(2-(a&15)*b)&15;b=b*(2-(a&255)*b)&255;b=b*(2-((a&65535)*
b&65535))&65535;b=b*(2-a*b%this._DV)%this._DV;return 0<b?this._DV-b:-b},_isEven:function(){return 0==(0<this.t?this[0]&1:this.s)},_exp:function(a,b){if(4294967295<a||1>a)return k.ONE;var c=m(),d=m(),f=b.convert(this),e=x(a)-1;for(f._copyTo(c);0<=--e;)if(b.sqrTo(c,d),0<(a&1<<e))b.mulTo(d,f,c);else{var g=c;c=d;d=g}return b.revert(c)},_intAt:D,toString:function(a){if(0>this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this._toRadix(a);
var b=(1<<a)-1,c,d=!1,f="",e=this.t,g=this._DB-e*this._DB%a;if(0<e--)for(g<this._DB&&0<(c=this[e]>>g)&&(d=!0,f="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));0<=e;)g<a?(c=(this[e]&(1<<g)-1)<<a-g,c|=this[--e]>>(g+=this._DB-a)):(c=this[e]>>(g-=a)&b,0>=g&&(g+=this._DB,--e)),0<c&&(d=!0),d&&(f+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));return d?f:"0"},negate:function(){var a=m();k.ZERO._subTo(this,a);return a},abs:function(){return 0>this.s?this.negate():this},compareTo:function(a){if(this.s!==
a.s)return this.s>a.s?1:-1;if(this.t!==a.t)return 0===this.s?this.t>a.t?1:-1:this.t<a.t?1:-1;for(var b=this.t;0<=--b;)if(this[b]!==a[b])return this[b]>a[b]?1:-1;return 0},bitLength:function(){return 0>=this.t?0:this._DB*(this.t-1)+x(this[this.t-1]^this.s&this._DM)},mod:function(a){var b=m();this.abs()._divRemTo(a,null,b);0>this.s&&0<b.compareTo(k.ZERO)&&a._subTo(b,b);return b},modPowInt:function(a,b){var c=256>a||b._isEven()?new E(b):new B(b);return this._exp(a,c)}});t._mixin(k,{ZERO:A(0),ONE:A(1),
_nbi:m,_nbv:A,_nbits:x,_Montgomery:B});z.math.BigInteger=k;return z.math.BigInteger});