1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ledger=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63;function placeHoldersCount(b64){var len=b64.length;if(len%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}return b64[len-2]==="="?2:b64[len-1]==="="?1:0}function byteLength(b64){return b64.length*3/4-placeHoldersCount(b64)}function toByteArray(b64){var i,l,tmp,placeHolders,arr;var len=b64.length;placeHolders=placeHoldersCount(b64);arr=new Arr(len*3/4-placeHolders);l=placeHolders>0?len-4:len;var L=0;for(i=0;i<l;i+=4){tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)];arr[L++]=tmp>>16&255;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}if(placeHolders===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[L++]=tmp&255}else if(placeHolders===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;i<end;i+=3){tmp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output.push(tripletToBase64(tmp))}return output.join("")}function fromByteArray(uint8){var tmp;var len=uint8.length;var extraBytes=len%3;var output="";var parts=[];var maxChunkLength=16383;for(var i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];output+=lookup[tmp>>2];output+=lookup[tmp<<4&63];output+="=="}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];output+=lookup[tmp>>10];output+=lookup[tmp>>4&63];output+=lookup[tmp<<2&63];output+="="}parts.push(output);return parts.join("")}},{}],2:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()<length){throw new RangeError("Invalid typed array length")}
vendor: 1,215 bytes, line 1
1if(Buffer.TYPED_ARRAY_SUPPORT){that=new Uint8Array(length);that.__proto__=Buffer.prototype}else{if(that===null){that=new Buffer(length)}that.length=length}return that}function Buffer(arg,encodingOrOffset,length){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(this instanceof Buffer)){return new Buffer(arg,encodingOrOffset,length)}if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return allocUnsafe(this,arg)}return from(this,arg,encodingOrOffset,length)}Buffer.poolSize=8192;Buffer._augment=function(arr){arr.__proto__=Buffer.prototype;return arr};function from(that,value,encodingOrOffset,length){if(typeof value==="number"){throw new TypeError('"value" argument must not be a number')}if(typeof ArrayBuffer!=="undefined"&&value instanceof ArrayBuffer){return fromArrayBuffer(that,value,encodingOrOffset,length)}if(typeof value==="string"){return fromString(that,value,encodingOrOffset)}return fromObject(that,value)}Buffer.from=function(value,encodingOrOffset,length){return from(null,value,encodingOrOffset,length)};if(Buffer.TYPED_ARRAY_SUPPORT){Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;
vendor: 5,015 bytes, line 1
1if(typeof Symbol!=="undefined"&&Symbol.species&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true})}}function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be a number')}else if(size<0){throw new RangeError('"size" argument must not be negative')}}function alloc(that,size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(that,size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(that,size).fill(fill,encoding):createBuffer(that,size).fill(fill)}return createBuffer(that,size)}Buffer.alloc=function(size,fill,encoding){return alloc(null,size,fill,encoding)};function allocUnsafe(that,size){assertSize(size);that=createBuffer(that,size<0?0:checked(size)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<size;++i){that[i]=0}}return that}Buffer.allocUnsafe=function(size){return allocUnsafe(null,size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(null,size)};function fromString(that,string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError('"encoding" must be a valid string encoding')}var length=byteLength(string,encoding)|0;that=createBuffer(that,length);var actual=that.write(string,encoding);if(actual!==length){that=that.slice(0,actual)}return that}function fromArrayLike(that,array){var length=array.length<0?0:checked(array.length)|0;that=createBuffer(that,length);for(var i=0;i<length;i+=1){that[i]=array[i]&255}return that}function fromArrayBuffer(that,array,byteOffset,length){array.byteLength;if(byteOffset<0||array.byteLength<byteOffset){throw new RangeError("'offset' is out of bounds")}if(array.byteLength<byteOffset+(length||0)){throw new RangeError("'length' is out of bounds")}if(byteOffset===undefined&&length===undefined){array=new Uint8Array(array)}else if(length===undefined){array=new Uint8Array(array,byteOffset)}else{array=new Uint8Array(array,byteOffset,length)}if(Buffer.TYPED_ARRAY_SUPPORT){that=array;that.__proto__=Buffer.prototype}else{that=fromArrayLike(that,array)}return that}function fromObject(that,obj){if(Buffer.isBuffer(obj)){var len=checked(obj.length)|0;that=createBuffer(that,len);if(that.length===0){return that}obj.copy(that,0,0,len);return that}if(obj){if(typeof ArrayBuffer!=="undefined"&&obj.buffer instanceof ArrayBuffer||"length"in obj){if(typeof obj.length!=="number"||isnan(obj.length)){return createBuffer(that,0)}return fromArrayLike(that,obj)}if(obj.type==="Buffer"&&isArray(obj.data)){return fromArrayLike(that,obj.data)}}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(length){if(length>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len;++i){if(a[i]!==b[i]){x=a[i];y=b[i];break}}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function isEncoding(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function concat(list,length){if(!isArray(list)){throw new TypeError('"list" argument must be an Array of Buffers')}if(list.length===0){return Buffer.alloc(0)}var i;if(length===undefined){length=0;for(i=0;i<list.length;++i){length+=list[i].length}}var buffer=Buffer.allocUnsafe(length);var pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(!Buffer.isBuffer(buf)){throw new TypeError('"list" argument must be an Array of Buffers')}buf.copy(buffer,pos);pos+=buf.length}return buffer};function byteLength(string,encoding){if(Buffer.isBuffer(string)){return string.length}if(typeof ArrayBuffer!=="undefined"&&typeof ArrayBuffer.isView==="function"&&(ArrayBuffer.isView(string)||string instanceof ArrayBuffer)){return string.byteLength}if(typeof string!=="string"){string=""+string}var len=string.length;if(len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":case undefined:return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}
vendor: 4,703 bytes, line 1
1if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i<len;i+=2){swap(this,i,i+1)}return this};Buffer.prototype.swap32=function swap32(){var len=this.length;if(len%4!==0){throw new RangeError("Buffer size must be a multiple of 32-bits")}for(var i=0;i<len;i+=4){swap(this,i,i+3);swap(this,i+1,i+2)}return this};Buffer.prototype.swap64=function swap64(){var len=this.length;if(len%8!==0){throw new RangeError("Buffer size must be a multiple of 64-bits")}for(var i=0;i<len;i+=8){swap(this,i,i+7);swap(this,i+1,i+6);swap(this,i+2,i+5);swap(this,i+3,i+4)}return this};Buffer.prototype.toString=function toString(){var length=this.length|0;if(length===0)return"";if(arguments.length===0)return utf8Slice(this,0,length);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return true;return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function inspect(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i<len;++i){if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i];y=targetCopy[i];break}}if(x<y)return-1;if(y<x)return 1;return 0};function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(buffer.length===0)return-1;if(typeof byteOffset==="string"){encoding=byteOffset;byteOffset=0}else if(byteOffset>2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++){if(read(arr,i)===read(val,foundIndex===-1?0:i-foundIndex)){if(foundIndex===-1)foundIndex=i;if(i-foundIndex+1===valLength)return foundIndex*indexSize}else{if(foundIndex!==-1)i-=i-foundIndex;foundIndex=-1}}}else{if(byteOffset+valLength>
vendor: 16,715 bytes, line 1
1arrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;j<valLength;j++){if(read(arr,i+j)!==read(val,j)){found=false;break}}if(found)return i}}return-1}Buffer.prototype.includes=function includes(val,byteOffset,encoding){return this.indexOf(val,byteOffset,encoding)!==-1};Buffer.prototype.indexOf=function indexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,true)};Buffer.prototype.lastIndexOf=function lastIndexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,false)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;++i){var parsed=parseInt(string.substr(i*2,2),16);if(isNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(asciiToBytes(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length)}Buffer.prototype.write=function write(string,offset,length,encoding){if(offset===undefined){encoding="utf8";length=this.length;offset=0}else if(length===undefined&&typeof offset==="string"){encoding=offset;length=this.length;offset=0}else if(isFinite(offset)){offset=offset|0;if(isFinite(length)){length=length|0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i<end){var firstByte=buf[i];var codePoint=null;var bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(i<len){res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH))}return res}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i){ret+=String.fromCharCode(buf[i]&127)}return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;++i){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function slice(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=this.subarray(start,end);newBuf.__proto__=Buffer.prototype}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined);for(var i=0;i<sliceLen;++i){newBuf[i]=this[i+start]}}return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}return val};Buffer.prototype.readUIntBE=function readUIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256)){val+=this[offset+i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUIntBE=function writeUIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;++i){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;++i){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256)){if(value<0&&sub===0&&this[offset+i-1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||this.length===0)return 0;
1if(targetStart<0){throw new RangeError("targetStart out of bounds")}if(start<0||start>=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart<end-start){end=target.length-targetStart+start}var len=end-start;var i;if(this===target&&start<targetStart&&targetStart<end){for(i=len-1;i>=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){ 2for(i=0;i<len;++i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,start+len),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(val.length===1){var code=val.charCodeAt(0);if(code<256){val=code}}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}}else if(typeof val==="number"){val=val&255}if(start<0||this.length<start||this.length<end){throw new RangeError("Out of range index")}if(end<=start){return this}start=start>>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i<end;++i){this[i]=val}}else{var bytes=Buffer.isBuffer(val)?val:utf8ToBytes(new Buffer(val,encoding).toString());var len=bytes.length;for(i=0;i<end-start;++i){this[i+start]=bytes[i%len]}}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(string,units){units=units||Infinity;var codePoint;var length=string.length;var leadSurrogate=null;var bytes=[];for(var i=0;i<length;++i){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;++i){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;++i){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length;++i){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":1,ieee754:3,isarray:4}],3:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<<eLen)-1;var eBias=eMax>>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<<eLen)-1;var eBias=eMax>>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],4:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],5:[function(require,module,exports){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run()}}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;runClearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){runTimeout(drainQueue)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.prependListener=noop;process.prependOnceListener=noop;process.listeners=function(name){return[]};process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],6:[function(require,module,exports){(function(process){(function(definition){"use strict";if(typeof bootstrap==="function"){bootstrap("promise",definition)}else if(typeof exports==="object"&&typeof module==="object"){module.exports=definition()}else if(typeof define==="function"&&define.amd){define(definition)}else if(typeof ses!=="undefined"){if(!ses.ok()){return}else{ses.makeQ=definition}}else if(typeof window!=="undefined"||typeof self!=="undefined"){var global=typeof window!=="undefined"?window:self;var previousQ=global.Q;global.Q=definition();global.Q.noConflict=function(){global.Q=previousQ;return this}}else{throw new Error("This environment was not anticipated by Q. Please file a bug.")}})(function(){"use strict";var hasStacks=false;try{throw new Error}catch(e){hasStacks=!!e.stack}var qStartingLine=captureLine();var qFileName;var noop=function(){};var nextTick=function(){var head={task:void 0,next:null};var tail=head;var flushing=false;var requestTick=void 0;var isNodeJS=false;var laterQueue=[];function flush(){var task,domain;while(head.next){head=head.next;task=head.task;head.task=void 0;domain=head.domain;if(domain){head.domain=void 0;domain.enter()}runSingle(task,domain)}while(laterQueue.length){task=laterQueue.pop();runSingle(task)}flushing=false}function runSingle(task,domain){try{task()}catch(e){if(isNodeJS){if(domain){domain.exit()}setTimeout(flush,0);if(domain){domain.enter()}throw e}else{setTimeout(function(){throw e},0)}}if(domain){domain.exit()}}nextTick=function(task){tail=tail.next={task:task,domain:isNodeJS&&process.domain,next:null};if(!flushing){flushing=true;requestTick()}};if(typeof process==="object"&&process.toString()==="[object process]"&&process.nextTick){isNodeJS=true;requestTick=function(){process.nextTick(flush)}}else if(typeof setImmediate==="function"){if(typeof window!=="undefined"){requestTick=setImmediate.bind(window,flush)}else{requestTick=function(){setImmediate(flush)}}}else if(typeof MessageChannel!=="undefined"){var channel=new MessageChannel;channel.port1.onmessage=function(){requestTick=requestPortTick;channel.port1.onmessage=flush;flush()};var requestPortTick=function(){channel.port2.postMessage(0)};requestTick=function(){setTimeout(flush,0);requestPortTick()}}else{requestTick=function(){setTimeout(flush,0)}}nextTick.runAfter=function(task){laterQueue.push(task);if(!flushing){flushing=true;requestTick()}};return nextTick}();var call=Function.call;function uncurryThis(f){return function(){return call.apply(f,arguments)}}var array_slice=uncurryThis(Array.prototype.slice);var array_reduce=uncurryThis(Array.prototype.reduce||function(callback,basis){var index=0,length=this.length;if(arguments.length===1){do{if(index in this){basis=this[index++];break}if(++index>=length){throw new TypeError}}while(1)}for(;index<length;index++){if(index in this){basis=callback(basis,this[index],index)}}return basis});var array_indexOf=uncurryThis(Array.prototype.indexOf||function(value){for(var i=0;i<this.length;i++){if(this[i]===value){return i}}return-1});var array_map=uncurryThis(Array.prototype.map||function(callback,thisp){var self=this;var collect=[];array_reduce(self,function(undefined,value,index){collect.push(callback.call(thisp,value,index,self))},void 0);return collect});var object_create=Object.create||function(prototype){function Type(){}Type.prototype=prototype;return new Type};var object_hasOwnProperty=uncurryThis(Object.prototype.hasOwnProperty);var object_keys=Object.keys||function(object){var keys=[];for(var key in object){if(object_hasOwnProperty(object,key)){keys.push(key)}}return keys};var object_toString=uncurryThis(Object.prototype.toString);function isObject(value){return value===Object(value)}function isStopIteration(exception){return object_toString(exception)==="[object StopIteration]"||exception instanceof QReturnValue}var QReturnValue;if(typeof ReturnValue!=="undefined"){QReturnValue=ReturnValue}else{QReturnValue=function(value){this.value=value}}var STACK_JUMP_SEPARATOR="From previous event:";function makeStackTraceLong(error,promise){if(hasStacks&&promise.stack&&typeof error==="object"&&error!==null&&error.stack&&error.stack.indexOf(STACK_JUMP_SEPARATOR)===-1){var stacks=[];for(var p=promise;!!p;p=p.source){if(p.stack){stacks.unshift(p.stack)}}stacks.unshift(error.stack);var concatedStacks=stacks.join("\n"+STACK_JUMP_SEPARATOR+"\n");error.stack=filterStackString(concatedStacks)}}function filterStackString(stackString){var lines=stackString.split("\n");var desiredLines=[];for(var i=0;i<lines.length;++i){var line=lines[i];if(!isInternalFrame(line)&&!isNodeFrame(line)&&line){desiredLines.push(line)}}return desiredLines.join("\n")}function isNodeFrame(stackLine){return stackLine.indexOf("(module.js:")!==-1||stackLine.indexOf("(node.js:")!==-1}function getFileNameAndLineNumber(stackLine){var attempt1=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);if(attempt1){return[attempt1[1],Number(attempt1[2])]}var attempt2=/at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);if(attempt2){return[attempt2[1],Number(attempt2[2])]}var attempt3=/.*@(.+):(\d+)$/.exec(stackLine);if(attempt3){return[attempt3[1],Number(attempt3[2])]}}function isInternalFrame(stackLine){var fileNameAndLineNumber=getFileNameAndLineNumber(stackLine);if(!fileNameAndLineNumber){return false}var fileName=fileNameAndLineNumber[0];var lineNumber=fileNameAndLineNumber[1];return fileName===qFileName&&lineNumber>=qStartingLine&&lineNumber<=qEndingLine}function captureLine(){if(!hasStacks){return}try{throw new Error}catch(e){var lines=e.stack.split("\n");var firstLine=lines[0].indexOf("@")>0?lines[1]:lines[2];var fileNameAndLineNumber=getFileNameAndLineNumber(firstLine);if(!fileNameAndLineNumber){return}qFileName=fileNameAndLineNumber[0];return fileNameAndLineNumber[1]}}function deprecate(callback,name,alternative){return function(){if(typeof console!=="undefined"&&typeof console.warn==="function"){console.warn(name+" is deprecated, use "+alternative+" instead.",new Error("").stack)}return callback.apply(callback,arguments)}}function Q(value){if(value instanceof Promise){return value}
2if(isPromiseAlike(value)){return coerce(value)}else{return fulfill(value)}}Q.resolve=Q;Q.nextTick=nextTick;Q.longStackSupport=false;if(typeof process==="object"&&process&&process.env&&process.env.Q_DEBUG){Q.longStackSupport=true}Q.defer=defer;function defer(){var messages=[],progressListeners=[],resolvedPromise;var deferred=object_create(defer.prototype);var promise=object_create(Promise.prototype);promise.promiseDispatch=function(resolve,op,operands){var args=array_slice(arguments);if(messages){messages.push(args);if(op==="when"&&operands[1]){progressListeners.push(operands[1])}}else{Q.nextTick(function(){resolvedPromise.promiseDispatch.apply(resolvedPromise,args)})}};promise.valueOf=function(){if(messages){return promise}var nearerValue=nearer(resolvedPromise);if(isPromise(nearerValue)){resolvedPromise=nearerValue}return nearerValue};promise.inspect=function(){if(!resolvedPromise){return{state:"pending"}}return resolvedPromise.inspect()};if(Q.longStackSupport&&hasStacks){try{throw new Error}catch(e){promise.stack=e.stack.substring(e.stack.indexOf("\n")+1)}}function become(newPromise){resolvedPromise=newPromise;promise.source=newPromise;array_reduce(messages,function(undefined,message){Q.nextTick(function(){newPromise.promiseDispatch.apply(newPromise,message)})},void 0);messages=void 0;progressListeners=void 0}deferred.promise=promise;deferred.resolve=function(value){if(resolvedPromise){return}become(Q(value))};deferred.fulfill=function(value){if(resolvedPromise){return}become(fulfill(value))};deferred.reject=function(reason){if(resolvedPromise){return}become(reject(reason))};deferred.notify=function(progress){if(resolvedPromise){return}array_reduce(progressListeners,function(undefined,progressListener){Q.nextTick(function(){progressListener(progress)})},void 0)};return deferred}defer.prototype.makeNodeResolver=function(){var self=this;return function(error,value){if(error){self.reject(error)}else if(arguments.length>2){self.resolve(array_slice(arguments,1))}else{self.resolve(value)}}};Q.Promise=promise;Q.promise=promise;function promise(resolver){if(typeof resolver!=="function"){throw new TypeError("resolver must be a function.")}var deferred=defer();try{resolver(deferred.resolve,deferred.reject,deferred.notify)}catch(reason){deferred.reject(reason)}return deferred.promise}promise.race=race;promise.all=all;promise.reject=reject;promise.resolve=Q;Q.passByCopy=function(object){return object};Promise.prototype.passByCopy=function(){return this};Q.join=function(x,y){return Q(x).join(y)};Promise.prototype.join=function(that){return Q([this,that]).spread(function(x,y){if(x===y){return x}else{throw new Error("Can't join: not the same: "+x+" "+y)}})};Q.race=race;function race(answerPs){return promise(function(resolve,reject){for(var i=0,len=answerPs.length;i<len;i++){Q(answerPs[i]).then(resolve,reject)}})}Promise.prototype.race=function(){return this.then(Q.race)};Q.makePromise=Promise;function Promise(descriptor,fallback,inspect){if(fallback===void 0){fallback=function(op){return reject(new Error("Promise does not support operation: "+op))}}if(inspect===void 0){inspect=function(){return{state:"unknown"}}}var promise=object_create(Promise.prototype);promise.promiseDispatch=function(resolve,op,args){var result;try{if(descriptor[op]){result=descriptor[op].apply(promise,args)}else{result=fallback.call(promise,op,args)}}catch(exception){result=reject(exception)}if(resolve){resolve(result)}};promise.inspect=inspect;if(inspect){var inspected=inspect();if(inspected.state==="rejected"){promise.exception=inspected.reason}promise.valueOf=function(){var inspected=inspect();if(inspected.state==="pending"||inspected.state==="rejected"){return promise}return inspected.value}}return promise}Promise.prototype.toString=function(){return"[object Promise]"};Promise.prototype.then=function(fulfilled,rejected,progressed){var self=this;var deferred=defer();var done=false;function _fulfilled(value){try{return typeof fulfilled==="function"?fulfilled(value):value}catch(exception){return reject(exception)}}function _rejected(exception){if(typeof rejected==="function"){makeStackTraceLong(exception,self);try{return rejected(exception)}catch(newException){return reject(newException)}}return reject(exception)}function _progressed(value){return typeof progressed==="function"?progressed(value):value}
2Q.nextTick(function(){self.promiseDispatch(function(value){if(done){return}done=true;deferred.resolve(_fulfilled(value))},"when",[function(exception){if(done){return}done=true;deferred.resolve(_rejected(exception))}])});self.promiseDispatch(void 0,"when",[void 0,function(value){var newValue;var threw=false;try{newValue=_progressed(value)}catch(e){threw=true;if(Q.onerror){Q.onerror(e)}else{throw e}}if(!threw){deferred.notify(newValue)}}]);return deferred.promise};Q.tap=function(promise,callback){return Q(promise).tap(callback)};Promise.prototype.tap=function(callback){callback=Q(callback);return this.then(function(value){return callback.fcall(value).thenResolve(value)})};Q.when=when;function when(value,fulfilled,rejected,progressed){return Q(value).then(fulfilled,rejected,progressed)}Promise.prototype.thenResolve=function(value){return this.then(function(){return value})};Q.thenResolve=function(promise,value){return Q(promise).thenResolve(value)};Promise.prototype.thenReject=function(reason){return this.then(function(){throw reason})};Q.thenReject=function(promise,reason){return Q(promise).thenReject(reason)};Q.nearer=nearer;function nearer(value){if(isPromise(value)){var inspected=value.inspect();if(inspected.state==="fulfilled"){return inspected.value}}return value}Q.isPromise=isPromise;function isPromise(object){return object instanceof Promise}Q.isPromiseAlike=isPromiseAlike;function isPromiseAlike(object){return isObject(object)&&typeof object.then==="function"}Q.isPending=isPending;function isPending(object){return isPromise(object)&&object.inspect().state==="pending"}Promise.prototype.isPending=function(){return this.inspect().state==="pending"};Q.isFulfilled=isFulfilled;function isFulfilled(object){return!isPromise(object)||object.inspect().state==="fulfilled"}Promise.prototype.isFulfilled=function(){return this.inspect().state==="fulfilled"};Q.isRejected=isRejected;function isRejected(object){return isPromise(object)&&object.inspect().state==="rejected"}Promise.prototype.isRejected=function(){return this.inspect().state==="rejected"};var unhandledReasons=[];var unhandledRejections=[];var reportedUnhandledRejections=[];var trackUnhandledRejections=true;function resetUnhandledRejections(){unhandledReasons.length=0;unhandledRejections.length=0;if(!trackUnhandledRejections){trackUnhandledRejections=true}}function trackRejection(promise,reason){if(!trackUnhandledRejections){return}if(typeof process==="object"&&typeof process.emit==="function"){Q.nextTick.runAfter(function(){if(array_indexOf(unhandledRejections,promise)!==-1){process.emit("unhandledRejection",reason,promise);reportedUnhandledRejections.push(promise)}})}unhandledRejections.push(promise);if(reason&&typeof reason.stack!=="undefined"){unhandledReasons.push(reason.stack)}else{unhandledReasons.push("(no stack) "+reason)}}function untrackRejection(promise){if(!trackUnhandledRejections){return}var at=array_indexOf(unhandledRejections,promise);if(at!==-1){if(typeof process==="object"&&typeof process.emit==="function"){Q.nextTick.runAfter(function(){var atReport=array_indexOf(reportedUnhandledRejections,promise);if(atReport!==-1){process.emit("rejectionHandled",unhandledReasons[at],promise);reportedUnhandledRejections.splice(atReport,1)}})}unhandledRejections.splice(at,1);unhandledReasons.splice(at,1)}}Q.resetUnhandledRejections=resetUnhandledRejections;Q.getUnhandledReasons=function(){return unhandledReasons.slice()};Q.stopUnhandledRejectionTracking=function(){resetUnhandledRejections();trackUnhandledRejections=false};resetUnhandledRejections();Q.reject=reject;function reject(reason){var rejection=Promise({when:function(rejected){if(rejected){untrackRejection(this)}return rejected?rejected(reason):this}},function fallback(){return this},function inspect(){return{state:"rejected",reason:reason}});trackRejection(rejection,reason);return rejection}Q.fulfill=fulfill;function fulfill(value){return Promise({when:function(){return value},get:function(name){return value[name]},set:function(name,rhs){value[name]=rhs},delete:function(name){delete value[name]},post:function(name,args){if(name===null||name===void 0){return value.a
2pply(void 0,args)}else{return value[name].apply(value,args)}},apply:function(thisp,args){return value.apply(thisp,args)},keys:function(){return object_keys(value)}},void 0,function inspect(){return{state:"fulfilled",value:value}})}function coerce(promise){var deferred=defer();Q.nextTick(function(){try{promise.then(deferred.resolve,deferred.reject,deferred.notify)}catch(exception){deferred.reject(exception)}});return deferred.promise}Q.master=master;function master(object){return Promise({isDef:function(){}},function fallback(op,args){return dispatch(object,op,args)},function(){return Q(object).inspect()})}Q.spread=spread;function spread(value,fulfilled,rejected){return Q(value).spread(fulfilled,rejected)}Promise.prototype.spread=function(fulfilled,rejected){return this.all().then(function(array){return fulfilled.apply(void 0,array)},rejected)};Q.async=async;function async(makeGenerator){return function(){function continuer(verb,arg){var result;if(typeof StopIteration==="undefined"){try{result=generator[verb](arg)}catch(exception){return reject(exception)}if(result.done){return Q(result.value)}else{return when(result.value,callback,errback)}}else{try{result=generator[verb](arg)}catch(exception){if(isStopIteration(exception)){return Q(exception.value)}else{return reject(exception)}}return when(result,callback,errback)}}var generator=makeGenerator.apply(this,arguments);var callback=continuer.bind(continuer,"next");var errback=continuer.bind(continuer,"throw");return callback()}}Q.spawn=spawn;function spawn(makeGenerator){Q.done(Q.async(makeGenerator)())}Q["return"]=_return;function _return(value){throw new QReturnValue(value)}Q.promised=promised;function promised(callback){return function(){return spread([this,all(arguments)],function(self,args){return callback.apply(self,args)})}}Q.dispatch=dispatch;function dispatch(object,op,args){return Q(object).dispatch(op,args)}Promise.prototype.dispatch=function(op,args){var self=this;var deferred=defer();Q.nextTick(function(){self.promiseDispatch(deferred.resolve,op,args)});return deferred.promise};Q.get=function(object,key){return Q(object).dispatch("get",[key])};Promise.prototype.get=function(key){return this.dispatch("get",[key])};Q.set=function(object,key,value){return Q(object).dispatch("set",[key,value])};Promise.prototype.set=function(key,value){return this.dispatch("set",[key,value])};Q.del=Q["delete"]=function(object,key){return Q(object).dispatch("delete",[key])};Promise.prototype.del=Promise.prototype["delete"]=function(key){return this.dispatch("delete",[key])};Q.mapply=Q.post=function(object,name,args){return Q(object).dispatch("post",[name,args])};Promise.prototype.mapply=Promise.prototype.post=function(name,args){return this.dispatch("post",[name,args])};Q.send=Q.mcall=Q.invoke=function(object,name){return Q(object).dispatch("post",[name,array_slice(arguments,2)])};Promise.prototype.send=Promise.prototype.mcall=Promise.prototype.invoke=function(name){return this.dispatch("post",[name,array_slice(arguments,1)])};Q.fapply=function(object,args){return Q(object).dispatch("apply",[void 0,args])};Promise.prototype.fapply=function(args){return this.dispatch("apply",[void 0,args])};Q["try"]=Q.fcall=function(object){return Q(object).dispatch("apply",[void 0,array_slice(arguments,1)])};Promise.prototype.fcall=function(){return this.dispatch("apply",[void 0,array_slice(arguments)])};Q.fbind=function(object){var promise=Q(object);var args=array_slice(arguments,1);return function fbound(){return promise.dispatch("apply",[this,args.concat(array_slice(arguments))])}};Promise.prototype.fbind=function(){var promise=this;var args=array_slice(arguments);return function fbound(){return promise.dispatch("apply",[this,args.concat(array_slice(arguments))])}};Q.keys=function(object){return Q(object).dispatch("keys",[])};Promise.prototype.keys=function(){return this.dispatch("keys",[])};Q.all=all;function all(promises){return when(promises,function(promises){var pendingCount=0;var deferred=defer();array_reduce(promises,function(undefined,promise,index){var snapshot;if(isPromise(promise)&&(snapshot=promise.inspect()).state==="fulfilled"){promises[index]=snapshot.value}else{++pendingCount;when(promise,function(value){promises[index]=value;if(--pendingCount===0){deferred.resolve(promises)}},deferred.reject,function(progress){deferred.notify({index:index,value:progress})})}},void 0);if(pendingCount===0){deferred.resolve(promises)}return deferred.promise})}
2Promise.prototype.all=function(){return all(this)};Q.any=any;function any(promises){if(promises.length===0){return Q.resolve()}var deferred=Q.defer();var pendingCount=0;array_reduce(promises,function(prev,current,index){var promise=promises[index];pendingCount++;when(promise,onFulfilled,onRejected,onProgress);function onFulfilled(result){deferred.resolve(result)}function onRejected(){pendingCount--;if(pendingCount===0){deferred.reject(new Error("Can't get fulfillment value from any promise, all "+"promises were rejected."))}}function onProgress(progress){deferred.notify({index:index,value:progress})}},undefined);return deferred.promise}Promise.prototype.any=function(){return any(this)};Q.allResolved=deprecate(allResolved,"allResolved","allSettled");function allResolved(promises){return when(promises,function(promises){promises=array_map(promises,Q);return when(all(array_map(promises,function(promise){return when(promise,noop,noop)})),function(){return promises})})}Promise.prototype.allResolved=function(){return allResolved(this)};Q.allSettled=allSettled;function allSettled(promises){return Q(promises).allSettled()}Promise.prototype.allSettled=function(){return this.then(function(promises){return all(array_map(promises,function(promise){promise=Q(promise);function regardless(){return promise.inspect()}return promise.then(regardless,regardless)}))})};Q.fail=Q["catch"]=function(object,rejected){return Q(object).then(void 0,rejected)};Promise.prototype.fail=Promise.prototype["catch"]=function(rejected){return this.then(void 0,rejected)};Q.progress=progress;function progress(object,progressed){return Q(object).then(void 0,void 0,progressed)}Promise.prototype.progress=function(progressed){return this.then(void 0,void 0,progressed)};Q.fin=Q["finally"]=function(object,callback){return Q(object)["finally"](callback)};Promise.prototype.fin=Promise.prototype["finally"]=function(callback){callback=Q(callback);return this.then(function(value){return callback.fcall().then(function(){return value})},function(reason){return callback.fcall().then(function(){throw reason})})};Q.done=function(object,fulfilled,rejected,progress){return Q(object).done(fulfilled,rejected,progress)};Promise.prototype.done=function(fulfilled,rejected,progress){var onUnhandledError=function(error){Q.nextTick(function(){makeStackTraceLong(error,promise);if(Q.onerror){Q.onerror(error)}else{throw error}})};var promise=fulfilled||rejected||progress?this.then(fulfilled,rejected,progress):this;if(typeof process==="object"&&process&&process.domain){onUnhandledError=process.domain.bind(onUnhandledError)}promise.then(void 0,onUnhandledError)};Q.timeout=function(object,ms,error){return Q(object).timeout(ms,error)};Promise.prototype.timeout=function(ms,error){var deferred=defer();var timeoutId=setTimeout(function(){if(!error||"string"===typeof error){error=new Error(error||"Timed out after "+ms+" ms");error.code="ETIMEDOUT"}deferred.reject(error)},ms);this.then(function(value){clearTimeout(timeoutId);deferred.resolve(value)},function(exception){clearTimeout(timeoutId);deferred.reject(exception)},deferred.notify);return deferred.promise};Q.delay=function(object,timeout){if(timeout===void 0){timeout=object;object=void 0}return Q(object).delay(timeout)};Promise.prototype.delay=function(timeout){return this.then(function(value){var deferred=defer();setTimeout(function(){deferred.resolve(value)},timeout);return deferred.promise})};Q.nfapply=function(callback,args){return Q(callback).nfapply(args)};Promise.prototype.nfapply=function(args){var deferred=defer();var nodeArgs=array_slice(args);nodeArgs.push(deferred.makeNodeResolver());this.fapply(nodeArgs).fail(deferred.reject);return deferred.promise};Q.nfcall=function(callback){var args=array_slice(arguments,1);return Q(callback).nfapply(args)};Promise.prototype.nfcall=function(){var nodeArgs=array_slice(arguments);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());this.fapply(nodeArgs).fail(deferred.reject);return deferred.promise};Q.nfbind=Q.denodeify=function(callback){var baseArgs=array_slice(arguments,1);return function(){var nodeArgs=baseArgs.concat(array_slice(arguments));var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());Q(callback).fapply(nodeArgs).fail(deferred.reject);return deferred.promise}};Promise.prototype.nfbind=Promise.prototype.denodeify=function(){var args=array_slice(arguments);args.unshift(this);return Q.denodeify.apply(void 0,args)};Q.nbind=function(callback,thisp){var baseArgs=array_slice(arguments,2);return function(){var nodeArgs=baseArgs.concat(array_slice(arguments));var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());function bound(){return callback.apply(thisp,arguments)}Q(bound).fapply(nodeArgs).fail(deferred.reject);return deferred.promise}};Promise.prototype.nbind=function(){var args=array_slice(arguments,0);args.unshift(this);return Q.nbind.apply(void 0,args)};Q.nmapply=Q.npost=function(object,name,args){return Q(object).npost(name,args)};Promise.prototype.nmapply=Promise.prototype.npost=function(name,args){var nodeArgs=array_slice(args||[]);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver()); 3this.dispatch("post",[name,nodeArgs]).fail(deferred.reject);return deferred.promise};Q.nsend=Q.nmcall=Q.ninvoke=function(object,name){var nodeArgs=array_slice(arguments,2);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());Q(object).dispatch("post",[name,nodeArgs]).fail(deferred.reject);return deferred.promise};Promise.prototype.nsend=Promise.prototype.nmcall=Promise.prototype.ninvoke=function(name){var nodeArgs=array_slice(arguments,1
3);var deferred=defer();nodeArgs.push(deferred.makeNodeResolver());this.dispatch("post",[name,nodeArgs]).fail(deferred.reject);return deferred.promise};Q.nodeify=nodeify;function nodeify(object,nodeback){return Q(object).nodeify(nodeback)}Promise.prototype.nodeify=function(nodeback){if(nodeback){this.then(function(value){Q.nextTick(function(){nodeback(null,value)})},function(error){Q.nextTick(function(){nodeback(error)})})}else{return this}};Q.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var qEndingLine=captureLine();return Q})}).call(this,require("_process"))},{_process:5}],7:[function(require,module,exports){"use strict";var u2f=u2f||{};if(typeof module!="undefined"){module.exports=u2f}var js_api_version;u2f.EXTENSION_ID="kmendfapggjehodndflmmgagdbamhnfd";u2f.MessageTypes={U2F_REGISTER_REQUEST:"u2f_register_request",U2F_REGISTER_RESPONSE:"u2f_register_response",U2F_SIGN_REQUEST:"u2f_sign_request",U2F_SIGN_RESPONSE:"u2f_sign_response",U2F_GET_API_VERSION_REQUEST:"u2f_get_api_version_request",U2F_GET_API_VERSION_RESPONSE:"u2f_get_api_version_response"};u2f.ErrorCodes={OK:0,OTHER_ERROR:1,BAD_REQUEST:2,CONFIGURATION_UNSUPPORTED:3,DEVICE_INELIGIBLE:4,TIMEOUT:5};u2f.U2fRequest;u2f.U2fResponse;u2f.Error;u2f.Transport;u2f.Transports;u2f.SignRequest;u2f.SignResponse;u2f.RegisterRequest;u2f.RegisterResponse;u2f.RegisteredKey;u2f.GetJsApiVersionResponse;u2f.getMessagePort=function(callback){if(typeof chrome!="undefined"&&chrome.runtime){var msg={type:u2f.MessageTypes.U2F_SIGN_REQUEST,signRequests:[]};chrome.runtime.sendMessage(u2f.EXTENSION_ID,msg,function(){if(!chrome.runtime.lastError){u2f.getChromeRuntimePort_(callback)}else{u2f.getIframePort_(callback)}})}else if(u2f.isAndroidChrome_()){u2f.getAuthenticatorPort_(callback)}else if(u2f.isIosChrome_()){u2f.getIosPort_(callback)}else{u2f.getIframePort_(callback)}};u2f.isAndroidChrome_=function(){var userAgent=navigator.userAgent;return userAgent.indexOf("Chrome")!=-1&&userAgent.indexOf("Android")!=-1};u2f.isIosChrome_=function(){return["iPhone","iPad","iPod"].indexOf(navigator.platform)>-1};u2f.getChromeRuntimePort_=function(callback){var port=chrome.runtime.connect(u2f.EXTENSION_ID,{includeTlsChannelId:true});setTimeout(function(){callback(new u2f.WrappedChromeRuntimePort_(port))},0)};u2f.getAuthenticatorPort_=function(callback){setTimeout(function(){callback(new u2f.WrappedAuthenticatorPort_)},0)};u2f.getIosPort_=function(callback){setTimeout(function(){callback(new u2f.WrappedIosPort_)},0)};u2f.WrappedChromeRuntimePort_=function(port){this.port_=port};u2f.formatSignRequest_=function(appId,challenge,registeredKeys,timeoutSeconds,reqId){if(js_api_version===undefined||js_api_version<1.1){var signRequests=[];for(var i=0;i<registeredKeys.length;i++){signRequests[i]={version:registeredKeys[i].version,challenge:challenge,keyHandle:registeredKeys[i].keyHandle,appId:appId}}return{type:u2f.MessageTypes.U2F_SIGN_REQUEST,signRequests:signRequests,timeoutSeconds:timeoutSeconds,requestId:reqId}}return{type:u2f.MessageTypes.U2F_SIGN_REQUEST,appId:appId,challenge:challenge,registeredKeys:registeredKeys,timeoutSeconds:timeoutSeconds,requestId:reqId}};u2f.formatRegisterRequest_=function(appId,registeredKeys,registerRequests,timeoutSeconds,reqId){if(js_api_version===undefined||js_api_version<1.1){for(var i=0;i<registerRequests.length;i++){registerRequests[i].appId=appId}var signRequests=[];for(var i=0;i<registeredKeys.length;i++){signRequests[i]={version:registeredKeys[i].version,challenge:registerRequests[0],keyHandle:registeredKeys[i].keyHandle,appId:appId}}return{type:u2f.MessageTypes.U2F_REGISTER_REQUEST,signRequests:signRequests,registerRequests:registerRequests,timeoutSeconds:timeoutSeconds,requestId:reqId}}return{type:u2f.MessageTypes.U2F_REGISTER_REQUEST,appId:appId,registerRequests:registerRequests,registeredKeys:registeredKeys,timeoutSeconds:timeoutSeconds,requestId:reqId}};u2f.WrappedChromeRuntimePort_.prototype.postMessage=function(message){this.port_.postMessage(message)};u2f.WrappedChromeRuntimePort_.prototype.addEventListener=function(eventName,handler){var name=eventName.toLowerCase();if(name=="message"||name=="onmessage"){this.port_.onMessage.addListener(function(message){handler({data:message})})}else{console.error("WrappedChromeRuntimePort only supports onMessage")}};u2f.WrappedAuthenticatorPort_=function(){this.requestId_=-1;this.requestObject_=null};u2f.WrappedAuthenticatorPort_.prototype.postMessage=function(message){var intentUrl=u2f.WrappedAuthenticatorPort_.INTENT_URL_BASE_+";S.request="+encodeURIComponent(JSON.stringify(message))+";end";document.location=intentUrl};u2f.WrappedAuthenticatorPort_.prototype.getPortType=function(){return"WrappedAuthenticatorPort_"};u2f.WrappedAuthenticatorPort_.prototype.addEventListener=function(eventName,handler){var name=eventName.toLowerCase();if(name=="message"){var self=this;window.addEventListener("message",self.onRequestUpdate_.bind(self,handler),false)}else{console.error("WrappedAuthenticatorPort only supports message")}};u2f.WrappedAuthenticatorPort_.prototype.onRequestUpdate_=function(callback,message){var messageObject=JSON.parse(message.data);var intentUrl=messageObject["intentURL"];var errorCode=messageObject["errorCode"];var responseObject=null;if(messageObject.hasOwnProperty("data")){responseObject=JSON.parse(messageObject["data"])}callback({data:responseObject})};u2f.WrappedAuthenticatorPort_.INTENT_URL_BASE_="intent:#Intent;action=com.ledger.android.u2f.bridge.AUTHENTICATE";u2f.WrappedIosPort_=function(){};u2f.WrappedIosPort_.prototype.postMessage=function(message){var str=JSON.stringify(message);var url="u2f://auth?"+encodeURI(str);location.replace(url)};u2f.WrappedIosPort_.prototype.getPortType=function(){return"WrappedIosPort_"};u2f.WrappedIosPort_.prototype.addEventListener=function(eventName,handler){var name=eventName.toLowerCase();if(name!=="message"){console.error("WrappedIosPort only supports message")}};u2f.getIframePort_=function(callback){var iframeOrigin="chrome-extension://"+u2f.EXTENSION_ID;var iframe=document.createElement("iframe");
3iframe.src=iframeOrigin+"/u2f-comms.html";iframe.setAttribute("style","display:none");document.body.appendChild(iframe);var channel=new MessageChannel;var ready=function(message){if(message.data=="ready"){channel.port1.removeEventListener("message",ready);callback(channel.port1)}else{console.error('First event on iframe port was not "ready"')}};channel.port1.addEventListener("message",ready);channel.port1.start();iframe.addEventListener("load",function(){iframe.contentWindow.postMessage("init",iframeOrigin,[channel.port2])})};u2f.EXTENSION_TIMEOUT_SEC=30;u2f.port_=null;u2f.waitingForPort_=[];u2f.reqCounter_=0;u2f.callbackMap_={};u2f.getPortSingleton_=function(callback){if(u2f.port_){callback(u2f.port_)}else{if(u2f.waitingForPort_.length==0){u2f.getMessagePort(function(port){u2f.port_=port;u2f.port_.addEventListener("message",u2f.responseHandler_);while(u2f.waitingForPort_.length)u2f.waitingForPort_.shift()(u2f.port_)})}u2f.waitingForPort_.push(callback)}};u2f.responseHandler_=function(message){var response=message.data;var reqId=response["requestId"];if(!reqId||!u2f.callbackMap_[reqId]){console.error("Unknown or missing requestId in response.");return}var cb=u2f.callbackMap_[reqId];delete u2f.callbackMap_[reqId];cb(response["responseData"])};u2f.sign=function(appId,challenge,registeredKeys,callback,opt_timeoutSeconds){if(js_api_version===undefined){u2f.getApiVersion(function(response){js_api_version=response["js_api_version"]===undefined?0:response["js_api_version"];u2f.sendSignRequest(appId,challenge,registeredKeys,callback,opt_timeoutSeconds)})}else{u2f.sendSignRequest(appId,challenge,registeredKeys,callback,opt_timeoutSeconds)}};u2f.sendSignRequest=function(appId,challenge,registeredKeys,callback,opt_timeoutSeconds){u2f.getPortSingleton_(function(port){var reqId=++u2f.reqCounter_;u2f.callbackMap_[reqId]=callback;var timeoutSeconds=typeof opt_timeoutSeconds!=="undefined"?opt_timeoutSeconds:u2f.EXTENSION_TIMEOUT_SEC;var req=u2f.formatSignRequest_(appId,challenge,registeredKeys,timeoutSeconds,reqId);port.postMessage(req)})};u2f.register=function(appId,registerRequests,registeredKeys,callback,opt_timeoutSeconds){if(js_api_version===undefined){u2f.getApiVersion(function(response){js_api_version=response["js_api_version"]===undefined?0:response["js_api_version"];u2f.sendRegisterRequest(appId,registerRequests,registeredKeys,callback,opt_timeoutSeconds)})}else{u2f.sendRegisterRequest(appId,registerRequests,registeredKeys,callback,opt_timeoutSeconds)}};u2f.sendRegisterRequest=function(appId,registerRequests,registeredKeys,callback,opt_timeoutSeconds){u2f.getPortSingleton_(function(port){var reqId=++u2f.reqCounter_;u2f.callbackMap_[reqId]=callback;var timeoutSeconds=typeof opt_timeoutSeconds!=="undefined"?opt_timeoutSeconds:u2f.EXTENSION_TIMEOUT_SEC;var req=u2f.formatRegisterRequest_(appId,registeredKeys,registerRequests,timeoutSeconds,reqId);port.postMessage(req)})};u2f.getApiVersion=function(callback,opt_timeoutSeconds){u2f.getPortSingleton_(function(port){if(port.getPortType){var apiVersion;switch(port.getPortType()){case"WrappedIosPort_":case"WrappedAuthenticatorPort_":apiVersion=1.1;break;default:apiVersion=0;break}callback({js_api_version:apiVersion});return}var reqId=++u2f.reqCounter_;u2f.callbackMap_[reqId]=callback;var req={type:u2f.MessageTypes.U2F_GET_API_VERSION_REQUEST,timeoutSeconds:typeof opt_timeoutSeconds!=="undefined"?opt_timeoutSeconds:u2f.EXTENSION_TIMEOUT_SEC,requestId:reqId};port.postMessage(req)})}},{}],8:[function(require,module,exports){var ledger=module.exports;ledger.comm_u2f=require("./ledger-comm-u2f");ledger.btc=require("./ledger-btc");ledger.eth=require("./ledger-eth");module.exports=ledger},{"./ledger-btc":9,"./ledger-comm-u2f":10,"./ledger-eth":11}],9:[function(require,module,exports){(function(Buffer){"use strict";var Q=require("q");var utils=require("./utils");var LedgerBtc=function(comm){this.comm=comm;this.comm.setScrambleKey("BTC")};LedgerBtc.prototype.getWalletPublicKey_async=function(path){var splitPath=utils.splitPath(path);var buffer=Buffer.alloc(5+1+splitPath.length*4);buffer[0]=224;buffer[1]=64;buffer[2]=0;buffer[3]=0;buffer[4]=1+splitPath.length*4;buffer[5]=splitPath.length;splitPath.forEach(function(element,index){buffer.writeUInt32BE(element,6+4*index)});var self=this;return this.comm.exchange(buffer.toString("hex"),[36864]).then(function(response){var result={};response=Buffer.from(response,"hex");var publicKeyLength=response[0];var addressLength=response[1+publicKeyLength];result["publicKey"]=response.slice(1,1+publicKeyLength).toString("hex");
3result["bitcoinAddress"]=response.slice(1+publicKeyLength+1,1+publicKeyLength+1+addressLength).toString("ascii");result["chainCode"]=response.slice(1+publicKeyLength+1+addressLength,1+publicKeyLength+1+addressLength+32).toString("hex");return result})};LedgerBtc.prototype.getTrustedInputRaw_async=function(firstRound,indexLookup,transactionData){var data;if(firstRound){var prefix=Buffer.alloc(4);prefix.writeUInt32BE(indexLookup,0);data=Buffer.concat([prefix,transactionData],transactionData.length+4)}else{data=transactionData}var buffer=Buffer.alloc(5);buffer[0]=224;buffer[1]=66;buffer[2]=firstRound?0:128;buffer[3]=0;buffer[4]=data.length;buffer=Buffer.concat([buffer,data],5+data.length);return this.comm.exchange(buffer.toString("hex"),[36864]).then(function(trustedInput){return trustedInput.substring(0,trustedInput.length-4)})};LedgerBtc.prototype.getTrustedInput_async=function(indexLookup,transaction){var currentObject=this;var processScriptBlocks=function(script,sequence){var scriptBlocks=[];var offset=0;while(offset!=script.length){var blockSize=script.length-offset>LedgerBtc.MAX_SCRIPT_BLOCK?LedgerBtc.MAX_SCRIPT_BLOCK:script.length-offset;if(offset+blockSize!=script.length){scriptBlocks.push(script.slice(offset,offset+blockSize))}else{scriptBlocks.push(Buffer.concat([script.slice(offset,offset+blockSize),sequence]))}offset+=blockSize}return utils.eachSeries(scriptBlocks,function(scriptBlock){return currentObject.getTrustedInputRaw_async(false,undefined,scriptBlock)})};var processInputs=function(){return utils.eachSeries(transaction["inputs"],function(input){data=Buffer.concat([input["prevout"],currentObject.createVarint(input["script"].length)]);return currentObject.getTrustedInputRaw_async(false,undefined,data).then(function(result){return processScriptBlocks(input["script"],input["sequence"])})}).then(function(){data=currentObject.createVarint(transaction["outputs"].length);return currentObject.getTrustedInputRaw_async(false,undefined,data)})};var processOutputs=function(){return utils.eachSeries(transaction["outputs"],function(output){data=output["amount"];data=Buffer.concat([data,currentObject.createVarint(output["script"].length),output["script"]]);return currentObject.getTrustedInputRaw_async(false,undefined,data).then(function(result){})}).then(function(){data=transaction["locktime"];return currentObject.getTrustedInputRaw_async(false,undefined,data)})};var data=Buffer.concat([transaction["version"],currentObject.createVarint(transaction["inputs"].length)]);return currentObject.getTrustedInputRaw_async(true,indexLookup,data).then(processInputs).then(processOutputs)};LedgerBtc.prototype.getVarint=function(data,offset){if(data[offset]<253){return[data[offset],1]}if(data[offset]==253){return[(data[offset+2]<<8)+data[offset+1],3]}if(data[offset]==254){return[(data[offset+4]<<24)+(data[offset+3]<<16)+(data[offset+2]<<8)+data[offset+1],5]}};LedgerBtc.prototype.startUntrustedHashTransactionInputRaw_async=function(newTransaction,firstRound,transactionData){var buffer=Buffer.alloc(5);buffer[0]=224;buffer[1]=68;buffer[2]=firstRound?0:128;buffer[3]=newTransaction?0:128;buffer[4]=transactionData.length;buffer=Buffer.concat([buffer,transactionData],5+transactionData.length);return this.comm.exchange(buffer.toString("hex"),[36864])};LedgerBtc.prototype.startUntrustedHashTransactionInput_async=function(newTransaction,transaction,inputs){var currentObject=this;var data=Buffer.concat([transaction["version"],currentObject.createVarint(transaction["inputs"].length)]);return currentObject.startUntrustedHashTransactionInputRaw_async(newTransaction,true,data).then(function(result){var i=0;return utils.eachSeries(transaction["inputs"],function(input){var inputKey;var prefix;if(inputs[i]["trustedInput"]){prefix=Buffer.alloc(2);prefix[0]=1;prefix[1]=inputs[i]["value"].length}else{prefix=Buffer.alloc(1);prefix[0]=0}data=Buffer.concat([prefix,inputs[i]["value"],currentObject.createVarint(input["script"].length)]);return currentObject.startUntrustedHashTransactionInputRaw_async(newTransaction,false,data).then(function(result){var scriptBlocks=[];var offset=0;if(input["script"].length==0){scriptBlocks.push(input["sequence"])}else{while(offset!=input["script"].length){var blockSize=input["script"].length-offset>LedgerBtc.MAX_SCRIPT_BLOCK?LedgerBtc.MAX_SCRIPT_BLOCK:input["script"].length-offset;if(offset+blockSize!=input["script"].length){scriptBlocks.push(input["script"].slice(offset,offset+blockSize))}else{scriptBlocks.push(Buffer.concat([input["script"].slice(offset,offset+blockSize),input["sequence"]]))}offset+=blockSize}}return utils.eachSeries(scriptBlocks,function(scriptBlock){return currentObject.startUntrustedHashTransactionInputRaw_async(newTransaction,false,scriptBlock)}).then(function(){i++})})})})};LedgerBtc.prototype.provideOutputFullChangePath_async=function(path){var splitPath=utils.splitPath(path);var buffer=Buffer.alloc(5+1+splitPath.length*4);buffer[0]=224;buffer[1]=74;buffer[2]=255;buffer[3]=0;buffer[4]=1+splitPath.length*4;buffer[5]=splitPath.length;splitPath.forEach(function(element,index){buffer.writeUInt32BE(element,6+4*index)});var self=this;return this.comm.exchange(buffer.toString("hex"),[36864])};LedgerBtc.prototype.hashOutputFull_async=function(outputScript){var offset=0;var self=this;return utils.asyncWhile(function(){return offset<outputScript.length},function(){var blockSize=offset+LedgerBtc.MAX_SCRIPT_BLOCK>=outputScript.length?outputScript.length-offset:LedgerBtc.MAX_SCRIPT_BLOCK;var p1=offset+blockSize==outputScript.length?128:0;var prefix=Buffer.alloc(5);prefix[0]=224;prefix[1]=74;prefix[2]=p1;prefix[3]=0;prefix[4]=blockSize;var data=Buffer.concat([prefix,outputScript.slice(offset,offset+blockSize)]);return self.comm.exchange(data.toString("hex"),[36864]).then(function(data){offset+=blockSize})})};LedgerBtc.prototype.signTransaction_async=function(path,lockTime,sigHashType){if(typeof lockTime=="undefined"){lockTime=LedgerBtc.DEFAULT_LOCKTIME}if(typeof sigHashType=="undefined"){sigHashType=LedgerBtc.SIGHASH_ALL}var splitPath=utils.splitPath(path);var buffer=Buffer.alloc(5+1+splitPath.length*4+1+4+1);var offset=0;buffer[offset++]=224;buffer[offset++]=72;buffer[offset++]=0;buffer[offset++]=0;buffer[offset++]=1+splitPath.length*4+1+4+1;buffer[offset++]=splitPath.length;splitPath.forEach(function(element){buffer.writeUInt32BE(element,offset);offset+=4});buffer[offset++]=0;buffer.writeUInt32LE(lockTime,offset);offset+=4;buffer[offset++]=sigHashType;var self=this;return self.comm.exchange(buffer.toString("hex"),[36864]).then(function(signature){var result=Buffer.from(signature,"hex");result[0]=48;return result.slice(0,result.length-2)})};
3LedgerBtc.prototype.signMessageNew_async=function(path,messageHex){var splitPath=utils.splitPath(path);var offset=0;var message=new Buffer(messageHex,"hex");var apdus=[];var response=[];var self=this;while(offset!=message.length){var maxChunkSize=offset==0?LedgerBtc.MAX_SCRIPT_BLOCK-1-splitPath.length*4-4:LedgerBtc.MAX_SCRIPT_BLOCK;var chunkSize=offset+maxChunkSize>message.length?message.length-offset:maxChunkSize;var buffer=new Buffer(offset==0?5+1+splitPath.length*4+2+chunkSize:5+chunkSize);buffer[0]=224;buffer[1]=78;buffer[2]=0;buffer[3]=offset==0?1:128;buffer[4]=offset==0?1+splitPath.length*4+2+chunkSize:chunkSize;if(offset==0){buffer[5]=splitPath.length;splitPath.forEach(function(element,index){buffer.writeUInt32BE(element,6+4*index)});buffer.writeUInt16BE(message.length,6+4*splitPath.length);message.copy(buffer,6+4*splitPath.length+2,offset,offset+chunkSize)}else{message.copy(buffer,5,offset,offset+chunkSize)}apdus.push(buffer.toString("hex"));offset+=chunkSize}return utils.foreach(apdus,function(apdu){return self.comm.exchange(apdu,[36864]).then(function(apduResponse){response=apduResponse})}).then(function(){buffer=Buffer.alloc(6);buffer[0]=224;buffer[1]=78;buffer[2]=128;buffer[3]=0;buffer[4]=1;buffer[5]=0;return self.comm.exchange(buffer.toString("hex"),[36864]).then(function(apduResponse){var response=Buffer.from(apduResponse,"hex");var result={};result["v"]=response[0]-48;var r=response.slice(4,4+response[3]);if(r[0]==0){r=r.slice(1)}result["r"]=r.toString("hex");var offset=4+response[3]+2;var s=response.slice(offset,offset+response[offset-1]);if(s[0]==0){s=s.slice(1)}result["s"]=s.toString("hex");return result})})};LedgerBtc.prototype.createPaymentTransactionNew_async=function(inputs,associatedKeysets,changePath,outputScript,lockTime,sigHashType){var nullScript=Buffer.alloc(0);var defaultVersion=Buffer.alloc(4);defaultVersion.writeUInt32LE(1,0);var trustedInputs=[];var regularOutputs=[];var signatures=[];var publicKeys=[];var firstRun=true;var resuming=false;var self=this;var targetTransaction={};outputScript=Buffer.from(outputScript,"hex");if(typeof lockTime=="undefined"){lockTime=LedgerBtc.DEFAULT_LOCKTIME}if(typeof sigHashType=="undefined"){sigHashType=LedgerBtc.SIGHASH_ALL}var deferred=Q.defer();utils.foreach(inputs,function(input,i){return utils.doIf(!resuming,function(){return self.getTrustedInput_async(input[1],input[0]).then(function(trustedInput){var inputItem={};inputItem["trustedInput"]=true;inputItem["value"]=Buffer.from(trustedInput,"hex");trustedInputs.push(inputItem)})}).then(function(){regularOutputs.push(input[0].outputs[input[1]])})}).then(function(){targetTransaction["version"]=defaultVersion;targetTransaction["inputs"]=[];for(var i=0;i<inputs.length;i++){var tmpInput={};var tmp=Buffer.alloc(4);var sequence;if(inputs[i].length>=4&&typeof inputs[i][3]!="undefined"){sequence=inputs[i][3]}else{sequence=LedgerBtc.DEFAULT_SEQUENCE}tmp.writeUInt32LE(sequence,0);tmpInput["script"]=nullScript;tmpInput["sequence"]=tmp;targetTransaction["inputs"].push(tmpInput)}}).then(function(){return utils.doIf(!resuming,function(){return utils.foreach(inputs,function(input,i){return self.getWalletPublicKey_async(associatedKeysets[i]).then(function(p){return p})}).then(function(result){for(var index=0;index<result.length;index++){publicKeys.push(self.compressPublicKey(Buffer.from(result[index]["publicKey"],"hex")))}})})}).then(function(){return utils.foreach(inputs,function(input,i){var usedScript;if(inputs[i].length>=3&&typeof inputs[i][2]!="undefined"){usedScript=Buffer.from(inputs[i][2],"hex")}else{usedScript=regularOutputs[i]["script"]}targetTransaction["inputs"][i]["script"]=usedScript;return self.startUntrustedHashTransactionInput_async(firstRun,targetTransaction,trustedInputs).then(function(){return utils.doIf(!resuming&&typeof changePath!="undefined",function(){return self.provideOutputFullChangePath_async(changePath)}).then(function(){return self.hashOutputFull_async(outputScript)}).then(function(resultHash){return self.signTransaction_async(associatedKeysets[i],lockTime,sigHashType).then(function(signature){signatures.push(signature);targetTransaction["inputs"][i]["script"]=nullScript;if(firstRun){firstRun=false}})})})})}).then(function(){for(var i=0;i<inputs.length;i++){var signatureSize=Buffer.alloc(1);var keySize=Buffer.alloc(1);signatureSize[0]=signatures[i].length;keySize[0]=publicKeys[i].length;targetTransaction["inputs"][i]["script"]=Buffer.concat([signatureSize,signatures[i],keySize,publicKeys[i]]);targetTransaction["inputs"][i]["prevout"]=trustedInputs[i]["value"].slice(4,4+36)}var lockTimeBuffer=Buffer.alloc(4);lockTimeBuffer.writeUInt32LE(lockTime,0);var result=Buffer.concat([self.serializeTransaction(targetTransaction),outputScript,lockTimeBuffer]);return result.toString("hex")}).fail(function(failure){throw failure}).then(function(result){deferred.resolve(result)}).fail(function(error){deferred.reject(error)});return deferred.promise};LedgerBtc.prototype.signP2SHTransaction_async=function(inputs,associatedKeysets,outputScript,lockTime,sigHashType){var nullScript=Buffer.alloc(0);var defaultVersion=Buffer.alloc(4);defaultVersion.writeUInt32LE(1,0);var trustedInputs=[];var regularOutputs=[];var signatures=[];var publicKeys=[];var firstRun=true;var resuming=false;var self=this;var targetTransaction={};outputScript=Buffer.from(outputScript,"hex");if(typeof lockTime=="undefined"){lockTime=LedgerBtc.DEFAULT_LOCKTIME}if(typeof sigHashType=="undefined"){sigHashType=LedgerBtc.SIGHASH_ALL}var deferred=Q.defer();utils.foreach(inputs,function(input,i){return utils.doIf(!resuming,function(){return self.getTrustedInput_async(input[1],input[0]).then(function(trustedInput){var inputItem={};inputItem["trustedInput"]=false;inputItem["value"]=Buffer.from(trustedInput,"hex").slice(4,4+36);trustedInputs.push(inputItem)})}).then(function(){regularOutputs.push(input[0].outputs[input[1]])})}).then(function(){targetTransaction["version"]=defaultVersion;targetTransaction["inputs"]=[];for(var i=0;i<inputs.length;i++){var tmpInput={};var tmp=Buffer.alloc(4);var sequence;if(inputs[i].length>=4&&typeof inputs[i][3]!="undefined"){sequence=inputs[i][3]}else{sequence=LedgerBtc.DEFAULT_SEQUENCE}tmp.writeUInt32LE(sequence,0);tmpInput["script"]=nullScript;tmpInput["sequence"]=tmp;targetTransaction["inputs"].push(tmpInput)}}).then(function(){return utils.foreach(inputs,function(input,i){var usedScript;if(inputs[i].length>=3&&typeof inputs[i][2]!="undefined"){usedScript=Buffer.from(inputs[i][2],"hex")}else{usedScript=regularOutputs[i]["script"]}targetTransaction["inputs"][i]["script"]=usedScript;return self.startUntrustedHashTransactionInput_async(firstRun,targetTransaction,trustedInputs).then(function(){return self.hashOutputFull_async(outputScript)}).then(function(resultHash){return self.signTransaction_async(associatedKeysets[i],lockTime,sigHashType).then(function(signature){signatures.push(signature.slice(0,signature.length-1).toString("hex"));targetTransaction["inputs"][i]["script"]=nullScript;if(firstRun){firstRun=false}})})})}).then(function(){return signatures}).fail(function(failure){throw failure}).then(function(result){deferred.resolve(result)}).fail(function(error){deferred.reject(error)});return deferred.promise};LedgerBtc.prototype.compressPublicKey=function(publicKey){var prefix=(publicKey[64]&1)!=0?3:2;var prefixBuffer=Buffer.alloc(1);prefixBuffer[0]=prefix;return Buffer.concat([prefixBuffer,publicKey.slice(1,1+32)])},LedgerBtc.prototype.createVarint=function(value){if(value<253){var buffer=Buffer.alloc(1);buffer[0]=value;return buffer}if(value<=65535){var buffer=Buffer.alloc(3);buffer[0]=253;buffer[1]=value&255;buffer[2]=value>>8&255;return buffer}var buffer=Buffer.alloc(4);buffer[0]=254;buffer[1]=value&255;buffer[2]=value>>8&255;buffer[3]=value>>16&255;buffer[4]=value>>24&255;return buffer};LedgerBtc.prototype.splitTransaction=function(transaction){var result={};var inputs=[];var outputs=[];var offset=0;var transaction=Buffer.from(transaction,"hex");var version=transaction.slice(offset,offset+4);offset+=4;var varint=this.getVarint(transaction,offset);var numberInputs=varint[0];offset+=varint[1];for(var i=0;i<numberInputs;i++){var input={};input["prevout"]=transaction.slice(offset,offset+36);offset+=36;varint=this.getVarint(transaction,offset);offset+=varint[1];input["script"]=transaction.slice(offset,offset+varint[0]);offset+=varint[0];input["sequence"]=transaction.slice(offset,offset+4);offset+=4;inputs.push(input)}varint=this.getVarint(transaction,offset);var numberOutputs=varint[0];offset+=varint[1];for(var i=0;i<numberOutputs;i++){var output={};output["amount"]=transaction.slice(offset,offset+8);offset+=8;varint=this.getVarint(transaction,offset);offset+=varint[1];output["script"]=transaction.slice(offset,offset+varint[0]);offset+=varint[0];outputs.push(output)}var locktime=transaction.slice(offset,offset+4);result["version"]=version;result["inputs"]=inputs;result["outputs"]=outputs;result["locktime"]=locktime;return result};LedgerBtc.prototype.serializeTransactionOutputs=function(transaction){var self=this;var outputBuffer=Buffer.alloc(0);if(typeof transaction["outputs"]!="undefined"){outputBuffer=Buffer.concat([outputBuffer,self.createVarint(transaction["outputs"].length)]);transaction["outputs"].forEach(function(output){outputBuffer=Buffer.concat([outputBuffer,output["amount"],self.createVarint(output["script"].length),output["script"]])})}return outputBuffer};LedgerBtc.prototype.serializeTransaction=function(transaction){var self=this;var inputBuffer=Buffer.alloc(0);transaction["inputs"].forEach(function(input){inputBuffer=Buffer.concat([inputBuffer,input["prevout"],self.createVarint(input["script"].length),input["script"],input["sequence"]])});var outputBuffer=self.serializeTransactionOutputs(transaction);if(typeof transaction["outputs"]!="undefined"){outputBuffer=Buffer.concat([outputBuffer,transaction["locktime"]])}return Buffer.concat([transaction["version"],self.createVarint(transaction["inputs"].length),inputBuffer,outputBuffer])};LedgerBtc.prototype.displayTransactionDebug=function(transaction){console.log("version "+transaction["version"].toString("hex"));for(var i=0;i<transaction["inputs"].length;i++){var input=transaction["inputs"][i];console.log("input "+i+" prevout "+input["prevout"].toString("hex")+" script "+input["script"].toString("hex")+" sequence "+input["sequence"].toString("hex"))}for(var i=0;i<transaction["outputs"].length;i++){var output=transaction["outputs"][i];console.log("output "+i+" amount "+output["amount"].toString("hex")+" script "+output["script"].toString("hex"))}console.log("locktime "+transaction["locktime"].toString("hex"))};LedgerBtc.MAX_SCRIPT_BLOCK=50;LedgerBtc.DEFAULT_LOCKTIME=0;LedgerBtc.DEFAULT_SEQUENCE=4294967295;LedgerBtc.SIGHASH_ALL=1;module.exports=LedgerBtc}).call(this,require("buffer").Buffer)},{"./utils":12,buffer:2,q:6}],10:[function(require,module,exports){(function(global,Buffer){"use strict";var Q=require("q");var chromeU2FApi=require("./chrome-u2f-api");var u2f=global.u2f?global.u2f:chromeU2FApi;var Ledger3=function(timeoutSeconds){this.timeoutSeconds=timeoutSeconds};Ledger3.wrapApdu=function(apdu,key){var result=Buffer.alloc(apdu.length);for(var i=0;i<apdu.length;i++){result[i]=apdu[i]^key[i%key.length]}return result};Ledger3.webSafe64=function(base64){return base64.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")};Ledger3.normal64=function(base64){return base64.replace(/\-/g,"+").replace(/_/g,"/")+"==".substring(0,3*base64.length%4)};Ledger3.prototype.u2fCallback=function(response,deferred,statusList){if(typeof response["signatureData"]!="undefined"){var data=Buffer.from(Ledger3.normal64(response["signatureData"]),"base64");if(typeof statusList!="undefined"){var statusFound=false;var sw=data.readUInt16BE(data.length-2);for(var index in statusList){if(statusList[index]==sw){statusFound=true;break}}if(!statusFound){deferred.reject("Invalid status "+sw.toString(16))}}deferred.resolve(data.toString("hex",5))}else{deferred.reject(response)}};Ledger3.prototype.exchange=function(apduHex,statusList){var apdu=Buffer.from(apduHex,"hex");var keyHandle=Ledger3.wrapApdu(apdu,this.scrambleKey);
3var challenge=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex");var key={};key["version"]="U2F_V2";key["keyHandle"]=Ledger3.webSafe64(keyHandle.toString("base64"));var self=this;var deferred=Q.defer();var localCallback=function(result){self.u2fCallback(result,deferred,statusList)};u2f.sign(location.origin,Ledger3.webSafe64(challenge.toString("base64")),[key],localCallback,this.timeoutSeconds);return deferred.promise};Ledger3.prototype.setScrambleKey=function(scrambleKey){this.scrambleKey=Buffer.from(scrambleKey,"ascii")};Ledger3.prototype.close_async=function(){return Q.fcall(function(){})};Ledger3.create_async=function(timeout){return Q.fcall(function(){return new Ledger3(timeout||20)})};module.exports=Ledger3}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"./chrome-u2f-api":7,buffer:2,q:6}],11:[function(require,module,exports){(function(Buffer){"use strict";var Q=require("q");var utils=require("./utils");var LedgerEth=function(comm){this.comm=comm;this.comm.setScrambleKey("w0w")};LedgerEth.prototype.getAddress_async=function(path,boolDisplay,boolChaincode){var splitPath=utils.splitPath(path);var buffer=new Buffer(5+1+splitPath.length*4);buffer[0]=224;buffer[1]=2;buffer[2]=boolDisplay?1:0;buffer[3]=boolChaincode?1:0;buffer[4]=1+splitPath.length*4;buffer[5]=splitPath.length;splitPath.forEach(function(element,index){buffer.writeUInt32BE(element,6+4*index)});return this.comm.exchange(buffer.toString("hex"),[36864]).then(function(response){var result={};var response=new Buffer(response,"hex");var publicKeyLength=response[0];var addressLength=response[1+publicKeyLength];result["publicKey"]=response.slice(1,1+publicKeyLength).toString("hex");result["address"]="0x"+response.slice(1+publicKeyLength+1,1+publicKeyLength+1+addressLength).toString("ascii");if(boolChaincode){result["chainCode"]=response.slice(1+publicKeyLength+1+addressLength,1+publicKeyLength+1+addressLength+32).toString("hex"); 4}return result})};LedgerEth.prototype.signTransaction_async=function(path,rawTxHex){var splitPath=utils.splitPath(path);var offset=0;var rawTx=new Buffer(rawTxHex,"hex");var apdus=[];var response=[];var self=this;while(offset!=rawTx.length){var maxChunkSize=offset==0?150-1-splitPath.length*4:150;var chunkSize=offset+maxChunkSize>rawTx.length?rawTx.length-offset:maxChunkSize;var buffer=new Buffer(offset==0?5+1+splitPath.length*4+chunkSize:5+chunkSize);buffer[0]=224;buffer[1]=4;buffer[2]=offset==0?0:128;buffer[3]=0;buffer[4]=offset==0?1+splitPath.length*4+chunkSize:chunkSize;if(offset==0){buffer[5]=splitPath.length;splitPath.forEach(function(element,index){buffer.writeUInt32BE(element,6+4*index)});rawTx.copy(buffer,6+4*splitPath.length,offset,offset+chunkSize)}else{rawTx.copy(buffer,5,offset,offset+chunkSize)}apdus.push(buffer.toString("hex"));offset+=chunkSize}return utils.foreach(apdus,function(apdu){return self.comm.exchange(apdu,[36864]).then(function(apduResponse){response=apduResponse})}).then(function(){response=new Buffer(response,"hex");var result={};result["v"]=response.slice(0,1).toString("hex");result["r"]=response.slice(1,1+32).toString("hex");result["s"]=response.slice(1+32,1+32+32).toString("hex");return result})};LedgerEth.prototype.getAppConfiguration_async=function(){var buffer=new Buffer(5);buffer[0]=224;buffer[1]=6;buffer[2]=0;buffer[3]=0;buffer[4]=0;return this.comm.exchange(buffer.toString("hex"),[36864]).then(function(response){var result={};var response=new Buffer(response,"hex");result["arbitraryDataEnabled"]=response[0]&1;result["version"]=""+response[1]+"."+response[2]+"."+response[3];return result})};LedgerEth.prototype.signPersonalMessage_async=function(path,messageHex){var splitPath=utils.splitPath(path);var offset=0;var message=new Buffer(messageHex,"hex");var apdus=[];var response=[];var self=this;while(offset!=message.length){var maxChunkSize=offset==0?150-1-splitPath.length*4-4:150;var chunkSize=offset+maxChunkSize>message.length?message.length-offset:maxChunkSize;var buffer=new Buffer(offset==0?5+1+splitPath.length*4+4+chunkSize:5+chunkSize);buffer[0]=224;buffer[1]=8;buffer[2]=offset==0?0:128;buffer[3]=0;buffer[4]=offset==0?1+splitPath.length*4+4+chunkSize:chunkSize;if(offset==0){buffer[5]=splitPath.length;splitPath.forEach(function(element,index){buffer.writeUInt32BE(element,6+4*index)});buffer.writeUInt32BE(message.length,6+4*splitPath.length);message.copy(buffer,6+4*splitPath.length+4,offset,offset+chunkSize)}else{message.copy(buffer,5,offset,offset+chunkSize)}apdus.push(buffer.toString("hex"));offset+=chunkSize}return utils.foreach(apdus,function(apdu){return self.comm.exchange(apdu,[36864]).then(function(apduResponse){response=apduResponse})}).then(function(){response=new Buffer(response,"hex");var result={};result["v"]=response[0];result["r"]=response.slice(1,1+32).toString("hex");result["s"]=response.slice(1+32,1+32+32).toString("hex");return result})};module.exports=LedgerEth}
4).call(this,require("buffer").Buffer)},{"./utils":12,buffer:2,q:6}],12:[function(require,module,exports){"use strict";var Q=require("q");var LedgerUtils={};LedgerUtils.eachSeries=function(arr,fun){return arr.reduce(function(p,e){return p.then(function(){return fun(e)})},Q.resolve())};LedgerUtils.splitPath=function(path){var result=[];var components=path.split("/");components.forEach(function(element,index){var number=parseInt(element,10);if(isNaN(number)){return}if(element.length>1&&element[element.length-1]=="'"){number+=2147483648}result.push(number)});return result};LedgerUtils.foreach=function(arr,callback){var deferred=Q.defer();var iterate=function(index,array,result){if(index>=array.length){deferred.resolve(result);return}callback(array[index],index).then(function(res){result.push(res);iterate(index+1,array,result)}).fail(function(ex){deferred.reject(ex)}).done()};iterate(0,arr,[]);return deferred.promise};LedgerUtils.doIf=function(condition,callback){var deferred=Q.defer();if(condition){deferred.resolve(callback())}else{deferred.resolve()}return deferred.promise};LedgerUtils.asyncWhile=function(condition,callback){var deferred=Q.defer();var iterate=function(result){if(!condition()){deferred.resolve(result);return}callback().then(function(res){result.push(res);iterate(result)}).fail(function(ex){deferred.reject(ex)}).done()};iterate([]);return deferred.promise};module.exports=LedgerUtils},{q:6}]},{},[8])(8)});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.