urbit-ob

JavaScript utilities for phonemic base wrangling.
Log | Files | Refs | README

commit aac3ef099a163bca5e5a6ed9dff616fa505cee17
parent de02df0268ecb3a7d9f142276807ef6ad5519b33
Author: Jared Tobin <jared@jtobin.io>
Date:   Fri, 19 Oct 2018 23:02:13 +1300

Temporarily browserify for distribution.

The gulpfile is not producing usable output downstream and I don't know
how to fix it at the moment.

Diffstat:
Mdist/index.js | 23153++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mpackage-lock.json | 2+-
Mpackage.json | 4++--
3 files changed, 23155 insertions(+), 4 deletions(-)

diff --git a/dist/index.js b/dist/index.js @@ -1 +1,23151 @@ -function init(){inited=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,r=t.length;n<r;++n)lookup[n]=t[n],revLookup[t.charCodeAt(n)]=n;revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63}function toByteArray(t){inited||init();var n,r,e,i,u,o,f=t.length;if(f%4>0)throw new Error("Invalid string. Length must be a multiple of 4");u="="===t[f-2]?2:"="===t[f-1]?1:0,o=new Arr(3*f/4-u),e=u>0?f-4:f;var a=0;for(n=0,r=0;n<e;n+=4,r+=3)i=revLookup[t.charCodeAt(n)]<<18|revLookup[t.charCodeAt(n+1)]<<12|revLookup[t.charCodeAt(n+2)]<<6|revLookup[t.charCodeAt(n+3)],o[a++]=i>>16&255,o[a++]=i>>8&255,o[a++]=255&i;return 2===u?(i=revLookup[t.charCodeAt(n)]<<2|revLookup[t.charCodeAt(n+1)]>>4,o[a++]=255&i):1===u&&(i=revLookup[t.charCodeAt(n)]<<10|revLookup[t.charCodeAt(n+1)]<<4|revLookup[t.charCodeAt(n+2)]>>2,o[a++]=i>>8&255,o[a++]=255&i),o}function tripletToBase64(t){return lookup[t>>18&63]+lookup[t>>12&63]+lookup[t>>6&63]+lookup[63&t]}function encodeChunk(t,n,r){for(var e,i=[],u=n;u<r;u+=3)e=(t[u]<<16)+(t[u+1]<<8)+t[u+2],i.push(tripletToBase64(e));return i.join("")}function fromByteArray(t){inited||init();for(var n,r=t.length,e=r%3,i="",u=[],o=0,f=r-e;o<f;o+=16383)u.push(encodeChunk(t,o,o+16383>f?f:o+16383));return 1===e?(n=t[r-1],i+=lookup[n>>2],i+=lookup[n<<4&63],i+="=="):2===e&&(n=(t[r-2]<<8)+t[r-1],i+=lookup[n>>10],i+=lookup[n>>4&63],i+=lookup[n<<2&63],i+="="),u.push(i),u.join("")}function read(t,n,r,e,i){var u,o,f=8*i-e-1,a=(1<<f)-1,s=a>>1,h=-7,l=r?i-1:0,c=r?-1:1,p=t[n+l];for(l+=c,u=p&(1<<-h)-1,p>>=-h,h+=f;h>0;u=256*u+t[n+l],l+=c,h-=8);for(o=u&(1<<-h)-1,u>>=-h,h+=e;h>0;o=256*o+t[n+l],l+=c,h-=8);if(0===u)u=1-s;else{if(u===a)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,e),u-=s}return(p?-1:1)*o*Math.pow(2,u-e)}function write(t,n,r,e,i,u){var o,f,a,s=8*u-i-1,h=(1<<s)-1,l=h>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=e?0:u-1,d=e?1:-1,g=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(f=isNaN(n)?1:0,o=h):(o=Math.floor(Math.log(n)/Math.LN2),n*(a=Math.pow(2,-o))<1&&(o--,a*=2),(n+=o+l>=1?c/a:c*Math.pow(2,1-l))*a>=2&&(o++,a/=2),o+l>=h?(f=0,o=h):o+l>=1?(f=(n*a-1)*Math.pow(2,i),o+=l):(f=n*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&f,p+=d,f/=256,i-=8);for(o=o<<i|f,s+=i;s>0;t[r+p]=255&o,p+=d,o/=256,s-=8);t[r+p-d]|=128*g}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(t,n){if(kMaxLength()<n)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(n)).__proto__=Buffer.prototype:(null===t&&(t=new Buffer(n)),t.length=n),t}function Buffer(t,n,r){if(!(Buffer.TYPED_ARRAY_SUPPORT||this instanceof Buffer))return new Buffer(t,n,r);if("number"==typeof t){if("string"==typeof n)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(this,t)}return from(this,t,n,r)}function from(t,n,r,e){if("number"==typeof n)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&n instanceof ArrayBuffer?fromArrayBuffer(t,n,r,e):"string"==typeof n?fromString(t,n,r):fromObject(t,n)}function assertSize(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function alloc(t,n,r,e){return assertSize(n),n<=0?createBuffer(t,n):void 0!==r?"string"==typeof e?createBuffer(t,n).fill(r,e):createBuffer(t,n).fill(r):createBuffer(t,n)}function allocUnsafe(t,n){if(assertSize(n),t=createBuffer(t,n<0?0:0|checked(n)),!Buffer.TYPED_ARRAY_SUPPORT)for(var r=0;r<n;++r)t[r]=0;return t}function fromString(t,n,r){if("string"==typeof r&&""!==r||(r="utf8"),!Buffer.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var e=0|byteLength(n,r),i=(t=createBuffer(t,e)).write(n,r);return i!==e&&(t=t.slice(0,i)),t}function fromArrayLike(t,n){var r=n.length<0?0:0|checked(n.length);t=createBuffer(t,r);for(var e=0;e<r;e+=1)t[e]=255&n[e];return t}function fromArrayBuffer(t,n,r,e){if(n.byteLength,r<0||n.byteLength<r)throw new RangeError("'offset' is out of bounds");if(n.byteLength<r+(e||0))throw new RangeError("'length' is out of bounds");return n=void 0===r&&void 0===e?new Uint8Array(n):void 0===e?new Uint8Array(n,r):new Uint8Array(n,r,e),Buffer.TYPED_ARRAY_SUPPORT?(t=n).__proto__=Buffer.prototype:t=fromArrayLike(t,n),t}function fromObject(t,n){if(internalIsBuffer(n)){var r=0|checked(n.length);return 0===(t=createBuffer(t,r)).length?t:(n.copy(t,0,0,r),t)}if(n){if("undefined"!=typeof ArrayBuffer&&n.buffer instanceof ArrayBuffer||"length"in n)return"number"!=typeof n.length||isnan(n.length)?createBuffer(t,0):fromArrayLike(t,n);if("Buffer"===n.type&&isArray(n.data))return fromArrayLike(t,n.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function checked(t){if(t>=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|t}function SlowBuffer(t){return+t!=t&&(t=0),Buffer.alloc(+t)}function internalIsBuffer(t){return!(null==t||!t._isBuffer)}function byteLength(t,n){if(internalIsBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var e=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return utf8ToBytes(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(t).length;default:if(e)return utf8ToBytes(t).length;n=(""+n).toLowerCase(),e=!0}}function slowToString(t,n,r){var e=!1;if((void 0===n||n<0)&&(n=0),n>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,n>>>=0,r<=n)return"";for(t||(t="utf8");;)switch(t){case"hex":return hexSlice(this,n,r);case"utf8":case"utf-8":return utf8Slice(this,n,r);case"ascii":return asciiSlice(this,n,r);case"latin1":case"binary":return latin1Slice(this,n,r);case"base64":return base64Slice(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,n,r);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}function swap(t,n,r){var e=t[n];t[n]=t[r],t[r]=e}function bidirectionalIndexOf(t,n,r,e,i){if(0===t.length)return-1;if("string"==typeof r?(e=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof n&&(n=Buffer.from(n,e)),internalIsBuffer(n))return 0===n.length?-1:arrayIndexOf(t,n,r,e,i);if("number"==typeof n)return n&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,n,r):Uint8Array.prototype.lastIndexOf.call(t,n,r):arrayIndexOf(t,[n],r,e,i);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(t,n,r,e,i){function u(t,n){return 1===o?t[n]:t.readUInt16BE(n*o)}var o=1,f=t.length,a=n.length;if(void 0!==e&&("ucs2"===(e=String(e).toLowerCase())||"ucs-2"===e||"utf16le"===e||"utf-16le"===e)){if(t.length<2||n.length<2)return-1;o=2,f/=2,a/=2,r/=2}var s;if(i){var h=-1;for(s=r;s<f;s++)if(u(t,s)===u(n,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===a)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+a>f&&(r=f-a),s=r;s>=0;s--){for(var l=!0,c=0;c<a;c++)if(u(t,s+c)!==u(n,c)){l=!1;break}if(l)return s}return-1}function hexWrite(t,n,r,e){r=Number(r)||0;var i=t.length-r;e?(e=Number(e))>i&&(e=i):e=i;var u=n.length;if(u%2!=0)throw new TypeError("Invalid hex string");e>u/2&&(e=u/2);for(var o=0;o<e;++o){var f=parseInt(n.substr(2*o,2),16);if(isNaN(f))return o;t[r+o]=f}return o}function utf8Write(t,n,r,e){return blitBuffer(utf8ToBytes(n,t.length-r),t,r,e)}function asciiWrite(t,n,r,e){return blitBuffer(asciiToBytes(n),t,r,e)}function latin1Write(t,n,r,e){return asciiWrite(t,n,r,e)}function base64Write(t,n,r,e){return blitBuffer(base64ToBytes(n),t,r,e)}function ucs2Write(t,n,r,e){return blitBuffer(utf16leToBytes(n,t.length-r),t,r,e)}function base64Slice(t,n,r){return fromByteArray(0===n&&r===t.length?t:t.slice(n,r))}function utf8Slice(t,n,r){r=Math.min(t.length,r);for(var e=[],i=n;i<r;){var u=t[i],o=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r){var a,s,h,l;switch(f){case 1:u<128&&(o=u);break;case 2:128==(192&(a=t[i+1]))&&(l=(31&u)<<6|63&a)>127&&(o=l);break;case 3:a=t[i+1],s=t[i+2],128==(192&a)&&128==(192&s)&&(l=(15&u)<<12|(63&a)<<6|63&s)>2047&&(l<55296||l>57343)&&(o=l);break;case 4:a=t[i+1],s=t[i+2],h=t[i+3],128==(192&a)&&128==(192&s)&&128==(192&h)&&(l=(15&u)<<18|(63&a)<<12|(63&s)<<6|63&h)>65535&&l<1114112&&(o=l)}}null===o?(o=65533,f=1):o>65535&&(o-=65536,e.push(o>>>10&1023|55296),o=56320|1023&o),e.push(o),i+=f}return decodeCodePointsArray(e)}function decodeCodePointsArray(t){var n=t.length;if(n<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,t);for(var r="",e=0;e<n;)r+=String.fromCharCode.apply(String,t.slice(e,e+=MAX_ARGUMENTS_LENGTH));return r}function asciiSlice(t,n,r){var e="";r=Math.min(t.length,r);for(var i=n;i<r;++i)e+=String.fromCharCode(127&t[i]);return e}function latin1Slice(t,n,r){var e="";r=Math.min(t.length,r);for(var i=n;i<r;++i)e+=String.fromCharCode(t[i]);return e}function hexSlice(t,n,r){var e=t.length;(!n||n<0)&&(n=0),(!r||r<0||r>e)&&(r=e);for(var i="",u=n;u<r;++u)i+=toHex(t[u]);return i}function utf16leSlice(t,n,r){for(var e=t.slice(n,r),i="",u=0;u<e.length;u+=2)i+=String.fromCharCode(e[u]+256*e[u+1]);return i}function checkOffset(t,n,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+n>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(t,n,r,e,i,u){if(!internalIsBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>i||n<u)throw new RangeError('"value" argument is out of bounds');if(r+e>t.length)throw new RangeError("Index out of range")}function objectWriteUInt16(t,n,r,e){n<0&&(n=65535+n+1);for(var i=0,u=Math.min(t.length-r,2);i<u;++i)t[r+i]=(n&255<<8*(e?i:1-i))>>>8*(e?i:1-i)}function objectWriteUInt32(t,n,r,e){n<0&&(n=4294967295+n+1);for(var i=0,u=Math.min(t.length-r,4);i<u;++i)t[r+i]=n>>>8*(e?i:3-i)&255}function checkIEEE754(t,n,r,e,i,u){if(r+e>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(t,n,r,e,i){return i||checkIEEE754(t,n,r,4,3.4028234663852886e38,-3.4028234663852886e38),write(t,n,r,e,23,4),r+4}function writeDouble(t,n,r,e,i){return i||checkIEEE754(t,n,r,8,1.7976931348623157e308,-1.7976931348623157e308),write(t,n,r,e,52,8),r+8}function base64clean(t){if((t=stringtrim(t).replace(INVALID_BASE64_RE,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}function stringtrim(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function toHex(t){return t<16?"0"+t.toString(16):t.toString(16)}function utf8ToBytes(t,n){n=n||1/0;for(var r,e=t.length,i=null,u=[],o=0;o<e;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(n-=3)>-1&&u.push(239,191,189);continue}if(o+1===e){(n-=3)>-1&&u.push(239,191,189);continue}i=r;continue}if(r<56320){(n-=3)>-1&&u.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(n-=3)>-1&&u.push(239,191,189);if(i=null,r<128){if((n-=1)<0)break;u.push(r)}else if(r<2048){if((n-=2)<0)break;u.push(r>>6|192,63&r|128)}else if(r<65536){if((n-=3)<0)break;u.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((n-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return u}function asciiToBytes(t){for(var n=[],r=0;r<t.length;++r)n.push(255&t.charCodeAt(r));return n}function utf16leToBytes(t,n){for(var r,e,i,u=[],o=0;o<t.length&&!((n-=2)<0);++o)e=(r=t.charCodeAt(o))>>8,i=r%256,u.push(i),u.push(e);return u}function base64ToBytes(t){return toByteArray(base64clean(t))}function blitBuffer(t,n,r,e){for(var i=0;i<e&&!(i+r>=n.length||i>=t.length);++i)n[i+r]=t[i];return i}function isnan(t){return t!==t}function isBuffer(t){return null!=t&&(!!t._isBuffer||isFastBuffer(t)||isSlowBuffer(t))}function isFastBuffer(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function isSlowBuffer(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&isFastBuffer(t.slice(0,0))}function createCommonjsModule(t,n){return n={exports:{}},t(n,n.exports),n.exports}var global$1="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,inited=!1,toString={}.toString,isArray=Array.isArray||function(t){return"[object Array]"==toString.call(t)},INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=void 0===global$1.TYPED_ARRAY_SUPPORT||global$1.TYPED_ARRAY_SUPPORT;var _kMaxLength=kMaxLength();Buffer.poolSize=8192,Buffer._augment=function(t){return t.__proto__=Buffer.prototype,t},Buffer.from=function(t,n,r){return from(null,t,n,r)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array),Buffer.alloc=function(t,n,r){return alloc(null,t,n,r)},Buffer.allocUnsafe=function(t){return allocUnsafe(null,t)},Buffer.allocUnsafeSlow=function(t){return allocUnsafe(null,t)},Buffer.isBuffer=isBuffer,Buffer.compare=function(t,n){if(!internalIsBuffer(t)||!internalIsBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var r=t.length,e=n.length,i=0,u=Math.min(r,e);i<u;++i)if(t[i]!==n[i]){r=t[i],e=n[i];break}return r<e?-1:e<r?1:0},Buffer.isEncoding=function(t){switch(String(t).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!0;default:return!1}},Buffer.concat=function(t,n){if(!isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Buffer.alloc(0);var r;if(void 0===n)for(n=0,r=0;r<t.length;++r)n+=t[r].length;var e=Buffer.allocUnsafe(n),i=0;for(r=0;r<t.length;++r){var u=t[r];if(!internalIsBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(e,i),i+=u.length}return e},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)swap(this,n,n+1);return this},Buffer.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)swap(this,n,n+3),swap(this,n+1,n+2);return this},Buffer.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)swap(this,n,n+7),swap(this,n+1,n+6),swap(this,n+2,n+5),swap(this,n+3,n+4);return this},Buffer.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?utf8Slice(this,0,t):slowToString.apply(this,arguments)},Buffer.prototype.equals=function(t){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",n=INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},Buffer.prototype.compare=function(t,n,r,e,i){if(!internalIsBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===r&&(r=t?t.length:0),void 0===e&&(e=0),void 0===i&&(i=this.length),n<0||r>t.length||e<0||i>this.length)throw new RangeError("out of range index");if(e>=i&&n>=r)return 0;if(e>=i)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,e>>>=0,i>>>=0,this===t)return 0;for(var u=i-e,o=r-n,f=Math.min(u,o),a=this.slice(e,i),s=t.slice(n,r),h=0;h<f;++h)if(a[h]!==s[h]){u=a[h],o=s[h];break}return u<o?-1:o<u?1:0},Buffer.prototype.includes=function(t,n,r){return-1!==this.indexOf(t,n,r)},Buffer.prototype.indexOf=function(t,n,r){return bidirectionalIndexOf(this,t,n,r,!0)},Buffer.prototype.lastIndexOf=function(t,n,r){return bidirectionalIndexOf(this,t,n,r,!1)},Buffer.prototype.write=function(t,n,r,e){if(void 0===n)e="utf8",r=this.length,n=0;else if(void 0===r&&"string"==typeof n)e=n,r=this.length,n=0;else{if(!isFinite(n))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");n|=0,isFinite(r)?(r|=0,void 0===e&&(e="utf8")):(e=r,r=void 0)}var i=this.length-n;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");for(var u=!1;;)switch(e){case"hex":return hexWrite(this,t,n,r);case"utf8":case"utf-8":return utf8Write(this,t,n,r);case"ascii":return asciiWrite(this,t,n,r);case"latin1":case"binary":return latin1Write(this,t,n,r);case"base64":return base64Write(this,t,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,n,r);default:if(u)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),u=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(t,n){var r=this.length;t=~~t,n=void 0===n?r:~~n,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),n<0?(n+=r)<0&&(n=0):n>r&&(n=r),n<t&&(n=t);var e;if(Buffer.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,n)).__proto__=Buffer.prototype;else{var i=n-t;e=new Buffer(i,void 0);for(var u=0;u<i;++u)e[u]=this[u+t]}return e},Buffer.prototype.readUIntLE=function(t,n,r){t|=0,n|=0,r||checkOffset(t,n,this.length);for(var e=this[t],i=1,u=0;++u<n&&(i*=256);)e+=this[t+u]*i;return e},Buffer.prototype.readUIntBE=function(t,n,r){t|=0,n|=0,r||checkOffset(t,n,this.length);for(var e=this[t+--n],i=1;n>0&&(i*=256);)e+=this[t+--n]*i;return e},Buffer.prototype.readUInt8=function(t,n){return n||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,n){return n||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,n){return n||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,n){return n||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,n){return n||checkOffset(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,n,r){t|=0,n|=0,r||checkOffset(t,n,this.length);for(var e=this[t],i=1,u=0;++u<n&&(i*=256);)e+=this[t+u]*i;return i*=128,e>=i&&(e-=Math.pow(2,8*n)),e},Buffer.prototype.readIntBE=function(t,n,r){t|=0,n|=0,r||checkOffset(t,n,this.length);for(var e=n,i=1,u=this[t+--e];e>0&&(i*=256);)u+=this[t+--e]*i;return i*=128,u>=i&&(u-=Math.pow(2,8*n)),u},Buffer.prototype.readInt8=function(t,n){return n||checkOffset(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,n){n||checkOffset(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,n){n||checkOffset(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,n){return n||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,n){return n||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,n){return n||checkOffset(t,4,this.length),read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,n){return n||checkOffset(t,4,this.length),read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,n){return n||checkOffset(t,8,this.length),read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,n){return n||checkOffset(t,8,this.length),read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,n,r,e){t=+t,n|=0,r|=0,e||checkInt(this,t,n,r,Math.pow(2,8*r)-1,0);var i=1,u=0;for(this[n]=255&t;++u<r&&(i*=256);)this[n+u]=t/i&255;return n+r},Buffer.prototype.writeUIntBE=function(t,n,r,e){t=+t,n|=0,r|=0,e||checkInt(this,t,n,r,Math.pow(2,8*r)-1,0);var i=r-1,u=1;for(this[n+i]=255&t;--i>=0&&(u*=256);)this[n+i]=t/u&255;return n+r},Buffer.prototype.writeUInt8=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=255&t,n+1},Buffer.prototype.writeUInt16LE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):objectWriteUInt16(this,t,n,!0),n+2},Buffer.prototype.writeUInt16BE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):objectWriteUInt16(this,t,n,!1),n+2},Buffer.prototype.writeUInt32LE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):objectWriteUInt32(this,t,n,!0),n+4},Buffer.prototype.writeUInt32BE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):objectWriteUInt32(this,t,n,!1),n+4},Buffer.prototype.writeIntLE=function(t,n,r,e){if(t=+t,n|=0,!e){var i=Math.pow(2,8*r-1);checkInt(this,t,n,r,i-1,-i)}var u=0,o=1,f=0;for(this[n]=255&t;++u<r&&(o*=256);)t<0&&0===f&&0!==this[n+u-1]&&(f=1),this[n+u]=(t/o>>0)-f&255;return n+r},Buffer.prototype.writeIntBE=function(t,n,r,e){if(t=+t,n|=0,!e){var i=Math.pow(2,8*r-1);checkInt(this,t,n,r,i-1,-i)}var u=r-1,o=1,f=0;for(this[n+u]=255&t;--u>=0&&(o*=256);)t<0&&0===f&&0!==this[n+u+1]&&(f=1),this[n+u]=(t/o>>0)-f&255;return n+r},Buffer.prototype.writeInt8=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=255&t,n+1},Buffer.prototype.writeInt16LE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):objectWriteUInt16(this,t,n,!0),n+2},Buffer.prototype.writeInt16BE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):objectWriteUInt16(this,t,n,!1),n+2},Buffer.prototype.writeInt32LE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):objectWriteUInt32(this,t,n,!0),n+4},Buffer.prototype.writeInt32BE=function(t,n,r){return t=+t,n|=0,r||checkInt(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):objectWriteUInt32(this,t,n,!1),n+4},Buffer.prototype.writeFloatLE=function(t,n,r){return writeFloat(this,t,n,!0,r)},Buffer.prototype.writeFloatBE=function(t,n,r){return writeFloat(this,t,n,!1,r)},Buffer.prototype.writeDoubleLE=function(t,n,r){return writeDouble(this,t,n,!0,r)},Buffer.prototype.writeDoubleBE=function(t,n,r){return writeDouble(this,t,n,!1,r)},Buffer.prototype.copy=function(t,n,r,e){if(r||(r=0),e||0===e||(e=this.length),n>=t.length&&(n=t.length),n||(n=0),e>0&&e<r&&(e=r),e===r)return 0;if(0===t.length||0===this.length)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),t.length-n<e-r&&(e=t.length-n+r);var i,u=e-r;if(this===t&&r<n&&n<e)for(i=u-1;i>=0;--i)t[i+n]=this[i+r];else if(u<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i<u;++i)t[i+n]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+u),n);return u},Buffer.prototype.fill=function(t,n,r,e){if("string"==typeof t){if("string"==typeof n?(e=n,n=0,r=this.length):"string"==typeof r&&(e=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==e&&"string"!=typeof e)throw new TypeError("encoding must be a string");if("string"==typeof e&&!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e)}else"number"==typeof t&&(t&=255);if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var u;if("number"==typeof t)for(u=n;u<r;++u)this[u]=t;else{var o=internalIsBuffer(t)?t:utf8ToBytes(new Buffer(t,e).toString()),f=o.length;for(u=0;u<r-n;++u)this[u+n]=o[u%f]}return this};var INVALID_BASE64_RE=/[^+\/0-9A-Za-z-_]/g,bufferEs6=Object.freeze({INSPECT_MAX_BYTES:INSPECT_MAX_BYTES,kMaxLength:_kMaxLength,Buffer:Buffer,SlowBuffer:SlowBuffer,isBuffer:isBuffer}),commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},bn$1=createCommonjsModule(function(t){!function(t,n){"use strict";function r(t,n){if(!t)throw new Error(n||"Assertion failed")}function e(t,n){t.super_=n;var r=function(){};r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,n,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==n&&"be"!==n||(r=n,n=10),this._init(t||0,n||10,r||"be"))}function u(t,n,r){for(var e=0,i=Math.min(t.length,r),u=n;u<i;u++){var o=t.charCodeAt(u)-48;e<<=4,e|=o>=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return e}function o(t,n,r,e){for(var i=0,u=Math.min(t.length,r),o=n;o<u;o++){var f=t.charCodeAt(o)-48;i*=e,i+=f>=49?f-49+10:f>=17?f-17+10:f}return i}function f(t){for(var n=new Array(t.bitLength()),r=0;r<n.length;r++){var e=r/26|0,i=r%26;n[r]=(t.words[e]&1<<i)>>>i}return n}function a(t,n,r){r.negative=n.negative^t.negative;var e=t.length+n.length|0;r.length=e,e=e-1|0;var i=0|t.words[0],u=0|n.words[0],o=i*u,f=67108863&o,a=o/67108864|0;r.words[0]=f;for(var s=1;s<e;s++){for(var h=a>>>26,l=67108863&a,c=Math.min(s,n.length-1),p=Math.max(0,s-t.length+1);p<=c;p++){var d=s-p|0;h+=(o=(i=0|t.words[d])*(u=0|n.words[p])+l)/67108864|0,l=67108863&o}r.words[s]=0|l,a=0|h}return 0!==a?r.words[s]=0|a:r.length--,r.strip()}function s(t,n,r){r.negative=n.negative^t.negative,r.length=t.length+n.length;for(var e=0,i=0,u=0;u<r.length-1;u++){var o=i;i=0;for(var f=67108863&e,a=Math.min(u,n.length-1),s=Math.max(0,u-t.length+1);s<=a;s++){var h=u-s,l=(0|t.words[h])*(0|n.words[s]),c=67108863&l;f=67108863&(c=c+f|0),i+=(o=(o=o+(l/67108864|0)|0)+(c>>>26)|0)>>>26,o&=67108863}r.words[u]=f,e=o,o=i}return 0!==e?r.words[u]=e:r.length--,r.strip()}function h(t,n,r){return(new l).mulp(t,n,r)}function l(t,n){this.x=t,this.y=n}function c(t,n){this.name=t,this.p=new i(n,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function p(){c.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function d(){c.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function g(){c.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function v(){c.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function m(t){if("string"==typeof t){var n=i._prime(t);this.m=n.p,this.prime=n}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function y(t){m.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof t?t.exports=i:n.BN=i,i.BN=i,i.wordSize=26;var _;try{_=bufferEs6.Buffer}catch(t){}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,n){return t.cmp(n)>0?t:n},i.min=function(t,n){return t.cmp(n)<0?t:n},i.prototype._init=function(t,n,e){if("number"==typeof t)return this._initNumber(t,n,e);if("object"==typeof t)return this._initArray(t,n,e);"hex"===n&&(n=16),r(n===(0|n)&&n>=2&&n<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===n?this._parseHex(t,i):this._parseBase(t,n,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===e&&this._initArray(this.toArray(),n,e)},i.prototype._initNumber=function(t,n,e){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===e&&this._initArray(this.toArray(),n,e)},i.prototype._initArray=function(t,n,e){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var u,o,f=0;if("be"===e)for(i=t.length-1,u=0;i>=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[u]|=o<<f&67108863,this.words[u+1]=o>>>26-f&67108863,(f+=24)>=26&&(f-=26,u++);else if("le"===e)for(i=0,u=0;i<t.length;i+=3)o=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[u]|=o<<f&67108863,this.words[u+1]=o>>>26-f&67108863,(f+=24)>=26&&(f-=26,u++);return this.strip()},i.prototype._parseHex=function(t,n){this.length=Math.ceil((t.length-n)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var e,i,o=0;for(r=t.length-6,e=0;r>=n;r-=6)i=u(t,r,r+6),this.words[e]|=i<<o&67108863,this.words[e+1]|=i>>>26-o&4194303,(o+=24)>=26&&(o-=26,e++);r+6!==n&&(i=u(t,n,r+6),this.words[e]|=i<<o&67108863,this.words[e+1]|=i>>>26-o&4194303),this.strip()},i.prototype._parseBase=function(t,n,r){this.words=[0],this.length=1;for(var e=0,i=1;i<=67108863;i*=n)e++;e--,i=i/n|0;for(var u=t.length-r,f=u%e,a=Math.min(u,u-f)+r,s=0,h=r;h<a;h+=e)s=o(t,h,h+e,n),this.imuln(i),this.words[0]+s<67108864?this.words[0]+=s:this._iaddn(s);if(0!==f){var l=1;for(s=o(t,h,t.length,n),h=0;h<f;h++)l*=n;this.imuln(l),this.words[0]+s<67108864?this.words[0]+=s:this._iaddn(s)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var n=0;n<this.length;n++)t.words[n]=this.words[n];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var w=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],M=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],b=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,n){t=t||10,n=0|n||1;var e;if(16===t||"hex"===t){e="";for(var i=0,u=0,o=0;o<this.length;o++){var f=this.words[o],a=(16777215&(f<<i|u)).toString(16);e=0!==(u=f>>>24-i&16777215)||o!==this.length-1?w[6-a.length]+a+e:a+e,(i+=2)>=26&&(i-=26,o--)}for(0!==u&&(e=u.toString(16)+e);e.length%n!=0;)e="0"+e;return 0!==this.negative&&(e="-"+e),e}if(t===(0|t)&&t>=2&&t<=36){var s=M[t],h=b[t];e="";var l=this.clone();for(l.negative=0;!l.isZero();){var c=l.modn(h).toString(t);e=(l=l.idivn(h)).isZero()?c+e:w[s-c.length]+c+e}for(this.isZero()&&(e="0"+e);e.length%n!=0;)e="0"+e;return 0!==this.negative&&(e="-"+e),e}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,n){return r(void 0!==_),this.toArrayLike(_,t,n)},i.prototype.toArray=function(t,n){return this.toArrayLike(Array,t,n)},i.prototype.toArrayLike=function(t,n,e){var i=this.byteLength(),u=e||Math.max(1,i);r(i<=u,"byte array longer than desired length"),r(u>0,"Requested array length <= 0"),this.strip();var o,f,a="le"===n,s=new t(u),h=this.clone();if(a){for(f=0;!h.isZero();f++)o=h.andln(255),h.iushrn(8),s[f]=o;for(;f<u;f++)s[f]=0}else{for(f=0;f<u-i;f++)s[f]=0;for(f=0;!h.isZero();f++)o=h.andln(255),h.iushrn(8),s[u-f-1]=o}return s},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var n=t,r=0;return n>=4096&&(r+=13,n>>>=13),n>=64&&(r+=7,n>>>=7),n>=8&&(r+=4,n>>>=4),n>=2&&(r+=2,n>>>=2),r+n},i.prototype._zeroBits=function(t){if(0===t)return 26;var n=t,r=0;return 0==(8191&n)&&(r+=13,n>>>=13),0==(127&n)&&(r+=7,n>>>=7),0==(15&n)&&(r+=4,n>>>=4),0==(3&n)&&(r+=2,n>>>=2),0==(1&n)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],n=this._countBits(t);return 26*(this.length-1)+n},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,n=0;n<this.length;n++){var r=this._zeroBits(this.words[n]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]|t.words[n];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var n;n=this.length>t.length?t:this;for(var r=0;r<n.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=n.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var n,r;this.length>t.length?(n=this,r=t):(n=t,r=this);for(var e=0;e<r.length;e++)this.words[e]=n.words[e]^r.words[e];if(this!==n)for(;e<n.length;e++)this.words[e]=n.words[e];return this.length=n.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var n=0|Math.ceil(t/26),e=t%26;this._expand(n),e>0&&n--;for(var i=0;i<n;i++)this.words[i]=67108863&~this.words[i];return e>0&&(this.words[i]=~this.words[i]&67108863>>26-e),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,n){r("number"==typeof t&&t>=0);var e=t/26|0,i=t%26;return this._expand(e+1),this.words[e]=n?this.words[e]|1<<i:this.words[e]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var n;if(0!==this.negative&&0===t.negative)return this.negative=0,n=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,n=this.isub(t),t.negative=1,n._normSign();var r,e;this.length>t.length?(r=this,e=t):(r=t,e=this);for(var i=0,u=0;u<e.length;u++)n=(0|r.words[u])+(0|e.words[u])+i,this.words[u]=67108863&n,i=n>>>26;for(;0!==i&&u<r.length;u++)n=(0|r.words[u])+i,this.words[u]=67108863&n,i=n>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;u<r.length;u++)this.words[u]=r.words[u];return this},i.prototype.add=function(t){var n;return 0!==t.negative&&0===this.negative?(t.negative=0,n=this.sub(t),t.negative^=1,n):0===t.negative&&0!==this.negative?(this.negative=0,n=t.sub(this),this.negative=1,n):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var n=this.iadd(t);return t.negative=1,n._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;var e,i;r>0?(e=this,i=t):(e=t,i=this);for(var u=0,o=0;o<i.length;o++)u=(n=(0|e.words[o])-(0|i.words[o])+u)>>26,this.words[o]=67108863&n;for(;0!==u&&o<e.length;o++)u=(n=(0|e.words[o])+u)>>26,this.words[o]=67108863&n;if(0===u&&o<e.length&&e!==this)for(;o<e.length;o++)this.words[o]=e.words[o];return this.length=Math.max(this.length,o),e!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var B=function(t,n,r){var e,i,u,o=t.words,f=n.words,a=r.words,s=0,h=0|o[0],l=8191&h,c=h>>>13,p=0|o[1],d=8191&p,g=p>>>13,v=0|o[2],m=8191&v,y=v>>>13,_=0|o[3],w=8191&_,M=_>>>13,b=0|o[4],B=8191&b,x=b>>>13,A=0|o[5],k=8191&A,E=A>>>13,S=0|o[6],R=8191&S,I=S>>>13,T=0|o[7],O=8191&T,j=T>>>13,L=0|o[8],U=8191&L,P=L>>>13,C=0|o[9],$=8191&C,z=C>>>13,N=0|f[0],q=8191&N,W=N>>>13,D=0|f[1],Y=8191&D,F=D>>>13,Z=0|f[2],G=8191&Z,V=Z>>>13,K=0|f[3],H=8191&K,X=K>>>13,J=0|f[4],Q=8191&J,tt=J>>>13,nt=0|f[5],rt=8191&nt,et=nt>>>13,it=0|f[6],ut=8191&it,ot=it>>>13,ft=0|f[7],at=8191&ft,st=ft>>>13,ht=0|f[8],lt=8191&ht,ct=ht>>>13,pt=0|f[9],dt=8191&pt,gt=pt>>>13;r.negative=t.negative^n.negative,r.length=19;var vt=(s+(e=Math.imul(l,q))|0)+((8191&(i=(i=Math.imul(l,W))+Math.imul(c,q)|0))<<13)|0;s=((u=Math.imul(c,W))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(d,q),i=(i=Math.imul(d,W))+Math.imul(g,q)|0,u=Math.imul(g,W);var mt=(s+(e=e+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,F)|0)+Math.imul(c,Y)|0))<<13)|0;s=((u=u+Math.imul(c,F)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,e=Math.imul(m,q),i=(i=Math.imul(m,W))+Math.imul(y,q)|0,u=Math.imul(y,W),e=e+Math.imul(d,Y)|0,i=(i=i+Math.imul(d,F)|0)+Math.imul(g,Y)|0,u=u+Math.imul(g,F)|0;var yt=(s+(e=e+Math.imul(l,G)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(c,G)|0))<<13)|0;s=((u=u+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(w,q),i=(i=Math.imul(w,W))+Math.imul(M,q)|0,u=Math.imul(M,W),e=e+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,F)|0)+Math.imul(y,Y)|0,u=u+Math.imul(y,F)|0,e=e+Math.imul(d,G)|0,i=(i=i+Math.imul(d,V)|0)+Math.imul(g,G)|0,u=u+Math.imul(g,V)|0;var _t=(s+(e=e+Math.imul(l,H)|0)|0)+((8191&(i=(i=i+Math.imul(l,X)|0)+Math.imul(c,H)|0))<<13)|0;s=((u=u+Math.imul(c,X)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(B,q),i=(i=Math.imul(B,W))+Math.imul(x,q)|0,u=Math.imul(x,W),e=e+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,F)|0)+Math.imul(M,Y)|0,u=u+Math.imul(M,F)|0,e=e+Math.imul(m,G)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(y,G)|0,u=u+Math.imul(y,V)|0,e=e+Math.imul(d,H)|0,i=(i=i+Math.imul(d,X)|0)+Math.imul(g,H)|0,u=u+Math.imul(g,X)|0;var wt=(s+(e=e+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;s=((u=u+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(k,q),i=(i=Math.imul(k,W))+Math.imul(E,q)|0,u=Math.imul(E,W),e=e+Math.imul(B,Y)|0,i=(i=i+Math.imul(B,F)|0)+Math.imul(x,Y)|0,u=u+Math.imul(x,F)|0,e=e+Math.imul(w,G)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(M,G)|0,u=u+Math.imul(M,V)|0,e=e+Math.imul(m,H)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(y,H)|0,u=u+Math.imul(y,X)|0,e=e+Math.imul(d,Q)|0,i=(i=i+Math.imul(d,tt)|0)+Math.imul(g,Q)|0,u=u+Math.imul(g,tt)|0;var Mt=(s+(e=e+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,et)|0)+Math.imul(c,rt)|0))<<13)|0;s=((u=u+Math.imul(c,et)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(R,q),i=(i=Math.imul(R,W))+Math.imul(I,q)|0,u=Math.imul(I,W),e=e+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,F)|0)+Math.imul(E,Y)|0,u=u+Math.imul(E,F)|0,e=e+Math.imul(B,G)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(x,G)|0,u=u+Math.imul(x,V)|0,e=e+Math.imul(w,H)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(M,H)|0,u=u+Math.imul(M,X)|0,e=e+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(y,Q)|0,u=u+Math.imul(y,tt)|0,e=e+Math.imul(d,rt)|0,i=(i=i+Math.imul(d,et)|0)+Math.imul(g,rt)|0,u=u+Math.imul(g,et)|0;var bt=(s+(e=e+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ot)|0)+Math.imul(c,ut)|0))<<13)|0;s=((u=u+Math.imul(c,ot)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(O,q),i=(i=Math.imul(O,W))+Math.imul(j,q)|0,u=Math.imul(j,W),e=e+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,F)|0)+Math.imul(I,Y)|0,u=u+Math.imul(I,F)|0,e=e+Math.imul(k,G)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(E,G)|0,u=u+Math.imul(E,V)|0,e=e+Math.imul(B,H)|0,i=(i=i+Math.imul(B,X)|0)+Math.imul(x,H)|0,u=u+Math.imul(x,X)|0,e=e+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,u=u+Math.imul(M,tt)|0,e=e+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,et)|0)+Math.imul(y,rt)|0,u=u+Math.imul(y,et)|0,e=e+Math.imul(d,ut)|0,i=(i=i+Math.imul(d,ot)|0)+Math.imul(g,ut)|0,u=u+Math.imul(g,ot)|0;var Bt=(s+(e=e+Math.imul(l,at)|0)|0)+((8191&(i=(i=i+Math.imul(l,st)|0)+Math.imul(c,at)|0))<<13)|0;s=((u=u+Math.imul(c,st)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,e=Math.imul(U,q),i=(i=Math.imul(U,W))+Math.imul(P,q)|0,u=Math.imul(P,W),e=e+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,F)|0)+Math.imul(j,Y)|0,u=u+Math.imul(j,F)|0,e=e+Math.imul(R,G)|0,i=(i=i+Math.imul(R,V)|0)+Math.imul(I,G)|0,u=u+Math.imul(I,V)|0,e=e+Math.imul(k,H)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(E,H)|0,u=u+Math.imul(E,X)|0,e=e+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,tt)|0)+Math.imul(x,Q)|0,u=u+Math.imul(x,tt)|0,e=e+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,et)|0)+Math.imul(M,rt)|0,u=u+Math.imul(M,et)|0,e=e+Math.imul(m,ut)|0,i=(i=i+Math.imul(m,ot)|0)+Math.imul(y,ut)|0,u=u+Math.imul(y,ot)|0,e=e+Math.imul(d,at)|0,i=(i=i+Math.imul(d,st)|0)+Math.imul(g,at)|0,u=u+Math.imul(g,st)|0;var xt=(s+(e=e+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;s=((u=u+Math.imul(c,ct)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,e=Math.imul($,q),i=(i=Math.imul($,W))+Math.imul(z,q)|0,u=Math.imul(z,W),e=e+Math.imul(U,Y)|0,i=(i=i+Math.imul(U,F)|0)+Math.imul(P,Y)|0,u=u+Math.imul(P,F)|0,e=e+Math.imul(O,G)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(j,G)|0,u=u+Math.imul(j,V)|0,e=e+Math.imul(R,H)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(I,H)|0,u=u+Math.imul(I,X)|0,e=e+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(E,Q)|0,u=u+Math.imul(E,tt)|0,e=e+Math.imul(B,rt)|0,i=(i=i+Math.imul(B,et)|0)+Math.imul(x,rt)|0,u=u+Math.imul(x,et)|0,e=e+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(M,ut)|0,u=u+Math.imul(M,ot)|0,e=e+Math.imul(m,at)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(y,at)|0,u=u+Math.imul(y,st)|0,e=e+Math.imul(d,lt)|0,i=(i=i+Math.imul(d,ct)|0)+Math.imul(g,lt)|0,u=u+Math.imul(g,ct)|0;var At=(s+(e=e+Math.imul(l,dt)|0)|0)+((8191&(i=(i=i+Math.imul(l,gt)|0)+Math.imul(c,dt)|0))<<13)|0;s=((u=u+Math.imul(c,gt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul($,Y),i=(i=Math.imul($,F))+Math.imul(z,Y)|0,u=Math.imul(z,F),e=e+Math.imul(U,G)|0,i=(i=i+Math.imul(U,V)|0)+Math.imul(P,G)|0,u=u+Math.imul(P,V)|0,e=e+Math.imul(O,H)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(j,H)|0,u=u+Math.imul(j,X)|0,e=e+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(I,Q)|0,u=u+Math.imul(I,tt)|0,e=e+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,et)|0)+Math.imul(E,rt)|0,u=u+Math.imul(E,et)|0,e=e+Math.imul(B,ut)|0,i=(i=i+Math.imul(B,ot)|0)+Math.imul(x,ut)|0,u=u+Math.imul(x,ot)|0,e=e+Math.imul(w,at)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(M,at)|0,u=u+Math.imul(M,st)|0,e=e+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(y,lt)|0,u=u+Math.imul(y,ct)|0;var kt=(s+(e=e+Math.imul(d,dt)|0)|0)+((8191&(i=(i=i+Math.imul(d,gt)|0)+Math.imul(g,dt)|0))<<13)|0;s=((u=u+Math.imul(g,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,e=Math.imul($,G),i=(i=Math.imul($,V))+Math.imul(z,G)|0,u=Math.imul(z,V),e=e+Math.imul(U,H)|0,i=(i=i+Math.imul(U,X)|0)+Math.imul(P,H)|0,u=u+Math.imul(P,X)|0,e=e+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(j,Q)|0,u=u+Math.imul(j,tt)|0,e=e+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,et)|0)+Math.imul(I,rt)|0,u=u+Math.imul(I,et)|0,e=e+Math.imul(k,ut)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(E,ut)|0,u=u+Math.imul(E,ot)|0,e=e+Math.imul(B,at)|0,i=(i=i+Math.imul(B,st)|0)+Math.imul(x,at)|0,u=u+Math.imul(x,st)|0,e=e+Math.imul(w,lt)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(M,lt)|0,u=u+Math.imul(M,ct)|0;var Et=(s+(e=e+Math.imul(m,dt)|0)|0)+((8191&(i=(i=i+Math.imul(m,gt)|0)+Math.imul(y,dt)|0))<<13)|0;s=((u=u+Math.imul(y,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul($,H),i=(i=Math.imul($,X))+Math.imul(z,H)|0,u=Math.imul(z,X),e=e+Math.imul(U,Q)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(P,Q)|0,u=u+Math.imul(P,tt)|0,e=e+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,et)|0)+Math.imul(j,rt)|0,u=u+Math.imul(j,et)|0,e=e+Math.imul(R,ut)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(I,ut)|0,u=u+Math.imul(I,ot)|0,e=e+Math.imul(k,at)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(E,at)|0,u=u+Math.imul(E,st)|0,e=e+Math.imul(B,lt)|0,i=(i=i+Math.imul(B,ct)|0)+Math.imul(x,lt)|0,u=u+Math.imul(x,ct)|0;var St=(s+(e=e+Math.imul(w,dt)|0)|0)+((8191&(i=(i=i+Math.imul(w,gt)|0)+Math.imul(M,dt)|0))<<13)|0;s=((u=u+Math.imul(M,gt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul($,Q),i=(i=Math.imul($,tt))+Math.imul(z,Q)|0,u=Math.imul(z,tt),e=e+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,et)|0)+Math.imul(P,rt)|0,u=u+Math.imul(P,et)|0,e=e+Math.imul(O,ut)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(j,ut)|0,u=u+Math.imul(j,ot)|0,e=e+Math.imul(R,at)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(I,at)|0,u=u+Math.imul(I,st)|0,e=e+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(E,lt)|0,u=u+Math.imul(E,ct)|0;var Rt=(s+(e=e+Math.imul(B,dt)|0)|0)+((8191&(i=(i=i+Math.imul(B,gt)|0)+Math.imul(x,dt)|0))<<13)|0;s=((u=u+Math.imul(x,gt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul($,rt),i=(i=Math.imul($,et))+Math.imul(z,rt)|0,u=Math.imul(z,et),e=e+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ot)|0)+Math.imul(P,ut)|0,u=u+Math.imul(P,ot)|0,e=e+Math.imul(O,at)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(j,at)|0,u=u+Math.imul(j,st)|0,e=e+Math.imul(R,lt)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(I,lt)|0,u=u+Math.imul(I,ct)|0;var It=(s+(e=e+Math.imul(k,dt)|0)|0)+((8191&(i=(i=i+Math.imul(k,gt)|0)+Math.imul(E,dt)|0))<<13)|0;s=((u=u+Math.imul(E,gt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,e=Math.imul($,ut),i=(i=Math.imul($,ot))+Math.imul(z,ut)|0,u=Math.imul(z,ot),e=e+Math.imul(U,at)|0,i=(i=i+Math.imul(U,st)|0)+Math.imul(P,at)|0,u=u+Math.imul(P,st)|0,e=e+Math.imul(O,lt)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(j,lt)|0,u=u+Math.imul(j,ct)|0;var Tt=(s+(e=e+Math.imul(R,dt)|0)|0)+((8191&(i=(i=i+Math.imul(R,gt)|0)+Math.imul(I,dt)|0))<<13)|0;s=((u=u+Math.imul(I,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,e=Math.imul($,at),i=(i=Math.imul($,st))+Math.imul(z,at)|0,u=Math.imul(z,st),e=e+Math.imul(U,lt)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(P,lt)|0,u=u+Math.imul(P,ct)|0;var Ot=(s+(e=e+Math.imul(O,dt)|0)|0)+((8191&(i=(i=i+Math.imul(O,gt)|0)+Math.imul(j,dt)|0))<<13)|0;s=((u=u+Math.imul(j,gt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,e=Math.imul($,lt),i=(i=Math.imul($,ct))+Math.imul(z,lt)|0,u=Math.imul(z,ct);var jt=(s+(e=e+Math.imul(U,dt)|0)|0)+((8191&(i=(i=i+Math.imul(U,gt)|0)+Math.imul(P,dt)|0))<<13)|0;s=((u=u+Math.imul(P,gt)|0)+(i>>>13)|0)+(jt>>>26)|0,jt&=67108863;var Lt=(s+(e=Math.imul($,dt))|0)+((8191&(i=(i=Math.imul($,gt))+Math.imul(z,dt)|0))<<13)|0;return s=((u=Math.imul(z,gt))+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=vt,a[1]=mt,a[2]=yt,a[3]=_t,a[4]=wt,a[5]=Mt,a[6]=bt,a[7]=Bt,a[8]=xt,a[9]=At,a[10]=kt,a[11]=Et,a[12]=St,a[13]=Rt,a[14]=It,a[15]=Tt,a[16]=Ot,a[17]=jt,a[18]=Lt,0!==s&&(a[19]=s,r.length++),r};Math.imul||(B=a),i.prototype.mulTo=function(t,n){var r=this.length+t.length;return 10===this.length&&10===t.length?B(this,t,n):r<63?a(this,t,n):r<1024?s(this,t,n):h(this,t,n)},l.prototype.makeRBT=function(t){for(var n=new Array(t),r=i.prototype._countBits(t)-1,e=0;e<t;e++)n[e]=this.revBin(e,r,t);return n},l.prototype.revBin=function(t,n,r){if(0===t||t===r-1)return t;for(var e=0,i=0;i<n;i++)e|=(1&t)<<n-i-1,t>>=1;return e},l.prototype.permute=function(t,n,r,e,i,u){for(var o=0;o<u;o++)e[o]=n[t[o]],i[o]=r[t[o]]},l.prototype.transform=function(t,n,r,e,i,u){this.permute(u,t,n,r,e,i);for(var o=1;o<i;o<<=1)for(var f=o<<1,a=Math.cos(2*Math.PI/f),s=Math.sin(2*Math.PI/f),h=0;h<i;h+=f)for(var l=a,c=s,p=0;p<o;p++){var d=r[h+p],g=e[h+p],v=r[h+p+o],m=e[h+p+o],y=l*v-c*m;m=l*m+c*v,v=y,r[h+p]=d+v,e[h+p]=g+m,r[h+p+o]=d-v,e[h+p+o]=g-m,p!==f&&(y=a*l-s*c,c=a*c+s*l,l=y)}},l.prototype.guessLen13b=function(t,n){var r=1|Math.max(n,t),e=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+e},l.prototype.conjugate=function(t,n,r){if(!(r<=1))for(var e=0;e<r/2;e++){var i=t[e];t[e]=t[r-e-1],t[r-e-1]=i,i=n[e],n[e]=-n[r-e-1],n[r-e-1]=-i}},l.prototype.normalize13b=function(t,n){for(var r=0,e=0;e<n/2;e++){var i=8192*Math.round(t[2*e+1]/n)+Math.round(t[2*e]/n)+r;t[e]=67108863&i,r=i<67108864?0:i/67108864|0}return t},l.prototype.convert13b=function(t,n,e,i){for(var u=0,o=0;o<n;o++)u+=0|t[o],e[2*o]=8191&u,u>>>=13,e[2*o+1]=8191&u,u>>>=13;for(o=2*n;o<i;++o)e[o]=0;r(0===u),r(0==(-8192&u))},l.prototype.stub=function(t){for(var n=new Array(t),r=0;r<t;r++)n[r]=0;return n},l.prototype.mulp=function(t,n,r){var e=2*this.guessLen13b(t.length,n.length),i=this.makeRBT(e),u=this.stub(e),o=new Array(e),f=new Array(e),a=new Array(e),s=new Array(e),h=new Array(e),l=new Array(e),c=r.words;c.length=e,this.convert13b(t.words,t.length,o,e),this.convert13b(n.words,n.length,s,e),this.transform(o,u,f,a,e,i),this.transform(s,u,h,l,e,i);for(var p=0;p<e;p++){var d=f[p]*h[p]-a[p]*l[p];a[p]=f[p]*l[p]+a[p]*h[p],f[p]=d}return this.conjugate(f,a,e),this.transform(f,a,c,u,e,i),this.conjugate(c,u,e),this.normalize13b(c,e),r.negative=t.negative^n.negative,r.length=t.length+n.length,r.strip()},i.prototype.mul=function(t){var n=new i(null);return n.words=new Array(this.length+t.length),this.mulTo(t,n)},i.prototype.mulf=function(t){var n=new i(null);return n.words=new Array(this.length+t.length),h(this,t,n)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var n=0,e=0;e<this.length;e++){var i=(0|this.words[e])*t,u=(67108863&i)+(67108863&n);n>>=26,n+=i/67108864|0,n+=u>>>26,this.words[e]=67108863&u}return 0!==n&&(this.words[e]=n,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var n=f(t);if(0===n.length)return new i(1);for(var r=this,e=0;e<n.length&&0===n[e];e++,r=r.sqr());if(++e<n.length)for(var u=r.sqr();e<n.length;e++,u=u.sqr())0!==n[e]&&(r=r.mul(u));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var n,e=t%26,i=(t-e)/26,u=67108863>>>26-e<<26-e;if(0!==e){var o=0;for(n=0;n<this.length;n++){var f=this.words[n]&u,a=(0|this.words[n])-f<<e;this.words[n]=a|o,o=f>>>26-e}o&&(this.words[n]=o,this.length++)}if(0!==i){for(n=this.length-1;n>=0;n--)this.words[n+i]=this.words[n];for(n=0;n<i;n++)this.words[n]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,n,e){r("number"==typeof t&&t>=0);var i;i=n?(n-n%26)/26:0;var u=t%26,o=Math.min((t-u)/26,this.length),f=67108863^67108863>>>u<<u,a=e;if(i-=o,i=Math.max(0,i),a){for(var s=0;s<o;s++)a.words[s]=this.words[s];a.length=o}if(0===o);else if(this.length>o)for(this.length-=o,s=0;s<this.length;s++)this.words[s]=this.words[s+o];else this.words[0]=0,this.length=1;var h=0;for(s=this.length-1;s>=0&&(0!==h||s>=i);s--){var l=0|this.words[s];this.words[s]=h<<26-u|l>>>u,h=l&f}return a&&0!==h&&(a.words[a.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,n,e){return r(0===this.negative),this.iushrn(t,n,e)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var n=t%26,e=(t-n)/26,i=1<<n;return!(this.length<=e)&&!!(this.words[e]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var n=t%26,e=(t-n)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=e)return this;if(0!==n&&e++,this.length=Math.min(e,this.length),0!==n){var i=67108863^67108863>>>n<<n;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var n=0;n<this.length&&this.words[n]>=67108864;n++)this.words[n]-=67108864,n===this.length-1?this.words[n+1]=1:this.words[n+1]++;return this.length=Math.max(this.length,n+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var n=0;n<this.length&&this.words[n]<0;n++)this.words[n]+=67108864,this.words[n+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,n,e){var i,u=t.length+e;this._expand(u);var o,f=0;for(i=0;i<t.length;i++){o=(0|this.words[i+e])+f;var a=(0|t.words[i])*n;f=((o-=67108863&a)>>26)-(a/67108864|0),this.words[i+e]=67108863&o}for(;i<this.length-e;i++)f=(o=(0|this.words[i+e])+f)>>26,this.words[i+e]=67108863&o;if(0===f)return this.strip();for(r(-1===f),f=0,i=0;i<this.length;i++)f=(o=-(0|this.words[i])+f)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,n){var r=this.length-t.length,e=this.clone(),u=t,o=0|u.words[u.length-1];0!==(r=26-this._countBits(o))&&(u=u.ushln(r),e.iushln(r),o=0|u.words[u.length-1]);var f,a=e.length-u.length;if("mod"!==n){(f=new i(null)).length=a+1,f.words=new Array(f.length);for(var s=0;s<f.length;s++)f.words[s]=0}var h=e.clone()._ishlnsubmul(u,1,a);0===h.negative&&(e=h,f&&(f.words[a]=1));for(var l=a-1;l>=0;l--){var c=67108864*(0|e.words[u.length+l])+(0|e.words[u.length+l-1]);for(c=Math.min(c/o|0,67108863),e._ishlnsubmul(u,c,l);0!==e.negative;)c--,e.negative=0,e._ishlnsubmul(u,1,l),e.isZero()||(e.negative^=1);f&&(f.words[l]=c)}return f&&f.strip(),e.strip(),"div"!==n&&0!==r&&e.iushrn(r),{div:f||null,mod:e}},i.prototype.divmod=function(t,n,e){if(r(!t.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var u,o,f;return 0!==this.negative&&0===t.negative?(f=this.neg().divmod(t,n),"mod"!==n&&(u=f.div.neg()),"div"!==n&&(o=f.mod.neg(),e&&0!==o.negative&&o.iadd(t)),{div:u,mod:o}):0===this.negative&&0!==t.negative?(f=this.divmod(t.neg(),n),"mod"!==n&&(u=f.div.neg()),{div:u,mod:f.mod}):0!=(this.negative&t.negative)?(f=this.neg().divmod(t.neg(),n),"div"!==n&&(o=f.mod.neg(),e&&0!==o.negative&&o.isub(t)),{div:f.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===n?{div:this.divn(t.words[0]),mod:null}:"mod"===n?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,n)},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var n=this.divmod(t);if(n.mod.isZero())return n.div;var r=0!==n.div.negative?n.mod.isub(t):n.mod,e=t.ushrn(1),i=t.andln(1),u=r.cmp(e);return u<0||1===i&&0===u?n.div:0!==n.div.negative?n.div.isubn(1):n.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var n=(1<<26)%t,e=0,i=this.length-1;i>=0;i--)e=(n*e+(0|this.words[i]))%t;return e},i.prototype.idivn=function(t){r(t<=67108863);for(var n=0,e=this.length-1;e>=0;e--){var i=(0|this.words[e])+67108864*n;this.words[e]=i/t|0,n=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var n=this,e=t.clone();n=0!==n.negative?n.umod(t):n.clone();for(var u=new i(1),o=new i(0),f=new i(0),a=new i(1),s=0;n.isEven()&&e.isEven();)n.iushrn(1),e.iushrn(1),++s;for(var h=e.clone(),l=n.clone();!n.isZero();){for(var c=0,p=1;0==(n.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(n.iushrn(c);c-- >0;)(u.isOdd()||o.isOdd())&&(u.iadd(h),o.isub(l)),u.iushrn(1),o.iushrn(1);for(var d=0,g=1;0==(e.words[0]&g)&&d<26;++d,g<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(f.isOdd()||a.isOdd())&&(f.iadd(h),a.isub(l)),f.iushrn(1),a.iushrn(1);n.cmp(e)>=0?(n.isub(e),u.isub(f),o.isub(a)):(e.isub(n),f.isub(u),a.isub(o))}return{a:f,b:a,gcd:e.iushln(s)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var n=this,e=t.clone();n=0!==n.negative?n.umod(t):n.clone();for(var u=new i(1),o=new i(0),f=e.clone();n.cmpn(1)>0&&e.cmpn(1)>0;){for(var a=0,s=1;0==(n.words[0]&s)&&a<26;++a,s<<=1);if(a>0)for(n.iushrn(a);a-- >0;)u.isOdd()&&u.iadd(f),u.iushrn(1);for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)o.isOdd()&&o.iadd(f),o.iushrn(1);n.cmp(e)>=0?(n.isub(e),u.isub(o)):(e.isub(n),o.isub(u))}var c;return(c=0===n.cmpn(1)?u:o).cmpn(0)<0&&c.iadd(t),c},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var n=this.clone(),r=t.clone();n.negative=0,r.negative=0;for(var e=0;n.isEven()&&r.isEven();e++)n.iushrn(1),r.iushrn(1);for(;;){for(;n.isEven();)n.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=n.cmp(r);if(i<0){var u=n;n=r,r=u}else if(0===i||0===r.cmpn(1))break;n.isub(r)}return r.iushln(e)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var n=t%26,e=(t-n)/26,i=1<<n;if(this.length<=e)return this._expand(e+1),this.words[e]|=i,this;for(var u=i,o=e;0!==u&&o<this.length;o++){var f=0|this.words[o];u=(f+=u)>>>26,f&=67108863,this.words[o]=f}return 0!==u&&(this.words[o]=u,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;this.strip();var e;if(this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var n=this.ucmp(t);return 0!==this.negative?0|-n:n},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var n=0,r=this.length-1;r>=0;r--){var e=0|this.words[r],i=0|t.words[r];if(e!==i){e<i?n=-1:e>i&&(n=1);break}}return n},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new m(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var x={k256:null,p224:null,p192:null,p25519:null};c.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},c.prototype.ireduce=function(t){var n,r=t;do{this.split(r,this.tmp),n=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(n>this.n);var e=n<this.n?-1:r.ucmp(this.p);return 0===e?(r.words[0]=0,r.length=1):e>0?r.isub(this.p):r.strip(),r},c.prototype.split=function(t,n){t.iushrn(this.n,0,n)},c.prototype.imulK=function(t){return t.imul(this.k)},e(p,c),p.prototype.split=function(t,n){for(var r=Math.min(t.length,9),e=0;e<r;e++)n.words[e]=t.words[e];if(n.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(n.words[n.length++]=4194303&i,e=10;e<t.length;e++){var u=0|t.words[e];t.words[e-10]=(4194303&u)<<4|i>>>22,i=u}i>>>=22,t.words[e-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},p.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var n=0,r=0;r<t.length;r++){var e=0|t.words[r];n+=977*e,t.words[r]=67108863&n,n=64*e+(n/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},e(d,c),e(g,c),e(v,c),v.prototype.imulK=function(t){for(var n=0,r=0;r<t.length;r++){var e=19*(0|t.words[r])+n,i=67108863&e;e>>>=26,t.words[r]=i,n=e}return 0!==n&&(t.words[t.length++]=n),t},i._prime=function(t){if(x[t])return x[t];var n;if("k256"===t)n=new p;else if("p224"===t)n=new d;else if("p192"===t)n=new g;else{if("p25519"!==t)throw new Error("Unknown prime "+t);n=new v}return x[t]=n,n},m.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},m.prototype._verify2=function(t,n){r(0==(t.negative|n.negative),"red works only with positives"),r(t.red&&t.red===n.red,"red works only with red numbers")},m.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},m.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},m.prototype.add=function(t,n){this._verify2(t,n);var r=t.add(n);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},m.prototype.iadd=function(t,n){this._verify2(t,n);var r=t.iadd(n);return r.cmp(this.m)>=0&&r.isub(this.m),r},m.prototype.sub=function(t,n){this._verify2(t,n);var r=t.sub(n);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},m.prototype.isub=function(t,n){this._verify2(t,n);var r=t.isub(n);return r.cmpn(0)<0&&r.iadd(this.m),r},m.prototype.shl=function(t,n){return this._verify1(t),this.imod(t.ushln(n))},m.prototype.imul=function(t,n){return this._verify2(t,n),this.imod(t.imul(n))},m.prototype.mul=function(t,n){return this._verify2(t,n),this.imod(t.mul(n))},m.prototype.isqr=function(t){return this.imul(t,t.clone())},m.prototype.sqr=function(t){return this.mul(t,t)},m.prototype.sqrt=function(t){if(t.isZero())return t.clone();var n=this.m.andln(3);if(r(n%2==1),3===n){var e=this.m.add(new i(1)).iushrn(2);return this.pow(t,e)}for(var u=this.m.subn(1),o=0;!u.isZero()&&0===u.andln(1);)o++,u.iushrn(1);r(!u.isZero());var f=new i(1).toRed(this),a=f.redNeg(),s=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,s).cmp(a);)h.redIAdd(a);for(var l=this.pow(h,u),c=this.pow(t,u.addn(1).iushrn(1)),p=this.pow(t,u),d=o;0!==p.cmp(f);){for(var g=p,v=0;0!==g.cmp(f);v++)g=g.redSqr();r(v<d);var m=this.pow(l,new i(1).iushln(d-v-1));c=c.redMul(m),l=m.redSqr(),p=p.redMul(l),d=v}return c},m.prototype.invm=function(t){var n=t._invmp(this.m);return 0!==n.negative?(n.negative=0,this.imod(n).redNeg()):this.imod(n)},m.prototype.pow=function(t,n){if(n.isZero())return new i(1).toRed(this);if(0===n.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var e=2;e<r.length;e++)r[e]=this.mul(r[e-1],t);var u=r[0],o=0,f=0,a=n.bitLength()%26;for(0===a&&(a=26),e=n.length-1;e>=0;e--){for(var s=n.words[e],h=a-1;h>=0;h--){var l=s>>h&1;u!==r[0]&&(u=this.sqr(u)),0!==l||0!==o?(o<<=1,o|=l,(4===++f||0===e&&0===h)&&(u=this.mul(u,r[o]),f=0,o=0)):f=0}a=26}return u},m.prototype.convertTo=function(t){var n=t.umod(this.m);return n===t?n.clone():n},m.prototype.convertFrom=function(t){var n=t.clone();return n.red=null,n},i.mont=function(t){return new y(t)},e(y,m),y.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},y.prototype.convertFrom=function(t){var n=this.imod(t.mul(this.rinv));return n.red=null,n},y.prototype.imul=function(t,n){if(t.isZero()||n.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(n),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(e).iushrn(this.shift),u=i;return i.cmp(this.m)>=0?u=i.isub(this.m):i.cmpn(0)<0&&(u=i.iadd(this.m)),u._forceRed(this)},y.prototype.mul=function(t,n){if(t.isZero()||n.isZero())return new i(0)._forceRed(this);var r=t.mul(n),e=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=r.isub(e).iushrn(this.shift),o=u;return u.cmp(this.m)>=0?o=u.isub(this.m):u.cmpn(0)<0&&(o=u.iadd(this.m)),o._forceRed(this)},y.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,commonjsGlobal)}),lodash=createCommonjsModule(function(t,n){(function(){function r(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function e(t,n,r,e){for(var i=-1,u=null==t?0:t.length;++i<u;){var o=t[i];n(e,o,r(o),t)}return e}function i(t,n){for(var r=-1,e=null==t?0:t.length;++r<e&&!1!==n(t[r],r,t););return t}function u(t,n){for(var r=null==t?0:t.length;r--&&!1!==n(t[r],r,t););return t}function o(t,n){for(var r=-1,e=null==t?0:t.length;++r<e;)if(!n(t[r],r,t))return!1;return!0}function f(t,n){for(var r=-1,e=null==t?0:t.length,i=0,u=[];++r<e;){var o=t[r];n(o,r,t)&&(u[i++]=o)}return u}function a(t,n){return!!(null==t?0:t.length)&&_(t,n,0)>-1}function s(t,n,r){for(var e=-1,i=null==t?0:t.length;++e<i;)if(r(n,t[e]))return!0;return!1}function h(t,n){for(var r=-1,e=null==t?0:t.length,i=Array(e);++r<e;)i[r]=n(t[r],r,t);return i}function l(t,n){for(var r=-1,e=n.length,i=t.length;++r<e;)t[i+r]=n[r];return t}function c(t,n,r,e){var i=-1,u=null==t?0:t.length;for(e&&u&&(r=t[++i]);++i<u;)r=n(r,t[i],i,t);return r}function p(t,n,r,e){var i=null==t?0:t.length;for(e&&i&&(r=t[--i]);i--;)r=n(r,t[i],i,t);return r}function d(t,n){for(var r=-1,e=null==t?0:t.length;++r<e;)if(n(t[r],r,t))return!0;return!1}function g(t){return t.split("")}function v(t){return t.match(jn)||[]}function m(t,n,r){var e;return r(t,function(t,r,i){if(n(t,r,i))return e=r,!1}),e}function y(t,n,r,e){for(var i=t.length,u=r+(e?1:-1);e?u--:++u<i;)if(n(t[u],u,t))return u;return-1}function _(t,n,r){return n===n?G(t,n,r):y(t,M,r)}function w(t,n,r,e){for(var i=r-1,u=t.length;++i<u;)if(e(t[i],n))return i;return-1}function M(t){return t!==t}function b(t,n){var r=null==t?0:t.length;return r?E(t,n)/r:Tt}function B(t){return function(n){return null==n?tt:n[t]}}function x(t){return function(n){return null==t?tt:t[n]}}function A(t,n,r,e,i){return i(t,function(t,i,u){r=e?(e=!1,t):n(r,t,i,u)}),r}function k(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}function E(t,n){for(var r,e=-1,i=t.length;++e<i;){var u=n(t[e]);u!==tt&&(r=r===tt?u:r+u)}return r}function S(t,n){for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);return e}function R(t,n){return h(n,function(n){return[n,t[n]]})}function I(t){return function(n){return t(n)}}function T(t,n){return h(n,function(n){return t[n]})}function O(t,n){return t.has(n)}function j(t,n){for(var r=-1,e=t.length;++r<e&&_(n,t[r],0)>-1;);return r}function L(t,n){for(var r=t.length;r--&&_(n,t[r],0)>-1;);return r}function U(t,n){for(var r=t.length,e=0;r--;)t[r]===n&&++e;return e}function P(t){return"\\"+yr[t]}function C(t,n){return null==t?tt:t[n]}function $(t){return sr.test(t)}function z(t){return hr.test(t)}function N(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}function q(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}function W(t,n){return function(r){return t(n(r))}}function D(t,n){for(var r=-1,e=t.length,i=0,u=[];++r<e;){var o=t[r];o!==n&&o!==ot||(t[r]=ot,u[i++]=r)}return u}function Y(t,n){return"__proto__"==n?tt:t[n]}function F(t){var n=-1,r=Array(t.size);return t.forEach(function(t){r[++n]=t}),r}function Z(t){var n=-1,r=Array(t.size);return t.forEach(function(t){r[++n]=[t,t]}),r}function G(t,n,r){for(var e=r-1,i=t.length;++e<i;)if(t[e]===n)return e;return-1}function V(t,n,r){for(var e=r+1;e--;)if(t[e]===n)return e;return e}function K(t){return $(t)?X(t):Ur(t)}function H(t){return $(t)?J(t):g(t)}function X(t){for(var n=fr.lastIndex=0;fr.test(t);)++n;return n}function J(t){return t.match(fr)||[]}function Q(t){return t.match(ar)||[]}var tt,nt=200,rt="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",et="Expected a function",it="__lodash_hash_undefined__",ut=500,ot="__lodash_placeholder__",ft=1,at=2,st=4,ht=1,lt=2,ct=1,pt=2,dt=4,gt=8,vt=16,mt=32,yt=64,_t=128,wt=256,Mt=512,bt=30,Bt="...",xt=800,At=16,kt=1,Et=2,St=1/0,Rt=9007199254740991,It=1.7976931348623157e308,Tt=NaN,Ot=4294967295,jt=Ot-1,Lt=Ot>>>1,Ut=[["ary",_t],["bind",ct],["bindKey",pt],["curry",gt],["curryRight",vt],["flip",Mt],["partial",mt],["partialRight",yt],["rearg",wt]],Pt="[object Arguments]",Ct="[object Array]",$t="[object AsyncFunction]",zt="[object Boolean]",Nt="[object Date]",qt="[object DOMException]",Wt="[object Error]",Dt="[object Function]",Yt="[object GeneratorFunction]",Ft="[object Map]",Zt="[object Number]",Gt="[object Null]",Vt="[object Object]",Kt="[object Proxy]",Ht="[object RegExp]",Xt="[object Set]",Jt="[object String]",Qt="[object Symbol]",tn="[object Undefined]",nn="[object WeakMap]",rn="[object WeakSet]",en="[object ArrayBuffer]",un="[object DataView]",on="[object Float32Array]",fn="[object Float64Array]",an="[object Int8Array]",sn="[object Int16Array]",hn="[object Int32Array]",ln="[object Uint8Array]",cn="[object Uint8ClampedArray]",pn="[object Uint16Array]",dn="[object Uint32Array]",gn=/\b__p \+= '';/g,vn=/\b(__p \+=) '' \+/g,mn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,yn=/&(?:amp|lt|gt|quot|#39);/g,_n=/[&<>"']/g,wn=RegExp(yn.source),Mn=RegExp(_n.source),bn=/<%=([\s\S]+?)%>/g,Bn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xn=/^\w*$/,An=/[\\^$.*+?()[\]{}|]/g,kn=RegExp(An.source),En=/^\s+|\s+$/g,Sn=/^\s+/,Rn=/\s+$/,In=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Tn=/\{\n\/\* \[wrapped with (.+)\] \*/,On=/,? & /,jn=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ln=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Un=/\w*$/,Pn=/^[-+]0x[0-9a-f]+$/i,Cn=/^0b[01]+$/i,$n=/^\[object .+?Constructor\]$/,zn=/^0o[0-7]+$/i,Nn=/^(?:0|[1-9]\d*)$/,qn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Wn=/($^)/,Dn=/['\n\r\u2028\u2029\\]/g,Yn="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Fn="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Zn="["+Fn+"]",Gn="["+Yn+"]",Vn="[a-z\\xdf-\\xf6\\xf8-\\xff]",Kn="[^\\ud800-\\udfff"+Fn+"\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",Hn="\\ud83c[\\udffb-\\udfff]",Xn="(?:\\ud83c[\\udde6-\\uddff]){2}",Jn="[\\ud800-\\udbff][\\udc00-\\udfff]",Qn="[A-Z\\xc0-\\xd6\\xd8-\\xde]",tr="(?:"+Vn+"|"+Kn+")",nr="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",rr="[\\ufe0e\\ufe0f]?"+nr+("(?:\\u200d(?:"+["[^\\ud800-\\udfff]",Xn,Jn].join("|")+")[\\ufe0e\\ufe0f]?"+nr+")*"),er="(?:"+["[\\u2700-\\u27bf]",Xn,Jn].join("|")+")"+rr,ir="(?:"+["[^\\ud800-\\udfff]"+Gn+"?",Gn,Xn,Jn,"[\\ud800-\\udfff]"].join("|")+")",ur=RegExp("['’]","g"),or=RegExp(Gn,"g"),fr=RegExp(Hn+"(?="+Hn+")|"+ir+rr,"g"),ar=RegExp([Qn+"?"+Vn+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Zn,Qn,"$"].join("|")+")","(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Zn,Qn+tr,"$"].join("|")+")",Qn+"?"+tr+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Qn+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",er].join("|"),"g"),sr=RegExp("[\\u200d\\ud800-\\udfff"+Yn+"\\ufe0e\\ufe0f]"),hr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,lr=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],cr=-1,pr={};pr[on]=pr[fn]=pr[an]=pr[sn]=pr[hn]=pr[ln]=pr[cn]=pr[pn]=pr[dn]=!0,pr[Pt]=pr[Ct]=pr[en]=pr[zt]=pr[un]=pr[Nt]=pr[Wt]=pr[Dt]=pr[Ft]=pr[Zt]=pr[Vt]=pr[Ht]=pr[Xt]=pr[Jt]=pr[nn]=!1;var dr={};dr[Pt]=dr[Ct]=dr[en]=dr[un]=dr[zt]=dr[Nt]=dr[on]=dr[fn]=dr[an]=dr[sn]=dr[hn]=dr[Ft]=dr[Zt]=dr[Vt]=dr[Ht]=dr[Xt]=dr[Jt]=dr[Qt]=dr[ln]=dr[cn]=dr[pn]=dr[dn]=!0,dr[Wt]=dr[Dt]=dr[nn]=!1;var gr={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},vr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},mr={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},yr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},_r=parseFloat,wr=parseInt,Mr="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,br="object"==typeof self&&self&&self.Object===Object&&self,Br=Mr||br||Function("return this")(),xr=n&&!n.nodeType&&n,Ar=xr&&!0&&t&&!t.nodeType&&t,kr=Ar&&Ar.exports===xr,Er=kr&&Mr.process,Sr=function(){try{var t=Ar&&Ar.require&&Ar.require("util").types;return t||Er&&Er.binding&&Er.binding("util")}catch(t){}}(),Rr=Sr&&Sr.isArrayBuffer,Ir=Sr&&Sr.isDate,Tr=Sr&&Sr.isMap,Or=Sr&&Sr.isRegExp,jr=Sr&&Sr.isSet,Lr=Sr&&Sr.isTypedArray,Ur=B("length"),Pr=x(gr),Cr=x(vr),$r=x(mr),zr=function t(n){function g(t){if(Jf(t)&&!sc(t)&&!(t instanceof X)){if(t instanceof G)return t;if(sh.call(t,"__wrapped__"))return Gu(t)}return new G(t)}function x(){}function G(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=tt}function X(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ot,this.__views__=[]}function J(){var t=new X(this.__wrapped__);return t.__actions__=Ri(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ri(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ri(this.__views__),t}function jn(){if(this.__filtered__){var t=new X(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t}function Yn(){var t=this.__wrapped__.value(),n=this.__dir__,r=sc(t),e=n<0,i=r?t.length:0,u=yu(0,i,this.__views__),o=u.start,f=u.end,a=f-o,s=e?f:o-1,h=this.__iteratees__,l=h.length,c=0,p=zh(a,this.__takeCount__);if(!r||!e&&i==a&&p==a)return ci(t,this.__actions__);var d=[];t:for(;a--&&c<p;){for(var g=-1,v=t[s+=n];++g<l;){var m=h[g],y=m.iteratee,_=m.type,w=y(v);if(_==Et)v=w;else if(!w){if(_==kt)continue t;break t}}d[c++]=v}return d}function Fn(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function Zn(){this.__data__=Kh?Kh(null):{},this.size=0}function Gn(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Vn(t){var n=this.__data__;if(Kh){var r=n[t];return r===it?tt:r}return sh.call(n,t)?n[t]:tt}function Kn(t){var n=this.__data__;return Kh?n[t]!==tt:sh.call(n,t)}function Hn(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Kh&&n===tt?it:n,this}function Xn(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function Jn(){this.__data__=[],this.size=0}function Qn(t){var n=this.__data__,r=Yr(n,t);return!(r<0)&&(r==n.length-1?n.pop():Bh.call(n,r,1),--this.size,!0)}function tr(t){var n=this.__data__,r=Yr(n,t);return r<0?tt:n[r][1]}function nr(t){return Yr(this.__data__,t)>-1}function rr(t,n){var r=this.__data__,e=Yr(r,t);return e<0?(++this.size,r.push([t,n])):r[e][1]=n,this}function er(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function ir(){this.size=0,this.__data__={hash:new Fn,map:new(Fh||Xn),string:new Fn}}function fr(t){var n=du(this,t).delete(t);return this.size-=n?1:0,n}function ar(t){return du(this,t).get(t)}function sr(t){return du(this,t).has(t)}function hr(t,n){var r=du(this,t),e=r.size;return r.set(t,n),this.size+=r.size==e?0:1,this}function gr(t){var n=-1,r=null==t?0:t.length;for(this.__data__=new er;++n<r;)this.add(t[n])}function vr(t){return this.__data__.set(t,it),this}function mr(t){return this.__data__.has(t)}function yr(t){var n=this.__data__=new Xn(t);this.size=n.size}function Mr(){this.__data__=new Xn,this.size=0}function br(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}function xr(t){return this.__data__.get(t)}function Ar(t){return this.__data__.has(t)}function Er(t,n){var r=this.__data__;if(r instanceof Xn){var e=r.__data__;if(!Fh||e.length<nt-1)return e.push([t,n]),this.size=++r.size,this;r=this.__data__=new er(e)}return r.set(t,n),this.size=r.size,this}function Sr(t,n){var r=sc(t),e=!r&&ac(t),i=!r&&!e&&lc(t),u=!r&&!e&&!i&&vc(t),o=r||e||i||u,f=o?S(t.length,rh):[],a=f.length;for(var s in t)!n&&!sh.call(t,s)||o&&("length"==s||i&&("offset"==s||"parent"==s)||u&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||ku(s,a))||f.push(s);return f}function Ur(t){var n=t.length;return n?t[Ge(0,n-1)]:tt}function Nr(t,n){return Du(Ri(t),Hr(n,0,t.length))}function qr(t){return Du(Ri(t))}function Wr(t,n,r){(r===tt||$f(t[n],r))&&(r!==tt||n in t)||Vr(t,n,r)}function Dr(t,n,r){var e=t[n];sh.call(t,n)&&$f(e,r)&&(r!==tt||n in t)||Vr(t,n,r)}function Yr(t,n){for(var r=t.length;r--;)if($f(t[r][0],n))return r;return-1}function Fr(t,n,r,e){return fl(t,function(t,i,u){n(e,t,r(t),u)}),e}function Zr(t,n){return t&&Ii(n,ja(n),t)}function Gr(t,n){return t&&Ii(n,La(n),t)}function Vr(t,n,r){"__proto__"==n&&Eh?Eh(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r}function Kr(t,n){for(var r=-1,e=n.length,i=Ks(e),u=null==t;++r<e;)i[r]=u?tt:Ia(t,n[r]);return i}function Hr(t,n,r){return t===t&&(r!==tt&&(t=t<=r?t:r),n!==tt&&(t=t>=n?t:n)),t}function Xr(t,n,r,e,u,o){var f,a=n&ft,s=n&at,h=n&st;if(r&&(f=u?r(t,e,u,o):r(t)),f!==tt)return f;if(!Xf(t))return t;var l=sc(t);if(l){if(f=Mu(t),!a)return Ri(t,f)}else{var c=_l(t),p=c==Dt||c==Yt;if(lc(t))return _i(t,a);if(c==Vt||c==Pt||p&&!u){if(f=s||p?{}:bu(t),!a)return s?Oi(t,Gr(f,t)):Ti(t,Zr(f,t))}else{if(!dr[c])return u?t:{};f=Bu(t,c,a)}}o||(o=new yr);var d=o.get(t);if(d)return d;if(o.set(t,f),gc(t))return t.forEach(function(e){f.add(Xr(e,n,r,e,t,o))}),f;if(pc(t))return t.forEach(function(e,i){f.set(i,Xr(e,n,r,i,t,o))}),f;var g=h?s?hu:su:s?La:ja,v=l?tt:g(t);return i(v||t,function(e,i){v&&(e=t[i=e]),Dr(f,i,Xr(e,n,r,i,t,o))}),f}function Jr(t){var n=ja(t);return function(r){return Qr(r,t,n)}}function Qr(t,n,r){var e=r.length;if(null==t)return!e;for(t=th(t);e--;){var i=r[e],u=n[i],o=t[i];if(o===tt&&!(i in t)||!u(o))return!1}return!0}function te(t,n,r){if("function"!=typeof t)throw new eh(et);return bl(function(){t.apply(tt,r)},n)}function ne(t,n,r,e){var i=-1,u=a,o=!0,f=t.length,l=[],c=n.length;if(!f)return l;r&&(n=h(n,I(r))),e?(u=s,o=!1):n.length>=nt&&(u=O,o=!1,n=new gr(n));t:for(;++i<f;){var p=t[i],d=null==r?p:r(p);if(p=e||0!==p?p:0,o&&d===d){for(var g=c;g--;)if(n[g]===d)continue t;l.push(p)}else u(n,d,e)||l.push(p)}return l}function re(t,n){var r=!0;return fl(t,function(t,e,i){return r=!!n(t,e,i)}),r}function ee(t,n,r){for(var e=-1,i=t.length;++e<i;){var u=t[e],o=n(u);if(null!=o&&(f===tt?o===o&&!sa(o):r(o,f)))var f=o,a=u}return a}function ie(t,n,r,e){var i=t.length;for((r=ga(r))<0&&(r=-r>i?0:i+r),(e=e===tt||e>i?i:ga(e))<0&&(e+=i),e=r>e?0:va(e);r<e;)t[r++]=n;return t}function ue(t,n){var r=[];return fl(t,function(t,e,i){n(t,e,i)&&r.push(t)}),r}function oe(t,n,r,e,i){var u=-1,o=t.length;for(r||(r=Au),i||(i=[]);++u<o;){var f=t[u];n>0&&r(f)?n>1?oe(f,n-1,r,e,i):l(i,f):e||(i[i.length]=f)}return i}function fe(t,n){return t&&sl(t,n,ja)}function ae(t,n){return t&&hl(t,n,ja)}function se(t,n){return f(n,function(n){return Vf(t[n])})}function he(t,n){for(var r=0,e=(n=mi(n,t)).length;null!=t&&r<e;)t=t[Yu(n[r++])];return r&&r==e?t:tt}function le(t,n,r){var e=n(t);return sc(t)?e:l(e,r(t))}function ce(t){return null==t?t===tt?tn:Gt:kh&&kh in th(t)?mu(t):Cu(t)}function pe(t,n){return t>n}function de(t,n){return null!=t&&sh.call(t,n)}function ge(t,n){return null!=t&&n in th(t)}function ve(t,n,r){return t>=zh(n,r)&&t<$h(n,r)}function me(t,n,r){for(var e=r?s:a,i=t[0].length,u=t.length,o=u,f=Ks(u),l=1/0,c=[];o--;){var p=t[o];o&&n&&(p=h(p,I(n))),l=zh(p.length,l),f[o]=!r&&(n||i>=120&&p.length>=120)?new gr(o&&p):tt}p=t[0];var d=-1,g=f[0];t:for(;++d<i&&c.length<l;){var v=p[d],m=n?n(v):v;if(v=r||0!==v?v:0,!(g?O(g,m):e(c,m,r))){for(o=u;--o;){var y=f[o];if(!(y?O(y,m):e(t[o],m,r)))continue t}g&&g.push(m),c.push(v)}}return c}function ye(t,n,r,e){return fe(t,function(t,i,u){n(e,r(t),i,u)}),e}function _e(t,n,e){var i=null==(t=zu(t,n=mi(n,t)))?t:t[Yu(co(n))];return null==i?tt:r(i,t,e)}function we(t){return Jf(t)&&ce(t)==Pt}function Me(t){return Jf(t)&&ce(t)==en}function be(t){return Jf(t)&&ce(t)==Nt}function Be(t,n,r,e,i){return t===n||(null==t||null==n||!Jf(t)&&!Jf(n)?t!==t&&n!==n:xe(t,n,r,e,Be,i))}function xe(t,n,r,e,i,u){var o=sc(t),f=sc(n),a=o?Ct:_l(t),s=f?Ct:_l(n),h=(a=a==Pt?Vt:a)==Vt,l=(s=s==Pt?Vt:s)==Vt,c=a==s;if(c&&lc(t)){if(!lc(n))return!1;o=!0,h=!1}if(c&&!h)return u||(u=new yr),o||vc(t)?uu(t,n,r,e,i,u):ou(t,n,a,r,e,i,u);if(!(r&ht)){var p=h&&sh.call(t,"__wrapped__"),d=l&&sh.call(n,"__wrapped__");if(p||d){var g=p?t.value():t,v=d?n.value():n;return u||(u=new yr),i(g,v,r,e,u)}}return!!c&&(u||(u=new yr),fu(t,n,r,e,i,u))}function Ae(t){return Jf(t)&&_l(t)==Ft}function ke(t,n,r,e){var i=r.length,u=i,o=!e;if(null==t)return!u;for(t=th(t);i--;){var f=r[i];if(o&&f[2]?f[1]!==t[f[0]]:!(f[0]in t))return!1}for(;++i<u;){var a=(f=r[i])[0],s=t[a],h=f[1];if(o&&f[2]){if(s===tt&&!(a in t))return!1}else{var l=new yr;if(e)var c=e(s,h,a,t,n,l);if(!(c===tt?Be(h,s,ht|lt,e,l):c))return!1}}return!0}function Ee(t){return!(!Xf(t)||Tu(t))&&(Vf(t)?gh:$n).test(Fu(t))}function Se(t){return Jf(t)&&ce(t)==Ht}function Re(t){return Jf(t)&&_l(t)==Xt}function Ie(t){return Jf(t)&&Hf(t.length)&&!!pr[ce(t)]}function Te(t){return"function"==typeof t?t:null==t?Bs:"object"==typeof t?sc(t)?Ce(t[0],t[1]):Pe(t):Ts(t)}function Oe(t){if(!Ou(t))return Ch(t);var n=[];for(var r in th(t))sh.call(t,r)&&"constructor"!=r&&n.push(r);return n}function je(t){if(!Xf(t))return Pu(t);var n=Ou(t),r=[];for(var e in t)("constructor"!=e||!n&&sh.call(t,e))&&r.push(e);return r}function Le(t,n){return t<n}function Ue(t,n){var r=-1,e=zf(t)?Ks(t.length):[];return fl(t,function(t,i,u){e[++r]=n(t,i,u)}),e}function Pe(t){var n=gu(t);return 1==n.length&&n[0][2]?Lu(n[0][0],n[0][1]):function(r){return r===t||ke(r,t,n)}}function Ce(t,n){return Su(t)&&ju(n)?Lu(Yu(t),n):function(r){var e=Ia(r,t);return e===tt&&e===n?Oa(r,t):Be(n,e,ht|lt)}}function $e(t,n,r,e,i){t!==n&&sl(n,function(u,o){if(Xf(u))i||(i=new yr),ze(t,n,o,r,$e,e,i);else{var f=e?e(Y(t,o),u,o+"",t,n,i):tt;f===tt&&(f=u),Wr(t,o,f)}},La)}function ze(t,n,r,e,i,u,o){var f=Y(t,r),a=Y(n,r),s=o.get(a);if(s)return void Wr(t,r,s);var h=u?u(f,a,r+"",t,n,o):tt,l=h===tt;if(l){var c=sc(a),p=!c&&lc(a),d=!c&&!p&&vc(a);h=a,c||p||d?sc(f)?h=f:Nf(f)?h=Ri(f):p?(l=!1,h=_i(a,!0)):d?(l=!1,h=xi(a,!0)):h=[]:oa(a)||ac(a)?(h=f,ac(f)?h=ya(f):(!Xf(f)||e&&Vf(f))&&(h=bu(a))):l=!1}l&&(o.set(a,h),i(h,a,e,u,o),o.delete(a)),Wr(t,r,h)}function Ne(t,n){var r=t.length;if(r)return n+=n<0?r:0,ku(n,r)?t[n]:tt}function qe(t,n,r){var e=-1;return n=h(n.length?n:[Bs],I(pu())),k(Ue(t,function(t,r,i){return{criteria:h(n,function(n){return n(t)}),index:++e,value:t}}),function(t,n){return ki(t,n,r)})}function We(t,n){return De(t,n,function(n,r){return Oa(t,r)})}function De(t,n,r){for(var e=-1,i=n.length,u={};++e<i;){var o=n[e],f=he(t,o);r(f,o)&&Qe(u,mi(o,t),f)}return u}function Ye(t){return function(n){return he(n,t)}}function Fe(t,n,r,e){var i=e?w:_,u=-1,o=n.length,f=t;for(t===n&&(n=Ri(n)),r&&(f=h(t,I(r)));++u<o;)for(var a=0,s=n[u],l=r?r(s):s;(a=i(f,l,a,e))>-1;)f!==t&&Bh.call(f,a,1),Bh.call(t,a,1);return t}function Ze(t,n){for(var r=t?n.length:0,e=r-1;r--;){var i=n[r];if(r==e||i!==u){var u=i;ku(i)?Bh.call(t,i,1):si(t,i)}}return t}function Ge(t,n){return t+Oh(Wh()*(n-t+1))}function Ve(t,n,r,e){for(var i=-1,u=$h(Th((n-t)/(r||1)),0),o=Ks(u);u--;)o[e?u:++i]=t,t+=r;return o}function Ke(t,n){var r="";if(!t||n<1||n>Rt)return r;do{n%2&&(r+=t),(n=Oh(n/2))&&(t+=t)}while(n);return r}function He(t,n){return Bl($u(t,n,Bs),t+"")}function Xe(t){return Ur(Za(t))}function Je(t,n){var r=Za(t);return Du(r,Hr(n,0,r.length))}function Qe(t,n,r,e){if(!Xf(t))return t;for(var i=-1,u=(n=mi(n,t)).length,o=u-1,f=t;null!=f&&++i<u;){var a=Yu(n[i]),s=r;if(i!=o){var h=f[a];(s=e?e(h,a,f):tt)===tt&&(s=Xf(h)?h:ku(n[i+1])?[]:{})}Dr(f,a,s),f=f[a]}return t}function ti(t){return Du(Za(t))}function ni(t,n,r){var e=-1,i=t.length;n<0&&(n=-n>i?0:i+n),(r=r>i?i:r)<0&&(r+=i),i=n>r?0:r-n>>>0,n>>>=0;for(var u=Ks(i);++e<i;)u[e]=t[e+n];return u}function ri(t,n){var r;return fl(t,function(t,e,i){return!(r=n(t,e,i))}),!!r}function ei(t,n,r){var e=0,i=null==t?e:t.length;if("number"==typeof n&&n===n&&i<=Lt){for(;e<i;){var u=e+i>>>1,o=t[u];null!==o&&!sa(o)&&(r?o<=n:o<n)?e=u+1:i=u}return i}return ii(t,n,Bs,r)}function ii(t,n,r,e){n=r(n);for(var i=0,u=null==t?0:t.length,o=n!==n,f=null===n,a=sa(n),s=n===tt;i<u;){var h=Oh((i+u)/2),l=r(t[h]),c=l!==tt,p=null===l,d=l===l,g=sa(l);if(o)var v=e||d;else v=s?d&&(e||c):f?d&&c&&(e||!p):a?d&&c&&!p&&(e||!g):!p&&!g&&(e?l<=n:l<n);v?i=h+1:u=h}return zh(u,jt)}function ui(t,n){for(var r=-1,e=t.length,i=0,u=[];++r<e;){var o=t[r],f=n?n(o):o;if(!r||!$f(f,a)){var a=f;u[i++]=0===o?0:o}}return u}function oi(t){return"number"==typeof t?t:sa(t)?Tt:+t}function fi(t){if("string"==typeof t)return t;if(sc(t))return h(t,fi)+"";if(sa(t))return ul?ul.call(t):"";var n=t+"";return"0"==n&&1/t==-St?"-0":n}function ai(t,n,r){var e=-1,i=a,u=t.length,o=!0,f=[],h=f;if(r)o=!1,i=s;else if(u>=nt){var l=n?null:gl(t);if(l)return F(l);o=!1,i=O,h=new gr}else h=n?[]:f;t:for(;++e<u;){var c=t[e],p=n?n(c):c;if(c=r||0!==c?c:0,o&&p===p){for(var d=h.length;d--;)if(h[d]===p)continue t;n&&h.push(p),f.push(c)}else i(h,p,r)||(h!==f&&h.push(p),f.push(c))}return f}function si(t,n){return n=mi(n,t),null==(t=zu(t,n))||delete t[Yu(co(n))]}function hi(t,n,r,e){return Qe(t,n,r(he(t,n)),e)}function li(t,n,r,e){for(var i=t.length,u=e?i:-1;(e?u--:++u<i)&&n(t[u],u,t););return r?ni(t,e?0:u,e?u+1:i):ni(t,e?u+1:0,e?i:u)}function ci(t,n){var r=t;return r instanceof X&&(r=r.value()),c(n,function(t,n){return n.func.apply(n.thisArg,l([t],n.args))},r)}function pi(t,n,r){var e=t.length;if(e<2)return e?ai(t[0]):[];for(var i=-1,u=Ks(e);++i<e;)for(var o=t[i],f=-1;++f<e;)f!=i&&(u[i]=ne(u[i]||o,t[f],n,r));return ai(oe(u,1),n,r)}function di(t,n,r){for(var e=-1,i=t.length,u=n.length,o={};++e<i;){var f=e<u?n[e]:tt;r(o,t[e],f)}return o}function gi(t){return Nf(t)?t:[]}function vi(t){return"function"==typeof t?t:Bs}function mi(t,n){return sc(t)?t:Su(t,n)?[t]:xl(wa(t))}function yi(t,n,r){var e=t.length;return r=r===tt?e:r,!n&&r>=e?t:ni(t,n,r)}function _i(t,n){if(n)return t.slice();var r=t.length,e=_h?_h(r):new t.constructor(r);return t.copy(e),e}function wi(t){var n=new t.constructor(t.byteLength);return new yh(n).set(new yh(t)),n}function Mi(t,n){var r=n?wi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function bi(t){var n=new t.constructor(t.source,Un.exec(t));return n.lastIndex=t.lastIndex,n}function Bi(t){return il?th(il.call(t)):{}}function xi(t,n){var r=n?wi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Ai(t,n){if(t!==n){var r=t!==tt,e=null===t,i=t===t,u=sa(t),o=n!==tt,f=null===n,a=n===n,s=sa(n);if(!f&&!s&&!u&&t>n||u&&o&&a&&!f&&!s||e&&o&&a||!r&&a||!i)return 1;if(!e&&!u&&!s&&t<n||s&&r&&i&&!e&&!u||f&&r&&i||!o&&i||!a)return-1}return 0}function ki(t,n,r){for(var e=-1,i=t.criteria,u=n.criteria,o=i.length,f=r.length;++e<o;){var a=Ai(i[e],u[e]);if(a)return e>=f?a:a*("desc"==r[e]?-1:1)}return t.index-n.index}function Ei(t,n,r,e){for(var i=-1,u=t.length,o=r.length,f=-1,a=n.length,s=$h(u-o,0),h=Ks(a+s),l=!e;++f<a;)h[f]=n[f];for(;++i<o;)(l||i<u)&&(h[r[i]]=t[i]);for(;s--;)h[f++]=t[i++];return h}function Si(t,n,r,e){for(var i=-1,u=t.length,o=-1,f=r.length,a=-1,s=n.length,h=$h(u-f,0),l=Ks(h+s),c=!e;++i<h;)l[i]=t[i];for(var p=i;++a<s;)l[p+a]=n[a];for(;++o<f;)(c||i<u)&&(l[p+r[o]]=t[i++]);return l}function Ri(t,n){var r=-1,e=t.length;for(n||(n=Ks(e));++r<e;)n[r]=t[r];return n}function Ii(t,n,r,e){var i=!r;r||(r={});for(var u=-1,o=n.length;++u<o;){var f=n[u],a=e?e(r[f],t[f],f,r,t):tt;a===tt&&(a=t[f]),i?Vr(r,f,a):Dr(r,f,a)}return r}function Ti(t,n){return Ii(t,ml(t),n)}function Oi(t,n){return Ii(t,yl(t),n)}function ji(t,n){return function(r,i){var u=sc(r)?e:Fr,o=n?n():{};return u(r,t,pu(i,2),o)}}function Li(t){return He(function(n,r){var e=-1,i=r.length,u=i>1?r[i-1]:tt,o=i>2?r[2]:tt;for(u=t.length>3&&"function"==typeof u?(i--,u):tt,o&&Eu(r[0],r[1],o)&&(u=i<3?tt:u,i=1),n=th(n);++e<i;){var f=r[e];f&&t(n,f,e,u)}return n})}function Ui(t,n){return function(r,e){if(null==r)return r;if(!zf(r))return t(r,e);for(var i=r.length,u=n?i:-1,o=th(r);(n?u--:++u<i)&&!1!==e(o[u],u,o););return r}}function Pi(t){return function(n,r,e){for(var i=-1,u=th(n),o=e(n),f=o.length;f--;){var a=o[t?f:++i];if(!1===r(u[a],a,u))break}return n}}function Ci(t,n,r){function e(){return(this&&this!==Br&&this instanceof e?u:t).apply(i?r:this,arguments)}var i=n&ct,u=Ni(t);return e}function $i(t){return function(n){var r=$(n=wa(n))?H(n):tt,e=r?r[0]:n.charAt(0),i=r?yi(r,1).join(""):n.slice(1);return e[t]()+i}}function zi(t){return function(n){return c(ys(Ja(n).replace(ur,"")),t,"")}}function Ni(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var r=ol(t.prototype),e=t.apply(r,n);return Xf(e)?e:r}}function qi(t,n,e){function i(){for(var o=arguments.length,f=Ks(o),a=o,s=cu(i);a--;)f[a]=arguments[a];var h=o<3&&f[0]!==s&&f[o-1]!==s?[]:D(f,s);return(o-=h.length)<e?Ji(t,n,Yi,i.placeholder,tt,f,h,tt,tt,e-o):r(this&&this!==Br&&this instanceof i?u:t,this,f)}var u=Ni(t);return i}function Wi(t){return function(n,r,e){var i=th(n);if(!zf(n)){var u=pu(r,3);n=ja(n),r=function(t){return u(i[t],t,i)}}var o=t(n,r,e);return o>-1?i[u?n[o]:o]:tt}}function Di(t){return au(function(n){var r=n.length,e=r,i=G.prototype.thru;for(t&&n.reverse();e--;){var u=n[e];if("function"!=typeof u)throw new eh(et);if(i&&!o&&"wrapper"==lu(u))var o=new G([],!0)}for(e=o?e:r;++e<r;){var f=lu(u=n[e]),a="wrapper"==f?vl(u):tt;o=a&&Iu(a[0])&&a[1]==(_t|gt|mt|wt)&&!a[4].length&&1==a[9]?o[lu(a[0])].apply(o,a[3]):1==u.length&&Iu(u)?o[f]():o.thru(u)}return function(){var t=arguments,e=t[0];if(o&&1==t.length&&sc(e))return o.plant(e).value();for(var i=0,u=r?n[i].apply(this,t):e;++i<r;)u=n[i].call(this,u);return u}})}function Yi(t,n,r,e,i,u,o,f,a,s){function h(){for(var m=arguments.length,y=Ks(m),_=m;_--;)y[_]=arguments[_];if(d)var w=cu(h),M=U(y,w);if(e&&(y=Ei(y,e,i,d)),u&&(y=Si(y,u,o,d)),m-=M,d&&m<s){var b=D(y,w);return Ji(t,n,Yi,h.placeholder,r,y,b,f,a,s-m)}var B=c?r:this,x=p?B[t]:t;return m=y.length,f?y=Nu(y,f):g&&m>1&&y.reverse(),l&&a<m&&(y.length=a),this&&this!==Br&&this instanceof h&&(x=v||Ni(x)),x.apply(B,y)}var l=n&_t,c=n&ct,p=n&pt,d=n&(gt|vt),g=n&Mt,v=p?tt:Ni(t);return h}function Fi(t,n){return function(r,e){return ye(r,t,n(e),{})}}function Zi(t,n){return function(r,e){var i;if(r===tt&&e===tt)return n;if(r!==tt&&(i=r),e!==tt){if(i===tt)return e;"string"==typeof r||"string"==typeof e?(r=fi(r),e=fi(e)):(r=oi(r),e=oi(e)),i=t(r,e)}return i}}function Gi(t){return au(function(n){return n=h(n,I(pu())),He(function(e){var i=this;return t(n,function(t){return r(t,i,e)})})})}function Vi(t,n){var r=(n=n===tt?" ":fi(n)).length;if(r<2)return r?Ke(n,t):n;var e=Ke(n,Th(t/K(n)));return $(n)?yi(H(e),0,t).join(""):e.slice(0,t)}function Ki(t,n,e,i){function u(){for(var n=-1,a=arguments.length,s=-1,h=i.length,l=Ks(h+a),c=this&&this!==Br&&this instanceof u?f:t;++s<h;)l[s]=i[s];for(;a--;)l[s++]=arguments[++n];return r(c,o?e:this,l)}var o=n&ct,f=Ni(t);return u}function Hi(t){return function(n,r,e){return e&&"number"!=typeof e&&Eu(n,r,e)&&(r=e=tt),n=da(n),r===tt?(r=n,n=0):r=da(r),e=e===tt?n<r?1:-1:da(e),Ve(n,r,e,t)}}function Xi(t){return function(n,r){return"string"==typeof n&&"string"==typeof r||(n=ma(n),r=ma(r)),t(n,r)}}function Ji(t,n,r,e,i,u,o,f,a,s){var h=n&gt,l=h?o:tt,c=h?tt:o,p=h?u:tt,d=h?tt:u;n|=h?mt:yt,(n&=~(h?yt:mt))&dt||(n&=~(ct|pt));var g=[t,n,i,p,l,d,c,f,a,s],v=r.apply(tt,g);return Iu(t)&&Ml(v,g),v.placeholder=e,qu(v,t,n)}function Qi(t){var n=Qs[t];return function(t,r){if(t=ma(t),r=null==r?0:zh(ga(r),292)){var e=(wa(t)+"e").split("e");return+((e=(wa(n(e[0]+"e"+(+e[1]+r)))+"e").split("e"))[0]+"e"+(+e[1]-r))}return n(t)}}function tu(t){return function(n){var r=_l(n);return r==Ft?q(n):r==Xt?Z(n):R(n,t(n))}}function nu(t,n,r,e,i,u,o,f){var a=n&pt;if(!a&&"function"!=typeof t)throw new eh(et);var s=e?e.length:0;if(s||(n&=~(mt|yt),e=i=tt),o=o===tt?o:$h(ga(o),0),f=f===tt?f:ga(f),s-=i?i.length:0,n&yt){var h=e,l=i;e=i=tt}var c=a?tt:vl(t),p=[t,n,r,e,i,h,l,u,o,f];if(c&&Uu(p,c),t=p[0],n=p[1],r=p[2],e=p[3],i=p[4],!(f=p[9]=p[9]===tt?a?0:t.length:$h(p[9]-s,0))&&n&(gt|vt)&&(n&=~(gt|vt)),n&&n!=ct)d=n==gt||n==vt?qi(t,n,f):n!=mt&&n!=(ct|mt)||i.length?Yi.apply(tt,p):Ki(t,n,r,e);else var d=Ci(t,n,r);return qu((c?ll:Ml)(d,p),t,n)}function ru(t,n,r,e){return t===tt||$f(t,oh[r])&&!sh.call(e,r)?n:t}function eu(t,n,r,e,i,u){return Xf(t)&&Xf(n)&&(u.set(n,t),$e(t,n,tt,eu,u),u.delete(n)),t}function iu(t){return oa(t)?tt:t}function uu(t,n,r,e,i,u){var o=r&ht,f=t.length,a=n.length;if(f!=a&&!(o&&a>f))return!1;var s=u.get(t);if(s&&u.get(n))return s==n;var h=-1,l=!0,c=r&lt?new gr:tt;for(u.set(t,n),u.set(n,t);++h<f;){var p=t[h],g=n[h];if(e)var v=o?e(g,p,h,n,t,u):e(p,g,h,t,n,u);if(v!==tt){if(v)continue;l=!1;break}if(c){if(!d(n,function(t,n){if(!O(c,n)&&(p===t||i(p,t,r,e,u)))return c.push(n)})){l=!1;break}}else if(p!==g&&!i(p,g,r,e,u)){l=!1;break}}return u.delete(t),u.delete(n),l}function ou(t,n,r,e,i,u,o){switch(r){case un:if(t.byteLength!=n.byteLength||t.byteOffset!=n.byteOffset)return!1;t=t.buffer,n=n.buffer;case en:return!(t.byteLength!=n.byteLength||!u(new yh(t),new yh(n)));case zt:case Nt:case Zt:return $f(+t,+n);case Wt:return t.name==n.name&&t.message==n.message;case Ht:case Jt:return t==n+"";case Ft:var f=q;case Xt:var a=e&ht;if(f||(f=F),t.size!=n.size&&!a)return!1;var s=o.get(t);if(s)return s==n;e|=lt,o.set(t,n);var h=uu(f(t),f(n),e,i,u,o);return o.delete(t),h;case Qt:if(il)return il.call(t)==il.call(n)}return!1}function fu(t,n,r,e,i,u){var o=r&ht,f=su(t),a=f.length;if(a!=su(n).length&&!o)return!1;for(var s=a;s--;){var h=f[s];if(!(o?h in n:sh.call(n,h)))return!1}var l=u.get(t);if(l&&u.get(n))return l==n;var c=!0;u.set(t,n),u.set(n,t);for(var p=o;++s<a;){var d=t[h=f[s]],g=n[h];if(e)var v=o?e(g,d,h,n,t,u):e(d,g,h,t,n,u);if(!(v===tt?d===g||i(d,g,r,e,u):v)){c=!1;break}p||(p="constructor"==h)}if(c&&!p){var m=t.constructor,y=n.constructor;m!=y&&"constructor"in t&&"constructor"in n&&!("function"==typeof m&&m instanceof m&&"function"==typeof y&&y instanceof y)&&(c=!1)}return u.delete(t),u.delete(n),c}function au(t){return Bl($u(t,tt,io),t+"")}function su(t){return le(t,ja,ml)}function hu(t){return le(t,La,yl)}function lu(t){for(var n=t.name+"",r=Xh[n],e=sh.call(Xh,n)?r.length:0;e--;){var i=r[e],u=i.func;if(null==u||u==t)return i.name}return n}function cu(t){return(sh.call(g,"placeholder")?g:t).placeholder}function pu(){var t=g.iteratee||xs;return t=t===xs?Te:t,arguments.length?t(arguments[0],arguments[1]):t}function du(t,n){var r=t.__data__;return Ru(n)?r["string"==typeof n?"string":"hash"]:r.map}function gu(t){for(var n=ja(t),r=n.length;r--;){var e=n[r],i=t[e];n[r]=[e,i,ju(i)]}return n}function vu(t,n){var r=C(t,n);return Ee(r)?r:tt}function mu(t){var n=sh.call(t,kh),r=t[kh];try{t[kh]=tt;var e=!0}catch(t){}var i=ch.call(t);return e&&(n?t[kh]=r:delete t[kh]),i}function yu(t,n,r){for(var e=-1,i=r.length;++e<i;){var u=r[e],o=u.size;switch(u.type){case"drop":t+=o;break;case"dropRight":n-=o;break;case"take":n=zh(n,t+o);break;case"takeRight":t=$h(t,n-o)}}return{start:t,end:n}}function _u(t){var n=t.match(Tn);return n?n[1].split(On):[]}function wu(t,n,r){for(var e=-1,i=(n=mi(n,t)).length,u=!1;++e<i;){var o=Yu(n[e]);if(!(u=null!=t&&r(t,o)))break;t=t[o]}return u||++e!=i?u:!!(i=null==t?0:t.length)&&Hf(i)&&ku(o,i)&&(sc(t)||ac(t))}function Mu(t){var n=t.length,r=new t.constructor(n);return n&&"string"==typeof t[0]&&sh.call(t,"index")&&(r.index=t.index,r.input=t.input),r}function bu(t){return"function"!=typeof t.constructor||Ou(t)?{}:ol(wh(t))}function Bu(t,n,r){var e=t.constructor;switch(n){case en:return wi(t);case zt:case Nt:return new e(+t);case un:return Mi(t,r);case on:case fn:case an:case sn:case hn:case ln:case cn:case pn:case dn:return xi(t,r);case Ft:return new e;case Zt:case Jt:return new e(t);case Ht:return bi(t);case Xt:return new e;case Qt:return Bi(t)}}function xu(t,n){var r=n.length;if(!r)return t;var e=r-1;return n[e]=(r>1?"& ":"")+n[e],n=n.join(r>2?", ":" "),t.replace(In,"{\n/* [wrapped with "+n+"] */\n")}function Au(t){return sc(t)||ac(t)||!!(xh&&t&&t[xh])}function ku(t,n){var r=typeof t;return!!(n=null==n?Rt:n)&&("number"==r||"symbol"!=r&&Nn.test(t))&&t>-1&&t%1==0&&t<n}function Eu(t,n,r){if(!Xf(r))return!1;var e=typeof n;return!!("number"==e?zf(r)&&ku(n,r.length):"string"==e&&n in r)&&$f(r[n],t)}function Su(t,n){if(sc(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!sa(t))||(xn.test(t)||!Bn.test(t)||null!=n&&t in th(n))}function Ru(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t}function Iu(t){var n=lu(t),r=g[n];if("function"!=typeof r||!(n in X.prototype))return!1;if(t===r)return!0;var e=vl(r);return!!e&&t===e[0]}function Tu(t){return!!lh&&lh in t}function Ou(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||oh)}function ju(t){return t===t&&!Xf(t)}function Lu(t,n){return function(r){return null!=r&&(r[t]===n&&(n!==tt||t in th(r)))}}function Uu(t,n){var r=t[1],e=n[1],i=r|e,u=i<(ct|pt|_t),o=e==_t&&r==gt||e==_t&&r==wt&&t[7].length<=n[8]||e==(_t|wt)&&n[7].length<=n[8]&&r==gt;if(!u&&!o)return t;e&ct&&(t[2]=n[2],i|=r&ct?0:dt);var f=n[3];if(f){var a=t[3];t[3]=a?Ei(a,f,n[4]):f,t[4]=a?D(t[3],ot):n[4]}return(f=n[5])&&(a=t[5],t[5]=a?Si(a,f,n[6]):f,t[6]=a?D(t[5],ot):n[6]),(f=n[7])&&(t[7]=f),e&_t&&(t[8]=null==t[8]?n[8]:zh(t[8],n[8])),null==t[9]&&(t[9]=n[9]),t[0]=n[0],t[1]=i,t}function Pu(t){var n=[];if(null!=t)for(var r in th(t))n.push(r);return n}function Cu(t){return ch.call(t)}function $u(t,n,e){return n=$h(n===tt?t.length-1:n,0),function(){for(var i=arguments,u=-1,o=$h(i.length-n,0),f=Ks(o);++u<o;)f[u]=i[n+u];u=-1;for(var a=Ks(n+1);++u<n;)a[u]=i[u];return a[n]=e(f),r(t,this,a)}}function zu(t,n){return n.length<2?t:he(t,ni(n,0,-1))}function Nu(t,n){for(var r=t.length,e=zh(n.length,r),i=Ri(t);e--;){var u=n[e];t[e]=ku(u,r)?i[u]:tt}return t}function qu(t,n,r){var e=n+"";return Bl(t,xu(e,Zu(_u(e),r)))}function Wu(t){var n=0,r=0;return function(){var e=Nh(),i=At-(e-r);if(r=e,i>0){if(++n>=xt)return arguments[0]}else n=0;return t.apply(tt,arguments)}}function Du(t,n){var r=-1,e=t.length,i=e-1;for(n=n===tt?e:n;++r<n;){var u=Ge(r,i),o=t[u];t[u]=t[r],t[r]=o}return t.length=n,t}function Yu(t){if("string"==typeof t||sa(t))return t;var n=t+"";return"0"==n&&1/t==-St?"-0":n}function Fu(t){if(null!=t){try{return ah.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Zu(t,n){return i(Ut,function(r){var e="_."+r[0];n&r[1]&&!a(t,e)&&t.push(e)}),t.sort()}function Gu(t){if(t instanceof X)return t.clone();var n=new G(t.__wrapped__,t.__chain__);return n.__actions__=Ri(t.__actions__),n.__index__=t.__index__,n.__values__=t.__values__,n}function Vu(t,n,r){n=(r?Eu(t,n,r):n===tt)?1:$h(ga(n),0);var e=null==t?0:t.length;if(!e||n<1)return[];for(var i=0,u=0,o=Ks(Th(e/n));i<e;)o[u++]=ni(t,i,i+=n);return o}function Ku(t){for(var n=-1,r=null==t?0:t.length,e=0,i=[];++n<r;){var u=t[n];u&&(i[e++]=u)}return i}function Hu(){var t=arguments.length;if(!t)return[];for(var n=Ks(t-1),r=arguments[0],e=t;e--;)n[e-1]=arguments[e];return l(sc(r)?Ri(r):[r],oe(n,1))}function Xu(t,n,r){var e=null==t?0:t.length;return e?(n=r||n===tt?1:ga(n),ni(t,n<0?0:n,e)):[]}function Ju(t,n,r){var e=null==t?0:t.length;return e?(n=r||n===tt?1:ga(n),n=e-n,ni(t,0,n<0?0:n)):[]}function Qu(t,n){return t&&t.length?li(t,pu(n,3),!0,!0):[]}function to(t,n){return t&&t.length?li(t,pu(n,3),!0):[]}function no(t,n,r,e){var i=null==t?0:t.length;return i?(r&&"number"!=typeof r&&Eu(t,n,r)&&(r=0,e=i),ie(t,n,r,e)):[]}function ro(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var i=null==r?0:ga(r);return i<0&&(i=$h(e+i,0)),y(t,pu(n,3),i)}function eo(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var i=e-1;return r!==tt&&(i=ga(r),i=r<0?$h(e+i,0):zh(i,e-1)),y(t,pu(n,3),i,!0)}function io(t){return(null==t?0:t.length)?oe(t,1):[]}function uo(t){return(null==t?0:t.length)?oe(t,St):[]}function oo(t,n){return(null==t?0:t.length)?(n=n===tt?1:ga(n),oe(t,n)):[]}function fo(t){for(var n=-1,r=null==t?0:t.length,e={};++n<r;){var i=t[n];e[i[0]]=i[1]}return e}function ao(t){return t&&t.length?t[0]:tt}function so(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var i=null==r?0:ga(r);return i<0&&(i=$h(e+i,0)),_(t,n,i)}function ho(t){return(null==t?0:t.length)?ni(t,0,-1):[]}function lo(t,n){return null==t?"":Ph.call(t,n)}function co(t){var n=null==t?0:t.length;return n?t[n-1]:tt}function po(t,n,r){var e=null==t?0:t.length;if(!e)return-1;var i=e;return r!==tt&&(i=(i=ga(r))<0?$h(e+i,0):zh(i,e-1)),n===n?V(t,n,i):y(t,M,i,!0)}function go(t,n){return t&&t.length?Ne(t,ga(n)):tt}function vo(t,n){return t&&t.length&&n&&n.length?Fe(t,n):t}function mo(t,n,r){return t&&t.length&&n&&n.length?Fe(t,n,pu(r,2)):t}function yo(t,n,r){return t&&t.length&&n&&n.length?Fe(t,n,tt,r):t}function _o(t,n){var r=[];if(!t||!t.length)return r;var e=-1,i=[],u=t.length;for(n=pu(n,3);++e<u;){var o=t[e];n(o,e,t)&&(r.push(o),i.push(e))}return Ze(t,i),r}function wo(t){return null==t?t:Dh.call(t)}function Mo(t,n,r){var e=null==t?0:t.length;return e?(r&&"number"!=typeof r&&Eu(t,n,r)?(n=0,r=e):(n=null==n?0:ga(n),r=r===tt?e:ga(r)),ni(t,n,r)):[]}function bo(t,n){return ei(t,n)}function Bo(t,n,r){return ii(t,n,pu(r,2))}function xo(t,n){var r=null==t?0:t.length;if(r){var e=ei(t,n);if(e<r&&$f(t[e],n))return e}return-1}function Ao(t,n){return ei(t,n,!0)}function ko(t,n,r){return ii(t,n,pu(r,2),!0)}function Eo(t,n){if(null==t?0:t.length){var r=ei(t,n,!0)-1;if($f(t[r],n))return r}return-1}function So(t){return t&&t.length?ui(t):[]}function Ro(t,n){return t&&t.length?ui(t,pu(n,2)):[]}function Io(t){var n=null==t?0:t.length;return n?ni(t,1,n):[]}function To(t,n,r){return t&&t.length?(n=r||n===tt?1:ga(n),ni(t,0,n<0?0:n)):[]}function Oo(t,n,r){var e=null==t?0:t.length;return e?(n=r||n===tt?1:ga(n),n=e-n,ni(t,n<0?0:n,e)):[]}function jo(t,n){return t&&t.length?li(t,pu(n,3),!1,!0):[]}function Lo(t,n){return t&&t.length?li(t,pu(n,3)):[]}function Uo(t){return t&&t.length?ai(t):[]}function Po(t,n){return t&&t.length?ai(t,pu(n,2)):[]}function Co(t,n){return n="function"==typeof n?n:tt,t&&t.length?ai(t,tt,n):[]}function $o(t){if(!t||!t.length)return[];var n=0;return t=f(t,function(t){if(Nf(t))return n=$h(t.length,n),!0}),S(n,function(n){return h(t,B(n))})}function zo(t,n){if(!t||!t.length)return[];var e=$o(t);return null==n?e:h(e,function(t){return r(n,tt,t)})}function No(t,n){return di(t||[],n||[],Dr)}function qo(t,n){return di(t||[],n||[],Qe)}function Wo(t){var n=g(t);return n.__chain__=!0,n}function Do(t,n){return n(t),t}function Yo(t,n){return n(t)}function Fo(){return Wo(this)}function Zo(){return new G(this.value(),this.__chain__)}function Go(){this.__values__===tt&&(this.__values__=pa(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?tt:this.__values__[this.__index__++]}}function Vo(){return this}function Ko(t){for(var n,r=this;r instanceof x;){var e=Gu(r);e.__index__=0,e.__values__=tt,n?i.__wrapped__=e:n=e;var i=e;r=r.__wrapped__}return i.__wrapped__=t,n}function Ho(){var t=this.__wrapped__;if(t instanceof X){var n=t;return this.__actions__.length&&(n=new X(this)),(n=n.reverse()).__actions__.push({func:Yo,args:[wo],thisArg:tt}),new G(n,this.__chain__)}return this.thru(wo)}function Xo(){return ci(this.__wrapped__,this.__actions__)}function Jo(t,n,r){var e=sc(t)?o:re;return r&&Eu(t,n,r)&&(n=tt),e(t,pu(n,3))}function Qo(t,n){return(sc(t)?f:ue)(t,pu(n,3))}function tf(t,n){return oe(ff(t,n),1)}function nf(t,n){return oe(ff(t,n),St)}function rf(t,n,r){return r=r===tt?1:ga(r),oe(ff(t,n),r)}function ef(t,n){return(sc(t)?i:fl)(t,pu(n,3))}function uf(t,n){return(sc(t)?u:al)(t,pu(n,3))}function of(t,n,r,e){t=zf(t)?t:Za(t),r=r&&!e?ga(r):0;var i=t.length;return r<0&&(r=$h(i+r,0)),aa(t)?r<=i&&t.indexOf(n,r)>-1:!!i&&_(t,n,r)>-1}function ff(t,n){return(sc(t)?h:Ue)(t,pu(n,3))}function af(t,n,r,e){return null==t?[]:(sc(n)||(n=null==n?[]:[n]),r=e?tt:r,sc(r)||(r=null==r?[]:[r]),qe(t,n,r))}function sf(t,n,r){var e=sc(t)?c:A,i=arguments.length<3;return e(t,pu(n,4),r,i,fl)}function hf(t,n,r){var e=sc(t)?p:A,i=arguments.length<3;return e(t,pu(n,4),r,i,al)}function lf(t,n){return(sc(t)?f:ue)(t,Af(pu(n,3)))}function cf(t){return(sc(t)?Ur:Xe)(t)}function pf(t,n,r){return n=(r?Eu(t,n,r):n===tt)?1:ga(n),(sc(t)?Nr:Je)(t,n)}function df(t){return(sc(t)?qr:ti)(t)}function gf(t){if(null==t)return 0;if(zf(t))return aa(t)?K(t):t.length;var n=_l(t);return n==Ft||n==Xt?t.size:Oe(t).length}function vf(t,n,r){var e=sc(t)?d:ri;return r&&Eu(t,n,r)&&(n=tt),e(t,pu(n,3))}function mf(t,n){if("function"!=typeof n)throw new eh(et);return t=ga(t),function(){if(--t<1)return n.apply(this,arguments)}}function yf(t,n,r){return n=r?tt:n,n=t&&null==n?t.length:n,nu(t,_t,tt,tt,tt,tt,n)}function _f(t,n){var r;if("function"!=typeof n)throw new eh(et);return t=ga(t),function(){return--t>0&&(r=n.apply(this,arguments)),t<=1&&(n=tt),r}}function wf(t,n,r){var e=nu(t,gt,tt,tt,tt,tt,tt,n=r?tt:n);return e.placeholder=wf.placeholder,e}function Mf(t,n,r){var e=nu(t,vt,tt,tt,tt,tt,tt,n=r?tt:n);return e.placeholder=Mf.placeholder,e}function bf(t,n,r){function e(n){var r=c,e=p;return c=p=tt,y=n,g=t.apply(e,r)}function i(t){return y=t,v=bl(f,n),_?e(t):g}function u(t){var r=t-y,e=n-(t-m);return w?zh(e,d-r):e}function o(t){var r=t-m,e=t-y;return m===tt||r>=n||r<0||w&&e>=d}function f(){var t=Xl();if(o(t))return a(t);v=bl(f,u(t))}function a(t){return v=tt,M&&c?e(t):(c=p=tt,g)}function s(){v!==tt&&dl(v),y=0,c=m=p=v=tt}function h(){return v===tt?g:a(Xl())}function l(){var t=Xl(),r=o(t);if(c=arguments,p=this,m=t,r){if(v===tt)return i(m);if(w)return v=bl(f,n),e(m)}return v===tt&&(v=bl(f,n)),g}var c,p,d,g,v,m,y=0,_=!1,w=!1,M=!0;if("function"!=typeof t)throw new eh(et);return n=ma(n)||0,Xf(r)&&(_=!!r.leading,d=(w="maxWait"in r)?$h(ma(r.maxWait)||0,n):d,M="trailing"in r?!!r.trailing:M),l.cancel=s,l.flush=h,l}function Bf(t){return nu(t,Mt)}function xf(t,n){if("function"!=typeof t||null!=n&&"function"!=typeof n)throw new eh(et);var r=function(){var e=arguments,i=n?n.apply(this,e):e[0],u=r.cache;if(u.has(i))return u.get(i);var o=t.apply(this,e);return r.cache=u.set(i,o)||u,o};return r.cache=new(xf.Cache||er),r}function Af(t){if("function"!=typeof t)throw new eh(et);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function kf(t){return _f(2,t)}function Ef(t,n){if("function"!=typeof t)throw new eh(et);return n=n===tt?n:ga(n),He(t,n)}function Sf(t,n){if("function"!=typeof t)throw new eh(et);return n=null==n?0:$h(ga(n),0),He(function(e){var i=e[n],u=yi(e,0,n);return i&&l(u,i),r(t,this,u)})}function Rf(t,n,r){var e=!0,i=!0;if("function"!=typeof t)throw new eh(et);return Xf(r)&&(e="leading"in r?!!r.leading:e,i="trailing"in r?!!r.trailing:i),bf(t,n,{leading:e,maxWait:n,trailing:i})}function If(t){return yf(t,1)}function Tf(t,n){return ec(vi(n),t)}function Of(){if(!arguments.length)return[];var t=arguments[0];return sc(t)?t:[t]}function jf(t){return Xr(t,st)}function Lf(t,n){return n="function"==typeof n?n:tt,Xr(t,st,n)}function Uf(t){return Xr(t,ft|st)}function Pf(t,n){return n="function"==typeof n?n:tt,Xr(t,ft|st,n)}function Cf(t,n){return null==n||Qr(t,n,ja(n))}function $f(t,n){return t===n||t!==t&&n!==n}function zf(t){return null!=t&&Hf(t.length)&&!Vf(t)}function Nf(t){return Jf(t)&&zf(t)}function qf(t){return!0===t||!1===t||Jf(t)&&ce(t)==zt}function Wf(t){return Jf(t)&&1===t.nodeType&&!oa(t)}function Df(t){if(null==t)return!0;if(zf(t)&&(sc(t)||"string"==typeof t||"function"==typeof t.splice||lc(t)||vc(t)||ac(t)))return!t.length;var n=_l(t);if(n==Ft||n==Xt)return!t.size;if(Ou(t))return!Oe(t).length;for(var r in t)if(sh.call(t,r))return!1;return!0}function Yf(t,n){return Be(t,n)}function Ff(t,n,r){var e=(r="function"==typeof r?r:tt)?r(t,n):tt;return e===tt?Be(t,n,tt,r):!!e}function Zf(t){if(!Jf(t))return!1;var n=ce(t);return n==Wt||n==qt||"string"==typeof t.message&&"string"==typeof t.name&&!oa(t)}function Gf(t){return"number"==typeof t&&Uh(t)}function Vf(t){if(!Xf(t))return!1;var n=ce(t);return n==Dt||n==Yt||n==$t||n==Kt}function Kf(t){return"number"==typeof t&&t==ga(t)}function Hf(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Rt}function Xf(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function Jf(t){return null!=t&&"object"==typeof t}function Qf(t,n){return t===n||ke(t,n,gu(n))}function ta(t,n,r){return r="function"==typeof r?r:tt,ke(t,n,gu(n),r)}function na(t){return ua(t)&&t!=+t}function ra(t){if(wl(t))throw new Xs(rt);return Ee(t)}function ea(t){return null===t}function ia(t){return null==t}function ua(t){return"number"==typeof t||Jf(t)&&ce(t)==Zt}function oa(t){if(!Jf(t)||ce(t)!=Vt)return!1;var n=wh(t);if(null===n)return!0;var r=sh.call(n,"constructor")&&n.constructor;return"function"==typeof r&&r instanceof r&&ah.call(r)==ph}function fa(t){return Kf(t)&&t>=-Rt&&t<=Rt}function aa(t){return"string"==typeof t||!sc(t)&&Jf(t)&&ce(t)==Jt}function sa(t){return"symbol"==typeof t||Jf(t)&&ce(t)==Qt}function ha(t){return t===tt}function la(t){return Jf(t)&&_l(t)==nn}function ca(t){return Jf(t)&&ce(t)==rn}function pa(t){if(!t)return[];if(zf(t))return aa(t)?H(t):Ri(t);if(Ah&&t[Ah])return N(t[Ah]());var n=_l(t);return(n==Ft?q:n==Xt?F:Za)(t)}function da(t){return t?(t=ma(t),t===St||t===-St?(t<0?-1:1)*It:t===t?t:0):0===t?t:0}function ga(t){var n=da(t),r=n%1;return n===n?r?n-r:n:0}function va(t){return t?Hr(ga(t),0,Ot):0}function ma(t){if("number"==typeof t)return t;if(sa(t))return Tt;if(Xf(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=Xf(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(En,"");var r=Cn.test(t);return r||zn.test(t)?wr(t.slice(2),r?2:8):Pn.test(t)?Tt:+t}function ya(t){return Ii(t,La(t))}function _a(t){return t?Hr(ga(t),-Rt,Rt):0===t?t:0}function wa(t){return null==t?"":fi(t)}function Ma(t,n){var r=ol(t);return null==n?r:Zr(r,n)}function ba(t,n){return m(t,pu(n,3),fe)}function Ba(t,n){return m(t,pu(n,3),ae)}function xa(t,n){return null==t?t:sl(t,pu(n,3),La)}function Aa(t,n){return null==t?t:hl(t,pu(n,3),La)}function ka(t,n){return t&&fe(t,pu(n,3))}function Ea(t,n){return t&&ae(t,pu(n,3))}function Sa(t){return null==t?[]:se(t,ja(t))}function Ra(t){return null==t?[]:se(t,La(t))}function Ia(t,n,r){var e=null==t?tt:he(t,n);return e===tt?r:e}function Ta(t,n){return null!=t&&wu(t,n,de)}function Oa(t,n){return null!=t&&wu(t,n,ge)}function ja(t){return zf(t)?Sr(t):Oe(t)}function La(t){return zf(t)?Sr(t,!0):je(t)}function Ua(t,n){var r={};return n=pu(n,3),fe(t,function(t,e,i){Vr(r,n(t,e,i),t)}),r}function Pa(t,n){var r={};return n=pu(n,3),fe(t,function(t,e,i){Vr(r,e,n(t,e,i))}),r}function Ca(t,n){return $a(t,Af(pu(n)))}function $a(t,n){if(null==t)return{};var r=h(hu(t),function(t){return[t]});return n=pu(n),De(t,r,function(t,r){return n(t,r[0])})}function za(t,n,r){var e=-1,i=(n=mi(n,t)).length;for(i||(i=1,t=tt);++e<i;){var u=null==t?tt:t[Yu(n[e])];u===tt&&(e=i,u=r),t=Vf(u)?u.call(t):u}return t}function Na(t,n,r){return null==t?t:Qe(t,n,r)}function qa(t,n,r,e){return e="function"==typeof e?e:tt,null==t?t:Qe(t,n,r,e)}function Wa(t,n,r){var e=sc(t),u=e||lc(t)||vc(t);if(n=pu(n,4),null==r){var o=t&&t.constructor;r=u?e?new o:[]:Xf(t)&&Vf(o)?ol(wh(t)):{}}return(u?i:fe)(t,function(t,e,i){return n(r,t,e,i)}),r}function Da(t,n){return null==t||si(t,n)}function Ya(t,n,r){return null==t?t:hi(t,n,vi(r))}function Fa(t,n,r,e){return e="function"==typeof e?e:tt,null==t?t:hi(t,n,vi(r),e)}function Za(t){return null==t?[]:T(t,ja(t))}function Ga(t){return null==t?[]:T(t,La(t))}function Va(t,n,r){return r===tt&&(r=n,n=tt),r!==tt&&(r=(r=ma(r))===r?r:0),n!==tt&&(n=(n=ma(n))===n?n:0),Hr(ma(t),n,r)}function Ka(t,n,r){return n=da(n),r===tt?(r=n,n=0):r=da(r),t=ma(t),ve(t,n,r)}function Ha(t,n,r){if(r&&"boolean"!=typeof r&&Eu(t,n,r)&&(n=r=tt),r===tt&&("boolean"==typeof n?(r=n,n=tt):"boolean"==typeof t&&(r=t,t=tt)),t===tt&&n===tt?(t=0,n=1):(t=da(t),n===tt?(n=t,t=0):n=da(n)),t>n){var e=t;t=n,n=e}if(r||t%1||n%1){var i=Wh();return zh(t+i*(n-t+_r("1e-"+((i+"").length-1))),n)}return Ge(t,n)}function Xa(t){return Wc(wa(t).toLowerCase())}function Ja(t){return(t=wa(t))&&t.replace(qn,Pr).replace(or,"")}function Qa(t,n,r){t=wa(t),n=fi(n);var e=t.length,i=r=r===tt?e:Hr(ga(r),0,e);return(r-=n.length)>=0&&t.slice(r,i)==n}function ts(t){return t=wa(t),t&&Mn.test(t)?t.replace(_n,Cr):t}function ns(t){return t=wa(t),t&&kn.test(t)?t.replace(An,"\\$&"):t}function rs(t,n,r){t=wa(t);var e=(n=ga(n))?K(t):0;if(!n||e>=n)return t;var i=(n-e)/2;return Vi(Oh(i),r)+t+Vi(Th(i),r)}function es(t,n,r){t=wa(t);var e=(n=ga(n))?K(t):0;return n&&e<n?t+Vi(n-e,r):t}function is(t,n,r){t=wa(t);var e=(n=ga(n))?K(t):0;return n&&e<n?Vi(n-e,r)+t:t}function us(t,n,r){return r||null==n?n=0:n&&(n=+n),qh(wa(t).replace(Sn,""),n||0)}function os(t,n,r){return n=(r?Eu(t,n,r):n===tt)?1:ga(n),Ke(wa(t),n)}function fs(){var t=arguments,n=wa(t[0]);return t.length<3?n:n.replace(t[1],t[2])}function as(t,n,r){return r&&"number"!=typeof r&&Eu(t,n,r)&&(n=r=tt),(r=r===tt?Ot:r>>>0)?(t=wa(t),t&&("string"==typeof n||null!=n&&!dc(n))&&!(n=fi(n))&&$(t)?yi(H(t),0,r):t.split(n,r)):[]}function ss(t,n,r){return t=wa(t),r=null==r?0:Hr(ga(r),0,t.length),n=fi(n),t.slice(r,r+n.length)==n}function hs(t,n,r){var e=g.templateSettings;r&&Eu(t,n,r)&&(n=tt),t=wa(t),n=Mc({},n,e,ru);var i,u,o=Mc({},n.imports,e.imports,ru),f=ja(o),a=T(o,f),s=0,h=n.interpolate||Wn,l="__p += '",c=nh((n.escape||Wn).source+"|"+h.source+"|"+(h===bn?Ln:Wn).source+"|"+(n.evaluate||Wn).source+"|$","g"),p="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++cr+"]")+"\n";t.replace(c,function(n,r,e,o,f,a){return e||(e=o),l+=t.slice(s,a).replace(Dn,P),r&&(i=!0,l+="' +\n__e("+r+") +\n'"),f&&(u=!0,l+="';\n"+f+";\n__p += '"),e&&(l+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),s=a+n.length,n}),l+="';\n";var d=n.variable;d||(l="with (obj) {\n"+l+"\n}\n"),l=(u?l.replace(gn,""):l).replace(vn,"$1").replace(mn,"$1;"),l="function("+(d||"obj")+") {\n"+(d?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(u?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var v=Dc(function(){return Js(f,p+"return "+l).apply(tt,a)});if(v.source=l,Zf(v))throw v;return v}function ls(t){return wa(t).toLowerCase()}function cs(t){return wa(t).toUpperCase()}function ps(t,n,r){if((t=wa(t))&&(r||n===tt))return t.replace(En,"");if(!t||!(n=fi(n)))return t;var e=H(t),i=H(n);return yi(e,j(e,i),L(e,i)+1).join("")}function ds(t,n,r){if((t=wa(t))&&(r||n===tt))return t.replace(Rn,"");if(!t||!(n=fi(n)))return t;var e=H(t);return yi(e,0,L(e,H(n))+1).join("")}function gs(t,n,r){if((t=wa(t))&&(r||n===tt))return t.replace(Sn,"");if(!t||!(n=fi(n)))return t;var e=H(t);return yi(e,j(e,H(n))).join("")}function vs(t,n){var r=bt,e=Bt;if(Xf(n)){var i="separator"in n?n.separator:i;r="length"in n?ga(n.length):r,e="omission"in n?fi(n.omission):e}var u=(t=wa(t)).length;if($(t)){var o=H(t);u=o.length}if(r>=u)return t;var f=r-K(e);if(f<1)return e;var a=o?yi(o,0,f).join(""):t.slice(0,f);if(i===tt)return a+e;if(o&&(f+=a.length-f),dc(i)){if(t.slice(f).search(i)){var s,h=a;for(i.global||(i=nh(i.source,wa(Un.exec(i))+"g")),i.lastIndex=0;s=i.exec(h);)var l=s.index;a=a.slice(0,l===tt?f:l)}}else if(t.indexOf(fi(i),f)!=f){var c=a.lastIndexOf(i);c>-1&&(a=a.slice(0,c))}return a+e}function ms(t){return t=wa(t),t&&wn.test(t)?t.replace(yn,$r):t}function ys(t,n,r){return t=wa(t),n=r?tt:n,n===tt?z(t)?Q(t):v(t):t.match(n)||[]}function _s(t){var n=null==t?0:t.length,e=pu();return t=n?h(t,function(t){if("function"!=typeof t[1])throw new eh(et);return[e(t[0]),t[1]]}):[],He(function(e){for(var i=-1;++i<n;){var u=t[i];if(r(u[0],this,e))return r(u[1],this,e)}})}function ws(t){return Jr(Xr(t,ft))}function Ms(t){return function(){return t}}function bs(t,n){return null==t||t!==t?n:t}function Bs(t){return t}function xs(t){return Te("function"==typeof t?t:Xr(t,ft))}function As(t){return Pe(Xr(t,ft))}function ks(t,n){return Ce(t,Xr(n,ft))}function Es(t,n,r){var e=ja(n),u=se(n,e);null!=r||Xf(n)&&(u.length||!e.length)||(r=n,n=t,t=this,u=se(n,ja(n)));var o=!(Xf(r)&&"chain"in r&&!r.chain),f=Vf(t);return i(u,function(r){var e=n[r];t[r]=e,f&&(t.prototype[r]=function(){var n=this.__chain__;if(o||n){var r=t(this.__wrapped__);return(r.__actions__=Ri(this.__actions__)).push({func:e,args:arguments,thisArg:t}),r.__chain__=n,r}return e.apply(t,l([this.value()],arguments))})}),t}function Ss(){return Br._===this&&(Br._=dh),this}function Rs(){}function Is(t){return t=ga(t),He(function(n){return Ne(n,t)})}function Ts(t){return Su(t)?B(Yu(t)):Ye(t)}function Os(t){return function(n){return null==t?tt:he(t,n)}}function js(){return[]}function Ls(){return!1}function Us(){return{}}function Ps(){return""}function Cs(){return!0}function $s(t,n){if((t=ga(t))<1||t>Rt)return[];var r=Ot,e=zh(t,Ot);n=pu(n),t-=Ot;for(var i=S(e,n);++r<t;)n(r);return i}function zs(t){return sc(t)?h(t,Yu):sa(t)?[t]:Ri(xl(wa(t)))}function Ns(t){var n=++hh;return wa(t)+n}function qs(t){return t&&t.length?ee(t,Bs,pe):tt}function Ws(t,n){return t&&t.length?ee(t,pu(n,2),pe):tt}function Ds(t){return b(t,Bs)}function Ys(t,n){return b(t,pu(n,2))}function Fs(t){return t&&t.length?ee(t,Bs,Le):tt}function Zs(t,n){return t&&t.length?ee(t,pu(n,2),Le):tt}function Gs(t){return t&&t.length?E(t,Bs):0}function Vs(t,n){return t&&t.length?E(t,pu(n,2)):0}var Ks=(n=null==n?Br:zr.defaults(Br.Object(),n,zr.pick(Br,lr))).Array,Hs=n.Date,Xs=n.Error,Js=n.Function,Qs=n.Math,th=n.Object,nh=n.RegExp,rh=n.String,eh=n.TypeError,ih=Ks.prototype,uh=Js.prototype,oh=th.prototype,fh=n["__core-js_shared__"],ah=uh.toString,sh=oh.hasOwnProperty,hh=0,lh=function(){var t=/[^.]+$/.exec(fh&&fh.keys&&fh.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ch=oh.toString,ph=ah.call(th),dh=Br._,gh=nh("^"+ah.call(sh).replace(An,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),vh=kr?n.Buffer:tt,mh=n.Symbol,yh=n.Uint8Array,_h=vh?vh.allocUnsafe:tt,wh=W(th.getPrototypeOf,th),Mh=th.create,bh=oh.propertyIsEnumerable,Bh=ih.splice,xh=mh?mh.isConcatSpreadable:tt,Ah=mh?mh.iterator:tt,kh=mh?mh.toStringTag:tt,Eh=function(){try{var t=vu(th,"defineProperty");return t({},"",{}),t}catch(t){}}(),Sh=n.clearTimeout!==Br.clearTimeout&&n.clearTimeout,Rh=Hs&&Hs.now!==Br.Date.now&&Hs.now,Ih=n.setTimeout!==Br.setTimeout&&n.setTimeout,Th=Qs.ceil,Oh=Qs.floor,jh=th.getOwnPropertySymbols,Lh=vh?vh.isBuffer:tt,Uh=n.isFinite,Ph=ih.join,Ch=W(th.keys,th),$h=Qs.max,zh=Qs.min,Nh=Hs.now,qh=n.parseInt,Wh=Qs.random,Dh=ih.reverse,Yh=vu(n,"DataView"),Fh=vu(n,"Map"),Zh=vu(n,"Promise"),Gh=vu(n,"Set"),Vh=vu(n,"WeakMap"),Kh=vu(th,"create"),Hh=Vh&&new Vh,Xh={},Jh=Fu(Yh),Qh=Fu(Fh),tl=Fu(Zh),nl=Fu(Gh),rl=Fu(Vh),el=mh?mh.prototype:tt,il=el?el.valueOf:tt,ul=el?el.toString:tt,ol=function(){function t(){}return function(n){if(!Xf(n))return{};if(Mh)return Mh(n);t.prototype=n;var r=new t;return t.prototype=tt,r}}();g.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:bn,variable:"",imports:{_:g}},g.prototype=x.prototype,g.prototype.constructor=g,G.prototype=ol(x.prototype),G.prototype.constructor=G,X.prototype=ol(x.prototype),X.prototype.constructor=X,Fn.prototype.clear=Zn,Fn.prototype.delete=Gn,Fn.prototype.get=Vn,Fn.prototype.has=Kn,Fn.prototype.set=Hn,Xn.prototype.clear=Jn,Xn.prototype.delete=Qn,Xn.prototype.get=tr,Xn.prototype.has=nr,Xn.prototype.set=rr,er.prototype.clear=ir,er.prototype.delete=fr,er.prototype.get=ar,er.prototype.has=sr,er.prototype.set=hr,gr.prototype.add=gr.prototype.push=vr,gr.prototype.has=mr,yr.prototype.clear=Mr,yr.prototype.delete=br,yr.prototype.get=xr,yr.prototype.has=Ar,yr.prototype.set=Er;var fl=Ui(fe),al=Ui(ae,!0),sl=Pi(),hl=Pi(!0),ll=Hh?function(t,n){return Hh.set(t,n),t}:Bs,cl=Eh?function(t,n){return Eh(t,"toString",{configurable:!0,enumerable:!1,value:Ms(n),writable:!0})}:Bs,pl=He,dl=Sh||function(t){return Br.clearTimeout(t)},gl=Gh&&1/F(new Gh([,-0]))[1]==St?function(t){return new Gh(t)}:Rs,vl=Hh?function(t){return Hh.get(t)}:Rs,ml=jh?function(t){return null==t?[]:(t=th(t),f(jh(t),function(n){return bh.call(t,n)}))}:js,yl=jh?function(t){for(var n=[];t;)l(n,ml(t)),t=wh(t);return n}:js,_l=ce;(Yh&&_l(new Yh(new ArrayBuffer(1)))!=un||Fh&&_l(new Fh)!=Ft||Zh&&"[object Promise]"!=_l(Zh.resolve())||Gh&&_l(new Gh)!=Xt||Vh&&_l(new Vh)!=nn)&&(_l=function(t){var n=ce(t),r=n==Vt?t.constructor:tt,e=r?Fu(r):"";if(e)switch(e){case Jh:return un;case Qh:return Ft;case tl:return"[object Promise]";case nl:return Xt;case rl:return nn}return n});var wl=fh?Vf:Ls,Ml=Wu(ll),bl=Ih||function(t,n){return Br.setTimeout(t,n)},Bl=Wu(cl),xl=function(t){var n=xf(t,function(t){return r.size===ut&&r.clear(),t}),r=n.cache;return n}(function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,function(t,r,e,i){n.push(e?i.replace(/\\(\\)?/g,"$1"):r||t)}),n}),Al=He(function(t,n){return Nf(t)?ne(t,oe(n,1,Nf,!0)):[]}),kl=He(function(t,n){var r=co(n);return Nf(r)&&(r=tt),Nf(t)?ne(t,oe(n,1,Nf,!0),pu(r,2)):[]}),El=He(function(t,n){var r=co(n);return Nf(r)&&(r=tt),Nf(t)?ne(t,oe(n,1,Nf,!0),tt,r):[]}),Sl=He(function(t){var n=h(t,gi);return n.length&&n[0]===t[0]?me(n):[]}),Rl=He(function(t){var n=co(t),r=h(t,gi);return n===co(r)?n=tt:r.pop(),r.length&&r[0]===t[0]?me(r,pu(n,2)):[]}),Il=He(function(t){var n=co(t),r=h(t,gi);return(n="function"==typeof n?n:tt)&&r.pop(),r.length&&r[0]===t[0]?me(r,tt,n):[]}),Tl=He(vo),Ol=au(function(t,n){var r=null==t?0:t.length,e=Kr(t,n);return Ze(t,h(n,function(t){return ku(t,r)?+t:t}).sort(Ai)),e}),jl=He(function(t){return ai(oe(t,1,Nf,!0))}),Ll=He(function(t){var n=co(t);return Nf(n)&&(n=tt),ai(oe(t,1,Nf,!0),pu(n,2))}),Ul=He(function(t){var n=co(t);return n="function"==typeof n?n:tt,ai(oe(t,1,Nf,!0),tt,n)}),Pl=He(function(t,n){return Nf(t)?ne(t,n):[]}),Cl=He(function(t){return pi(f(t,Nf))}),$l=He(function(t){var n=co(t);return Nf(n)&&(n=tt),pi(f(t,Nf),pu(n,2))}),zl=He(function(t){var n=co(t);return n="function"==typeof n?n:tt,pi(f(t,Nf),tt,n)}),Nl=He($o),ql=He(function(t){var n=t.length,r=n>1?t[n-1]:tt;return r="function"==typeof r?(t.pop(),r):tt,zo(t,r)}),Wl=au(function(t){var n=t.length,r=n?t[0]:0,e=this.__wrapped__,i=function(n){return Kr(n,t)};return!(n>1||this.__actions__.length)&&e instanceof X&&ku(r)?((e=e.slice(r,+r+(n?1:0))).__actions__.push({func:Yo,args:[i],thisArg:tt}),new G(e,this.__chain__).thru(function(t){return n&&!t.length&&t.push(tt),t})):this.thru(i)}),Dl=ji(function(t,n,r){sh.call(t,r)?++t[r]:Vr(t,r,1)}),Yl=Wi(ro),Fl=Wi(eo),Zl=ji(function(t,n,r){sh.call(t,r)?t[r].push(n):Vr(t,r,[n])}),Gl=He(function(t,n,e){var i=-1,u="function"==typeof n,o=zf(t)?Ks(t.length):[];return fl(t,function(t){o[++i]=u?r(n,t,e):_e(t,n,e)}),o}),Vl=ji(function(t,n,r){Vr(t,r,n)}),Kl=ji(function(t,n,r){t[r?0:1].push(n)},function(){return[[],[]]}),Hl=He(function(t,n){if(null==t)return[];var r=n.length;return r>1&&Eu(t,n[0],n[1])?n=[]:r>2&&Eu(n[0],n[1],n[2])&&(n=[n[0]]),qe(t,oe(n,1),[])}),Xl=Rh||function(){return Br.Date.now()},Jl=He(function(t,n,r){var e=ct;if(r.length){var i=D(r,cu(Jl));e|=mt}return nu(t,e,n,r,i)}),Ql=He(function(t,n,r){var e=ct|pt;if(r.length){var i=D(r,cu(Ql));e|=mt}return nu(n,e,t,r,i)}),tc=He(function(t,n){return te(t,1,n)}),nc=He(function(t,n,r){return te(t,ma(n)||0,r)});xf.Cache=er;var rc=pl(function(t,n){var e=(n=1==n.length&&sc(n[0])?h(n[0],I(pu())):h(oe(n,1),I(pu()))).length;return He(function(i){for(var u=-1,o=zh(i.length,e);++u<o;)i[u]=n[u].call(this,i[u]);return r(t,this,i)})}),ec=He(function(t,n){var r=D(n,cu(ec));return nu(t,mt,tt,n,r)}),ic=He(function(t,n){var r=D(n,cu(ic));return nu(t,yt,tt,n,r)}),uc=au(function(t,n){return nu(t,wt,tt,tt,tt,n)}),oc=Xi(pe),fc=Xi(function(t,n){return t>=n}),ac=we(function(){return arguments}())?we:function(t){return Jf(t)&&sh.call(t,"callee")&&!bh.call(t,"callee")},sc=Ks.isArray,hc=Rr?I(Rr):Me,lc=Lh||Ls,cc=Ir?I(Ir):be,pc=Tr?I(Tr):Ae,dc=Or?I(Or):Se,gc=jr?I(jr):Re,vc=Lr?I(Lr):Ie,mc=Xi(Le),yc=Xi(function(t,n){return t<=n}),_c=Li(function(t,n){if(Ou(n)||zf(n))return void Ii(n,ja(n),t);for(var r in n)sh.call(n,r)&&Dr(t,r,n[r])}),wc=Li(function(t,n){Ii(n,La(n),t)}),Mc=Li(function(t,n,r,e){Ii(n,La(n),t,e)}),bc=Li(function(t,n,r,e){Ii(n,ja(n),t,e)}),Bc=au(Kr),xc=He(function(t,n){t=th(t);var r=-1,e=n.length,i=e>2?n[2]:tt;for(i&&Eu(n[0],n[1],i)&&(e=1);++r<e;)for(var u=n[r],o=La(u),f=-1,a=o.length;++f<a;){var s=o[f],h=t[s];(h===tt||$f(h,oh[s])&&!sh.call(t,s))&&(t[s]=u[s])}return t}),Ac=He(function(t){return t.push(tt,eu),r(Ic,tt,t)}),kc=Fi(function(t,n,r){null!=n&&"function"!=typeof n.toString&&(n=ch.call(n)),t[n]=r},Ms(Bs)),Ec=Fi(function(t,n,r){null!=n&&"function"!=typeof n.toString&&(n=ch.call(n)),sh.call(t,n)?t[n].push(r):t[n]=[r]},pu),Sc=He(_e),Rc=Li(function(t,n,r){$e(t,n,r)}),Ic=Li(function(t,n,r,e){$e(t,n,r,e)}),Tc=au(function(t,n){var r={};if(null==t)return r;var e=!1;n=h(n,function(n){return n=mi(n,t),e||(e=n.length>1),n}),Ii(t,hu(t),r),e&&(r=Xr(r,ft|at|st,iu));for(var i=n.length;i--;)si(r,n[i]);return r}),Oc=au(function(t,n){return null==t?{}:We(t,n)}),jc=tu(ja),Lc=tu(La),Uc=zi(function(t,n,r){return n=n.toLowerCase(),t+(r?Xa(n):n)}),Pc=zi(function(t,n,r){return t+(r?"-":"")+n.toLowerCase()}),Cc=zi(function(t,n,r){return t+(r?" ":"")+n.toLowerCase()}),$c=$i("toLowerCase"),zc=zi(function(t,n,r){return t+(r?"_":"")+n.toLowerCase()}),Nc=zi(function(t,n,r){return t+(r?" ":"")+Wc(n)}),qc=zi(function(t,n,r){return t+(r?" ":"")+n.toUpperCase()}),Wc=$i("toUpperCase"),Dc=He(function(t,n){try{return r(t,tt,n)}catch(t){return Zf(t)?t:new Xs(t)}}),Yc=au(function(t,n){return i(n,function(n){n=Yu(n),Vr(t,n,Jl(t[n],t))}),t}),Fc=Di(),Zc=Di(!0),Gc=He(function(t,n){return function(r){return _e(r,t,n)}}),Vc=He(function(t,n){return function(r){return _e(t,r,n)}}),Kc=Gi(h),Hc=Gi(o),Xc=Gi(d),Jc=Hi(),Qc=Hi(!0),tp=Zi(function(t,n){return t+n},0),np=Qi("ceil"),rp=Zi(function(t,n){return t/n},1),ep=Qi("floor"),ip=Zi(function(t,n){return t*n},1),up=Qi("round"),op=Zi(function(t,n){return t-n},0);return g.after=mf,g.ary=yf,g.assign=_c,g.assignIn=wc,g.assignInWith=Mc,g.assignWith=bc,g.at=Bc,g.before=_f,g.bind=Jl,g.bindAll=Yc,g.bindKey=Ql,g.castArray=Of,g.chain=Wo,g.chunk=Vu,g.compact=Ku,g.concat=Hu,g.cond=_s,g.conforms=ws,g.constant=Ms,g.countBy=Dl,g.create=Ma,g.curry=wf,g.curryRight=Mf,g.debounce=bf,g.defaults=xc,g.defaultsDeep=Ac,g.defer=tc,g.delay=nc,g.difference=Al,g.differenceBy=kl,g.differenceWith=El,g.drop=Xu,g.dropRight=Ju,g.dropRightWhile=Qu,g.dropWhile=to,g.fill=no,g.filter=Qo,g.flatMap=tf,g.flatMapDeep=nf,g.flatMapDepth=rf,g.flatten=io,g.flattenDeep=uo,g.flattenDepth=oo,g.flip=Bf,g.flow=Fc,g.flowRight=Zc,g.fromPairs=fo,g.functions=Sa,g.functionsIn=Ra,g.groupBy=Zl,g.initial=ho,g.intersection=Sl,g.intersectionBy=Rl,g.intersectionWith=Il,g.invert=kc,g.invertBy=Ec,g.invokeMap=Gl,g.iteratee=xs,g.keyBy=Vl,g.keys=ja,g.keysIn=La,g.map=ff,g.mapKeys=Ua,g.mapValues=Pa,g.matches=As,g.matchesProperty=ks,g.memoize=xf,g.merge=Rc,g.mergeWith=Ic,g.method=Gc,g.methodOf=Vc,g.mixin=Es,g.negate=Af,g.nthArg=Is,g.omit=Tc,g.omitBy=Ca,g.once=kf,g.orderBy=af,g.over=Kc,g.overArgs=rc,g.overEvery=Hc,g.overSome=Xc,g.partial=ec,g.partialRight=ic,g.partition=Kl,g.pick=Oc,g.pickBy=$a,g.property=Ts,g.propertyOf=Os,g.pull=Tl,g.pullAll=vo,g.pullAllBy=mo,g.pullAllWith=yo,g.pullAt=Ol,g.range=Jc,g.rangeRight=Qc,g.rearg=uc,g.reject=lf,g.remove=_o,g.rest=Ef,g.reverse=wo,g.sampleSize=pf,g.set=Na,g.setWith=qa,g.shuffle=df,g.slice=Mo,g.sortBy=Hl,g.sortedUniq=So,g.sortedUniqBy=Ro,g.split=as,g.spread=Sf,g.tail=Io,g.take=To,g.takeRight=Oo,g.takeRightWhile=jo,g.takeWhile=Lo,g.tap=Do,g.throttle=Rf,g.thru=Yo,g.toArray=pa,g.toPairs=jc,g.toPairsIn=Lc,g.toPath=zs,g.toPlainObject=ya,g.transform=Wa,g.unary=If,g.union=jl,g.unionBy=Ll,g.unionWith=Ul,g.uniq=Uo,g.uniqBy=Po,g.uniqWith=Co,g.unset=Da,g.unzip=$o,g.unzipWith=zo,g.update=Ya,g.updateWith=Fa,g.values=Za,g.valuesIn=Ga,g.without=Pl,g.words=ys,g.wrap=Tf,g.xor=Cl,g.xorBy=$l,g.xorWith=zl,g.zip=Nl,g.zipObject=No,g.zipObjectDeep=qo,g.zipWith=ql,g.entries=jc,g.entriesIn=Lc,g.extend=wc,g.extendWith=Mc,Es(g,g),g.add=tp,g.attempt=Dc,g.camelCase=Uc,g.capitalize=Xa,g.ceil=np,g.clamp=Va,g.clone=jf,g.cloneDeep=Uf,g.cloneDeepWith=Pf,g.cloneWith=Lf,g.conformsTo=Cf,g.deburr=Ja,g.defaultTo=bs,g.divide=rp,g.endsWith=Qa,g.eq=$f,g.escape=ts,g.escapeRegExp=ns,g.every=Jo,g.find=Yl,g.findIndex=ro,g.findKey=ba,g.findLast=Fl,g.findLastIndex=eo,g.findLastKey=Ba,g.floor=ep,g.forEach=ef,g.forEachRight=uf,g.forIn=xa,g.forInRight=Aa,g.forOwn=ka,g.forOwnRight=Ea,g.get=Ia,g.gt=oc,g.gte=fc,g.has=Ta,g.hasIn=Oa,g.head=ao,g.identity=Bs,g.includes=of,g.indexOf=so,g.inRange=Ka,g.invoke=Sc,g.isArguments=ac,g.isArray=sc,g.isArrayBuffer=hc,g.isArrayLike=zf,g.isArrayLikeObject=Nf,g.isBoolean=qf,g.isBuffer=lc,g.isDate=cc,g.isElement=Wf,g.isEmpty=Df,g.isEqual=Yf,g.isEqualWith=Ff,g.isError=Zf,g.isFinite=Gf,g.isFunction=Vf,g.isInteger=Kf,g.isLength=Hf,g.isMap=pc,g.isMatch=Qf,g.isMatchWith=ta,g.isNaN=na,g.isNative=ra,g.isNil=ia,g.isNull=ea,g.isNumber=ua,g.isObject=Xf,g.isObjectLike=Jf,g.isPlainObject=oa,g.isRegExp=dc,g.isSafeInteger=fa,g.isSet=gc,g.isString=aa,g.isSymbol=sa,g.isTypedArray=vc,g.isUndefined=ha,g.isWeakMap=la,g.isWeakSet=ca,g.join=lo,g.kebabCase=Pc,g.last=co,g.lastIndexOf=po,g.lowerCase=Cc,g.lowerFirst=$c,g.lt=mc,g.lte=yc,g.max=qs,g.maxBy=Ws,g.mean=Ds,g.meanBy=Ys,g.min=Fs,g.minBy=Zs,g.stubArray=js,g.stubFalse=Ls,g.stubObject=Us,g.stubString=Ps,g.stubTrue=Cs,g.multiply=ip,g.nth=go,g.noConflict=Ss,g.noop=Rs,g.now=Xl,g.pad=rs,g.padEnd=es,g.padStart=is,g.parseInt=us,g.random=Ha,g.reduce=sf,g.reduceRight=hf,g.repeat=os,g.replace=fs,g.result=za,g.round=up,g.runInContext=t,g.sample=cf,g.size=gf,g.snakeCase=zc,g.some=vf,g.sortedIndex=bo,g.sortedIndexBy=Bo,g.sortedIndexOf=xo,g.sortedLastIndex=Ao,g.sortedLastIndexBy=ko,g.sortedLastIndexOf=Eo,g.startCase=Nc,g.startsWith=ss,g.subtract=op,g.sum=Gs,g.sumBy=Vs,g.template=hs,g.times=$s,g.toFinite=da,g.toInteger=ga,g.toLength=va,g.toLower=ls,g.toNumber=ma,g.toSafeInteger=_a,g.toString=wa,g.toUpper=cs,g.trim=ps,g.trimEnd=ds,g.trimStart=gs,g.truncate=vs,g.unescape=ms,g.uniqueId=Ns,g.upperCase=qc,g.upperFirst=Wc,g.each=ef,g.eachRight=uf,g.first=ao,Es(g,function(){var t={};return fe(g,function(n,r){sh.call(g.prototype,r)||(t[r]=n)}),t}(),{chain:!1}),g.VERSION="4.17.10",i(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){g[t].placeholder=g}),i(["drop","take"],function(t,n){X.prototype[t]=function(r){r=r===tt?1:$h(ga(r),0);var e=this.__filtered__&&!n?new X(this):this.clone();return e.__filtered__?e.__takeCount__=zh(r,e.__takeCount__):e.__views__.push({size:zh(r,Ot),type:t+(e.__dir__<0?"Right":"")}),e},X.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}}),i(["filter","map","takeWhile"],function(t,n){var r=n+1,e=r==kt||3==r;X.prototype[t]=function(t){var n=this.clone();return n.__iteratees__.push({iteratee:pu(t,3),type:r}),n.__filtered__=n.__filtered__||e,n}}),i(["head","last"],function(t,n){var r="take"+(n?"Right":"");X.prototype[t]=function(){return this[r](1).value()[0]}}),i(["initial","tail"],function(t,n){var r="drop"+(n?"":"Right");X.prototype[t]=function(){return this.__filtered__?new X(this):this[r](1)}}),X.prototype.compact=function(){return this.filter(Bs)},X.prototype.find=function(t){return this.filter(t).head()},X.prototype.findLast=function(t){return this.reverse().find(t)},X.prototype.invokeMap=He(function(t,n){return"function"==typeof t?new X(this):this.map(function(r){return _e(r,t,n)})}),X.prototype.reject=function(t){return this.filter(Af(pu(t)))},X.prototype.slice=function(t,n){t=ga(t);var r=this;return r.__filtered__&&(t>0||n<0)?new X(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),n!==tt&&(r=(n=ga(n))<0?r.dropRight(-n):r.take(n-t)),r)},X.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},X.prototype.toArray=function(){return this.take(Ot)},fe(X.prototype,function(t,n){var r=/^(?:filter|find|map|reject)|While$/.test(n),e=/^(?:head|last)$/.test(n),i=g[e?"take"+("last"==n?"Right":""):n],u=e||/^find/.test(n);i&&(g.prototype[n]=function(){var n=this.__wrapped__,o=e?[1]:arguments,f=n instanceof X,a=o[0],s=f||sc(n),h=function(t){var n=i.apply(g,l([t],o));return e&&c?n[0]:n};s&&r&&"function"==typeof a&&1!=a.length&&(f=s=!1);var c=this.__chain__,p=!!this.__actions__.length,d=u&&!c,v=f&&!p;if(!u&&s){n=v?n:new X(this);var m=t.apply(n,o);return m.__actions__.push({func:Yo,args:[h],thisArg:tt}),new G(m,c)}return d&&v?t.apply(this,o):(m=this.thru(h),d?e?m.value()[0]:m.value():m)})}),i(["pop","push","shift","sort","splice","unshift"],function(t){var n=ih[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",e=/^(?:pop|shift)$/.test(t);g.prototype[t]=function(){var t=arguments;if(e&&!this.__chain__){var i=this.value();return n.apply(sc(i)?i:[],t)}return this[r](function(r){return n.apply(sc(r)?r:[],t)})}}),fe(X.prototype,function(t,n){var r=g[n];if(r){var e=r.name+"";(Xh[e]||(Xh[e]=[])).push({name:n,func:r})}}),Xh[Yi(tt,pt).name]=[{name:"wrapper",func:tt}],X.prototype.clone=J,X.prototype.reverse=jn,X.prototype.value=Yn,g.prototype.at=Wl,g.prototype.chain=Fo,g.prototype.commit=Zo,g.prototype.next=Go,g.prototype.plant=Ko,g.prototype.reverse=Ho,g.prototype.toJSON=g.prototype.valueOf=g.prototype.value=Xo,g.prototype.first=g.prototype.head,Ah&&(g.prototype[Ah]=Vo),g}();"function"==typeof tt&&"object"==typeof tt.amd&&tt.amd?Br._=zr:Ar?((Ar.exports=zr)._=zr,xr._=zr):Br._=zr}).call(commonjsGlobal)}),lodash_1=lodash.reduce,lodash_2=lodash.concat,lodash_3=lodash.chunk,lodash_4=lodash.isUndefined,lodash_5=lodash.isString,lodash_6=lodash.every,lodash_7=lodash.map,lodash_8=lodash.split,lodash$2=Object.freeze({default:lodash,__moduleExports:lodash,reduce:lodash_1,concat:lodash_2,chunk:lodash_3,isUndefined:lodash_4,isString:lodash_5,every:lodash_6,map:lodash_7,split:lodash_8}),require$$0$1=lodash$2&&lodash||lodash$2,src=createCommonjsModule(function(t){const{reduce:reduce,concat:concat,chunk:chunk,isUndefined:isUndefined,isString:isString,every:every,map:map,split:split}=require$$0$1,n=[3077398253,3995603712,2243735041,1261992695],r=`\ndozmarbinwansamlitsighidfidlissogdirwacsabwissibrigsoldopmodfoglidhopdardorlorhodfolrintogsilmirholpaslacrovlivdalsatlibtabhanticpidtorbolfosdotlosdilforpilramtirwintadbicdifrocwidbisdasmidloprilnardapmolsanlocnovsitnidtipsicropwitnatpanminritpodmottamtolsavposnapnopsomfinfonbanmorworsipronnorbotwicsocwatdolmagpicdavbidbaltimtasmalligsivtagpadsaldivdactansidfabtarmonranniswolmispallasdismaprabtobrollatlonnodnavfignomnibpagsopralbilhaddocridmocpacravripfaltodtiltinhapmicfanpattaclabmogsimsonpinlomrictapfirhasbosbatpochactidhavsaplindibhosdabbitbarracparloddosbortochilmactomdigfilfasmithobharmighinradmashalraglagfadtopmophabnilnosmilfopfamdatnoldinhatnacrisfotribhocnimlarfitwalrapsarnalmoslandondanladdovrivbacpollaptalpitnambonrostonfodponsovnocsorlavmatmipfip`,e=(t,n)=>[n.slice(0,t),n.slice(t)],i=t=>t.toString(16).padStart(2,"0"),u=`\nzodnecbudwessevpersutletfulpensytdurwepserwylsunrypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnexlunmeplutseppesdelsulpedtemledtulmetwenbynhexfebpyldulhetmevruttylwydtepbesdexsefwycburderneppurrysrebdennutsubpetrulsynregtydsupsemwynrecmegnetsecmulnymtevwebsummutnyxrextebfushepbenmuswyxsymselrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpelsyptermebsetdutdegtexsurfeltudnuxruxrenwytnubmedlytdusnebrumtynseglyxpunresredfunrevrefmectedrusbexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermertenlusnussyltecmexpubrymtucfyllepdebbermughuttunbylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmylwedducfurfexnulluclennerlexrupnedlecrydlydfenwelnydhusrelrudneshesfetdesretdunlernyrsebhulrylludremlysfynwerrycsugnysnyllyndyndemluxfedsedbecmunlyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes`.match(/.{1,3}/g),o=r.match(/.{1,3}/g),f=(t,n)=>t[n],a=t=>t.length,s=t=>t.length-1,h=(t,n)=>t.indexOf(n),l=t=>t%2!=0,c=t=>!l(t),p=t=>Array.from(Array(t),(t,n)=>n),d=t=>f(o,t),g=t=>f(u,t),v=t=>[...u,...o].includes(t),m=t=>u.includes(t),y=t=>o.includes(t),_=t=>h(o,t),w=t=>h(u,t),M=t=>parseInt(t,2).toString(10),b=t=>t.toString(2),B=t=>b(t).padStart(8,"0"),x=t=>t.replace(/[\^~-]/g,"").match(/.{1,3}/g),A=t=>reduce(t,(t,n,r)=>c(r)?0===r?`~${t}${n}`?16===r:`${t}^${n}`:`${t}-${n}`:`${t}${n}`,""),k=t=>{if(t>=65536&&t<=4294967295){const n=S(t-65536)+65536;return n}if(t>=4294967296&&t<=0x10000000000000000){const n=new bn$1("4294967295"),r=new bn$1("18446744069414584000"),e=t.and(n),i=t.and(r);let u=new bn$1(k(e));return i.or(u)}return t},E=t=>{if(t>=65536&&t<=4294967295){const n=new bn$1(R(t-65536)),r=n.add(new bn$1(65536)).toNumber();return r}if(t>=4294967296&&t<=bn(0x10000000000000000)){const n=new bn$1(t),r=n.and(new bn$1("0xFFFFFFFF")),e=n.and(new bn$1("0xffffffff00000000")),i=e.or(E(r));return i.toNumber()}return t},S=t=>{let n=[t%65535,t/65535];for(var r=0;r<4;r++)n=I(r,n[0],n[1]);const e=65535*n[0]+n[1];return e},R=t=>{let n=[t%65535,t/65535];for(var r=3;r>-1;r--)n=T(r,n[0],n[1]);const e=new bn$1(65535);const i=e.mul(new bn$1(n[0])).add(new bn$1(n[1]));return i.toNumber()},I=(t,r,e)=>{r=Math.floor(r);const i=[e,0];const u=new bn$1(c(t)?65535:65536);const o=new bn$1(O(n[t],2,e));const f=o.add(new bn$1(r)).mod(u);i[1]=f.toNumber();return i},T=(t,r,e)=>{r=Math.floor(r);const i=[e,0];const u=new bn$1(c(t)?65535:65536);const o=new bn$1(O(n[t],2,e));const f=new bn$1(u+r);const a=f.sub(o.mod(u)).mod(u).toString();i[1]=a;return i},O=(t,n,r)=>{const e=255&r;const i=(65280&r)/256;const u=j(String.fromCharCode(e)+String.fromCharCode(i),t);return u},j=(t,n)=>{n||(n=0);const r=new bn$1(3432918353);const e=new bn$1(461845907);const i=4294967295;const u=new bn$1(a(t));let o=new bn$1(n);let f;const s=4294967292&u;for(var h=0;h<s;h+=4){var l=t.charCodeAt(h+3)?t.charCodeAt(h+3):0;f=bn(255&t.charCodeAt(h))|(255&t.charCodeAt(h+1))<<8|(255&t.charCodeAt(h+2))<<16|l<<24,f=(f*=r)<<15|(4294967295&f)>>17,o=5*(o=(o^=f*=e)<<13|(4294967295&o)>>19)+3864292196}f=0;const c=3&u;3==c&&(f=(255&t.charCodeAt(s+2))<<16);3!=c&&2!=c||(f|=(255&t.charCodeAt(s+1))<<8);if(3==c||2==c||1==c){f|=255&t.charCodeAt(s),f=new bn$1(f*r);var p=new bn$1(f.and(new bn$1(i)).shrn(17));f=(f=f.shln(15).or(p)).mul(e),o=o.xor(f)}o=o.xor(u);o=o.xor(o.and(new bn$1(i)).shrn(16));o=o.mul(new bn$1(2246822507));o=o.xor(o.and(new bn$1(i)).shrn(13));o=o.mul(new bn$1(3266489909));o=o.xor(o.and(new bn$1(i)).shrn(16));return o.and(new bn$1(i)).toNumber()},L=new bn$1(0),U=new bn$1(1),P=new bn$1(2),C=new bn$1(3),$=new bn$1(4),z=new bn$1(5),N=t=>{const n=Y(C,t);return n.lte(U)?"czar":n.eq(P)?"king":n.lte($)?"duke":n.lte(new bn$1(8))?"earl":"pawn"},q=t=>{const n=N(t);const r="czar"===n?t:"king"===n?F(C,U,t):"duke"===n?F($,U,t):"earl"===n?F(z,U,t):L;return nt(r)},W=t=>P.pow(t),D=(t,n,r)=>{const e=W(t).mul(n);return r.div(W(e))},Y=(t,n,r=L)=>n.eq(L)?r:Y(t,D(t,U,n),r.add(U)),F=(t,n,r)=>r.mod(W(W(t).mul(n))),Z=t=>{let n=new bn$1(k(t));let r=Y($,n);let e=(t,n,i)=>{let u=F($,U,t);let o=d(D(C,U,u));let f=g(F(C,U,u));let a=n.mod($).eq(L)?n.eq(L)?"":"--":"-";let s=o+f+a+i;return n.eq(r)?i:e(D($,U,t),n.add(U),s)};let i=Y(C,n);return"~"+(i.lte(U)?g(n):e(n,L,""))},G=t=>{const n=t.toArrayLike(Buffer);const r=l(n.length)&&n.length>1?concat([[n[0]]],chunk(n.slice(1),2)):chunk(n,2);const e=t=>isUndefined(t[1])?d(0)+g(t[0]):d(t[0])+g(t[1]);const i=t=>isUndefined(t[1])?g(t[0]):d(t[0])+g(t[1]);const u=t=>l(t.length)&&r.length>1?e(t):i(t);return r.reduce((t,n)=>t+("~"===t?"":"-")+u(n),"~")},V=t=>{const n=Buffer.from(t,"hex");const r=l(n.length)?concat([[n[0]]],chunk(n.slice(1),2)):chunk(n,2);const e=map(r,t=>isUndefined(t[1])?d(0)+g(t[0]):d(t[0])+g(t[1]));return 0===t.length?"~zod":e.reduce((t,n)=>t+("~"===t?"":"-")+n,"~")},K=t=>{const n=split(t.slice(1),"-");const r=map(n,t=>{let n=e(3,t);let r=""===n[1]?i(w(n[0])):i(_(n[0]))+i(w(n[1]));return r});return 0===t.length?"00":r.join("")},H=t=>"00"===t.slice(0,2)?H(t.slice(2)):t,X=(t,n)=>H(t)===H(n),J=(t,n)=>{const r=K(t);const e=K(n);return X(r,e)},Q=t=>{const n=a(x(t));if(n<=1)return"galaxy";if(n<=2)return"star";if(n<=4)return"planet";if(n<=8)return"moon";if(n<=16)return"comet";return"invalid"},tt=t=>{const n=a(b(t));if(n<=8)return"galaxy";if(n<=16)return"star";if(n<=32)return"planet";if(n<=64)return"moon";if(n<=128)return"comet";return"invalid"},nt=t=>{const n=a(b(t));if(n<=8)return it(t);if(n<=16)return ut(t);if(n<=32)return ot(t);n<=64&&console.error("Convert to moon not currently supported.");n<=128&&console.error("Convert to comet not currently supported.");return"invalid"},rt=(t,n)=>{isUndefined(n)&&(n=!0);if(!et(t))return;isString(t)&&(t=x(t));const r=reduce(t,(n,r,e)=>l(e)||1===a(t)?n+B(w(r)):n+B(_(r)),"");const e=M(r);return n?E(e):e},et=t=>{const n=x(t);if(l(a(n))&&1!==a(n))return!1;const r=map(n,(t,r)=>l(r)||1===a(n)?m(t):y(t));return every(r,t=>!0===t)},it=t=>ft(t,1),ut=t=>ft(t,2),ot=(t,n)=>{isUndefined(n)&&(n=!0);return ft(t,4,n)},ft=(t,n,r)=>{isUndefined(r)&&(r=!0);n||(n=t<256?1:t<65536?2:4);4===n&&r&&(t=k(t));const e=reduce(p(n),(n,r)=>{const e=Math.floor(t%256);t/=256;const i=l(r)?d(e):g(e);return n=2===r?i+"-"+n:i+n},"");return e};t.exports={patp2add:rt,add2patp:nt,tierOfpatp:Q,tierOfadd:tt,toGalaxyName:it,toStarName:ut,toPlanetName:ot,isValidName:et,patp:Z,patq:G,hex2patq:V,patq2hex:K,eqPatq:J,sein:q,_clan:N,_add2patp:ft,_getsuffix:g,_muk:O,_feen:k,_fend:E,_teil:R,_getAt:f,_len:a,_lid:s,_indexOf:h,_isOdd:l,_isEven:c,_seq:p,_getPrefix:d,_getSuffix:g,_doesExist:v,_doesSuffixExist:m,_doesPrefixExist:y,_getPrefixIndex:_,_getSuffixIndex:w,_bin2dec:M,_dec2bin:b,_syl2bin:B,_eqModLeadingZeroBytes:X,_met:Y,_arr2patp:A}}),src_1=src.patp2add,src_2=src.add2patp,src_3=src.tierOfpatp,src_4=src.tierOfadd,src_5=src.toGalaxyName,src_6=src.toStarName,src_7=src.toPlanetName,src_8=src.isValidName,src_9=src.patp,src_10=src.patq,src_11=src.hex2patq,src_12=src.patq2hex,src_13=src.eqPatq,src_14=src.sein,src_15=src._clan,src_16=src._add2patp,src_17=src._getsuffix,src_18=src._muk,src_19=src._feen,src_20=src._fend,src_21=src._teil,src_22=src._getAt,src_23=src._len,src_24=src._lid,src_25=src._indexOf,src_26=src._isOdd,src_27=src._isEven,src_28=src._seq,src_29=src._getPrefix,src_30=src._getSuffix,src_31=src._doesExist,src_32=src._doesSuffixExist,src_33=src._doesPrefixExist,src_34=src._getPrefixIndex,src_35=src._getSuffixIndex,src_36=src._bin2dec,src_37=src._dec2bin,src_38=src._syl2bin,src_39=src._eqModLeadingZeroBytes,src_40=src._met,src_41=src._arr2patp;export{src_1 as patp2add,src_2 as add2patp,src_3 as tierOfpatp,src_4 as tierOfadd,src_5 as toGalaxyName,src_6 as toStarName,src_7 as toPlanetName,src_8 as isValidName,src_9 as patp,src_10 as patq,src_11 as hex2patq,src_12 as patq2hex,src_13 as eqPatq,src_14 as sein,src_15 as _clan,src_16 as _add2patp,src_17 as _getsuffix,src_18 as _muk,src_19 as _feen,src_20 as _fend,src_21 as _teil,src_22 as _getAt,src_23 as _len,src_24 as _lid,src_25 as _indexOf,src_26 as _isOdd,src_27 as _isEven,src_28 as _seq,src_29 as _getPrefix,src_30 as _getSuffix,src_31 as _doesExist,src_32 as _doesSuffixExist,src_33 as _doesPrefixExist,src_34 as _getPrefixIndex,src_35 as _getSuffixIndex,src_36 as _bin2dec,src_37 as _dec2bin,src_38 as _syl2bin,src_39 as _eqModLeadingZeroBytes,src_40 as _met,src_41 as _arr2patp};export default src; +(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.urbitOb = f()}})(function(){var define,module,exports;return (function(){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}return e})()({1:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + Buffer = require('buffer').Buffer; + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + } + + if (base === 16) { + this._parseHex(number, start); + } else { + this._parseBase(number, base, start); + } + + if (number[0] === '-') { + this.negative = 1; + } + + this.strip(); + + if (endian !== 'le') return; + + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; + + function parseHex (str, start, end) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r <<= 4; + + // 'a' - 'f' + if (c >= 49 && c <= 54) { + r |= c - 49 + 0xa; + + // 'A' - 'F' + } else if (c >= 17 && c <= 22) { + r |= c - 17 + 0xa; + + // '0' - '9' + } else { + r |= c & 0xf; + } + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + // Scan 24-bit chunks and add them to the number + var off = 0; + for (i = number.length - 6, j = 0; i >= start; i -= 6) { + w = parseHex(number, i, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + if (i + 6 !== start) { + w = parseHex(number, start, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } + this.strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; + + // '0' - '9' + } else { + r += c; + } + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + BN.prototype.inspect = function inspect () { + return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>'; + }; + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; + + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); + + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } + + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[i] = b; + } + + for (; i < reqLength; i++) { + res[i] = 0; + } + } + + return res; + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this.strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this.strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this.strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this.strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this.strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this.strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out.strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out.strip(); + } + + function jumboMulTo (self, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out.strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this.strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this.strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this.strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) < num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this.strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this.strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this.strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q.strip(); + } + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modn = function modn (num) { + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return acc; + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + return this.strip(); + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this.strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + r.strip(); + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); + +},{"buffer":5}],2:[function(require,module,exports){ +(function (global){ +/** + * @license + * Lodash <https://lodash.com/> + * Copyright JS Foundation and other contributors <https://js.foundation/> + * Released under MIT license <https://lodash.com/license> + * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +;(function() { + + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; + + /** Used as the semantic version number. */ + var VERSION = '4.17.10'; + + /** Used as the size to enable large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; + + /** Error message constants. */ + var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', + FUNC_ERROR_TEXT = 'Expected a function'; + + /** Used to stand-in for `undefined` hash values. */ + var HASH_UNDEFINED = '__lodash_hash_undefined__'; + + /** Used as the maximum memoize cache size. */ + var MAX_MEMOIZE_SIZE = 500; + + /** Used as the internal argument placeholder. */ + var PLACEHOLDER = '__lodash_placeholder__'; + + /** Used to compose bitmasks for cloning. */ + var CLONE_DEEP_FLAG = 1, + CLONE_FLAT_FLAG = 2, + CLONE_SYMBOLS_FLAG = 4; + + /** Used to compose bitmasks for value comparisons. */ + var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + + /** Used to compose bitmasks for function metadata. */ + var WRAP_BIND_FLAG = 1, + WRAP_BIND_KEY_FLAG = 2, + WRAP_CURRY_BOUND_FLAG = 4, + WRAP_CURRY_FLAG = 8, + WRAP_CURRY_RIGHT_FLAG = 16, + WRAP_PARTIAL_FLAG = 32, + WRAP_PARTIAL_RIGHT_FLAG = 64, + WRAP_ARY_FLAG = 128, + WRAP_REARG_FLAG = 256, + WRAP_FLIP_FLAG = 512; + + /** Used as default options for `_.truncate`. */ + var DEFAULT_TRUNC_LENGTH = 30, + DEFAULT_TRUNC_OMISSION = '...'; + + /** Used to detect hot functions by number of calls within a span of milliseconds. */ + var HOT_COUNT = 800, + HOT_SPAN = 16; + + /** Used to indicate the type of lazy iteratees. */ + var LAZY_FILTER_FLAG = 1, + LAZY_MAP_FLAG = 2, + LAZY_WHILE_FLAG = 3; + + /** Used as references for various `Number` constants. */ + var INFINITY = 1 / 0, + MAX_SAFE_INTEGER = 9007199254740991, + MAX_INTEGER = 1.7976931348623157e+308, + NAN = 0 / 0; + + /** Used as references for the maximum length and index of an array. */ + var MAX_ARRAY_LENGTH = 4294967295, + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; + + /** Used to associate wrap methods with their bit flags. */ + var wrapFlags = [ + ['ary', WRAP_ARY_FLAG], + ['bind', WRAP_BIND_FLAG], + ['bindKey', WRAP_BIND_KEY_FLAG], + ['curry', WRAP_CURRY_FLAG], + ['curryRight', WRAP_CURRY_RIGHT_FLAG], + ['flip', WRAP_FLIP_FLAG], + ['partial', WRAP_PARTIAL_FLAG], + ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], + ['rearg', WRAP_REARG_FLAG] + ]; + + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + domExcTag = '[object DOMException]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + nullTag = '[object Null]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + proxyTag = '[object Proxy]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + undefinedTag = '[object Undefined]', + weakMapTag = '[object WeakMap]', + weakSetTag = '[object WeakSet]'; + + var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** Used to match empty string literals in compiled template source. */ + var reEmptyStringLeading = /\b__p \+= '';/g, + reEmptyStringMiddle = /\b(__p \+=) '' \+/g, + reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; + + /** Used to match HTML entities and HTML characters. */ + var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, + reUnescapedHtml = /[&<>"']/g, + reHasEscapedHtml = RegExp(reEscapedHtml.source), + reHasUnescapedHtml = RegExp(reUnescapedHtml.source); + + /** Used to match template delimiters. */ + var reEscape = /<%-([\s\S]+?)%>/g, + reEvaluate = /<%([\s\S]+?)%>/g, + reInterpolate = /<%=([\s\S]+?)%>/g; + + /** Used to match property names within property paths. */ + var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + + /** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ + var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, + reHasRegExpChar = RegExp(reRegExpChar.source); + + /** Used to match leading and trailing whitespace. */ + var reTrim = /^\s+|\s+$/g, + reTrimStart = /^\s+/, + reTrimEnd = /\s+$/; + + /** Used to match wrap detail comments. */ + var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, + reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, + reSplitDetails = /,? & /; + + /** Used to match words composed of alphanumeric characters. */ + var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + + /** Used to match backslashes in property paths. */ + var reEscapeChar = /\\(\\)?/g; + + /** + * Used to match + * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). + */ + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; + + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; + + /** Used to detect bad signed hexadecimal string values. */ + var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + + /** Used to detect binary string values. */ + var reIsBinary = /^0b[01]+$/i; + + /** Used to detect host constructors (Safari). */ + var reIsHostCtor = /^\[object .+?Constructor\]$/; + + /** Used to detect octal string values. */ + var reIsOctal = /^0o[0-7]+$/i; + + /** Used to detect unsigned integer values. */ + var reIsUint = /^(?:0|[1-9]\d*)$/; + + /** Used to match Latin Unicode letters (excluding mathematical operators). */ + var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + + /** Used to ensure capturing order of template delimiters. */ + var reNoMatch = /($^)/; + + /** Used to match unescaped characters in compiled string literals. */ + var reUnescapedString = /['\n\r\u2028\u2029\\]/g; + + /** Used to compose unicode character classes. */ + var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f', + reComboHalfMarksRange = '\\ufe20-\\ufe2f', + rsComboSymbolsRange = '\\u20d0-\\u20ff', + rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, + rsDingbatRange = '\\u2700-\\u27bf', + rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', + rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', + rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', + rsPunctuationRange = '\\u2000-\\u206f', + rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', + rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', + rsVarRange = '\\ufe0e\\ufe0f', + rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; + + /** Used to compose unicode capture groups. */ + var rsApos = "['\u2019]", + rsAstral = '[' + rsAstralRange + ']', + rsBreak = '[' + rsBreakRange + ']', + rsCombo = '[' + rsComboRange + ']', + rsDigits = '\\d+', + rsDingbat = '[' + rsDingbatRange + ']', + rsLower = '[' + rsLowerRange + ']', + rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', + rsNonAstral = '[^' + rsAstralRange + ']', + rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', + rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', + rsUpper = '[' + rsUpperRange + ']', + rsZWJ = '\\u200d'; + + /** Used to compose unicode regexes. */ + var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', + rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', + rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', + rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', + reOptMod = rsModifier + '?', + rsOptVar = '[' + rsVarRange + ']?', + rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', + rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', + rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', + rsSeq = rsOptVar + reOptMod + rsOptJoin, + rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, + rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + + /** Used to match apostrophes. */ + var reApos = RegExp(rsApos, 'g'); + + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ + var reComboMark = RegExp(rsCombo, 'g'); + + /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ + var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + + /** Used to match complex or compound words. */ + var reUnicodeWord = RegExp([ + rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', + rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', + rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, + rsUpper + '+' + rsOptContrUpper, + rsOrdUpper, + rsOrdLower, + rsDigits, + rsEmoji + ].join('|'), 'g'); + + /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ + var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + + /** Used to detect strings that need a more robust regexp to match words. */ + var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + + /** Used to assign default `context` object properties. */ + var contextProps = [ + 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', + 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', + 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + ]; + + /** Used to make template sourceURLs easier to identify. */ + var templateCounter = -1; + + /** Used to identify `toStringTag` values of typed arrays. */ + var typedArrayTags = {}; + typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = + typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = + typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = + typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = + typedArrayTags[uint32Tag] = true; + typedArrayTags[argsTag] = typedArrayTags[arrayTag] = + typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = + typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = + typedArrayTags[errorTag] = typedArrayTags[funcTag] = + typedArrayTags[mapTag] = typedArrayTags[numberTag] = + typedArrayTags[objectTag] = typedArrayTags[regexpTag] = + typedArrayTags[setTag] = typedArrayTags[stringTag] = + typedArrayTags[weakMapTag] = false; + + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = + cloneableTags[boolTag] = cloneableTags[dateTag] = + cloneableTags[float32Tag] = cloneableTags[float64Tag] = + cloneableTags[int8Tag] = cloneableTags[int16Tag] = + cloneableTags[int32Tag] = cloneableTags[mapTag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[setTag] = + cloneableTags[stringTag] = cloneableTags[symbolTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[weakMapTag] = false; + + /** Used to map Latin Unicode letters to basic Latin letters. */ + var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 's' + }; + + /** Used to map characters to HTML entities. */ + var htmlEscapes = { + '&': '&amp;', + '<': '&lt;', + '>': '&gt;', + '"': '&quot;', + "'": '&#39;' + }; + + /** Used to map HTML entities to characters. */ + var htmlUnescapes = { + '&amp;': '&', + '&lt;': '<', + '&gt;': '>', + '&quot;': '"', + '&#39;': "'" + }; + + /** Used to escape characters for inclusion in compiled string literals. */ + var stringEscapes = { + '\\': '\\', + "'": "'", + '\n': 'n', + '\r': 'r', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + /** Built-in method references without a dependency on `root`. */ + var freeParseFloat = parseFloat, + freeParseInt = parseInt; + + /** Detect free variable `global` from Node.js. */ + var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + + /** Detect free variable `self`. */ + var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + + /** Used as a reference to the global object. */ + var root = freeGlobal || freeSelf || Function('return this')(); + + /** Detect free variable `exports`. */ + var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + + /** Detect free variable `module`. */ + var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports`. */ + var moduleExports = freeModule && freeModule.exports === freeExports; + + /** Detect free variable `process` from Node.js. */ + var freeProcess = moduleExports && freeGlobal.process; + + /** Used to access faster Node.js helpers. */ + var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} + }()); + + /* Node.js helper references. */ + var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, + nodeIsDate = nodeUtil && nodeUtil.isDate, + nodeIsMap = nodeUtil && nodeUtil.isMap, + nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, + nodeIsSet = nodeUtil && nodeUtil.isSet, + nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + + /*--------------------------------------------------------------------------*/ + + /** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ + function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); + } + + /** + * A specialized version of `baseAggregator` for arrays. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function arrayAggregator(array, setter, iteratee, accumulator) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + var value = array[index]; + setter(accumulator, value, iteratee(value), array); + } + return accumulator; + } + + /** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.forEachRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ + function arrayEachRight(array, iteratee) { + var length = array == null ? 0 : array.length; + + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; + } + } + return array; + } + + /** + * A specialized version of `_.every` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + */ + function arrayEvery(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } + } + return true; + } + + /** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; + } + + /** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; + } + + /** + * This function is like `arrayIncludes` except that it accepts a comparator. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ + function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } + } + return false; + } + + /** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + + /** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ + function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; + } + + /** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; + } + + /** + * A specialized version of `_.reduceRight` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ + function arrayReduceRight(array, iteratee, accumulator, initAccum) { + var length = array == null ? 0 : array.length; + if (initAccum && length) { + accumulator = array[--length]; + } + while (length--) { + accumulator = iteratee(accumulator, array[length], length, array); + } + return accumulator; + } + + /** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; + } + + /** + * Gets the size of an ASCII `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + var asciiSize = baseProperty('length'); + + /** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function asciiToArray(string) { + return string.split(''); + } + + /** + * Splits an ASCII `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function asciiWords(string) { + return string.match(reAsciiWord) || []; + } + + /** + * The base implementation of methods like `_.findKey` and `_.findLastKey`, + * without support for iteratee shorthands, which iterates over `collection` + * using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the found element or its key, else `undefined`. + */ + function baseFindKey(collection, predicate, eachFunc) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = key; + return false; + } + }); + return result; + } + + /** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); + + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); + } + + /** + * This function is like `baseIndexOf` except that it accepts a comparator. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @param {Function} comparator The comparator invoked per element. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function baseIndexOfWith(array, value, fromIndex, comparator) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (comparator(array[index], value)) { + return index; + } + } + return -1; + } + + /** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ + function baseIsNaN(value) { + return value !== value; + } + + /** + * The base implementation of `_.mean` and `_.meanBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the mean. + */ + function baseMean(array, iteratee) { + var length = array == null ? 0 : array.length; + return length ? (baseSum(array, iteratee) / length) : NAN; + } + + /** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.propertyOf` without support for deep paths. + * + * @private + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyOf(object) { + return function(key) { + return object == null ? undefined : object[key]; + }; + } + + /** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ + function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + + /** + * The base implementation of `_.sum` and `_.sumBy` without support for + * iteratee shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function baseSum(array, iteratee) { + var result, + index = -1, + length = array.length; + + while (++index < length) { + var current = iteratee(array[index]); + if (current !== undefined) { + result = result === undefined ? current : (result + current); + } + } + return result; + } + + /** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ + function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; + } + + /** + * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array + * of key-value pairs for `object` corresponding to the property names of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the key-value pairs. + */ + function baseToPairs(object, props) { + return arrayMap(props, function(key) { + return [key, object[key]]; + }); + } + + /** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ + function baseUnary(func) { + return function(value) { + return func(value); + }; + } + + /** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ + function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; + }); + } + + /** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function cacheHas(cache, key) { + return cache.has(key); + } + + /** + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the first unmatched string symbol. + */ + function charsStartIndex(strSymbols, chrSymbols) { + var index = -1, + length = strSymbols.length; + + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } + + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the last unmatched string symbol. + */ + function charsEndIndex(strSymbols, chrSymbols) { + var index = strSymbols.length; + + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; + } + + /** + * Gets the number of `placeholder` occurrences in `array`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} placeholder The placeholder to search for. + * @returns {number} Returns the placeholder count. + */ + function countHolders(array, placeholder) { + var length = array.length, + result = 0; + + while (length--) { + if (array[length] === placeholder) { + ++result; + } + } + return result; + } + + /** + * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A + * letters to basic Latin letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ + var deburrLetter = basePropertyOf(deburredLetters); + + /** + * Used by `_.escape` to convert characters to HTML entities. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + var escapeHtmlChar = basePropertyOf(htmlEscapes); + + /** + * Used by `_.template` to escape characters for inclusion in compiled string literals. + * + * @private + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. + */ + function escapeStringChar(chr) { + return '\\' + stringEscapes[chr]; + } + + /** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function getValue(object, key) { + return object == null ? undefined : object[key]; + } + + /** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ + function hasUnicode(string) { + return reHasUnicode.test(string); + } + + /** + * Checks if `string` contains a word composed of Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a word is found, else `false`. + */ + function hasUnicodeWord(string) { + return reHasUnicodeWord.test(string); + } + + /** + * Converts `iterator` to an array. + * + * @private + * @param {Object} iterator The iterator to convert. + * @returns {Array} Returns the converted array. + */ + function iteratorToArray(iterator) { + var data, + result = []; + + while (!(data = iterator.next()).done) { + result.push(data.value); + } + return result; + } + + /** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ + function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; + } + + /** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ + function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; + } + + /** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ + function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value === placeholder || value === PLACEHOLDER) { + array[index] = PLACEHOLDER; + result[resIndex++] = index; + } + } + return result; + } + + /** + * Gets the value at `key`, unless `key` is "__proto__". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ + function safeGet(object, key) { + return key == '__proto__' + ? undefined + : object[key]; + } + + /** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ + function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; + } + + /** + * Converts `set` to its value-value pairs. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the value-value pairs. + */ + function setToPairs(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = [value, value]; + }); + return result; + } + + /** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + + /** + * A specialized version of `_.lastIndexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function strictLastIndexOf(array, value, fromIndex) { + var index = fromIndex + 1; + while (index--) { + if (array[index] === value) { + return index; + } + } + return index; + } + + /** + * Gets the number of symbols in `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the string size. + */ + function stringSize(string) { + return hasUnicode(string) + ? unicodeSize(string) + : asciiSize(string); + } + + /** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); + } + + /** + * Used by `_.unescape` to convert HTML entities to characters. + * + * @private + * @param {string} chr The matched character to unescape. + * @returns {string} Returns the unescaped character. + */ + var unescapeHtmlChar = basePropertyOf(htmlUnescapes); + + /** + * Gets the size of a Unicode `string`. + * + * @private + * @param {string} string The string inspect. + * @returns {number} Returns the string size. + */ + function unicodeSize(string) { + var result = reUnicode.lastIndex = 0; + while (reUnicode.test(string)) { + ++result; + } + return result; + } + + /** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ + function unicodeToArray(string) { + return string.match(reUnicode) || []; + } + + /** + * Splits a Unicode `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ + function unicodeWords(string) { + return string.match(reUnicodeWord) || []; + } + + /*--------------------------------------------------------------------------*/ + + /** + * Create a new pristine `lodash` function using the `context` object. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Util + * @param {Object} [context=root] The context object. + * @returns {Function} Returns a new `lodash` function. + * @example + * + * _.mixin({ 'foo': _.constant('foo') }); + * + * var lodash = _.runInContext(); + * lodash.mixin({ 'bar': lodash.constant('bar') }); + * + * _.isFunction(_.foo); + * // => true + * _.isFunction(_.bar); + * // => false + * + * lodash.isFunction(lodash.foo); + * // => false + * lodash.isFunction(lodash.bar); + * // => true + * + * // Create a suped-up `defer` in Node.js. + * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; + */ + var runInContext = (function runInContext(context) { + context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); + + /** Built-in constructor references. */ + var Array = context.Array, + Date = context.Date, + Error = context.Error, + Function = context.Function, + Math = context.Math, + Object = context.Object, + RegExp = context.RegExp, + String = context.String, + TypeError = context.TypeError; + + /** Used for built-in method references. */ + var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; + + /** Used to detect overreaching core-js shims. */ + var coreJsData = context['__core-js_shared__']; + + /** Used to resolve the decompiled source of functions. */ + var funcToString = funcProto.toString; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** Used to generate unique IDs. */ + var idCounter = 0; + + /** Used to detect methods masquerading as native. */ + var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; + }()); + + /** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ + var nativeObjectToString = objectProto.toString; + + /** Used to infer the `Object` constructor. */ + var objectCtorString = funcToString.call(Object); + + /** Used to restore the original `_` reference in `_.noConflict`. */ + var oldDash = root._; + + /** Used to detect if a method is native. */ + var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** Built-in value references. */ + var Buffer = moduleExports ? context.Buffer : undefined, + Symbol = context.Symbol, + Uint8Array = context.Uint8Array, + allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, + getPrototype = overArg(Object.getPrototypeOf, Object), + objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice, + spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, + symIterator = Symbol ? Symbol.iterator : undefined, + symToStringTag = Symbol ? Symbol.toStringTag : undefined; + + var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} + }()); + + /** Mocked built-ins. */ + var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, + ctxNow = Date && Date.now !== root.Date.now && Date.now, + ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; + + /* Built-in method references for those with the same name as other `lodash` methods. */ + var nativeCeil = Math.ceil, + nativeFloor = Math.floor, + nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, + nativeIsFinite = context.isFinite, + nativeJoin = arrayProto.join, + nativeKeys = overArg(Object.keys, Object), + nativeMax = Math.max, + nativeMin = Math.min, + nativeNow = Date.now, + nativeParseInt = context.parseInt, + nativeRandom = Math.random, + nativeReverse = arrayProto.reverse; + + /* Built-in method references that are verified to be native. */ + var DataView = getNative(context, 'DataView'), + Map = getNative(context, 'Map'), + Promise = getNative(context, 'Promise'), + Set = getNative(context, 'Set'), + WeakMap = getNative(context, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); + + /** Used to store function metadata. */ + var metaMap = WeakMap && new WeakMap; + + /** Used to lookup unminified function names. */ + var realNames = {}; + + /** Used to detect maps, sets, and weakmaps. */ + var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); + + /** Used to convert symbols to primitives and strings. */ + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a `lodash` object which wraps `value` to enable implicit method + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. + * + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. + * + * The execution of chained methods is lazy, that is, it's deferred until + * `_#value` is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array and iteratees accept only + * one argument. The heuristic for whether a section qualifies for shortcut + * fusion is subject to change. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, + * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, + * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, + * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, + * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, + * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, + * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, + * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, + * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, + * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, + * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, + * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, + * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, + * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, + * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, + * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, + * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, + * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, + * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, + * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, + * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, + * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, + * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, + * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, + * `upperFirst`, `value`, and `words` + * + * @name _ + * @constructor + * @category Seq + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2, 3]); + * + * // Returns an unwrapped value. + * wrapped.reduce(_.add); + * // => 6 + * + * // Returns a wrapped value. + * var squares = wrapped.map(square); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ + function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); + } + + /** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ + var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; + }()); + + /** + * The function whose prototype chain sequence wrappers inherit from. + * + * @private + */ + function baseLodash() { + // No operation performed. + } + + /** + * The base constructor for creating `lodash` wrapper objects. + * + * @private + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable explicit method chain sequences. + */ + function LodashWrapper(value, chainAll) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__chain__ = !!chainAll; + this.__index__ = 0; + this.__values__ = undefined; + } + + /** + * By default, the template delimiters used by lodash are like those in + * embedded Ruby (ERB) as well as ES2015 template strings. Change the + * following template settings to use alternative delimiters. + * + * @static + * @memberOf _ + * @type {Object} + */ + lodash.templateSettings = { + + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'escape': reEscape, + + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'evaluate': reEvaluate, + + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + 'interpolate': reInterpolate, + + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type {string} + */ + 'variable': '', + + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type {Object} + */ + 'imports': { + + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type {Function} + */ + '_': lodash + } + }; + + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + lodash.prototype.constructor = lodash; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. + * + * @private + * @constructor + * @param {*} value The value to wrap. + */ + function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = MAX_ARRAY_LENGTH; + this.__views__ = []; + } + + /** + * Creates a clone of the lazy wrapper object. + * + * @private + * @name clone + * @memberOf LazyWrapper + * @returns {Object} Returns the cloned `LazyWrapper` object. + */ + function lazyClone() { + var result = new LazyWrapper(this.__wrapped__); + result.__actions__ = copyArray(this.__actions__); + result.__dir__ = this.__dir__; + result.__filtered__ = this.__filtered__; + result.__iteratees__ = copyArray(this.__iteratees__); + result.__takeCount__ = this.__takeCount__; + result.__views__ = copyArray(this.__views__); + return result; + } + + /** + * Reverses the direction of lazy iteration. + * + * @private + * @name reverse + * @memberOf LazyWrapper + * @returns {Object} Returns the new reversed `LazyWrapper` object. + */ + function lazyReverse() { + if (this.__filtered__) { + var result = new LazyWrapper(this); + result.__dir__ = -1; + result.__filtered__ = true; + } else { + result = this.clone(); + result.__dir__ *= -1; + } + return result; + } + + /** + * Extracts the unwrapped value from its lazy wrapper. + * + * @private + * @name value + * @memberOf LazyWrapper + * @returns {*} Returns the unwrapped value. + */ + function lazyValue() { + var array = this.__wrapped__.value(), + dir = this.__dir__, + isArr = isArray(array), + isRight = dir < 0, + arrLength = isArr ? array.length : 0, + view = getView(0, arrLength, this.__views__), + start = view.start, + end = view.end, + length = end - start, + index = isRight ? end : (start - 1), + iteratees = this.__iteratees__, + iterLength = iteratees.length, + resIndex = 0, + takeCount = nativeMin(length, this.__takeCount__); + + if (!isArr || (!isRight && arrLength == length && takeCount == length)) { + return baseWrapperValue(array, this.__actions__); + } + var result = []; + + outer: + while (length-- && resIndex < takeCount) { + index += dir; + + var iterIndex = -1, + value = array[index]; + + while (++iterIndex < iterLength) { + var data = iteratees[iterIndex], + iteratee = data.iteratee, + type = data.type, + computed = iteratee(value); + + if (type == LAZY_MAP_FLAG) { + value = computed; + } else if (!computed) { + if (type == LAZY_FILTER_FLAG) { + continue outer; + } else { + break outer; + } + } + } + result[resIndex++] = value; + } + return result; + } + + // Ensure `LazyWrapper` is an instance of `baseLodash`. + LazyWrapper.prototype = baseCreate(baseLodash.prototype); + LazyWrapper.prototype.constructor = LazyWrapper; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ + function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; + } + + /** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; + } + + /** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty.call(data, key) ? data[key] : undefined; + } + + /** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); + } + + /** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ + function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; + } + + // Add methods to `Hash`. + Hash.prototype.clear = hashClear; + Hash.prototype['delete'] = hashDelete; + Hash.prototype.get = hashGet; + Hash.prototype.has = hashHas; + Hash.prototype.set = hashSet; + + /*------------------------------------------------------------------------*/ + + /** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ + function listCacheClear() { + this.__data__ = []; + this.size = 0; + } + + /** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; + } + + /** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; + } + + /** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; + } + + /** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ + function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; + } + + // Add methods to `ListCache`. + ListCache.prototype.clear = listCacheClear; + ListCache.prototype['delete'] = listCacheDelete; + ListCache.prototype.get = listCacheGet; + ListCache.prototype.has = listCacheHas; + ListCache.prototype.set = listCacheSet; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } + } + + /** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ + function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; + } + + /** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; + } + + /** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function mapCacheGet(key) { + return getMapData(this, key).get(key); + } + + /** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function mapCacheHas(key) { + return getMapData(this, key).has(key); + } + + /** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ + function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; + } + + // Add methods to `MapCache`. + MapCache.prototype.clear = mapCacheClear; + MapCache.prototype['delete'] = mapCacheDelete; + MapCache.prototype.get = mapCacheGet; + MapCache.prototype.has = mapCacheHas; + MapCache.prototype.set = mapCacheSet; + + /*------------------------------------------------------------------------*/ + + /** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ + function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } + } + + /** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ + function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; + } + + /** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ + function setCacheHas(value) { + return this.__data__.has(value); + } + + // Add methods to `SetCache`. + SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; + SetCache.prototype.has = setCacheHas; + + /*------------------------------------------------------------------------*/ + + /** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ + function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; + } + + /** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ + function stackClear() { + this.__data__ = new ListCache; + this.size = 0; + } + + /** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ + function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; + } + + /** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ + function stackGet(key) { + return this.__data__.get(key); + } + + /** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ + function stackHas(key) { + return this.__data__.has(key); + } + + /** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ + function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; + } + + // Add methods to `Stack`. + Stack.prototype.clear = stackClear; + Stack.prototype['delete'] = stackDelete; + Stack.prototype.get = stackGet; + Stack.prototype.has = stackHas; + Stack.prototype.set = stackSet; + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ + function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; + } + + /** + * A specialized version of `_.sample` for arrays. + * + * @private + * @param {Array} array The array to sample. + * @returns {*} Returns the random element. + */ + function arraySample(array) { + var length = array.length; + return length ? array[baseRandom(0, length - 1)] : undefined; + } + + /** + * A specialized version of `_.sampleSize` for arrays. + * + * @private + * @param {Array} array The array to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function arraySampleSize(array, n) { + return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); + } + + /** + * A specialized version of `_.shuffle` for arrays. + * + * @private + * @param {Array} array The array to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function arrayShuffle(array) { + return shuffleSelf(copyArray(array)); + } + + /** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } + } + + /** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } + } + + /** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ + function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; + } + + /** + * Aggregates elements of `collection` on `accumulator` with keys transformed + * by `iteratee` and values set by `setter`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ + function baseAggregator(collection, setter, iteratee, accumulator) { + baseEach(collection, function(value, key, collection) { + setter(accumulator, value, iteratee(value), collection); + }); + return accumulator; + } + + /** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); + } + + /** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ + function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); + } + + /** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ + function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } + } + + /** + * The base implementation of `_.at` without support for individual paths. + * + * @private + * @param {Object} object The object to iterate over. + * @param {string[]} paths The property paths to pick. + * @returns {Array} Returns the picked elements. + */ + function baseAt(object, paths) { + var index = -1, + length = paths.length, + result = Array(length), + skip = object == null; + + while (++index < length) { + result[index] = skip ? undefined : get(object, paths[index]); + } + return result; + } + + /** + * The base implementation of `_.clamp` which doesn't coerce arguments. + * + * @private + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. + */ + function baseClamp(number, lower, upper) { + if (number === number) { + if (upper !== undefined) { + number = number <= upper ? number : upper; + } + if (lower !== undefined) { + number = number >= lower ? number : lower; + } + } + return number; + } + + /** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG; + + if (customizer) { + result = object ? customizer(value, key, object, stack) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + + return result; + } + + if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + + return result; + } + + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; + } + + /** + * The base implementation of `_.conforms` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. + */ + function baseConforms(source) { + var props = keys(source); + return function(object) { + return baseConformsTo(object, source, props); + }; + } + + /** + * The base implementation of `_.conformsTo` which accepts `props` to check. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. + */ + function baseConformsTo(object, source, props) { + var length = props.length; + if (object == null) { + return !length; + } + object = Object(object); + while (length--) { + var key = props[length], + predicate = source[key], + value = object[key]; + + if ((value === undefined && !(key in object)) || !predicate(value)) { + return false; + } + } + return true; + } + + /** + * The base implementation of `_.delay` and `_.defer` which accepts `args` + * to provide to `func`. + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Array} args The arguments to provide to `func`. + * @returns {number|Object} Returns the timer id or timeout object. + */ + function baseDelay(func, wait, args) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + return setTimeout(function() { func.apply(undefined, args); }, wait); + } + + /** + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Array} values The values to exclude. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + */ + function baseDifference(array, values, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + isCommon = true, + length = array.length, + result = [], + valuesLength = values.length; + + if (!length) { + return result; + } + if (iteratee) { + values = arrayMap(values, baseUnary(iteratee)); + } + if (comparator) { + includes = arrayIncludesWith; + isCommon = false; + } + else if (values.length >= LARGE_ARRAY_SIZE) { + includes = cacheHas; + isCommon = false; + values = new SetCache(values); + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee == null ? value : iteratee(value); + + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(values, computed, comparator)) { + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ + var baseEach = createBaseEach(baseForOwn); + + /** + * The base implementation of `_.forEachRight` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ + var baseEachRight = createBaseEach(baseForOwnRight, true); + + /** + * The base implementation of `_.every` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` + */ + function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; + } + + /** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ + function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index], + current = iteratee(value); + + if (current != null && (computed === undefined + ? (current === current && !isSymbol(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; + } + + /** + * The base implementation of `_.fill` without an iteratee call guard. + * + * @private + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. + */ + function baseFill(array, value, start, end) { + var length = array.length; + + start = toInteger(start); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : toInteger(end); + if (end < 0) { + end += length; + } + end = start > end ? 0 : toLength(end); + while (start < end) { + array[start++] = value; + } + return array; + } + + /** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ + function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; + } + + /** + * The base implementation of `_.flatten` with support for restricting flattening. + * + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ + function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (depth > 0 && predicate(value)) { + if (depth > 1) { + // Recursively flatten arrays (susceptible to call stack limits). + baseFlatten(value, depth - 1, predicate, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; + } + + /** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseFor = createBaseFor(); + + /** + * This function is like `baseFor` except that it iterates over properties + * in the opposite order. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ + var baseForRight = createBaseFor(true); + + /** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); + } + + /** + * The base implementation of `_.forOwnRight` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ + function baseForOwnRight(object, iteratee) { + return object && baseForRight(object, iteratee, keys); + } + + /** + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from `props`. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the function names. + */ + function baseFunctions(object, props) { + return arrayFilter(props, function(key) { + return isFunction(object[key]); + }); + } + + /** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ + function baseGet(object, path) { + path = castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; + } + + /** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ + function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); + } + + /** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); + } + + /** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ + function baseGt(value, other) { + return value > other; + } + + /** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHas(object, key) { + return object != null && hasOwnProperty.call(object, key); + } + + /** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ + function baseHasIn(object, key) { + return object != null && key in Object(object); + } + + /** + * The base implementation of `_.inRange` which doesn't coerce arguments. + * + * @private + * @param {number} number The number to check. + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + */ + function baseInRange(number, start, end) { + return number >= nativeMin(start, end) && number < nativeMax(start, end); + } + + /** + * The base implementation of methods like `_.intersection`, without support + * for iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of shared values. + */ + function baseIntersection(arrays, iteratee, comparator) { + var includes = comparator ? arrayIncludesWith : arrayIncludes, + length = arrays[0].length, + othLength = arrays.length, + othIndex = othLength, + caches = Array(othLength), + maxLength = Infinity, + result = []; + + while (othIndex--) { + var array = arrays[othIndex]; + if (othIndex && iteratee) { + array = arrayMap(array, baseUnary(iteratee)); + } + maxLength = nativeMin(array.length, maxLength); + caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) + ? new SetCache(othIndex && array) + : undefined; + } + array = arrays[0]; + + var index = -1, + seen = caches[0]; + + outer: + while (++index < length && result.length < maxLength) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (!(seen + ? cacheHas(seen, computed) + : includes(result, computed, comparator) + )) { + othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if (!(cache + ? cacheHas(cache, computed) + : includes(arrays[othIndex], computed, comparator)) + ) { + continue outer; + } + } + if (seen) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.invert` and `_.invertBy` which inverts + * `object` with values transformed by `iteratee` and set by `setter`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform values. + * @param {Object} accumulator The initial inverted object. + * @returns {Function} Returns `accumulator`. + */ + function baseInverter(object, setter, iteratee, accumulator) { + baseForOwn(object, function(value, key, object) { + setter(accumulator, iteratee(value), key, object); + }); + return accumulator; + } + + /** + * The base implementation of `_.invoke` without support for individual + * method arguments. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ + function baseInvoke(object, path, args) { + path = castPath(path, object); + object = parent(object, path); + var func = object == null ? object : object[toKey(last(path))]; + return func == null ? undefined : apply(func, object, args); + } + + /** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ + function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; + } + + /** + * The base implementation of `_.isArrayBuffer` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + */ + function baseIsArrayBuffer(value) { + return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; + } + + /** + * The base implementation of `_.isDate` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + */ + function baseIsDate(value) { + return isObjectLike(value) && baseGetTag(value) == dateTag; + } + + /** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); + } + + /** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); + } + + /** + * The base implementation of `_.isMap` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + */ + function baseIsMap(value) { + return isObjectLike(value) && getTag(value) == mapTag; + } + + /** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ + function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) + : result + )) { + return false; + } + } + } + return true; + } + + /** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ + function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); + } + + /** + * The base implementation of `_.isRegExp` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + */ + function baseIsRegExp(value) { + return isObjectLike(value) && baseGetTag(value) == regexpTag; + } + + /** + * The base implementation of `_.isSet` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ + function baseIsSet(value) { + return isObjectLike(value) && getTag(value) == setTag; + } + + /** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ + function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; + } + + /** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ + function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); + } + + /** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; + } + + /** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function baseKeysIn(object) { + if (!isObject(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + return result; + } + + /** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ + function baseLt(value, other) { + return value < other; + } + + /** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; + } + + /** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; + } + + /** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); + } + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; + } + + /** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + if (isObject(srcValue)) { + stack || (stack = new Stack); + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); + } + + /** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ + function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); + + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); + } + + /** + * The base implementation of `_.nth` which doesn't coerce arguments. + * + * @private + * @param {Array} array The array to query. + * @param {number} n The index of the element to return. + * @returns {*} Returns the nth element of `array`. + */ + function baseNth(array, n) { + var length = array.length; + if (!length) { + return; + } + n += n < 0 ? length : 0; + return isIndex(n, length) ? array[n] : undefined; + } + + /** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ + function baseOrderBy(collection, iteratees, orders) { + var index = -1; + iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); + + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + + /** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ + function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); + } + + /** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ + function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; + + while (++index < length) { + var path = paths[index], + value = baseGet(object, path); + + if (predicate(value, path)) { + baseSet(result, castPath(path, object), value); + } + } + return result; + } + + /** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ + function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; + } + + /** + * The base implementation of `_.pullAllBy` without support for iteratee + * shorthands. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to remove. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns `array`. + */ + function basePullAll(array, values, iteratee, comparator) { + var indexOf = comparator ? baseIndexOfWith : baseIndexOf, + index = -1, + length = values.length, + seen = array; + + if (array === values) { + values = copyArray(values); + } + if (iteratee) { + seen = arrayMap(array, baseUnary(iteratee)); + } + while (++index < length) { + var fromIndex = 0, + value = values[index], + computed = iteratee ? iteratee(value) : value; + + while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { + if (seen !== array) { + splice.call(seen, fromIndex, 1); + } + splice.call(array, fromIndex, 1); + } + } + return array; + } + + /** + * The base implementation of `_.pullAt` without support for individual + * indexes or capturing the removed elements. + * + * @private + * @param {Array} array The array to modify. + * @param {number[]} indexes The indexes of elements to remove. + * @returns {Array} Returns `array`. + */ + function basePullAt(array, indexes) { + var length = array ? indexes.length : 0, + lastIndex = length - 1; + + while (length--) { + var index = indexes[length]; + if (length == lastIndex || index !== previous) { + var previous = index; + if (isIndex(index)) { + splice.call(array, index, 1); + } else { + baseUnset(array, index); + } + } + } + return array; + } + + /** + * The base implementation of `_.random` without support for returning + * floating-point numbers. + * + * @private + * @param {number} lower The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the random number. + */ + function baseRandom(lower, upper) { + return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); + } + + /** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ + function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; + } + return result; + } + + /** + * The base implementation of `_.repeat` which doesn't coerce arguments. + * + * @private + * @param {string} string The string to repeat. + * @param {number} n The number of times to repeat the string. + * @returns {string} Returns the repeated string. + */ + function baseRepeat(string, n) { + var result = ''; + if (!string || n < 1 || n > MAX_SAFE_INTEGER) { + return result; + } + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. + do { + if (n % 2) { + result += string; + } + n = nativeFloor(n / 2); + if (n) { + string += string; + } + } while (n); + + return result; + } + + /** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ + function baseRest(func, start) { + return setToString(overRest(func, start, identity), func + ''); + } + + /** + * The base implementation of `_.sample`. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @returns {*} Returns the random element. + */ + function baseSample(collection) { + return arraySample(values(collection)); + } + + /** + * The base implementation of `_.sampleSize` without param guards. + * + * @private + * @param {Array|Object} collection The collection to sample. + * @param {number} n The number of elements to sample. + * @returns {Array} Returns the random elements. + */ + function baseSampleSize(collection, n) { + var array = values(collection); + return shuffleSelf(array, baseClamp(n, 0, array.length)); + } + + /** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ + function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; + } + + /** + * The base implementation of `setData` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + + /** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); + }; + + /** + * The base implementation of `_.shuffle`. + * + * @private + * @param {Array|Object} collection The collection to shuffle. + * @returns {Array} Returns the new shuffled array. + */ + function baseShuffle(collection) { + return shuffleSelf(values(collection)); + } + + /** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; + } + + /** + * The base implementation of `_.some` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ + function baseSome(collection, predicate) { + var result; + + baseEach(collection, function(value, index, collection) { + result = predicate(value, index, collection); + return !result; + }); + return !!result; + } + + /** + * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which + * performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseSortedIndex(array, value, retHighest) { + var low = 0, + high = array == null ? low : array.length; + + if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if (computed !== null && !isSymbol(computed) && + (retHighest ? (computed <= value) : (computed < value))) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return baseSortedIndexBy(array, value, identity, retHighest); + } + + /** + * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` + * which invokes `iteratee` for `value` and each element of `array` to compute + * their sort ranking. The iteratee is invoked with one argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} iteratee The iteratee invoked per element. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ + function baseSortedIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + + var low = 0, + high = array == null ? 0 : array.length, + valIsNaN = value !== value, + valIsNull = value === null, + valIsSymbol = isSymbol(value), + valIsUndefined = value === undefined; + + while (low < high) { + var mid = nativeFloor((low + high) / 2), + computed = iteratee(array[mid]), + othIsDefined = computed !== undefined, + othIsNull = computed === null, + othIsReflexive = computed === computed, + othIsSymbol = isSymbol(computed); + + if (valIsNaN) { + var setLow = retHighest || othIsReflexive; + } else if (valIsUndefined) { + setLow = othIsReflexive && (retHighest || othIsDefined); + } else if (valIsNull) { + setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); + } else if (valIsSymbol) { + setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); + } else if (othIsNull || othIsSymbol) { + setLow = false; + } else { + setLow = retHighest ? (computed <= value) : (computed < value); + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); + } + + /** + * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseSortedUniq(array, iteratee) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + if (!index || !eq(computed, seen)) { + var seen = computed; + result[resIndex++] = value === 0 ? 0 : value; + } + } + return result; + } + + /** + * The base implementation of `_.toNumber` which doesn't ensure correct + * conversions of binary, hexadecimal, or octal string values. + * + * @private + * @param {*} value The value to process. + * @returns {number} Returns the number. + */ + function baseToNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + return +value; + } + + /** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ + function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + } + + /** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ + function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (comparator) { + isCommon = false; + includes = arrayIncludesWith; + } + else if (length >= LARGE_ARRAY_SIZE) { + var set = iteratee ? null : createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = iteratee ? [] : result; + } + outer: + while (++index < length) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = (comparator || value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + if (iteratee) { + seen.push(computed); + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; + } + + /** + * The base implementation of `_.unset`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The property path to unset. + * @returns {boolean} Returns `true` if the property is deleted, else `false`. + */ + function baseUnset(object, path) { + path = castPath(path, object); + object = parent(object, path); + return object == null || delete object[toKey(last(path))]; + } + + /** + * The base implementation of `_.update`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to update. + * @param {Function} updater The function to produce the updated value. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ + function baseUpdate(object, path, updater, customizer) { + return baseSet(object, path, updater(baseGet(object, path)), customizer); + } + + /** + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ + function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length) && + predicate(array[index], index, array)) {} + + return isDrop + ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) + : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); + } + + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to perform to resolve the unwrapped value. + * @returns {*} Returns the resolved value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + return arrayReduce(actions, function(result, action) { + return action.func.apply(action.thisArg, arrayPush([result], action.args)); + }, result); + } + + /** + * The base implementation of methods like `_.xor`, without support for + * iteratee shorthands, that accepts an array of arrays to inspect. + * + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of values. + */ + function baseXor(arrays, iteratee, comparator) { + var length = arrays.length; + if (length < 2) { + return length ? baseUniq(arrays[0]) : []; + } + var index = -1, + result = Array(length); + + while (++index < length) { + var array = arrays[index], + othIndex = -1; + + while (++othIndex < length) { + if (othIndex != index) { + result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); + } + } + } + return baseUniq(baseFlatten(result, 1), iteratee, comparator); + } + + /** + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. + * + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. + */ + function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; + } + + /** + * Casts `value` to an empty array if it's not an array like object. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array|Object} Returns the cast array-like object. + */ + function castArrayLikeObject(value) { + return isArrayLikeObject(value) ? value : []; + } + + /** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ + function castFunction(value) { + return typeof value == 'function' ? value : identity; + } + + /** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ + function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); + } + + /** + * A `baseRest` alias which can be replaced with `identity` by module + * replacement plugins. + * + * @private + * @type {Function} + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ + var castRest = baseRest; + + /** + * Casts `array` to a slice if it's needed. + * + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. + */ + function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); + } + + /** + * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). + * + * @private + * @param {number|Object} id The timer id or timeout object of the timer to clear. + */ + var clearTimeout = ctxClearTimeout || function(id) { + return root.clearTimeout(id); + }; + + /** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ + function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; + } + + /** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array(result).set(new Uint8Array(arrayBuffer)); + return result; + } + + /** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ + function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); + } + + /** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ + function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; + } + + /** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ + function cloneSymbol(symbol) { + return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; + } + + /** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ + function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); + } + + /** + * Compares values to sort them in ascending order. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ + function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol(value); + + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol(other); + + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; + } + } + return 0; + } + + /** + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ + function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; + } + + /** + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. + * + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgs(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersLength = holders.length, + leftIndex = -1, + leftLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(leftLength + rangeLength), + isUncurried = !isCurried; + + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + } + while (rangeLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; + } + + /** + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. + * + * @private + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. + */ + function composeArgsRight(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersIndex = -1, + holdersLength = holders.length, + rightIndex = -1, + rightLength = partials.length, + rangeLength = nativeMax(argsLength - holdersLength, 0), + result = Array(rangeLength + rightLength), + isUncurried = !isCurried; + + while (++argsIndex < rangeLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + } + return result; + } + + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; + } + + /** + * Copies own symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); + } + + /** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ + function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); + } + + /** + * Creates a function like `_.groupBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} [initializer] The accumulator object initializer. + * @returns {Function} Returns the new aggregator function. + */ + function createAggregator(setter, initializer) { + return function(collection, iteratee) { + var func = isArray(collection) ? arrayAggregator : baseAggregator, + accumulator = initializer ? initializer() : {}; + + return func(collection, setter, getIteratee(iteratee, 2), accumulator); + }; + } + + /** + * Creates a function like `_.assign`. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ + function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; + + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); + } + + /** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = fromRight ? length : -1, + iterable = Object(collection); + + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; + } + + /** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ + function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; + } + + /** + * Creates a function that wraps `func` to invoke it with the optional `this` + * binding of `thisArg`. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createBind(func, bitmask, thisArg) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); + + function wrapper() { + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return fn.apply(isBind ? thisArg : this, arguments); + } + return wrapper; + } + + /** + * Creates a function like `_.lowerFirst`. + * + * @private + * @param {string} methodName The name of the `String` case method to use. + * @returns {Function} Returns the new case function. + */ + function createCaseFirst(methodName) { + return function(string) { + string = toString(string); + + var strSymbols = hasUnicode(string) + ? stringToArray(string) + : undefined; + + var chr = strSymbols + ? strSymbols[0] + : string.charAt(0); + + var trailing = strSymbols + ? castSlice(strSymbols, 1).join('') + : string.slice(1); + + return chr[methodName]() + trailing; + }; + } + + /** + * Creates a function like `_.camelCase`. + * + * @private + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. + */ + function createCompounder(callback) { + return function(string) { + return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); + }; + } + + /** + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. + * + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. + */ + function createCtor(Ctor) { + return function() { + // Use a `switch` statement to work with class constructors. See + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); + + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; + } + + /** + * Creates a function that wraps `func` to enable currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {number} arity The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createCurry(func, bitmask, arity) { + var Ctor = createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length, + placeholder = getHolder(wrapper); + + while (index--) { + args[index] = arguments[index]; + } + var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) + ? [] + : replaceHolders(args, placeholder); + + length -= holders.length; + if (length < arity) { + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, undefined, + args, holders, undefined, undefined, arity - length); + } + var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + return apply(fn, this, args); + } + return wrapper; + } + + /** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ + function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = getIteratee(predicate, 3); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; + } + + /** + * Creates a `_.flow` or `_.flowRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new flow function. + */ + function createFlow(fromRight) { + return flatRest(function(funcs) { + var length = funcs.length, + index = length, + prereq = LodashWrapper.prototype.thru; + + if (fromRight) { + funcs.reverse(); + } + while (index--) { + var func = funcs[index]; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + if (prereq && !wrapper && getFuncName(func) == 'wrapper') { + var wrapper = new LodashWrapper([], true); + } + } + index = wrapper ? index : length; + while (++index < length) { + func = funcs[index]; + + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : undefined; + + if (data && isLaziable(data[0]) && + data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && + !data[4].length && data[9] == 1 + ) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); + } else { + wrapper = (func.length == 1 && isLaziable(func)) + ? wrapper[funcName]() + : wrapper.thru(func); + } + } + return function() { + var args = arguments, + value = args[0]; + + if (wrapper && args.length == 1 && isArray(value)) { + return wrapper.plant(value).value(); + } + var index = 0, + result = length ? funcs[index].apply(this, args) : value; + + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }); + } + + /** + * Creates a function that wraps `func` to invoke it with optional `this` + * binding of `thisArg`, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & WRAP_ARY_FLAG, + isBind = bitmask & WRAP_BIND_FLAG, + isBindKey = bitmask & WRAP_BIND_KEY_FLAG, + isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), + isFlip = bitmask & WRAP_FLIP_FLAG, + Ctor = isBindKey ? undefined : createCtor(func); + + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length; + + while (index--) { + args[index] = arguments[index]; + } + if (isCurried) { + var placeholder = getHolder(wrapper), + holdersCount = countHolders(args, placeholder); + } + if (partials) { + args = composeArgs(args, partials, holders, isCurried); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight, isCurried); + } + length -= holdersCount; + if (isCurried && length < arity) { + var newHolders = replaceHolders(args, placeholder); + return createRecurry( + func, bitmask, createHybrid, wrapper.placeholder, thisArg, + args, newHolders, argPos, ary, arity - length + ); + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; + + length = args.length; + if (argPos) { + args = reorder(args, argPos); + } else if (isFlip && length > 1) { + args.reverse(); + } + if (isAry && ary < length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtor(fn); + } + return fn.apply(thisBinding, args); + } + return wrapper; + } + + /** + * Creates a function like `_.invertBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} toIteratee The function to resolve iteratees. + * @returns {Function} Returns the new inverter function. + */ + function createInverter(setter, toIteratee) { + return function(object, iteratee) { + return baseInverter(object, setter, toIteratee(iteratee), {}); + }; + } + + /** + * Creates a function that performs a mathematical operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @param {number} [defaultValue] The value used for `undefined` arguments. + * @returns {Function} Returns the new mathematical operation function. + */ + function createMathOperation(operator, defaultValue) { + return function(value, other) { + var result; + if (value === undefined && other === undefined) { + return defaultValue; + } + if (value !== undefined) { + result = value; + } + if (other !== undefined) { + if (result === undefined) { + return other; + } + if (typeof value == 'string' || typeof other == 'string') { + value = baseToString(value); + other = baseToString(other); + } else { + value = baseToNumber(value); + other = baseToNumber(other); + } + result = operator(value, other); + } + return result; + }; + } + + /** + * Creates a function like `_.over`. + * + * @private + * @param {Function} arrayFunc The function to iterate over iteratees. + * @returns {Function} Returns the new over function. + */ + function createOver(arrayFunc) { + return flatRest(function(iteratees) { + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); + return baseRest(function(args) { + var thisArg = this; + return arrayFunc(iteratees, function(iteratee) { + return apply(iteratee, thisArg, args); + }); + }); + }); + } + + /** + * Creates the padding for `string` based on `length`. The `chars` string + * is truncated if the number of characters exceeds `length`. + * + * @private + * @param {number} length The padding length. + * @param {string} [chars=' '] The string used as padding. + * @returns {string} Returns the padding for `string`. + */ + function createPadding(length, chars) { + chars = chars === undefined ? ' ' : baseToString(chars); + + var charsLength = chars.length; + if (charsLength < 2) { + return charsLength ? baseRepeat(chars, length) : chars; + } + var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); + return hasUnicode(chars) + ? castSlice(stringToArray(result), 0, length).join('') + : result.slice(0, length); + } + + /** + * Creates a function that wraps `func` to invoke it with the `this` binding + * of `thisArg` and `partials` prepended to the arguments it receives. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. + * @returns {Function} Returns the new wrapped function. + */ + function createPartial(func, bitmask, thisArg, partials) { + var isBind = bitmask & WRAP_BIND_FLAG, + Ctor = createCtor(func); + + function wrapper() { + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength), + fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; + + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + return apply(fn, isBind ? thisArg : this, args); + } + return wrapper; + } + + /** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ + function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step, fromRight); + }; + } + + /** + * Creates a function that performs a relational operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new relational operation function. + */ + function createRelationalOperation(operator) { + return function(value, other) { + if (!(typeof value == 'string' && typeof other == 'string')) { + value = toNumber(value); + other = toNumber(other); + } + return operator(value, other); + }; + } + + /** + * Creates a function that wraps `func` to continue currying. + * + * @private + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {Function} wrapFunc The function to create the `func` wrapper. + * @param {*} placeholder The placeholder value. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { + var isCurry = bitmask & WRAP_CURRY_FLAG, + newHolders = isCurry ? holders : undefined, + newHoldersRight = isCurry ? undefined : holders, + newPartials = isCurry ? partials : undefined, + newPartialsRight = isCurry ? undefined : partials; + + bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); + + if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { + bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); + } + var newData = [ + func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, + newHoldersRight, argPos, ary, arity + ]; + + var result = wrapFunc.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return setWrapToString(result, func, bitmask); + } + + /** + * Creates a function like `_.round`. + * + * @private + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. + */ + function createRound(methodName) { + var func = Math[methodName]; + return function(number, precision) { + number = toNumber(number); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); + if (precision) { + // Shift with exponential notation to avoid floating-point issues. + // See [MDN](https://mdn.io/round#Examples) for more details. + var pair = (toString(number) + 'e').split('e'), + value = func(pair[0] + 'e' + (+pair[1] + precision)); + + pair = (toString(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); + } + return func(number); + }; + } + + /** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ + var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); + }; + + /** + * Creates a `_.toPairs` or `_.toPairsIn` function. + * + * @private + * @param {Function} keysFunc The function to get the keys of a given object. + * @returns {Function} Returns the new pairs function. + */ + function createToPairs(keysFunc) { + return function(object) { + var tag = getTag(object); + if (tag == mapTag) { + return mapToArray(object); + } + if (tag == setTag) { + return setToPairs(object); + } + return baseToPairs(object, keysFunc(object)); + }; + } + + /** + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. + * + * @private + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * 512 - `_.flip` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ + function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); + arity = arity === undefined ? arity : toInteger(arity); + length -= holders ? holders.length : 0; + + if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; + + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func); + + var newData = [ + func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, + argPos, ary, arity + ]; + + if (data) { + mergeData(newData, data); + } + func = newData[0]; + bitmask = newData[1]; + thisArg = newData[2]; + partials = newData[3]; + holders = newData[4]; + arity = newData[9] = newData[9] === undefined + ? (isBindKey ? 0 : func.length) + : nativeMax(newData[9] - length, 0); + + if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { + bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); + } + if (!bitmask || bitmask == WRAP_BIND_FLAG) { + var result = createBind(func, bitmask, thisArg); + } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { + result = createCurry(func, bitmask, arity); + } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { + result = createPartial(func, bitmask, thisArg, partials); + } else { + result = createHybrid.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setWrapToString(setter(result, newData), func, bitmask); + } + + /** + * Used by `_.defaults` to customize its `_.assignIn` use to assign properties + * of source objects to the destination object for all destination properties + * that resolve to `undefined`. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ + function customDefaultsAssignIn(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; + } + + /** + * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source + * objects into destination objects that are passed thru. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to merge. + * @param {Object} object The parent object of `objValue`. + * @param {Object} source The parent object of `srcValue`. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + * @returns {*} Returns the value to assign. + */ + function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { + if (isObject(objValue) && isObject(srcValue)) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, objValue); + baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); + stack['delete'](srcValue); + } + return objValue; + } + + /** + * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain + * objects. + * + * @private + * @param {*} value The value to inspect. + * @param {string} key The key of the property to inspect. + * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. + */ + function customOmitClone(value) { + return isPlainObject(value) ? undefined : value; + } + + /** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ + function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; + } + + /** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; + } + + /** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; + } + + /** + * A specialized version of `baseRest` which flattens the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ + function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); + } + + /** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); + } + + /** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ + function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); + } + + /** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ + var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); + }; + + /** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ + function getFuncName(func) { + var result = (func.name + ''), + array = realNames[result], + length = hasOwnProperty.call(realNames, result) ? array.length : 0; + + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; + } + + /** + * Gets the argument placeholder value for `func`. + * + * @private + * @param {Function} func The function to inspect. + * @returns {*} Returns the placeholder value. + */ + function getHolder(func) { + var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; + return object.placeholder; + } + + /** + * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, + * this function returns the custom method, otherwise it returns `baseIteratee`. + * If arguments are provided, the chosen function is invoked with them and + * its result is returned. + * + * @private + * @param {*} [value] The value to convert to an iteratee. + * @param {number} [arity] The arity of the created iteratee. + * @returns {Function} Returns the chosen function or its result. + */ + function getIteratee() { + var result = lodash.iteratee || iteratee; + result = result === iteratee ? baseIteratee : result; + return arguments.length ? result(arguments[0], arguments[1]) : result; + } + + /** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ + function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; + } + + /** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ + function getMatchData(object) { + var result = keys(object), + length = result.length; + + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } + return result; + } + + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; + } + + /** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ + function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; + } + + /** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbols = !nativeGetSymbols ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); + }; + + /** + * Creates an array of the own and inherited enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; + }; + + /** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + var getTag = baseGetTag; + + // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. + if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; + } + + /** + * Gets the view, applying any `transforms` to the `start` and `end` positions. + * + * @private + * @param {number} start The start of the view. + * @param {number} end The end of the view. + * @param {Array} transforms The transformations to apply to the view. + * @returns {Object} Returns an object containing the `start` and `end` + * positions of the view. + */ + function getView(start, end, transforms) { + var index = -1, + length = transforms.length; + + while (++index < length) { + var data = transforms[index], + size = data.size; + + switch (data.type) { + case 'drop': start += size; break; + case 'dropRight': end -= size; break; + case 'take': end = nativeMin(end, start + size); break; + case 'takeRight': start = nativeMax(start, end - size); break; + } + } + return { 'start': start, 'end': end }; + } + + /** + * Extracts wrapper details from the `source` body comment. + * + * @private + * @param {string} source The source to inspect. + * @returns {Array} Returns the wrapper details. + */ + function getWrapDetails(source) { + var match = source.match(reWrapDetails); + return match ? match[1].split(reSplitDetails) : []; + } + + /** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ + function hasPath(object, path, hasFunc) { + path = castPath(path, object); + + var index = -1, + length = path.length, + result = false; + + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; + } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); + } + + /** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ + function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; + } + + /** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; + } + + /** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return cloneArrayBuffer(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case dataViewTag: + return cloneDataView(object, isDeep); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + return cloneTypedArray(object, isDeep); + + case mapTag: + return new Ctor; + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + return cloneRegExp(object); + + case setTag: + return new Ctor; + + case symbolTag: + return cloneSymbol(object); + } + } + + /** + * Inserts wrapper `details` in a comment at the top of the `source` body. + * + * @private + * @param {string} source The source to modify. + * @returns {Array} details The details to insert. + * @returns {string} Returns the modified source. + */ + function insertWrapDetails(source, details) { + var length = details.length; + if (!length) { + return source; + } + var lastIndex = length - 1; + details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; + details = details.join(length > 2 ? ', ' : ' '); + return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); + } + + /** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ + function isFlattenable(value) { + return isArray(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); + } + + /** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ + function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); + } + + /** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); + } + return false; + } + + /** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ + function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); + } + + /** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ + function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); + } + + /** + * Checks if `func` has a lazy counterpart. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. + */ + function isLaziable(func) { + var funcName = getFuncName(func), + other = lodash[funcName]; + + if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; + } + + /** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ + function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); + } + + /** + * Checks if `func` is capable of being masked. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `func` is maskable, else `false`. + */ + var isMaskable = coreJsData ? isFunction : stubFalse; + + /** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ + function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; + + return value === proto; + } + + /** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ + function isStrictComparable(value) { + return value === value && !isObject(value); + } + + /** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ + function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; + } + + /** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ + function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; + } + + /** + * Merges the function metadata of `source` into `data`. + * + * Merging metadata reduces the number of wrappers used to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ + function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); + + var isCombo = + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || + ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || + ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); + + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; + } + // Use source `thisArg` if available. + if (srcBitmask & WRAP_BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : value; + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = value; + } + // Use source `ary` if it's smaller. + if (srcBitmask & WRAP_ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; + + return data; + } + + /** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; + } + + /** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ + function objectToString(value) { + return nativeObjectToString.call(value); + } + + /** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ + function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply(func, this, otherArgs); + }; + } + + /** + * Gets the parent value at `path` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path to get the parent value of. + * @returns {*} Returns the parent value. + */ + function parent(object, path) { + return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); + } + + /** + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. + * + * @private + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. + */ + function reorder(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = copyArray(array); + + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; + } + + /** + * Sets metadata for `func`. + * + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) + * for more details. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var setData = shortOut(baseSetData); + + /** + * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @returns {number|Object} Returns the timer id or timeout object. + */ + var setTimeout = ctxSetTimeout || function(func, wait) { + return root.setTimeout(func, wait); + }; + + /** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ + var setToString = shortOut(baseSetToString); + + /** + * Sets the `toString` method of `wrapper` to mimic the source of `reference` + * with wrapper details in a comment at the top of the source body. + * + * @private + * @param {Function} wrapper The function to modify. + * @param {Function} reference The reference function. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Function} Returns `wrapper`. + */ + function setWrapToString(wrapper, reference, bitmask) { + var source = (reference + ''); + return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); + } + + /** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ + function shortOut(func) { + var count = 0, + lastCalled = 0; + + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; + } + + /** + * A specialized version of `_.shuffle` which mutates and sets the size of `array`. + * + * @private + * @param {Array} array The array to shuffle. + * @param {number} [size=array.length] The size of `array`. + * @returns {Array} Returns `array`. + */ + function shuffleSelf(array, size) { + var index = -1, + length = array.length, + lastIndex = length - 1; + + size = size === undefined ? length : size; + while (++index < size) { + var rand = baseRandom(index, lastIndex), + value = array[rand]; + + array[rand] = array[index]; + array[index] = value; + } + array.length = size; + return array; + } + + /** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ + var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; + }); + + /** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ + function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; + } + + /** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ + function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; + } + + /** + * Updates wrapper `details` based on `bitmask` flags. + * + * @private + * @returns {Array} details The details to modify. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Array} Returns `details`. + */ + function updateWrapDetails(details, bitmask) { + arrayEach(wrapFlags, function(pair) { + var value = '_.' + pair[0]; + if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { + details.push(value); + } + }); + return details.sort(); + } + + /** + * Creates a clone of `wrapper`. + * + * @private + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. + */ + function wrapperClone(wrapper) { + if (wrapper instanceof LazyWrapper) { + return wrapper.clone(); + } + var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); + result.__actions__ = copyArray(wrapper.__actions__); + result.__index__ = wrapper.__index__; + result.__values__ = wrapper.__values__; + return result; + } + + /*------------------------------------------------------------------------*/ + + /** + * Creates an array of elements split into groups the length of `size`. + * If `array` can't be split evenly, the final chunk will be the remaining + * elements. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the new array of chunks. + * @example + * + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] + * + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] + */ + function chunk(array, size, guard) { + if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { + size = 1; + } else { + size = nativeMax(toInteger(size), 0); + } + var length = array == null ? 0 : array.length; + if (!length || size < 1) { + return []; + } + var index = 0, + resIndex = 0, + result = Array(nativeCeil(length / size)); + + while (index < length) { + result[resIndex++] = baseSlice(array, index, (index += size)); + } + return result; + } + + /** + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] + */ + function compact(array) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result[resIndex++] = value; + } + } + return result; + } + + /** + * Creates a new array concatenating `array` with any additional arrays + * and/or values. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); + * + * console.log(other); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ + function concat() { + var length = arguments.length; + if (!length) { + return []; + } + var args = Array(length - 1), + array = arguments[0], + index = length; + + while (index--) { + args[index - 1] = arguments[index]; + } + return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); + } + + /** + * Creates an array of `array` values not included in the other given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. + * + * **Note:** Unlike `_.pullAll`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.without, _.xor + * @example + * + * _.difference([2, 1], [2, 3]); + * // => [1] + */ + var difference = baseRest(function(array, values) { + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) + : []; + }); + + /** + * This method is like `_.difference` except that it accepts `iteratee` which + * is invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * **Note:** Unlike `_.pullAllBy`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2] + * + * // The `_.property` iteratee shorthand. + * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] + */ + var differenceBy = baseRest(function(array, values) { + var iteratee = last(values); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) + : []; + }); + + /** + * This method is like `_.difference` except that it accepts `comparator` + * which is invoked to compare elements of `array` to `values`. The order and + * references of result values are determined by the first array. The comparator + * is invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.pullAllWith`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. + * @example + * + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * + * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); + * // => [{ 'x': 2, 'y': 1 }] + */ + var differenceWith = baseRest(function(array, values) { + var comparator = last(values); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) + : []; + }); + + /** + * Creates a slice of `array` with `n` elements dropped from the beginning. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.drop([1, 2, 3]); + * // => [2, 3] + * + * _.drop([1, 2, 3], 2); + * // => [3] + * + * _.drop([1, 2, 3], 5); + * // => [] + * + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function drop(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + return baseSlice(array, n < 0 ? 0 : n, length); + } + + /** + * Creates a slice of `array` with `n` elements dropped from the end. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. + * @example + * + * _.dropRight([1, 2, 3]); + * // => [1, 2] + * + * _.dropRight([1, 2, 3], 2); + * // => [1] + * + * _.dropRight([1, 2, 3], 5); + * // => [] + * + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] + */ + function dropRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = (guard || n === undefined) ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, 0, n < 0 ? 0 : n); + } + + /** + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; + * + * _.dropRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney'] + * + * // The `_.matches` iteratee shorthand. + * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropRightWhile(users, ['active', false]); + * // => objects for ['barney'] + * + * // The `_.property` iteratee shorthand. + * _.dropRightWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] + */ + function dropRightWhile(array, predicate) { + return (array && array.length) + ? baseWhile(array, getIteratee(predicate, 3), true, true) + : []; + } + + /**