"use strict";function t(n,t,i){if(4!==t.length)throw new sjcl.exception.invalid("invalid aes block size");var r=n.b[i],f=t[0]^r[0],e=t[i?3:1]^r[1],o=t[2]^r[2];t=t[i?1:3]^r[3];var u,y,p,s,b=r.length/4-2,h=4,w=[0,0,0,0];n=(u=n.s[i])[0];var c=u[1],l=u[2],a=u[3],v=u[4];for(s=0;s<b;s++)u=n[f>>>24]^c[e>>16&255]^l[o>>8&255]^a[255&t]^r[h],y=n[e>>>24]^c[o>>16&255]^l[t>>8&255]^a[255&f]^r[h+1],p=n[o>>>24]^c[t>>16&255]^l[f>>8&255]^a[255&e]^r[h+2],t=n[t>>>24]^c[f>>16&255]^l[e>>8&255]^a[255&o]^r[h+3],h+=4,f=u,e=y,o=p;for(s=0;s<4;s++)w[i?3&-s:s]=v[f>>>24]<<24^v[e>>16&255]<<16^v[o>>8&255]<<8^v[255&t]^r[h++],u=f,f=e,e=o,o=t,t=u;return w}function u(n,t){for(var r,o,i=n.F,y=n.b,a=i[0],f=i[1],s=i[2],c=i[3],e=i[4],l=i[5],h=i[6],v=i[7],u=0;u<64;u++)u<16?r=t[u]:(r=t[u+1&15],o=t[u+14&15],r=t[15&u]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(o>>>17^o>>>19^o>>>10^o<<15^o<<13)+t[15&u]+t[u+9&15]|0),r=r+v+(e>>>6^e>>>11^e>>>25^e<<26^e<<21^e<<7)+(h^e&(l^h))+y[u],v=h,h=l,l=e,e=c+r|0,c=s,s=f,a=r+((f=a)&s^c&(f^s))+(f>>>2^f>>>13^f>>>22^f<<30^f<<19^f<<10)|0;i[0]=i[0]+a|0;i[1]=i[1]+f|0;i[2]=i[2]+s|0;i[3]=i[3]+c|0;i[4]=i[4]+e|0;i[5]=i[5]+l|0;i[6]=i[6]+h|0;i[7]=i[7]+v|0}function A(n,t){var i,r=sjcl.random.K[n],u=[];for(i in r)r.hasOwnProperty(i)&&u.push(r[i]);for(i=0;i<u.length;i++)u[i](t)}function C(n,t){"undefined"!=typeof window&&window.performance&&"function"==typeof window.performance.now?n.addEntropy(window.performance.now(),t,"loadtime"):n.addEntropy((new Date).valueOf(),t,"loadtime")}function y(n){n.b=z(n).concat(z(n));n.L=new sjcl.cipher.aes(n.b)}function z(n){for(var t=0;t<4&&(n.h[t]=n.h[t]+1|0,!n.h[t]);t++);return n.L.encrypt(n.h)}function B(n,t){return function(){t.apply(n,arguments)}}var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(n){this.toString=function(){return"CORRUPT: "+this.message};this.message=n},invalid:function(n){this.toString=function(){return"INVALID: "+this.message};this.message=n},bug:function(n){this.toString=function(){return"BUG: "+this.message};this.message=n},notReady:function(n){this.toString=function(){return"NOT READY: "+this.message};this.message=n}}},D,E,F,G,H;sjcl.cipher.aes=function(n){this.s[0][0][0]||this.O();var i,t,u,o,r=this.s[0][4],f=this.s[1],e=1;if(4!==(i=n.length)&&6!==i&&8!==i)throw new sjcl.exception.invalid("invalid aes key size");for(this.b=[u=n.slice(0),o=[]],n=i;n<4*i+28;n++)t=u[n-1],(0==n%i||8===i&&4==n%i)&&(t=r[t>>>24]<<24^r[t>>16&255]<<16^r[t>>8&255]<<8^r[255&t],0==n%i&&(t=t<<8^t>>>24^e<<24,e=e<<1^283*(e>>7))),u[n]=u[n-i]^t;for(i=0;n;i++,n--)t=u[3&i?n:n-4],o[i]=n<=4||i<4?t:f[0][r[t>>>24]]^f[1][r[t>>16&255]]^f[2][r[t>>8&255]]^f[3][r[255&t]]};sjcl.cipher.aes.prototype={encrypt:function(n){return t(this,n,0)},decrypt:function(n){return t(this,n,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){for(var i,t,h,u,r,e,o=this.s[0],s=this.s[1],c=o[4],a=s[4],f=[],l=[],n=0;n<256;n++)l[(f[n]=n<<1^283*(n>>7))^n]=n;for(i=t=0;!c[i];i^=h||1,t=l[t]||1)for(r=(r=t^t<<1^t<<2^t<<3^t<<4)>>8^255&r^99,e=16843009*(u=f[n=f[h=f[a[c[i]=r]=i]]])^65537*n^257*h^16843008*i,u=257*f[r]^16843008*r,n=0;n<4;n++)o[n][i]=u=u<<24^u>>>8,s[n][r]=e=e<<24^e>>>8;for(n=0;n<5;n++)o[n]=o[n].slice(0),s[n]=s[n].slice(0)}};sjcl.bitArray={bitSlice:function(n,t,i){return n=sjcl.bitArray.$(n.slice(t/32),32-(31&t)).slice(1),void 0===i?n:sjcl.bitArray.clamp(n,i-t)},extract:function(n,t,i){var r=Math.floor(-t-i&31);return(-32&(t+i-1^t)?n[t/32|0]<<32-r^n[t/32+1|0]>>>r:n[t/32|0]>>>r)&(1<<i)-1},concat:function(n,t){if(0===n.length||0===t.length)return n.concat(t);var i=n[n.length-1],r=sjcl.bitArray.getPartial(i);return 32===r?n.concat(t):sjcl.bitArray.$(t,r,0|i,n.slice(0,n.length-1))},bitLength:function(n){var t=n.length;return 0===t?0:32*(t-1)+sjcl.bitArray.getPartial(n[t-1])},clamp:function(n,t){if(32*n.length<t)return n;var i=(n=n.slice(0,Math.ceil(t/32))).length;return t&=31,0<i&&t&&(n[i-1]=sjcl.bitArray.partial(t,n[i-1]&2147483648>>t-1,1)),n},partial:function(n,t,i){return 32===n?t:(i?0|t:t<<32-n)+1099511627776*n},getPartial:function(n){return Math.round(n/1099511627776)||32},equal:function(n,t){if(sjcl.bitArray.bitLength(n)!==sjcl.bitArray.bitLength(t))return!1;for(var r=0,i=0;i<n.length;i++)r|=n[i]^t[i];return 0===r},$:function(n,t,i,r){var u;for(void(u=0)===r&&(r=[]);32<=t;t-=32)r.push(i),i=0;if(0===t)return r.concat(n);for(u=0;u<n.length;u++)r.push(i|n[u]>>>t),i=n[u]<<32-t;return u=n.length?n[n.length-1]:0,n=sjcl.bitArray.getPartial(u),r.push(sjcl.bitArray.partial(t+n&31,32<t+n?i:r.pop(),1)),r},i:function(n,t){return[n[0]^t[0],n[1]^t[1],n[2]^t[2],n[3]^t[3]]},byteswapM:function(n){for(var i,t=0;t<n.length;++t)i=n[t],n[t]=i>>>24|i>>>8&65280|(65280&i)<<8|i<<24;return n}};sjcl.codec.utf8String={fromBits:function(n){for(var i,r="",u=sjcl.bitArray.bitLength(n),t=0;t<u/8;t++)0==(3&t)&&(i=n[t/4]),r+=String.fromCharCode(i>>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(r))},toBits:function(n){n=unescape(encodeURIComponent(n));for(var r=[],i=0,t=0;t<n.length;t++)i=i<<8|n.charCodeAt(t),3==(3&t)&&(r.push(i),i=0);return 3&t&&r.push(sjcl.bitArray.partial(8*(3&t),i)),r}};sjcl.codec.hex={fromBits:function(n){for(var i="",t=0;t<n.length;t++)i+=(0xf00000000000+(0|n[t])).toString(16).substr(4);return i.substr(0,sjcl.bitArray.bitLength(n)/4)},toBits:function(n){var t,i,r=[];for(i=(n=n.replace(/\s|0x/g,"")).length,n+="00000000",t=0;t<n.length;t+=8)r.push(0^parseInt(n.substr(t,8),16));return sjcl.bitArray.clamp(r,4*i)}};sjcl.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(n,t,i){var r=sjcl.codec.base32.BASE,o=sjcl.codec.base32.REMAINING,u="",f=0,s=sjcl.codec.base32.B,e=0,h=sjcl.bitArray.bitLength(n);for(i&&(s=sjcl.codec.base32.X),i=0;u.length*r<h;)u+=s.charAt((e^n[i]>>>f)>>>o),f<r?(e=n[i]<<r-f,f+=o,i++):(e<<=r,f-=r);for(;7&u.length&&!t;)u+="=";return u},toBits:function(n,t){n=n.replace(/\s|=/g,"").toUpperCase();var r,u,o=sjcl.codec.base32.BITS,l=sjcl.codec.base32.BASE,s=sjcl.codec.base32.REMAINING,e=[],i=0,h=sjcl.codec.base32.B,f=0,c="base32";for(t&&(h=sjcl.codec.base32.X,c="base32hex"),r=0;r<n.length;r++){if((u=h.indexOf(n.charAt(r)))<0){if(!t)try{return sjcl.codec.base32hex.toBits(n)}catch(n){}throw new sjcl.exception.invalid("this isn't "+c+"!");}s<i?(i-=s,e.push(f^u>>>i),f=u<<o-i):f^=u<<o-(i+=l)}return 56&i&&e.push(sjcl.bitArray.partial(56&i,f,1)),e}};sjcl.codec.base32hex={fromBits:function(n,t){return sjcl.codec.base32.fromBits(n,t,1)},toBits:function(n){return sjcl.codec.base32.toBits(n,1)}};sjcl.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(n,t,i){var r="",u=0,f=sjcl.codec.base64.B,e=0,o=sjcl.bitArray.bitLength(n);for(i&&(f=f.substr(0,62)+"-_"),i=0;6*r.length<o;)r+=f.charAt((e^n[i]>>>u)>>>26),u<6?(e=n[i]<<6-u,u+=26,i++):(e<<=6,u-=6);for(;3&r.length&&!t;)r+="=";return r},toBits:function(n,t){n=n.replace(/\s|=/g,"");var r,u,e=[],i=0,o=sjcl.codec.base64.B,f=0;for(t&&(o=o.substr(0,62)+"-_"),r=0;r<n.length;r++){if((u=o.indexOf(n.charAt(r)))<0)throw new sjcl.exception.invalid("this isn't base64!");26<i?(i-=26,e.push(f^u>>>i),f=u<<32-i):f^=u<<32-(i+=6)}return 56&i&&e.push(sjcl.bitArray.partial(56&i,f,1)),e}};sjcl.codec.base64url={fromBits:function(n){return sjcl.codec.base64.fromBits(n,1,1)},toBits:function(n){return sjcl.codec.base64.toBits(n,1)}};sjcl.hash.sha256=function(n){this.b[0]||this.O();n?(this.F=n.F.slice(0),this.A=n.A.slice(0),this.l=n.l):this.reset()};sjcl.hash.sha256.hash=function(n){return(new sjcl.hash.sha256).update(n).finalize()};sjcl.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(n){var t,r,f,i;if("string"==typeof n&&(n=sjcl.codec.utf8String.toBits(n)),r=this.A=sjcl.bitArray.concat(this.A,n),t=this.l,9007199254740991<(n=this.l=t+sjcl.bitArray.bitLength(n)))throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){for(f=new Uint32Array(r),i=0,t=512+t-(512+t&511);t<=n;t+=512)u(this,f.subarray(16*i,16*(i+1))),i+=1;r.splice(0,16*i)}else for(t=512+t-(512+t&511);t<=n;t+=512)u(this,r.splice(0,16));return this},finalize:function(){for(var n=this.A,i=this.F,t=(n=sjcl.bitArray.concat(n,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)n.push(0);for(n.push(Math.floor(this.l/4294967296)),n.push(0|this.l);n.length;)u(this,n.splice(0,16));return this.reset(),i},Y:[],b:[],O:function(){function u(n){return 4294967296*(n-Math.floor(n))|0}for(var n,r,t=0,i=2;t<64;i++){for(r=!0,n=2;n*n<=i;n++)if(0==i%n){r=!1;break}r&&(t<8&&(this.Y[t]=u(Math.pow(i,.5))),this.b[t]=u(Math.pow(i,1/3)),t++)}}};sjcl.mode.ccm={name:"ccm",G:[],listenProgress:function(n){sjcl.mode.ccm.G.push(n)},unListenProgress:function(n){-1<(n=sjcl.mode.ccm.G.indexOf(n))&&sjcl.mode.ccm.G.splice(n,1)},fa:function(n){for(var i=sjcl.mode.ccm.G.slice(),t=0;t<i.length;t+=1)i[t](n)},encrypt:function(n,t,i,r,u){var f,e=t.slice(0),o=sjcl.bitArray,s=o.bitLength(i)/8,h=o.bitLength(e)/8;if(u=u||64,r=r||[],s<7)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(f=2;f<4&&h>>>8*f;f++);return f<15-s&&(f=15-s),i=o.clamp(i,8*(15-f)),t=sjcl.mode.ccm.V(n,t,i,r,u,f),e=sjcl.mode.ccm.C(n,e,i,t,u,f),o.concat(e.data,e.tag)},decrypt:function(n,t,i,r,u){u=u||64;r=r||[];var f=sjcl.bitArray,s=f.bitLength(i)/8,e=f.bitLength(t),o=f.clamp(t,e-u),h=f.bitSlice(t,e-u);if(e=(e-u)/8,s<7)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(t=2;t<4&&e>>>8*t;t++);if(t<15-s&&(t=15-s),i=f.clamp(i,8*(15-t)),o=sjcl.mode.ccm.C(n,o,i,h,u,t),n=sjcl.mode.ccm.V(n,o.data,i,r,u,t),!f.equal(o.tag,n))throw new sjcl.exception.corrupt("ccm: tag doesn't match");return o.data},na:function(n,t,i,r,u,f){var o=[],e=sjcl.bitArray,s=e.i;if(r=[e.partial(8,(t.length?64:0)|r-2<<2|f-1)],(r=e.concat(r,i))[3]|=u,r=n.encrypt(r),t.length)for((i=e.bitLength(t)/8)<=65279?o=[e.partial(16,i)]:i<=4294967295&&(o=e.concat([e.partial(16,65534)],[i])),o=e.concat(o,t),t=0;t<o.length;t+=4)r=n.encrypt(s(r,o.slice(t,t+4).concat([0,0,0])));return r},V:function(n,t,i,r,u,f){var e=sjcl.bitArray,o=e.i;if((u/=8)%2||u<4||16<u)throw new sjcl.exception.invalid("ccm: invalid tag length");if(4294967295<r.length||4294967295<t.length)throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data");for(i=sjcl.mode.ccm.na(n,r,i,u,e.bitLength(t)/8,f),r=0;r<t.length;r+=4)i=n.encrypt(o(i,t.slice(r,r+4).concat([0,0,0])));return e.clamp(i,8*u)},C:function(n,t,i,r,u,f){var e,o=sjcl.bitArray;e=o.i;var s=t.length,c=o.bitLength(t),h=s/50,l=h;if(i=o.concat([o.partial(8,f-1)],i).concat([0,0,0]).slice(0,4),r=o.bitSlice(e(r,n.encrypt(i)),0,u),!s)return{tag:r,data:[]};for(e=0;e<s;e+=4)h<e&&(sjcl.mode.ccm.fa(e/s),h+=l),i[3]++,u=n.encrypt(i),t[e]^=u[0],t[e+1]^=u[1],t[e+2]^=u[2],t[e+3]^=u[3];return{tag:r,data:o.clamp(t,c)}}};sjcl.mode.ocb2={name:"ocb2",encrypt:function(n,t,i,r,u,f){var h,l;if(128!==sjcl.bitArray.bitLength(i))throw new sjcl.exception.invalid("ocb iv must be 128 bits");var o,a=sjcl.mode.ocb2.S,c=sjcl.bitArray,e=c.i,s=[0,0,0,0];for(i=a(n.encrypt(i)),l=[],r=r||[],u=u||64,o=0;o+4<t.length;o+=4)s=e(s,h=t.slice(o,o+4)),l=l.concat(e(i,n.encrypt(e(i,h)))),i=a(i);return h=t.slice(o),t=c.bitLength(h),o=n.encrypt(e(i,[0,0,0,t])),s=e(s,e((h=c.clamp(e(h.concat([0,0,0]),o),t)).concat([0,0,0]),o)),s=n.encrypt(e(s,e(i,a(i)))),r.length&&(s=e(s,f?r:sjcl.mode.ocb2.pmac(n,r))),l.concat(c.concat(h,c.clamp(s,u)))},decrypt:function(n,t,i,r,u,f){if(128!==sjcl.bitArray.bitLength(i))throw new sjcl.exception.invalid("ocb iv must be 128 bits");u=u||64;var c,l,a=sjcl.mode.ocb2.S,h=sjcl.bitArray,e=h.i,o=[0,0,0,0],s=a(n.encrypt(i)),v=sjcl.bitArray.bitLength(t)-u,y=[];for(r=r||[],i=0;i+4<v/32;i+=4)o=e(o,c=e(s,n.decrypt(e(s,t.slice(i,i+4))))),y=y.concat(c),s=a(s);if(l=v-32*i,o=e(o,c=e(c=n.encrypt(e(s,[0,0,0,l])),h.clamp(t.slice(i),l).concat([0,0,0]))),o=n.encrypt(e(o,e(s,a(s)))),r.length&&(o=e(o,f?r:sjcl.mode.ocb2.pmac(n,r))),!h.equal(h.clamp(o,u),h.bitSlice(t,v)))throw new sjcl.exception.corrupt("ocb: tag doesn't match");return y.concat(h.clamp(c,l))},pmac:function(n,t){for(var f=sjcl.mode.ocb2.S,o=sjcl.bitArray,u=o.i,e=[0,0,0,0],r=u(r=n.encrypt([0,0,0,0]),f(f(r))),i=0;i+4<t.length;i+=4)r=f(r),e=u(e,n.encrypt(u(r,t.slice(i,i+4))));return i=t.slice(i),o.bitLength(i)<128&&(r=u(r,f(r)),i=o.concat(i,[-2147483648,0,0,0])),e=u(e,i),n.encrypt(u(f(u(r,f(r))),e))},S:function(n){return[n[0]<<1^n[1]>>>31,n[1]<<1^n[2]>>>31,n[2]<<1^n[3]>>>31,n[3]<<1^135*(n[0]>>>31)]}};sjcl.mode.gcm={name:"gcm",encrypt:function(n,t,i,r,u){var f=t.slice(0);return t=sjcl.bitArray,r=r||[],n=sjcl.mode.gcm.C(!0,n,f,r,i,u||128),t.concat(n.data,n.tag)},decrypt:function(n,t,i,r,u){var f=t.slice(0),e=sjcl.bitArray,o=e.bitLength(f);if(r=r||[],(u=u||128)<=o?(t=e.bitSlice(f,o-u),f=e.bitSlice(f,0,o-u)):(t=f,f=[]),n=sjcl.mode.gcm.C(!1,n,f,r,i,u),!e.equal(n.tag,t))throw new sjcl.exception.corrupt("gcm: tag doesn't match");return n.data},ka:function(n,t){var u,r,f,i,e,o=sjcl.bitArray.i;for(f=[0,0,0,0],i=t.slice(0),u=0;u<128;u++){for((r=0!=(n[Math.floor(u/32)]&1<<31-u%32))&&(f=o(f,i)),e=0!=(1&i[3]),r=3;0<r;r--)i[r]=i[r]>>>1|(1&i[r-1])<<31;i[0]>>>=1;e&&(i[0]^=-520093696)}return f},j:function(n,t,i){var r,u=i.length;for(t=t.slice(0),r=0;r<u;r+=4)t[0]^=4294967295&i[r],t[1]^=4294967295&i[r+1],t[2]^=4294967295&i[r+2],t[3]^=4294967295&i[r+3],t=sjcl.mode.gcm.ka(t,n);return t},C:function(n,t,i,r,u,f){var s,o,e,h,a,y,l,v,c=sjcl.bitArray;for(y=i.length,l=c.bitLength(i),v=c.bitLength(r),o=c.bitLength(u),s=t.encrypt([0,0,0,0]),96===o?(u=u.slice(0),u=c.concat(u,[1])):(u=sjcl.mode.gcm.j(s,[0,0,0,0],u),u=sjcl.mode.gcm.j(s,u,[0,0,Math.floor(o/4294967296),4294967295&o])),o=sjcl.mode.gcm.j(s,[0,0,0,0],r),a=u.slice(0),r=o.slice(0),n||(r=sjcl.mode.gcm.j(s,o,i)),h=0;h<y;h+=4)a[3]++,e=t.encrypt(a),i[h]^=e[0],i[h+1]^=e[1],i[h+2]^=e[2],i[h+3]^=e[3];return i=c.clamp(i,l),n&&(r=sjcl.mode.gcm.j(s,o,i)),n=[Math.floor(v/4294967296),4294967295&v,Math.floor(l/4294967296),4294967295&l],r=sjcl.mode.gcm.j(s,r,n),e=t.encrypt(u),r[0]^=e[0],r[1]^=e[1],r[2]^=e[2],r[3]^=e[3],{tag:c.bitSlice(r,0,f),data:i}}};sjcl.misc.hmac=function(n,t){this.W=t=t||sjcl.hash.sha256;var i,r=[[],[]],u=t.prototype.blockSize/32;for(this.w=[new t,new t],n.length>u&&(n=t.hash(n)),i=0;i<u;i++)r[0][i]=909522486^n[i],r[1][i]=1549556828^n[i];this.w[0].update(r[0]);this.w[1].update(r[1]);this.R=new t(this.w[0])};sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(n){if(this.aa)throw new sjcl.exception.invalid("encrypt on already updated hmac called!");return this.update(n),this.digest(n)};sjcl.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]);this.aa=!1};sjcl.misc.hmac.prototype.update=function(n){this.aa=!0;this.R.update(n)};sjcl.misc.hmac.prototype.digest=function(){var n=this.R.finalize();return n=new this.W(this.w[1]).update(n).finalize(),this.reset(),n};sjcl.misc.pbkdf2=function(n,t,i,r,u){if(i=i||1e4,r<0||i<0)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"==typeof n&&(n=sjcl.codec.utf8String.toBits(n));"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));n=new(u=u||sjcl.misc.hmac)(n);for(var e,s,o,f=[],c=sjcl.bitArray,h=1;32*f.length<(r||1);h++){for(u=e=n.encrypt(c.concat(t,[h])),s=1;s<i;s++)for(e=n.encrypt(e),o=0;o<e.length;o++)u[o]^=e[o];f=f.concat(u)}return r&&(f=c.clamp(f,r)),f};sjcl.prng=function(n){this.c=[new sjcl.hash.sha256];this.m=[0];this.P=0;this.H={};this.N=0;this.U={};this.Z=this.f=this.o=this.ha=0;this.b=[0,0,0,0,0,0,0,0];this.h=[0,0,0,0];this.L=void 0;this.M=n;this.D=!1;this.K={progress:{},seeded:{}};this.u=this.ga=0;this.I=1;this.J=2;this.ca=65536;this.T=[0,48,64,96,128,192,256,384,512,768,1024];this.da=3e4;this.ba=80};sjcl.prng.prototype={randomWords:function(n,t){var i,r,e=[],u,f;if((i=this.isReady(t))===this.u)throw new sjcl.exception.notReady("generator isn't seeded");if(i&this.J){for(i=!(i&this.I),r=[],f=0,this.Z=r[0]=(new Date).valueOf()+this.da,u=0;u<16;u++)r.push(4294967296*Math.random()|0);for(u=0;u<this.c.length&&(r=r.concat(this.c[u].finalize()),f+=this.m[u],this.m[u]=0,i||!(this.P&1<<u));u++);for(this.P>=1<<this.c.length&&(this.c.push(new sjcl.hash.sha256),this.m.push(0)),this.f-=f,f>this.o&&(this.o=f),this.P++,this.b=sjcl.hash.sha256.hash(this.b.concat(r)),this.L=new sjcl.cipher.aes(this.b),i=0;i<4&&(this.h[i]=this.h[i]+1|0,!this.h[i]);i++);}for(i=0;i<n;i+=4)0==(i+1)%this.ca&&y(this),r=z(this),e.push(r[0],r[1],r[2],r[3]);return y(this),e.slice(0,n)},setDefaultParanoia:function(n,t){if(0===n&&"Setting paranoia=0 will ruin your security; use it only for testing"!==t)throw new sjcl.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=n},addEntropy:function(n,t,i){i=i||"user";var e,u,o=(new Date).valueOf(),r=this.H[i],s=this.isReady(),f=0;switch(void 0===(e=this.U[i])&&(e=this.U[i]=this.ha++),void 0===r&&(r=this.H[i]=0),this.H[i]=(this.H[i]+1)%this.c.length,typeof n){case"number":void 0===t&&(t=1);this.c[r].update([e,this.N++,1,t,o,1,0|n]);break;case"object":if("[object Uint32Array]"===(i=Object.prototype.toString.call(n))){for(u=[],i=0;i<n.length;i++)u.push(n[i]);n=u}else for("[object Array]"!==i&&(f=1),i=0;i<n.length&&!f;i++)"number"!=typeof n[i]&&(f=1);if(!f){if(void 0===t)for(i=t=0;i<n.length;i++)for(u=n[i];0<u;)t++,u>>>=1;this.c[r].update([e,this.N++,2,t,o,n.length].concat(n))}break;case"string":void 0===t&&(t=n.length);this.c[r].update([e,this.N++,3,t,o,n.length]);this.c[r].update(n);break;default:f=1}if(f)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[r]+=t;this.f+=t;s===this.u&&(this.isReady()!==this.u&&A("seeded",Math.max(this.o,this.f)),A("progress",this.getProgress()))},isReady:function(n){return n=this.T[void 0!==n?n:this.M],this.o&&this.o>=n?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=n?this.J|this.u:this.u},getProgress:function(n){return n=this.T[n||this.M],this.o>=n?1:this.f>n?1:this.f/n},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:B(this,this.ma),mouseCollector:B(this,this.oa),keyboardCollector:B(this,this.la),accelerometerCollector:B(this,this.ea),touchCollector:B(this,this.qa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else{if(!document.attachEvent)throw new sjcl.exception.bug("can't attach event");document.attachEvent("onload",this.a.loadTimeCollector);document.attachEvent("onmousemove",this.a.mouseCollector);document.attachEvent("keypress",this.a.keyboardCollector)}this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(n,t){this.K[n][this.ga++]=t},removeEventListener:function(n,t){var r,i,u=this.K[n],f=[];for(i in u)u.hasOwnProperty(i)&&u[i]===t&&f.push(i);for(r=0;r<f.length;r++)delete u[i=f[r]]},la:function(){C(this,1)},oa:function(n){var t,i;try{t=n.x||n.clientX||n.offsetX||0;i=n.y||n.clientY||n.offsetY||0}catch(n){i=t=0}0!=t&&0!=i&&this.addEntropy([t,i],2,"mouse");C(this,0)},qa:function(n){n=n.touches[0]||n.changedTouches[0];this.addEntropy([n.pageX||n.clientX,n.pageY||n.clientY],1,"touch");C(this,0)},ma:function(){C(this,2)},ea:function(n){if(n=n.accelerationIncludingGravity.x||n.accelerationIncludingGravity.y||n.accelerationIncludingGravity.z,window.orientation){var t=window.orientation;"number"==typeof t&&this.addEntropy(t,1,"accelerometer")}n&&this.addEntropy(n,2,"accelerometer");C(this,0)}};sjcl.random=new sjcl.prng(6);n:try{if(G="undefined"!=typeof module&&module.exports){try{H=require("crypto")}catch(t){H=null}G=E=H}if(G&&E.randomBytes)D=E.randomBytes(128),D=new Uint32Array(new Uint8Array(D).buffer),sjcl.random.addEntropy(D,1024,"crypto['randomBytes']");else if("undefined"!=typeof window&&"undefined"!=typeof Uint32Array){if(F=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(F);else{if(!window.msCrypto||!window.msCrypto.getRandomValues)break n;window.msCrypto.getRandomValues(F)}sjcl.random.addEntropy(F,1024,"crypto['getRandomValues']")}}catch(t){"undefined"!=typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(t))}sjcl.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(n,t,i,r){i=i||{};r=r||{};var f,e=sjcl.json,u=e.g({iv:sjcl.random.randomWords(4,0)},e.defaults);if(e.g(u,i),i=u.adata,"string"==typeof u.salt&&(u.salt=sjcl.codec.base64.toBits(u.salt)),"string"==typeof u.iv&&(u.iv=sjcl.codec.base64.toBits(u.iv)),!sjcl.mode[u.mode]||!sjcl.cipher[u.cipher]||"string"==typeof n&&u.iter<=100||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||u.iv.length<2||4<u.iv.length)throw new sjcl.exception.invalid("json encrypt: invalid parameters");return"string"==typeof n?(n=(f=sjcl.misc.cachedPbkdf2(n,u)).key.slice(0,u.ks/32),u.salt=f.salt):sjcl.ecc&&n instanceof sjcl.ecc.elGamal.publicKey&&(f=n.kem(),u.kemtag=f.tag,n=f.key.slice(0,u.ks/32)),"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t)),"string"==typeof i&&(u.adata=i=sjcl.codec.utf8String.toBits(i)),f=new sjcl.cipher[u.cipher](n),e.g(r,u),r.key=n,u.ct="ccm"===u.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&t instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.encrypt(f,t,u.iv,i,u.ts):sjcl.mode[u.mode].encrypt(f,t,u.iv,i,u.ts),u},encrypt:function(){var n=sjcl.json,t=n.ja.apply(n,arguments);return n.encode(t)},ia:function(n,t,i,r){i=i||{};r=r||{};var u,f,e=sjcl.json;if(u=(t=e.g(e.g(e.g({},e.defaults),t),i,!0)).adata,"string"==typeof t.salt&&(t.salt=sjcl.codec.base64.toBits(t.salt)),"string"==typeof t.iv&&(t.iv=sjcl.codec.base64.toBits(t.iv)),!sjcl.mode[t.mode]||!sjcl.cipher[t.cipher]||"string"==typeof n&&t.iter<=100||64!==t.ts&&96!==t.ts&&128!==t.ts||128!==t.ks&&192!==t.ks&&256!==t.ks||!t.iv||t.iv.length<2||4<t.iv.length)throw new sjcl.exception.invalid("json decrypt: invalid parameters");return"string"==typeof n?(n=(f=sjcl.misc.cachedPbkdf2(n,t)).key.slice(0,t.ks/32),t.salt=f.salt):sjcl.ecc&&n instanceof sjcl.ecc.elGamal.secretKey&&(n=n.unkem(sjcl.codec.base64.toBits(t.kemtag)).slice(0,t.ks/32)),"string"==typeof u&&(u=sjcl.codec.utf8String.toBits(u)),f=new sjcl.cipher[t.cipher](n),u="ccm"===t.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&t.ct instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.decrypt(f,t.ct,t.iv,t.tag,u,t.ts):sjcl.mode[t.mode].decrypt(f,t.ct,t.iv,u,t.ts),e.g(r,t),r.key=n,1===i.raw?u:sjcl.codec.utf8String.fromBits(u)},decrypt:function(n,t,i,r){var u=sjcl.json;return u.ia(n,u.decode(t),i,r)},encode:function(n){var t,i="{",r="";for(t in n)if(n.hasOwnProperty(t)){if(!t.match(/^[a-z0-9]+$/i))throw new sjcl.exception.invalid("json encode: invalid property name");switch(i+=r+'"'+t+'":',r=",",typeof n[t]){case"number":case"boolean":i+=n[t];break;case"string":i+='"'+escape(n[t])+'"';break;case"object":i+='"'+sjcl.codec.base64.fromBits(n[t],0)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type");}}return i+"}"},decode:function(n){if(!(n=n.replace(/\s/g,"")).match(/^\{.*\}$/))throw new sjcl.exception.invalid("json decode: this isn't json!");n=n.replace(/^\{|\}$/g,"").split(/,/);for(var t,r={},i=0;i<n.length;i++){if(!(t=n[i].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new sjcl.exception.invalid("json decode: this isn't json!");null!=t[3]?r[t[2]]=parseInt(t[3],10):null!=t[4]?r[t[2]]=t[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(t[4]):unescape(t[4]):null!=t[5]&&(r[t[2]]="true"===t[5])}return r},g:function(n,t,i){if(void 0===n&&(n={}),void 0===t)return n;for(var r in t)if(t.hasOwnProperty(r)){if(i&&void 0!==n[r]&&n[r]!==t[r])throw new sjcl.exception.invalid("required parameter overridden");n[r]=t[r]}return n},sa:function(n,t){var i,r={};for(i in n)n.hasOwnProperty(i)&&n[i]!==t[i]&&(r[i]=n[i]);return r},ra:function(n,t){for(var r={},i=0;i<t.length;i++)void 0!==n[t[i]]&&(r[t[i]]=n[t[i]]);return r}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.pa={};sjcl.misc.cachedPbkdf2=function(n,t){var r,i=sjcl.misc.pa;return r=(t=t||{}).iter||1e3,(r=(i=i[n]=i[n]||{})[r]=i[r]||{firstSalt:t.salt&&t.salt.length?t.salt.slice(0):sjcl.random.randomWords(2,0)})[i=void 0===t.salt?r.firstSalt:t.salt]=r[i]||sjcl.misc.pbkdf2(n,i,t.iter),{key:r[i].slice(0),salt:i.slice(0)}};"undefined"!=typeof module&&module.exports&&(module.exports=sjcl);"function"==typeof define&&define([],function(){return sjcl})