/* twilio-ip-messaging.js 0.9.6
The following license applies to all parts of this software except as
documented below.
Copyright (c) 2016, Twilio, inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of Twilio nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software includes javascript-state-machine under the following license.
Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
This software includes durational under the following license.
Copyright (c) 2014 Micheil Smith
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This software includes loglevel under the following license.
Copyright (c) 2013 Tim Perry
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This software includes q under the following license.
Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
This software includes platform.js under the following license.
Copyright 2014 Benjamin Tan
Copyright 2011-2015 John-David Dalton
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
!function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;st?-1:u+10>t?t-u+26+26:f+26>t?t-f:c+26>t?t-c+26:void 0}function n(e){function n(e){c[l++]=e}var r,i,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=e.length;u="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0,c=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var l=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),c}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),l="-".charCodeAt(0),h="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],2:[function(e,t,n){(function(t){/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh
* @license MIT
*/
"use strict";function r(){function e(){}try{var t=new Uint8Array(1);return t.foo=function(){return 42},t.constructor=e,42===t.foo()&&t.constructor===e&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(n){return!1}}function i(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e){return this instanceof o?(o.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?s(this,e):"string"==typeof e?a(this,e,arguments.length>1?arguments[1]:"utf8"):u(this,e)):arguments.length>1?new o(e,arguments[1]):new o(e)}function s(e,t){if(e=y(e,0>t?0:0|m(t)),!o.TYPED_ARRAY_SUPPORT)for(var n=0;t>n;n++)e[n]=0;return e}function a(e,t,n){"string"==typeof n&&""!==n||(n="utf8");var r=0|g(t,n);return e=y(e,r),e.write(t,n),e}function u(e,t){if(o.isBuffer(t))return c(e,t);if(X(t))return f(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(t.buffer instanceof ArrayBuffer)return l(e,t);if(t instanceof ArrayBuffer)return h(e,t)}return t.length?p(e,t):d(e,t)}function c(e,t){var n=0|m(t.length);return e=y(e,n),t.copy(e,0,0,n),e}function f(e,t){var n=0|m(t.length);e=y(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function l(e,t){var n=0|m(t.length);e=y(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(e,t){return o.TYPED_ARRAY_SUPPORT?(t.byteLength,e=o._augment(new Uint8Array(t))):e=l(e,new Uint8Array(t)),e}function p(e,t){var n=0|m(t.length);e=y(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t){var n,r=0;"Buffer"===t.type&&X(t.data)&&(n=t.data,r=0|m(n.length)),e=y(e,r);for(var i=0;r>i;i+=1)e[i]=255&n[i];return e}function y(e,t){o.TYPED_ARRAY_SUPPORT?(e=o._augment(new Uint8Array(t)),e.__proto__=o.prototype):(e.length=t,e._isBuffer=!0);var n=0!==t&&t<=o.poolSize>>>1;return n&&(e.parent=V),e}function m(e){if(e>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function v(e,t){if(!(this instanceof v))return new v(e,t);var n=new o(e,t);return delete n.parent,n}function g(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(e).length;default:if(r)return Y(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return U(this,t,n);case"utf8":case"utf-8":return R(this,t,n);case"ascii":return A(this,t,n);case"binary":return C(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function w(e,t,n,r){return J(Y(t,e.length-n),e,n,r)}function E(e,t,n,r){return J(H(t),e,n,r)}function S(e,t,n,r){return E(e,t,n,r)}function k(e,t,n,r){return J(G(t),e,n,r)}function x(e,t,n,r){return J(W(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?$.fromByteArray(e):$.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n>=i+a){var u,c,f,l;switch(a){case 1:128>o&&(s=o);break;case 2:u=e[i+1],128===(192&u)&&(l=(31&o)<<6|63&u,l>127&&(s=l));break;case 3:u=e[i+1],c=e[i+2],128===(192&u)&&128===(192&c)&&(l=(15&o)<<12|(63&u)<<6|63&c,l>2047&&(55296>l||l>57343)&&(s=l));break;case 4:u=e[i+1],c=e[i+2],f=e[i+3],128===(192&u)&&128===(192&c)&&128===(192&f)&&(l=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&f,l>65535&&1114112>l&&(s=l))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return I(r)}function I(e){var t=e.length;if(Z>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Z));return n}function A(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function C(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function U(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=z(e[o]);return i}function P(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,n,r,i,s){if(!o.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||s>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range")}function L(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function D(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function M(e,t,n,r,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function B(e,t,n,r,i){return i||M(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,i){return i||M(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(e,t,n,r,52,8),n+8}function q(e){if(e=F(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function F(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function z(e){return 16>e?"0"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function H(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function G(e){return $.toByteArray(q(e))}function J(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}var $=e("base64-js"),K=e("ieee754"),X=e("isarray");n.Buffer=o,n.SlowBuffer=v,n.INSPECT_MAX_BYTES=50,o.poolSize=8192;var V={};o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),o.TYPED_ARRAY_SUPPORT?(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array):(o.prototype.length=void 0,o.prototype.parent=void 0),o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);s>i&&e[i]===t[i];)++i;return i!==s&&(n=e[i],r=t[i]),r>n?-1:n>r?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!X(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new o(0);var n;if(void 0===t)for(t=0,n=0;n0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},o.prototype.compare=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:o.compare(this,e)},o.prototype.indexOf=function(e,t){function n(e,t,n){for(var r=-1,i=0;n+i2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(o.isBuffer(e))return n(this,e,t);if("number"==typeof e)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):n(this,[e],t);throw new TypeError("val must be string, number or Buffer")},o.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},o.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},o.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var i=r;r=t,t=0|n,n=i}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return E(this,e,t,n);case"binary":return S(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var r;if(o.TYPED_ARRAY_SUPPORT)r=o._augment(this.subarray(e,t));else{var i=t-e;r=new o(i,void 0);for(var s=0;i>s;s++)r[s]=this[s+e]}return r.length&&(r.parent=this.parent||this),r},o.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},o.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),K.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),K.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),K.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),K.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||j(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);j(this,e,t,n,i-1,-i)}var o=0,s=1,a=0>e?1:0;for(this[t]=255&e;++o>0)-a&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);j(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0>e?1:0;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=(e/s>>0)-a&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-tn&&r>t)for(i=s-1;i>=0;i--)e[i+t]=this[i+n];else if(1e3>s||!o.TYPED_ARRAY_SUPPORT)for(i=0;s>i;i++)e[i+t]=this[i+n];else e._set(this.subarray(n,n+s),t);return s},o.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=Y(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}},o.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(o.TYPED_ARRAY_SUPPORT)return new o(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Q=o.prototype;o._augment=function(e){return e.constructor=o,e._isBuffer=!0,e._set=e.set,e.get=Q.get,e.set=Q.set,e.write=Q.write,e.toString=Q.toString,e.toLocaleString=Q.toString,e.toJSON=Q.toJSON,e.equals=Q.equals,e.compare=Q.compare,e.indexOf=Q.indexOf,e.copy=Q.copy,e.slice=Q.slice,e.readUIntLE=Q.readUIntLE,e.readUIntBE=Q.readUIntBE,e.readUInt8=Q.readUInt8,e.readUInt16LE=Q.readUInt16LE,e.readUInt16BE=Q.readUInt16BE,e.readUInt32LE=Q.readUInt32LE,e.readUInt32BE=Q.readUInt32BE,e.readIntLE=Q.readIntLE,e.readIntBE=Q.readIntBE,e.readInt8=Q.readInt8,e.readInt16LE=Q.readInt16LE,e.readInt16BE=Q.readInt16BE,e.readInt32LE=Q.readInt32LE,e.readInt32BE=Q.readInt32BE,e.readFloatLE=Q.readFloatLE,e.readFloatBE=Q.readFloatBE,e.readDoubleLE=Q.readDoubleLE,e.readDoubleBE=Q.readDoubleBE,e.writeUInt8=Q.writeUInt8,e.writeUIntLE=Q.writeUIntLE,e.writeUIntBE=Q.writeUIntBE,e.writeUInt16LE=Q.writeUInt16LE,e.writeUInt16BE=Q.writeUInt16BE,e.writeUInt32LE=Q.writeUInt32LE,e.writeUInt32BE=Q.writeUInt32BE,e.writeIntLE=Q.writeIntLE,e.writeIntBE=Q.writeIntBE,e.writeInt8=Q.writeInt8,e.writeInt16LE=Q.writeInt16LE,e.writeInt16BE=Q.writeInt16BE,e.writeInt32LE=Q.writeInt32LE,e.writeInt32BE=Q.writeInt32BE,e.writeFloatLE=Q.writeFloatLE,e.writeFloatBE=Q.writeFloatBE,e.writeDoubleLE=Q.writeDoubleLE,e.writeDoubleBE=Q.writeDoubleBE,e.fill=Q.fill,e.inspect=Q.inspect,e.toArrayBuffer=Q.toArrayBuffer,e};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":1,ieee754:5,isarray:3}],3:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],4:[function(e,t,n){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],a(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(s(n))for(o=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,u=0;r>u;u++)c[u].apply(this,o);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],5:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<>1,f=-7,l=n?i-1:0,h=n?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,y=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*y}},{}],6:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],7:[function(e,t,n){function r(){f=!1,a.length?c=a.concat(c):l=-1,c.length&&i()}function i(){if(!f){var e=setTimeout(r);f=!0;for(var t=c.length;t;){for(a=c,c=[];++l1)for(var n=1;n0){var n=4-t;e+=new Array(n+1).join("=")}return e=e.replace(/-/g,"+").replace(/_/g,"/"),s(e)}function s(e){return new n(e,"base64").toString()}function a(e){var t=null;return!e.grants&&e.scope?t=u(e.scope):e.grants instanceof Array?t=c(e.grants):"object"==typeof e.grants&&(t=f(e.grants)),t}function u(e){var t=decodeURIComponent(e).match(/identity=(.*?)(&|$)/i);return t&&decodeURIComponent(t[1])}function c(e){for(var t=null,n=0;n=t.expires,clearTimeout(t._tokenExpiredTimer),t._tokenExpiredTimer=setTimeout(function(){t._isExpired=!0,t._tokenExpiredTimer=null,t.emit("tokenExpired",t)},t.expires-Date.now()),t._token=e,t._tokenPayload=r,n(t)});return this._pendingUpdate=n,n},t.exports=r}).call(this,e("buffer").Buffer)},{buffer:2,events:4,util:11}],9:[function(e,t,n){"use strict";t.exports.AccessManager=e("./accessmanager")},{"./accessmanager":8}],10:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],11:[function(e,t,n){(function(t,r){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),y(t)?r.showHidden=t:t&&n._extend(r,t),w(r.showHidden)&&(r.showHidden=!1),w(r.depth)&&(r.depth=2),w(r.colors)&&(r.colors=!1),w(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&T(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return b(i)||(i=u(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),y=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),x(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(t);if(0===s.length){if(T(t)){var m=t.name?": "+t.name:"";return e.stylize("[Function"+m+"]","special")}if(E(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(k(t))return e.stylize(Date.prototype.toString.call(t),"date");if(x(t))return f(t)}var v="",g=!1,_=["{","}"];if(d(t)&&(g=!0,_=["[","]"]),T(t)){var w=t.name?": "+t.name:"";v=" [Function"+w+"]"}if(E(t)&&(v=" "+RegExp.prototype.toString.call(t)),k(t)&&(v=" "+Date.prototype.toUTCString.call(t)),x(t)&&(v=" "+f(t)),0===s.length&&(!g||0==t.length))return _[0]+v+_[1];if(0>r)return E(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var S;return S=g?l(e,t,r,y,s):s.map(function(n){return h(e,t,r,y,n,g)}),e.seen.pop(),p(S,v,_)}function c(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return g(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)U(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}function h(e,t,n,r,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),U(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function y(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return null==e}function g(e){return"number"==typeof e}function b(e){return"string"==typeof e}function _(e){return"symbol"==typeof e}function w(e){return void 0===e}function E(e){return S(e)&&"[object RegExp]"===I(e)}function S(e){return"object"==typeof e&&null!==e}function k(e){return S(e)&&"[object Date]"===I(e)}function x(e){return S(e)&&("[object Error]"===I(e)||e instanceof Error)}function T(e){return"function"==typeof e}function R(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function I(e){return Object.prototype.toString.call(e)}function A(e){return 10>e?"0"+e.toString(10):e.toString(10)}function C(){var e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var P=/%[sdj%]/g;n.format=function(e){if(!b(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=m(a)||!S(a)?" "+a:" "+i(a);return s},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(w(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var O,j={};n.debuglog=function(e){if(w(O)&&(O=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!j[e])if(new RegExp("\\b"+e+"\\b","i").test(O)){var r=t.pid;j[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else j[e]=function(){};return j[e]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=d,n.isBoolean=y,n.isNull=m,n.isNullOrUndefined=v,n.isNumber=g,n.isString=b,n.isSymbol=_,n.isUndefined=w,n.isRegExp=E,n.isObject=S,n.isDate=k,n.isError=x,n.isFunction=T,n.isPrimitive=R,n.isBuffer=e("./support/isBuffer");var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",C(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":10,_process:7,inherits:6}],12:[function(require,module,exports){(function(global){!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.Twilio||(t.Twilio={})).IPMessaging=e()}}(function(){var define,module,exports;return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0?(this._subscriptions.set(e,n),Promise.resolve(!1)):(this._subscriptions["delete"](e),this._unsubscribeOnServer(e))},r.prototype.getSubscribers=function(e){var t=this._subscriptions.get(e);return t?t:new Set},r.prototype.forEach=function(e){this._subscriptions.forEach(function(t,n){t.forEach(function(t){return e(n,t)})})},Object.freeze(r),t.exports=r},{loglevel:57}],10:[function(e,t,n){"use strict";function r(e){try{return new Date(e)}catch(t){return null}}function i(e,t,n,o){var a=this;if(!(this instanceof i))return new i(e,t,n,o);var c=n.attributes||{},l=n.createdBy,h=r(n.dateCreated),p=r(n.dateUpdated),d=n.name||n.friendlyName,y=n.lastConsumedMessageIndex||null,m="known",v=n.type||i.type.PUBLIC,g=n.uniqueName||null,b=n.channelUrl;n.isPrivate&&(v=i.type.PRIVATE);try{JSON.stringify(c)}catch(_){throw new Error("Attributes must be a valid JSON object.")}var w=new Map,E=new u(this,e,t,w);E.on("memberJoined",this.emit.bind(this,"memberJoined")),E.on("memberLeft",this.emit.bind(this,"memberLeft")),E.on("memberUpdated",this.emit.bind(this,"memberUpdated")),E.on("memberInfoUpdated",this.emit.bind(this,"memberInfoUpdated"));var S=[],k=new f(this,e,S);k.on("messageAdded",this.emit.bind(this,"messageAdded")),k.on("messageUpdated",this.emit.bind(this,"messageUpdated")),k.on("messageRemoved",this.emit.bind(this,"messageRemoved")),Object.defineProperties(this,{_attributes:{get:function(){return c},set:function(e){return c=e}},_createdBy:{get:function(){return l},set:function(e){return l=e}},_dateCreated:{get:function(){return h},set:function(e){return h=e}},_dateUpdated:{get:function(){return p},set:function(e){return p=e}},_friendlyName:{get:function(){return d},set:function(e){return d=e}},_lastConsumedMessageIndex:{get:function(){return y},set:function(e){return y=e}},_type:{get:function(){return v},set:function(e){return v=e}},_sid:{get:function(){return o},set:function(e){return o=e}},_status:{get:function(){return m},set:function(e){return m=e}},_uniqueName:{get:function(){return g},set:function(e){return g=e}},_entityPromise:{value:null,writable:!0},_subscribePromise:{value:null,writable:!0},_lastTypingUpdate:{value:0,writable:!0},_membersEntity:{value:E},_messagesEntity:{value:k},_session:{value:e},_uri:{value:b,writable:!0},attributes:{enumerable:!0,get:function(){return c}},createdBy:{enumerable:!0,get:function(){return l}},dateCreated:{enumerable:!0,get:function(){return h}},dateUpdated:{enumerable:!0,get:function(){return p}},friendlyName:{enumerable:!0,get:function(){return d}},isPrivate:{enumerable:!0,get:function(){return a._type===i.type.PRIVATE}},lastConsumedMessageIndex:{enumerable:!0,get:function(){return y}},members:{enumerable:!0,value:w},messages:{enumerable:!0,value:S},sid:{enumerable:!0,get:function(){return o}},status:{enumerable:!0,get:function(){return m}},type:{enumerable:!0,get:function(){return v}},uniqueName:{enumerable:!0,get:function(){return g}}}),s.call(this)}function o(e,t){try{"string"==typeof e.attributes?e.attributes=JSON.parse(e.attributes):e.attributes&&JSON.stringify(e.attributes)}catch(n){h.warn("Retrieved malformed attributes from the server for channel: "+t),e.attributes={}}try{e.dateCreated&&(e.dateCreated=new Date(e.dateCreated))}catch(n){h.warn("Retrieved malformed attributes from the server for channel: "+t),delete e.dateCreated}try{e.dateUpdated&&(e.dateUpdated=new Date(e.dateUpdated))}catch(n){h.warn("Retrieved malformed attributes from the server for channel: "+t),delete e.dateUpdated}}var s=e("events").EventEmitter,a=e("util").inherits,u=e("./data/members"),c=e("./member"),f=e("./data/messages"),l=e("../../util/jsondiff"),h=e("loglevel"),p={attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",name:"friendlyName",sid:"sid",status:"status",type:"type",uniqueName:"uniqueName"};a(i,s),i.type={PUBLIC:"public",PRIVATE:"private"},i.status={KNOWN:"known",INVITED:"invited",JOINED:"joined",FAILED:"failed"},Object.freeze(i.type),Object.freeze(i.status),i.prototype._subscribe=function(){var e=this;return this._entityPromise?this._entityPromise:(this._entityPromise=this._session.datasync.openEntity(this._uri).then(function(t){return e._entity=t,t.subscribe(),t.on("updated",function(t){return e._update(t)}),e._update(t.getData()),e._entity}),this._entityPromise)},i.prototype._subscribeStreams=function(){var e=this;return this._subscribePromise=this._subscribePromise||this._subscribe().then(function(t){var n=t.value("/messagesUrl"),r=t.value("/rosterUrl");return Promise.all([e._messagesEntity.subscribe(n).then(function(){return e._messagesEntity.getMessages()}),e._membersEntity.subscribe(r)])}).then(function(){return e._entity}),this._subscribePromise},i.prototype._fetch=function(){return this._session.datasync.openEntity(this._uri).then(function(e){return e.getData()})},i.prototype._unsubscribe=function(){var e=[];return this._entityPromise&&e.push(this._entity.unsubscribe()),e.push(this._membersEntity.unsubscribe()),e.push(this._messagesEntity.unsubscribe()),this._entityPromise=null,this._subscribePromise=null,Promise.all(e)},i.prototype._setStatus=function(e){this._status!==e&&(this._status=e,e===i.status.JOINED?this._subscribeStreams():e===i.status.INVITED?this._subscribe():this._entityPromise&&this._unsubscribe())},i.prototype._update=function(e){o(e,this._sid);var t=!1;for(var n in e){var r=p[n];r&&(r===p.attributes?l.isDeepEqual(this._attributes,e.attributes)||(this._attributes=e.attributes,t=!0):e[n]instanceof Date?this[r]&&this[r].getTime()===e[n].getTime()||(this["_"+r]=e[n],t=!0):this[r]!==e[n]&&(this["_"+r]=e[n],t=!0))}e.status||e.uniqueName||this._uniqueName&&(this._uniqueName=null,t=!0),t&&this.emit("updated",this)},i.prototype.add=function(e){if(!e||"string"!=typeof e)throw new Error("Channel.add requires an identity parameter");return this._membersEntity.add(e)},i.prototype.advanceLastConsumedMessageIndex=function(e){var t=this;if(parseInt(e)!==e){var n="Channel.advanceLastConsumedMessageIndex requires an integral index parameter";throw new Error(n)}return this._subscribeStreams().then(function(){(null===t.lastConsumedMessageIndex||parseInt(e)>t.lastConsumedMessageIndex)&&t._session.advanceLastConsumedMessageIndexForChannel(t,e)}).then(function(){return t})},i.prototype.decline=function(){var e=this;return this._session.addCommand("declineInvitation",{channelSid:this._sid}).then(function(){return e})},i.prototype["delete"]=function(){var e=this;return this._session.addCommand("destroyChannel",{channelSid:this._sid}).then(function(){return e})},i.prototype.getAttributes=function(){var e=this;return this._entityPromise?this._subscribe().then(function(){return e.attributes}):this._fetch().then(function(t){return e._update(t),e.attributes})},i.prototype.getMessages=function(e,t){var n=this;return this._subscribeStreams().then(function(){return n._messagesEntity.getMessages(e,t)})},i.prototype.getMembers=function(){var e=this;return this._subscribeStreams().then(function(){return e._membersEntity.getMembers()})},i.prototype.invite=function(e){if("string"!=typeof e||!e.length)throw new Error("Channel.invite requires an identity parameter");return this._membersEntity.invite(e)},i.prototype.join=function(){var e=this;return this._session.addCommand("joinChannel",{channelSid:this._sid}).then(function(){return e})},i.prototype.leave=function(){var e=this;return this._status!==i.status.JOINED?Promise.resolve(this):this._session.addCommand("leaveChannel",{channelSid:this._sid}).then(function(){return e})},i.prototype.removeMember=function(e){if(!e||"string"!=typeof e&&!(e instanceof c))throw new Error("Channel.removeMember requires a member parameter.");return this._membersEntity.remove("string"==typeof e?e:e.identity)},i.prototype.sendMessage=function(e){return this._messagesEntity.send(e)},i.prototype.setAllMessagesConsumed=function(){var e=this;return this._subscribeStreams().then(function(){return null!==e.messages&&e.messages.length>0?e.advanceLastConsumedMessageIndex(e.messages[e.messages.length-1].index):void 0}).then(function(){return e})},i.prototype.typing=function(){return this._lastTypingUpdate>Date.now()-this._session.typingTimeout?Promise.resolve():(this._lastTypingUpdate=Date.now(),this._session.sendTypingIndicator(this._sid))},i.prototype.updateAttributes=function(e){var t=this;if("undefined"==typeof e)throw new Error("Attributes is a required parameter for updateAttributes");
if(e.constructor!==Object)throw new Error("Attributes must be a valid JSON object.");return this._session.addCommand("editAttributes",{channelSid:this._sid,attributes:JSON.stringify(e)}).then(function(){return t})},i.prototype.updateFriendlyName=function(e){var t=this;return this._friendlyName===e?Promise.resolve(this):this._session.addCommand("editFriendlyName",{channelSid:this._sid,friendlyName:e}).then(function(){return t})},i.prototype.updateLastConsumedMessageIndex=function(e){var t=this;if(parseInt(e)!==e){var n="Channel.updateLastConsumedMessageIndex requires an integral index parameter";throw new Error(n)}return this._subscribeStreams().then(function(){t._session.updateLastConsumedMessageIndexForChannel(t,e)}).then(function(){return t})},i.prototype.updateType=function(e){if(e!==i.type.PRIVATE&&e!==i.type.PUBLIC)throw new Error("Can't set unknown channel type "+e);if(this._type!==e)throw new Error("Changing of channel type isn't supported");return Promise.resolve(this)},i.prototype.updateUniqueName=function(e){var t=this;return this._uniqueName===e?Promise.resolve(this):this._session.addCommand("editUniqueName",{channelSid:this._sid,uniqueName:e}).then(function(){return t})},Object.freeze(i),t.exports=i},{"../../util/jsondiff":34,"./data/members":14,"./data/messages":15,"./member":17,events:51,loglevel:57,util:93}],11:[function(e,t,n){"use strict";function r(e,t){var n=this;t=t||{},t.logLevel=t.logLevel||"error",s.setDefaultLevel(t.logLevel),s.setLevel(t.logLevel);var r=new a(t);if("string"==typeof e&&(e=new y(e)),!e||!e.token)throw new Error("A valid Twilio AccessManager or Capability Token must be passed to IPMessaging Client");var o=e.token,m=t.twilsockClient||new p(o,t),v=t.transportClient||new d(m,t),g=t.notificationClient||new h("ip_messaging",o,v,m,t),b=t.dataSyncClient||new l(o,g,v,t),_=new u(b,v,o,r),w=_.initialize(),E=new f(_,b,e.identity);E.on("userInfoUpdated",this.emit.bind(this,"userInfoUpdated"));var S=new Map,k=new c(_,E,S),x=w.then(function(){return k.on("channelAdded",n.emit.bind(n,"channelAdded")),k.on("channelRemoved",n.emit.bind(n,"channelRemoved")),k.on("channelInvited",n.emit.bind(n,"channelInvited")),k.on("channelJoined",n.emit.bind(n,"channelJoined")),k.on("channelLeft",n.emit.bind(n,"channelLeft")),k.on("channelUpdated",n.emit.bind(n,"channelUpdated")),k.on("memberJoined",n.emit.bind(n,"memberJoined")),k.on("memberLeft",n.emit.bind(n,"memberLeft")),k.on("memberUpdated",n.emit.bind(n,"memberUpdated")),k.on("messageAdded",n.emit.bind(n,"messageAdded")),k.on("messageUpdated",n.emit.bind(n,"messageUpdated")),k.on("messageRemoved",n.emit.bind(n,"messageRemoved")),k.on("typingStarted",n.emit.bind(n,"typingStarted")),k.on("typingEnded",n.emit.bind(n,"typingEnded")),k.fetchChannels(_)});e.on("tokenExpired",function(){return n.emit("tokenExpired",e)}),e.on("tokenUpdated",function(){return n._updateToken(e.token)}),Object.defineProperties(this,{_channelsPromise:{value:x},_datasync:{value:b},_notification:{value:g},_session:{value:_},_sessionPromise:{value:w},_token:{value:o,writable:!0},_twilsock:{value:m},_userInfos:{value:E},_userInfo:{writable:!0},accessManager:{enumerable:!0,value:e},channels:{enumerable:!0,value:S},identity:{enumerable:!0,get:function(){return e.identity}},userInfo:{enumerable:!0,get:function(){return n._userInfos.myUserInfo}}}),this._initialize(t.typingTimeout||5e3),i.call(this)}var i=e("events").EventEmitter,o=e("util").inherits,s=e("loglevel"),a=e("./configuration"),u=e("./session.js"),c=e("./data/channels.js"),f=e("./data/userinfos.js"),l=e("../datasync/client"),h=e("../notification/client"),p=e("../twilsock/client"),d=e("../transport"),y=e("twilio-common").AccessManager,m=e("../../../package.json").version;Object.defineProperties(r,{version:{enumerable:!0,value:m}}),o(r,i),r.prototype._initialize=function(e){var t=this;return this._sessionPromise.then(function(){t._notification.subscribe("twilio.ipmsg.typing_indicator","twilsock"),t._notification.subscribe("twilio.channel.new_message","gcm"),t._notification.subscribe("twilio.channel.added_to_channel","gcm"),t._notification.on("message",function(n,r){"twilio.ipmsg.typing_indicator"===n&&(s.trace("Got new typing indicator push!"),s.trace(r),t._channelsPromise.then(function(e){return e.channels.get(r.channel_sid)}).then(function(t){var n=!0,i=!1,o=void 0;try{for(var s,a=t.members.values()[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;if(u.identity===r.identity){u._startTyping(e);break}}}catch(c){i=!0,o=c}finally{try{!n&&a["return"]&&a["return"]()}finally{if(i)throw o}}})["catch"](function(e){throw s.error("IMPSG E: ",e),e}))})})},r.prototype._updateToken=function(e){var t=this;return e&&3===e.split(".").length?e===this._token?Promise.resolve(this):(this._token=e,s.info("IPMSG I: authTokenUpdated"),Promise.all([this._twilsock.setAuthToken(e),this._notification.setAuthToken(e),this._datasync.setAuthToken(e),this._sessionPromise.then(function(){return t._session.updateToken(e)})]).then(function(){return t})):s.error("Received a malformed token from AccessManager. Token not updated in IP MessagingClient.")},r.prototype.getChannelBySid=function(e){var t=this;if(!e||"string"!=typeof e)throw new Error("Client.getChannelBySid requires a channelSid parameter");return this._channelsPromise.then(function(){return t.channels.get(e)})},r.prototype.getChannelByUniqueName=function(e){var t=this;if(!e||"string"!=typeof e)throw new Error("Client.getChannelByUniqueName requires a uniqueName parameter");return this._channelsPromise.then(function(){var n=!0,r=!1,i=void 0;try{for(var o,s=t.channels.values()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;if(a.uniqueName===e)return a}}catch(u){r=!0,i=u}finally{try{!n&&s["return"]&&s["return"]()}finally{if(r)throw i}}})},r.prototype.getChannels=function(){var e=this;return this._channelsPromise.then(function(){var t=[];return e.channels.forEach(function(e){return t.push(e)}),t})},r.prototype.createChannel=function(e){return e=e||{},this._channelsPromise.then(function(t){return t.addChannel(e)})},Object.freeze(r),t.exports=r},{"../../../package.json":97,"../datasync/client":1,"../notification/client":21,"../transport":25,"../twilsock/client":27,"./configuration":12,"./data/channels.js":13,"./data/userinfos.js":16,"./session.js":19,events:51,loglevel:57,"twilio-common":88,util:93}],12:[function(e,t,n){"use strict";function r(e){e=e||{};var t=e.IPMessaging||{},n=t.typingUri||i;Object.defineProperties(this,{typingIndicatorUri:{enumerable:!0,value:n+o},typingIndicatorTimeout:{enumerable:!0,value:1e3*s},consumptionReportInterval:{enumerable:!0,value:a}})}var i="https://aim.twilio.com",o="/v1/typing",s=5,a="PT5S";t.exports=r},{}],13:[function(e,t,n){"use strict";function r(e,t,n){Object.defineProperties(this,{_userInfos:{value:t},_session:{value:e},channels:{enumerable:!0,value:n}}),i.call(this)}var i=e("events").EventEmitter,o=e("util").inherits,s=e("../channel");o(r,i),r.prototype.addChannel=function(e){var t=this;return this._session.addCommand("createChannel",{friendlyName:e.friendlyName,uniqueName:e.uniqueName,type:e.isPrivate?"private":"public",attributes:JSON.stringify(e.attributes)}).then(function(e){var n=t.channels.get(e.channelSid);if(n)return n._update(e),n;var r=new s(t._session,t._userInfos,e,e.channelSid);return t.channels.set(r.sid,r),t._registerForEvents(r),r._subscribe().then(function(){return t.emit("channelAdded",r),r})})},r.prototype.fetchChannels=function(e){var t=this;return new Promise(function(n,r){function i(){a=!0,t._fetchPublicChannels(s).then(function(){return t._fetchMyChannels(o)}).then(function(){n(t)},function(e){r(e)})}var o=e.getMyChannelsUrl(),s=e.getChannelsUrl(),a=!1;e.onKeyUpdated("/channelsUrl",function(e){s=e,o&&!a&&i()}),e.onKeyUpdated("/myChannelsUrl",function(e){o=e,s&&!a&&i()})})},r.prototype._fetchMyChannels=function(e){var t=this;return this._session.datasync.openMap(e).then(function(e){e.subscribe(),e.on("entityAdded",function(e){var n=e.id;t._upsertChannel(n,e.value)}),e.on("entityRemoved",function(e){var n=t.channels.get(e);n&&("joined"!==n.status&&"invited"!==n.status||(n._setStatus("known"),t.emit("channelLeft",n)),n.isPrivate&&(t.channels["delete"](e),t.emit("channelRemoved",n)))}),e.on("entityUpdated",function(e){var n=e.id;t._upsertChannel(n,e.value)});var n=[];return e.forEach(function(e){var r=e.value,i=e.id;n.push(t._upsertChannel(i,r))}).then(function(){return Promise.all(n)}).then(function(){return t})})},r.prototype._fetchPublicChannels=function(e){var t=this;return this._session.datasync.openMap(e).then(function(e){return e.subscribe(),e.on("entityAdded",function(e){var n=e.id,r=t.channels.get(n);r||(r=new s(t._session,t._userInfos,e.value,n),t._registerForEvents(r),t.channels.set(n,r),t.emit("channelAdded",r))}),e.on("entityRemoved",function(e){var n=t.channels.get(e);n&&("joined"!==n.status&&"invited"!==n.status||(n._unsubscribe(),t.emit("channelLeft",n)),t.channels["delete"](e),t.emit("channelRemoved",n))}),e.on("entityUpdated",function(e){var n=e.id;t._upsertChannel(n,e.value)}),e.forEach(function(e){var n=e.value,r=e.id,i=new s(t._session,t._userInfos,n,r);t._registerForEvents(i),t.channels.set(r,i)}).then(function(){return t})})},r.prototype._upsertChannel=function(e,t){var n=this,r=this.channels.get(e);return r?("joined"===t.status&&"joined"!==r.status?(r._setStatus("joined"),t.lastConsumedMessageIndex&&(r._lastConsumedMessageIndex=t.lastConsumedMessageIndex),this.emit("channelJoined",r)):"invited"===t.status&&"invited"!==r.status?(r._setStatus("invited"),this.emit("channelInvited",r)):"known"!==t.status||"invited"!==r.status&&"joined"!==r.status?"notParticipating"===t.status&&"private"===t.type?r._subscribe():r._update(t):(r._setStatus("known"),r._update(t),this.emit("channelLeft",r)),Promise.resolve(r)):(r=new s(this._session,this._userInfos,t,e),this._registerForEvents(r),this.channels.set(e,r),r._subscribe().then(function(){return"joined"===t.status?(r._setStatus("joined"),n.emit("channelJoined",r)):"invited"===t.status&&(r._setStatus("invited"),n.emit("channelInvited",r)),n.emit("channelAdded",r),r}))},r.prototype._registerForEvents=function(e){var t=this;e.on("updated",function(){return t.emit("channelUpdated",e)}),e.on("memberJoined",this.emit.bind(this,"memberJoined")),e.on("memberLeft",this.emit.bind(this,"memberLeft")),e.on("memberUpdated",this.emit.bind(this,"memberUpdated")),e.on("messageAdded",this.emit.bind(this,"messageAdded")),e.on("messageUpdated",this.emit.bind(this,"messageUpdated")),e.on("messageRemoved",this.emit.bind(this,"messageRemoved")),e.on("typingStarted",this.emit.bind(this,"typingStarted")),e.on("typingEnded",this.emit.bind(this,"typingEnded"))},t.exports=r},{"../channel":10,events:51,util:93}],14:[function(e,t,n){"use strict";function r(e,t,n,r){Object.defineProperties(this,{_datasync:{value:t.datasync},_userInfos:{value:n},_session:{value:t},_rosterStreamPromise:{writable:!0,value:null},channel:{enumerable:!0,value:e},members:{enumerable:!0,value:r}}),i.call(this)}var i=e("events").EventEmitter,o=e("util").inherits,s=e("../member");o(r,i),r.prototype.unsubscribe=function(){return this._rosterStreamPromise?this._rosterStreamPromise.then(function(e){return e.unsubscribe()}):Promise.resolve()},r.prototype.subscribe=function(e){var t=this;return this._rosterStreamPromise=this._datasync.openMap(e).then(function(e){e.subscribe(),e.on("entityAdded",function(e){t.upsertMember(e.id,e.value).then(function(e){t.emit("memberJoined",e)})}),e.on("entityRemoved",function(e){if(t.members.has(e)){var n=t.members.get(e);t.members["delete"](e),t.emit("memberLeft",n)}}),e.on("entityUpdated",function(e){t.upsertMember(e.id,e.value)});var n=[];return e.forEach(function(e){n.push(t.upsertMember(e.id,e.value))}).then(function(){return Promise.all(n)}).then(function(){return e})}),this._rosterStreamPromise},r.prototype.upsertMember=function(e,t){var n=this,r=this.members.get(e);return r?(r._update(t),Promise.resolve(r)):this._userInfos.getUserInfo(t.identity,t.userInfo).then(function(i){return r=new s(n.channel,t,e,i),n.members.set(e,r),r.on("updated",function(){return n.emit("memberUpdated",r)}),r.on("userInfoUpdated",function(){return n.emit("memberInfoUpdated",r)}),r})},r.prototype.getMembersList=function(){var e=[];return this.members.forEach(function(t){return e.push(t)}),e},r.prototype.getMembers=function(){var e=this;return this._rosterStreamPromise.then(function(){var t=[];return e.members.forEach(function(e){return t.push(e)}),t})},r.prototype.add=function(e){return this._session.addCommand("addMember",{channelSid:this.channel.sid,username:e})},r.prototype.invite=function(e){return this._session.addCommand("inviteMember",{channelSid:this.channel.sid,username:e})},r.prototype.remove=function(e){return this._session.addCommand("removeMember",{channelSid:this.channel.sid,username:e})},t.exports=r},{"../member":17,events:51,util:93}],15:[function(e,t,n){"use strict";function r(e,t,n){var r=a.defer();Object.defineProperties(this,{_datasync:{value:t.datasync},_deferred:{value:r},_eventStreamPromise:{value:null,writable:!0},_sortedMessages:{value:n},_messagesByIndex:{value:new Map},_session:{value:t},_waitForURI:{value:r.promise},channel:{enumerable:!0,value:e}}),i.call(this)}var i=e("events").EventEmitter,o=e("util").inherits,s=e("../message"),a=e("q");o(r,i),r.prototype.subscribe=function(e){var t=this;return this._eventStreamPromise=this._eventStreamPromise||this._datasync.openStream(e).then(function(e){return e.on("entityAdded",function(e){var n=new s(t.channel,e.id,e.value);t._sortedMessages.push(n),t._messagesByIndex.set(n.index,n),n.on("updated",function(){return t.emit("messageUpdated",n)});var r=!0,i=!1,o=void 0;try{for(var a,u=t.channel.members.values()[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var c=a.value;if(c.identity===n.author){c._endTyping();break}}}catch(f){i=!0,o=f}finally{try{!r&&u["return"]&&u["return"]()}finally{if(i)throw o}}t.emit("messageAdded",n)}),e.on("entityRemoved",function(e){var n=t._removeMessageById(e);n&&(t._messagesByIndex["delete"](n.index),n.removeAllListeners("updated"),t.emit("messageRemoved",n))}),e.on("entityUpdated",function(e){var n=t._messagesByIndex.get(e.id);n&&n._update(e.value)}),t._deferred.resolve(e),e}),this._eventStreamPromise.then(function(e){return e.subscribe(),e})},r.prototype.unsubscribe=function(){return this._eventStreamPromise?this._eventStreamPromise.then(function(e){return e.unsubscribe()}):Promise.resolve()},r.prototype._removeMessageById=function(e){for(var t=void 0,n=0;n is a required parameter for updateBody");return this.channel._session.addCommand("editMessage",{channelSid:this.channel.sid,messageIdx:this.index.toString(),text:e}).then(function(){return t})},t.exports=r},{events:51,util:93}],19:[function(e,t,n){"use strict";function r(e,t,n,r){var i=this,s="undefined"!=typeof navigator?o.parse(navigator.userAgent):o;Object.defineProperties(this,{_consumptionHorizonUpdateTimer:{value:null,writable:!0},_consumptionHorizonReports:{value:new Map},_purpose:{value:"com.twilio.rtd.ipmsg"},_endpointPlatform:{value:["js",c,s.os,s.name,s.version].join("|")},_pendingCommands:{value:new Map},_sessionContextChangeTracker:{value:new a},_sessionStreamPromise:{value:null,writable:!0},_config:{value:r},identity:{enumerable:!0,get:function(){return i._sessionContextChangeTracker._data.identity}},userInfo:{enumerable:!0,get:function(){return i._sessionContextChangeTracker._data.userInfo}},datasync:{enumerable:!0,value:e},transport:{value:t},token:{enumerable:!0,value:n,writable:!0},typingTimeout:{value:r.typingIndicatorTimeout,writable:!0}})}var i=e("../../util/guid"),o=e("platform"),s=e("loglevel"),a=e("../../util/changetracker"),u=e("durational"),c=e("../../../package.json").version;r.prototype.initialize=function(){var e=this,t={type:"IpMsgSession",version:"v2",endpointPlatform:this._endpointPlatform,token:this.token};return this._sessionStreamPromise=this.datasync.createStream(this._purpose,t).then(function(t){return s.trace("IPMSG: session created"),t.on("entityAdded",function(t){return e._processCommandResponse(t)}),t.on("entityUpdated",function(t){return e._processCommandResponse(t)}),t.on("contextUpdated",function(t){return e._sessionContextChangeTracker.update(t)}),t.subscribe(),t})["catch"](function(e){throw s.error("IPMSG: failed to create session",e),e}),this._sessionStreamPromise},r.prototype.addCommand=function(e,t){return this._processCommand(e,t)},r.prototype._processCommand=function(e,t){var n=this,r={request:t};return r.request.action=e,r.commandId=i(),new Promise(function(e,t){n._sessionStreamPromise.then(function(i){n._pendingCommands.set(r.commandId,{resolve:e,reject:t}),i.add(r)})["catch"](function(e){t(new Error("Can't add command: "+e.message))})})},r.prototype._processCommandResponse=function(e){if(e.value.hasOwnProperty("response")&&e.value.hasOwnProperty("commandId")&&this._pendingCommands.has(e.value.commandId)){var t=e.value,n=e.value.commandId;if(200===t.response.status){s.trace("Command succeeded: ",t);var r=this._pendingCommands.get(n).resolve;this._pendingCommands["delete"](n),r(t.response)}else{s.error("Command failed: ",t);var i=this._pendingCommands.get(n).reject;this._pendingCommands["delete"](n),i(new Error(JSON.stringify(t)))}}},r.prototype.updateToken=function(e){return this._sessionStreamPromise.then(function(t){return t.getContext().then(function(n){return n.token=e,t.updateContext(n)})})["catch"](function(e){throw s.error("Couldn't update the token in session context",e),new Error(e)})},r.prototype.onKeyUpdated=function(e,t){this._sessionContextChangeTracker.addEventHandler("keyAdded",e,t),this._sessionContextChangeTracker.addEventHandler("keyUpdated",e,t)},r.prototype.getChannelsUrl=function(){var e=this;return new Promise(function(t){e._sessionStreamPromise.then(function(e){return e.getContext()}).then(function(n){n.hasOwnProperty("channelsUrl")?t(n.channelsUrl):e.onKeyUpdated("/channelsUrl",t)})})},r.prototype.getMyChannelsUrl=function(){var e=this;return new Promise(function(t){e._sessionStreamPromise.then(function(e){return e.getContext()}).then(function(n){n.hasOwnProperty("myChannelsUrl")?t(n.myChannelsUrl):e.onKeyUpdated("/myChannelsUrl",t)})})},r.prototype.getUserInfosData=function(){var e=this;return new Promise(function(t){function n(e){t({mapsUrl:e.mapsUrl,userInfo:e.userInfo,identity:e.identity})}e._sessionStreamPromise.then(function(e){return e.getContext()}).then(function(t){t.hasOwnProperty("mapsUrl")?n(t):e.onKeyUpdated("/mapsUrl",function(){e._sessionStreamPromise.then(function(e){return e.getContext()}).then(function(e){return n(e)})})})})},r.prototype._getConsumptionReportInterval=function(){var e=this;return this._sessionStreamPromise.then(function(e){return e.getContext()}).then(function(t){return u.fromString(t.consumptionReportInterval||e._config.consumptionReportInterval)})},r.prototype.updateLastConsumedMessageIndexForChannel=function(e,t){var n=this;this._getConsumptionReportInterval().then(function(r){n._consumptionHorizonReports.set(e.sid,{channelSid:e.sid,messageIdx:t}),n._delayedSendConsumptionHorizon(r)})},r.prototype.advanceLastConsumedMessageIndexForChannel=function(e,t){var n=this;this._getConsumptionReportInterval().then(function(r){var i=n._consumptionHorizonReports.get(e.sid);(!i&&e.lastConsumedMessageIndex0&&n.addCommand("consumptionReport",{report:e}),n._consumptionHorizonUpdateTimer=null},1e3*e.seconds)}()},r.prototype.sendTypingIndicator=function(e){var t=this;s.trace("IPMSG I: sending typing indicator");var n=this._config.typingIndicatorUri,r={"X-Twilio-Token":this.token,"Content-Type":"application/x-www-form-urlencoded"},i="ChannelSid="+e;return this.transport.post(n,r,i).then(function(e){return i.hasOwnProperty("typing_timeout")&&(t.typingTimeout=1e3*i.typing_timeout),e}).then(null,function(e){throw s.error("IPMSG E: failed to send typing indicator: ",e),e})},t.exports=r},{"../../../package.json":97,"../../util/changetracker":31,"../../util/guid":32,durational:49,loglevel:57,platform:58}],20:[function(e,t,n){"use strict";function r(e,t,n,r){var o=this;Object.defineProperties(this,{_datasync:{value:n},_session:{value:r},_identity:{value:e},_uri:{value:t,writable:!0},_attributes:{value:{},writable:!0},_friendlyName:{value:null,writable:!0},_promiseToFetch:{writable:!0},identity:{enumerable:!0,get:function(){return o._identity}},attributes:{enumerable:!0,get:function(){return o._attributes}},friendlyName:{enumerable:!0,get:function(){return o._friendlyName}}}),i.call(this)}var i=e("events").EventEmitter,o=e("util").inherits;o(r,i),r.prototype._update=function(e,t){switch(e){case"friendlyName":this._friendlyName=t;break;case"attributes":try{this._attributes=JSON.parse(t)}catch(n){this._attributes={}}break;default:return}this.emit("updated")},r.prototype._fetch=function(){var e=this;if(!this._uri)return Promise.resolve(this);var t=function(t){return e._update(t.id,t.value.value)};return this._promiseToFetch=this._datasync.openMap(this._uri).then(function(e){return e.subscribe(),e.on("entityUpdated",t),Promise.all([e.get("friendlyName").then(t),e.get("attributes").then(t)])}).then(function(){return e})["catch"](function(t){throw e._promiseToFetch=null,t}),this._promiseToFetch},r.prototype._ensureFetched=function(){return this._promiseToFetch||this._fetch()},r.prototype.updateAttributes=function(e){var t=this;if(e.constructor!==Object)throw new Error("Attributes must be an object.");return this._session.addCommand("editUserAttributes",{username:this._identity,attributes:JSON.stringify(e)}).then(function(){return t})},r.prototype.updateFriendlyName=function(e){var t=this;return this._session.addCommand("editUserFriendlyName",{username:this._identity,friendlyName:e}).then(function(){return t})},Object.freeze(r),t.exports=r},{events:51,util:93}],21:[function(e,t,n){"use strict";function r(e,t,n,r,o){var s=this;if(!t)throw new Error("Token is required for Notification client");var c={overall:!1,transport:!1,registration:!1},f=new a(t,o);Object.defineProperties(this,{_config:{value:f},_registrar:{value:new u(e,n,f)},_twilsock:{value:r},_reliableTransportState:{value:c}}),i.call(this),this._registrar.on("stateChanged",function(e){s._onRegistrationStateChange(e)}),this._registrar.on("needReliableTransport",this._onNeedReliableTransport.bind(this)),this._twilsock.on("message",function(e,t){return s._routeMessage(e,t)}),this._twilsock.on("connected",function(e){s._onTransportStateChange(!0),s._registrar.setNotificationId("twilsock",e)}),this._twilsock.on("disconnected",function(){s._onTransportStateChange(!1)})}var i=e("events").EventEmitter,o=e("util").inherits,s=e("loglevel"),a=e("./configuration"),u=e("./registrar");o(r,i),r.prototype._routeMessage=function(e,t){s.trace("Message arrived: ",e,t),this.emit("message",e,t)},r.prototype._onNeedReliableTransport=function(e){e?this._twilsock.connect():this._twilsock.disconnect()},r.prototype._onRegistrationStateChange=function(e){this._reliableTransportState.registration="registered"===e,this._updateTransportState()},r.prototype._onTransportStateChange=function(e){this._reliableTransportState.transport=e,this._updateTransportState()},r.prototype._updateTransportState=function(){var e=this._reliableTransportState.transport&&this._reliableTransportState.registration;this._reliableTransportState.overall!==e&&(this._reliableTransportState.overall=e,s.info("NTFCN I: Transport ready "+e),this.emit("transportReady",e))},r.prototype.subscribe=function(e,t){return s.trace("Add subscriptions for event type: ",e),t=t||"twilsock",this._registrar.subscribe(e,t)},r.prototype.unsubscribe=function(e,t){return this._registrar.unsubscribe(e,t)},r.prototype.handlePushNotification=function(e){s.warn("Push message passed, but no functionality implemented yet: "+e)},r.prototype.setGCMToken=function(e){this._registrar.setNotificationId("gcm",e)},r.prototype.setAuthToken=function(e){s.info("NTFCN I: authTokenUpdated"),this._config.updateToken(e),this._registrar._updateGcmRegistration(),this._twilsock.disconnect().then(this._twilsock.connect.bind(this._twilsock))},Object.freeze(r),t.exports=r},{"./configuration":22,"./registrar":24,events:51,loglevel:57,util:93}],22:[function(e,t,n){"use strict";function r(e,t){var n=this;t=(t||{}).Notification||{};var r=t.ersUri||i;Object.defineProperties(this,{_registrarUri:{value:r+o},_token:{value:e,writable:!0},registrarUri:{get:function(){return n._registrarUri}},token:{get:function(){return n._token}}})}var i="https://ers.twilio.com",o="/v1/registrations";r.prototype.updateToken=function(e){this._token=e},t.exports=r},{}],23:[function(e,t,n){"use strict";function r(e,t,n,r){var o=this,u=s.create({initial:{state:"unregistered",event:"init",defer:!0},events:[{name:"userUpdate",from:["unregistered"],to:"registering"},{name:"userUpdate",from:["registered"],to:"unregistering"},{name:"registered",from:["registering","retrying"],to:"registered"},{name:"unregistered",from:["unregistering"],to:"unregistered"},{name:"retry",from:["retrying"],
to:"retrying"},{name:"failure",from:["registering"],to:"retrying"},{name:"failure",from:["retrying"],to:"retrying"},{name:"failure",from:["unregistering"],to:"unregistered"}],callbacks:{onregistering:function(e,t,n,r){return o._register(r)},onunregistering:function(){return o._unregister()},onregistered:function(){return o._onRegistered()},onunregistered:function(){return o._onUnregistered()},onretrying:function(e,t,n,r){return o._initRetry(r)},onfailure:function(e,t,n,r){"retrying"===t&&o._initRetry(r)}}}),c=a.exponential({randomisationFactor:.2,initialDelay:2e3,maxDelay:12e4});c.on("ready",function(){o._retry()});var f=("undefined"!=typeof navigator?navigator.userAgent:"web").substring(0,128);Object.defineProperties(this,{_transport:{value:t},_url:{value:n.registrarUri,writable:!1},_config:{value:n},_productId:{value:e},_platform:{value:f},_fsm:{value:u},_backoff:{value:c},_channelType:{value:r},_registrationId:{value:!1,writable:!0},_notificationId:{value:!1},_messageTypes:{value:[],writable:!0},_pendingUpdate:{value:null,writable:!0}}),i.call(this),u.init()}var i=e("events").EventEmitter,o=e("util").inherits,s=e("javascript-state-machine"),a=e("backoff"),u=e("loglevel");o(r,i),r.prototype.update=function(e,t){var n={notificationId:e,messageTypes:t};this._fsm.is("unregistered")?n.notificationId&&n.messageTypes.length>0&&this._fsm.userUpdate(n):this._fsm.is("registered")?(this._fsm.userUpdate(n),this._setPendingUpdate(n)):this._setPendingUpdate(n)},r.prototype._setPendingUpdate=function(e){this._pendingUpdate=e},r.prototype._checkPendingUpdate=function(){if(this._pendingUpdate){var e=this._pendingUpdate;this._pendingUpdate=null,this.update(e.notificationId,e.messageTypes)}},r.prototype._initRetry=function(e){this._pendingUpdate||this._setPendingUpdate(e),this._backoff.backoff()},r.prototype._retry=function(){if(this._pendingUpdate){var e=this._pendingUpdate;this._pendingUpdate=null,this._register(e)}},r.prototype._onRegistered=function(){this._backoff.reset(),this.emit("stateChanged","registered"),this._checkPendingUpdate()},r.prototype._onUnregistered=function(){this._backoff.reset(),this.emit("stateChanged","unregistered"),this._checkPendingUpdate()},r.prototype._register=function(e){var t=this,n={endpoint_platform:this._platform,channel_type:this._channelType,version:"2",message_types:e.messageTypes,data:{},ttl:"PT24H"};"twilsock"===this._channelType?n.data.url=e.notificationId:n.data.registration_id=e.notificationId;var r=this._url+"?productId="+this._productId,i={"Content-Type":"application/json","X-Twilio-Token":this._config.token};return u.trace("NTFCN I: Creating registration for channel ",this._channelType),this._transport.post(r,i,n).then(function(n){t._registrationId=n.body.id,t._registrationData=e,u.debug("NTFCN I: Registration created: ",n),t._fsm.registered()})["catch"](function(n){return u.error("NTFCN E: Registration failed: ",n),t._fsm.failure(e),n})},r.prototype._unregister=function(){var e=this;if(!this._registrationId)return Promise.resolve();var t=this._url+"/"+this._registrationId+"?productId="+this._productId,n={"Content-Type":"application/json","X-Twilio-Token":this._config.token};u.trace("NTFCN I: removing registration for ",this._channelType),this._transport["delete"](t,n).then(function(){u.debug("NTFCN I: registration removed for ",e._channelType),e._registrationId=!1,e._fsm.unregistered()})["catch"](function(t){return u.error("NTFCN E: failed to remove of registration ",e.channelType,t),e._fsm.failure(),t})},Object.freeze(r),t.exports=r},{backoff:36,events:51,"javascript-state-machine":56,loglevel:57,util:93}],24:[function(e,t,n){"use strict";function r(e,t,n){var r=this,o={twilsock:new Set,gcm:new Set},s={twilsock:null,gcm:null},u=new a(e,t,n,"twilsock"),c=new a(e,t,n,"gcm");Object.defineProperties(this,{_conf:{value:n},_subscriptions:{value:o},_notificationIds:{value:s},_twilsockRegistrar:{value:u},_gcmRegistrar:{value:c}}),i.call(this),u.on("stateChanged",function(e){return r.emit("stateChanged",e)})}var i=e("events").EventEmitter,o=e("util").inherits,s=e("loglevel"),a=e("./registrar.connector");o(r,i),r.prototype.setNotificationId=function(e,t){s.trace("NTFCN I: Notification id for channel ",e,t),this._notificationIds[e]!==t&&(this._notificationIds[e]=t,this._updateRegistration(e))},r.prototype.refreshSubscriptions=function(){s.info("NTFCN: Refresh registrations"),this._updateTwilsockRegistration()},r.prototype.hasSubscription=function(e,t){if("twilsock"===t)return this._subscriptions.twilsock.has(e);if("gcm"===t)return this._subscriptions.gcm.has(e);throw new Error("Unknown channel type: "+t)},r.prototype.subscribe=function(e,t){if(!this.hasSubscription(e,t))if("twilsock"===t)0===this._subscriptions.twilsock.size&&this.emit("needReliableTransport",!0),this._subscriptions.twilsock.add(e),this._updateTwilsockRegistration();else{if("gcm"!==t)throw new Error("Can't subscribe to the channel type "+t);this._subscriptions.gcm.add(e),this._updateGcmRegistration()}},r.prototype.unsubscribe=function(e,t){this.hasSubscription(e,t)&&("twilsock"===t?(this._subscriptions.twilsock["delete"](e),this._updateTwilsockRegistration(),0===this._subscriptions.twilsock.size&&this.emit("needReliableTransport",!1)):"gcm"===t&&(this._subscriptions.gcm["delete"](e),this._updateGcmRegistration()))},r.prototype._updateRegistration=function(e){return"twilsock"===e?this._updateTwilsockRegistration():"gcm"===e?this._updateGcmRegistration():void 0},r.prototype._updateTwilsockRegistration=function(){if(!this._notificationIds.twilsock)return void s.trace("Ignoring twilsock registration update request: no twilsock id in place");var e=this._notificationIds.twilsock,t=[];this._subscriptions.twilsock.forEach(function(e){return t.push(e)}),s.debug("Subscribing to the twilsock notifications"),this._twilsockRegistrar.update(e,t)},r.prototype._updateGcmRegistration=function(){if(!this._notificationIds.gcm)return void s.trace("Ignoring twilsock registration update request: no twilsock id in place");var e=this._notificationIds.gcm,t=[];this._subscriptions.gcm.forEach(function(e){return t.push(e)}),this._gcmRegistrar.update(e,t)},Object.freeze(r),t.exports=r},{"./registrar.connector":23,events:51,loglevel:57,util:93}],25:[function(e,t,n){"use strict";function r(e){var t=e.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(t){var n={protocol:t[1],host:t[2],hostname:t[3],port:t[4],pathname:t[5],search:t[6],hash:t[7]};if(n.search.length>0){var r=n.search.substring(1);n.params=r.split("&").map(function(e){return e.split("=")}).reduce(function(e,t){return e[t[0]]=t[1],e},{})}return n}throw new Error("Incorrect URI: "+e)}function i(e,t){var n=r(t),i={method:e,host:n.host,path:n.pathname};return n.params&&(i.params=n.params),i}function o(e,t,n,r){return{to:i(e,t),headers:n,body:r}}function s(e){return{status:e.status,headers:e.header.http_headers,body:e.body}}function a(e,t,n){return{url:e,headers:t,body:n}}function u(e){try{e.body=JSON.parse(e.body)}finally{return e}}function c(e){Object.defineProperties(this,{_activeGetRequests:{value:new Map},_twilsock:{value:e},_http:{value:f}}),e&&e.connect()}var f=e("./request");c.prototype._shouldUseTwilsock=function(){return this._twilsock&&this._twilsock.isConnected},c.prototype._get=function(e,t){return this._shouldUseTwilsock()?this._twilsock.send(o("GET",e,t)).then(s):this._http.get(a(e,t)).then(u)},c.prototype.get=function(e,t){var n=this;if(this._activeGetRequests.has(e))return this._activeGetRequests.get(e);var r=this._get(e,t).then(function(t){return n._activeGetRequests["delete"](e),t})["catch"](function(t){throw n._activeGetRequests["delete"](e),t});return this._activeGetRequests.set(e,r),r},c.prototype.post=function(e,t,n){return this._shouldUseTwilsock()?this._twilsock.send(o("POST",e,t,n)).then(s):this._http.post(a(e,t,n)).then(u)},c.prototype.put=function(e,t,n){return this._shouldUseTwilsock()?this._twilsock.send(o("PUT",e,t,n)).then(s):this._http.put(a(e,t,n)).then(u)},c.prototype["delete"]=function(e,t){return this._shouldUseTwilsock()?this._twilsock.send(o("DELETE",e,t)).then(u):this._http["delete"](a(e,t)).then(u)},Object.freeze(c),t.exports=c},{"./request":26}],26:[function(e,t,n){"use strict";function r(e){return e.split("\r\n").map(function(e){return e.split(": ")}).filter(function(e){return 2===e.length&&e[1].length>0}).reduce(function(e,t){return e[t[0]]=t[1],e},{})}function i(e,t){var n=new Promise(function(n,i){var s=new o;s.open(e,t.url,!0),s.onreadystatechange=function(){if(4===s.readyState)if(200<=s.status&&s.status<300){var e=r(s.getAllResponseHeaders());n({status:s.status,headers:e,body:s.responseText})}else i({status:s.status,description:s.statusText,body:s.responseText})};for(var a in t.headers)s.setRequestHeader(a,t.headers[a]),"Content-Type"===a&&"application/json"===t.headers[a]&&(t.body=JSON.stringify(t.body));s.send(t.body)});return n}var o="undefined"==typeof XMLHttpRequest?e("xmlhttprequest").XMLHttpRequest:XMLHttpRequest,s=i;s.get=function(e){return i("GET",e)},s.post=function(e){return i("POST",e)},s.put=function(e){return i("PUT",e)},s["delete"]=function(e){return i("DELETE",e)},t.exports=s},{xmlhttprequest:95}],27:[function(e,t,n){"use strict";function r(e,t){var n=this,r=new a(e,t),o=new u(r),s=new c(o);Object.defineProperties(this,{_config:{value:r},_socket:{value:o},_network:{value:s},isConnected:{get:function(){return n._socket.isConnected()}}}),i.call(this),this._socket.on("message",function(e,t){return n.emit("message",e,t)}),this._socket.on("connected",function(e){return n.emit("connected",e)}),this._socket.on("disconnected",function(){return n.emit("disconnected")})}var i=e("events").EventEmitter,o=e("util").inherits,s=e("loglevel"),a=e("./configuration.js"),u=e("./twilsock.js"),c=e("./packetinterface.js");o(r,i),r.prototype.send=function(e){return this._network.send(e.to,e.headers,e.body)},r.prototype.setAuthToken=function(e){var t=this;s.info("Twilsock I: authTokenUpdated"),this._config.updateToken(e),this._socket.disconnect().then(function(){return t._socket.connect()})},r.prototype.connect=function(){return this._socket.connect()},r.prototype.disconnect=function(){return this._socket.disconnect()},Object.freeze(r),t.exports=r},{"./configuration.js":28,"./packetinterface.js":29,"./twilsock.js":30,events:51,loglevel:57,util:93}],28:[function(e,t,n){"use strict";function r(e,t){var n=this;t=t||{};var r=t.Twilsock||{},s=r.uri||t.wsServer||i;Object.defineProperties(this,{_twilsockWsHost:{value:s+o},_token:{value:e,writable:!0},token:{get:function(){return n._token}},twilsockUri:{get:function(){return n._twilsockWsHost}}})}var i="wss://tsock.twilio.com",o="/v2/wsconnect";r.prototype.updateToken=function(e){this._token=e},t.exports=r},{}],29:[function(e,t,n){"use strict";function r(e){Object.defineProperties(this,{_activeRequests:{value:new Map},_socket:{value:e}}),this._socket.on("reply",this._processReply.bind(this))}function i(e){return-1!==[200,201,204].indexOf(e)}var o=e("loglevel"),s=3e4;r.prototype._processReply=function(e){var t=this._activeRequests.get(e.id);t&&(clearTimeout(t.timeout),this._activeRequests["delete"](e.id),i(e.status.code)?i(e.header.http_status.code)?t.resolve(e):t.reject({status:e.header.http_status.code,description:e.header.http_status.status,body:e.body}):t.reject(new Error("Transport failure: "+e.status.status)))},r.prototype.send=function(e,t,n){var r=this;return new Promise(function(i,a){var u=r._socket.send(e,t,n);o.trace("Twilsock: message sent: ",{id:u,address:e,headers:t,body:n});var c={resolve:i,reject:a,timeout:setTimeout(function(){o.debug("Request",u,"is timed out"),a(new Error("Timeout"))},s)};r._activeRequests.set(u,c)})},r.prototype.shutdown=function(){this._activeRequests.forEach(function(e){clearTimeout(e.timeout)}),this._activeRequests.clear()},t.exports=r},{loglevel:57}],30:[function(e,t,n){(function(n){"use strict";function r(e){var t=this,n=arguments;u.call(this);var r=d.create({initial:"disconnected",events:[{name:"userConnect",from:["disconnected"],to:"connecting"},{name:"userDisconnect",from:["connecting","connected","retrying"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"connected"},{name:"socketClosed",from:["connecting","connected"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketRejected",from:["connecting","connected"],to:"disconnecting"}],callbacks:{onconnecting:function(){t._startWatchdogTimer(),t._setupSocket(),t.emit("connecting")},onretrying:function(){t._initRetry(),t.emit("connecting")},onenterconnected:this._onConnected.bind(this),onuserDisconnect:this._closeSocket.bind(this),ondisconnected:function(){if(t._stopWatchdogTimer(),t._onDisconnected(),t._disconnectedPromiseResolve){var e=t._disconnectedPromiseResolve;t._disconnectedPromiseResolve=null,e()}},onsocketRejected:function(){var e=Array.prototype.slice.call(n,3,n.length);t._onSocketRejected(e)}},error:function(){l.trace("Twilsock FSM: unexpected transition",arguments)}}),i=h.exponential({randomisationFactor:.2,initialDelay:2e3,maxDelay:12e4});i.on("ready",function(){t._retry()}),Object.defineProperties(this,{_config:{value:e},_transportReady:{value:!1,writable:!0},_disconnectedPromiseResolve:{value:null,writable:!0},_backoff:{value:i},_fsm:{value:r},_watchTimer:{value:null,writable:!0},_timestamp:{value:0,writable:!0}})}function i(e){for(var t="",n=0;n0){var f=r+a.size+a.headerSize;u.hasOwnProperty("payload_type")&&0!==u.payload_type.indexOf("application/json")?0===u.payload_type.indexOf("text/plain")&&(c=new n(s.subarray(f)).toString()):c=o(s.subarray(f))}e._updateActivityTimestamp(),"ready"===u.method?(l.trace("Twilsock ready",c),e._wschannelUrl=c.wschannel_url,e._confirmReceiving(u),e._fsm.socketConnected()):"notification"===u.method?(e._confirmReceiving(u),e.emit("message",u.message_type,c)):"reply"===u.method?e.emit("reply",{id:u.id,status:u.status,header:u,body:c}):"ping"===u.method?e._confirmReceiving(u):"close"===u.method&&(l.trace("Twilsock connection close initated by server"),e._confirmReceiving(u),e._fsm.socketRejected(c))},this._socket=r},r.prototype._confirmReceiving=function(e){var t={method:"reply",id:e.id,payload_type:"application/json",status:{code:200,status:"OK"}};this._sendPacket(t)},r.prototype._sendPacket=function(e,t){var r=s(t);e.payload_size=n.byteLength(r);var i=JSON.stringify(e)+"\r\n",o="TWILSOCK V1.0 "+(n.byteLength(i)-2)+"\r\n",a=new Uint8Array(new n(o+i+r));this._socket.send(a.buffer)},r.prototype._cancelRetryAttempt=function(){this._backoff.reset()},r.prototype._closeSocket=function(){this._cancelRetryAttempt(),this._socket&&this._socket.close()},r.prototype.connect=function(){this._fsm.userConnect()},r.prototype.disconnect=function(){var e=this;return this._fsm.is("disconnected")?Promise.resolve():new Promise(function(t){e._fsm.userDisconnect(),e._disconnectedPromiseResolve=t})},r.prototype.isConnected=function(){return this._socket&&1===this._socket.readyState},r.prototype.send=function(e,t,n){var r=c.makeUUID(),i={host:e.host,path:e.path,method:e.method};e.hasOwnProperty("params")&&(i.params=e.params);var o={method:"message",id:r,http_header:i};return t&&(o.http_header.headers=t),t&&t.hasOwnProperty("Content-Type")&&(o.payload_type=t["Content-Type"]),this._sendPacket(o,n),r},r.prototype._onSocketRejected=function(e){l.error("Twilsock connection closed by server",e),this.emit("remoteClose",e),this._closeSocket()},r.prototype._startWatchdogTimer=function(){var e=this;this._timestamp=Date.now(),this._watchTimer=setInterval(function(){Date.now()-e._timestamp>m&&e._socket.close()},y)},r.prototype._stopWatchdogTimer=function(){clearInterval(this._watchTimer)},r.prototype._updateActivityTimestamp=function(){this._timestamp=Date.now()},Object.freeze(r),t.exports=r}).call(this,e("buffer").Buffer)},{"../../util":33,backoff:36,buffer:45,events:51,"javascript-state-machine":56,loglevel:57,util:93,ws:94}],31:[function(e,t,n){"use strict";function r(e){var t=this;Object.defineProperties(this,{_pendingListeners:{value:{}},_data:{value:e||{},writable:!0}}),i.call(this),["keyAdded","keyRemoved","keyUpdated"].forEach(function(e){t._pendingListeners[e]={},t.on(e,function(n,r){var i=t._pendingListeners[e][n]||[];i.forEach(function(e){return e(r)}),t._pendingListeners[e][n]=[]})})}var i=e("events").EventEmitter,o=e("util").inherits,s=e("./jsondiff");o(r,i),r.prototype._traverse=function(e,t){var n=this,r=s.diff(e,t);r.forEach(function(e){"add"===e.op?n.emit("keyAdded",e.path,e.value):"replace"===e.op?n.emit("keyUpdated",e.path,e.value):"remove"===e.op&&n.emit("keyRemoved",e.path)})},r.prototype.update=function(e){var t=this._data;this._data=e,this._traverse(t,e)},r.prototype.addEventHandler=function(e,t,n){var r=this._pendingListeners[e][t]||[];r.push(n),this._pendingListeners[e][t]=r},t.exports=r},{"./jsondiff":34,events:51,util:93}],32:[function(e,t,n){"use strict";function r(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+e()+e()+e()+e()+e()+e()}t.exports=r},{}],33:[function(_dereq_,module,exports){(function(Buffer){"use strict";function decodeBase64URL(e){var t=e.length%4;if(t>0){var n=4-t;e+=new Array(n+1).join("=")}return e=e.replace(/-/g,"+").replace(/_/g,"/"),decodeBase64(e)}function memoize(e){var t={};return function(){var n=Array.prototype.slice.call(arguments,0);return t[n]?t[n]:t[n]=e.apply(null,n)}}function deepClone(e){return JSON.parse(JSON.stringify(e))}function fromURLFormEncoded(e){if(!e)return{};for(var t={},n=e.split("&"),r=0;rs;r=++s)o=e[r],this.flattenObject(o,t+r,n);else if(this.isObject(e))for(i in e)o=e[i],this.flattenObject(o,t+i,n);return n},r.prototype.diff=function(e,t){var n,r,i,o,s,a,u,c,f,l,h,p,d,y,m;if(!this.isSameContainer(e,t))throw new Error("Patches can only be derived from objects or arrays");p=this.flattenObject(e),d=this.flattenObject(t),n={},y={},m={},l={};for(s in p)if(i=p[s],o=d[s],this.getParent(d,s))if(o){if(this.isSameContainer(i.value,o.value))continue;this.isEqual(i.value,o.value)||(m[s]=o)}else y[s]=i;for(s in d)i=p[s],o=d[s],!i&&this.isSameContainer(this.getParent(p,s),this.getParent(d,s))&&(n[s]=o);for(a in y){i=y[a];for(u in n)if(o=n[u],this.isEqual(o.value,i.value)){delete y[a],delete n[u],l[u]=a;break}}h=[];for(s in n)r=n[s],h.push({op:"add",path:s,value:r.value});for(s in y)h.push({op:"remove",path:s});for(s in m)r=m[s],h.push({op:"replace",path:s,value:r.value});for(f in l)c=l[f],h.push({op:"move",from:c,path:f});return h},r.diff=function(e,t){var n=new r;return n.diff(e,t)},r.isDeepEqual=function(e,t){return 0===this.diff(e,t).length},t.exports=r},{}],35:[function(e,t,n){"use strict";function r(e,t){return new r.Client(e,t)}r.Client=e("./clients/ipmessaging/client"),r.DataSyncClient=e("./clients/datasync/client"),r.NotificationClient=e("./clients/notification/client"),r.Transport=e("./clients/transport"),r.TwilsockClient=e("./clients/twilsock/client"),t.exports=r},{"./clients/datasync/client":1,"./clients/ipmessaging/client":11,"./clients/notification/client":21,"./clients/transport":25,"./clients/twilsock/client":27}],36:[function(e,t,n){
// Copyright (c) 2012 Mathieu Turcotte
// Licensed under the MIT license.
var r=e("./lib/backoff"),i=e("./lib/strategy/exponential"),o=e("./lib/strategy/fibonacci"),s=e("./lib/function_call.js");t.exports.Backoff=r,t.exports.FunctionCall=s,t.exports.FibonacciStrategy=o,t.exports.ExponentialStrategy=i,t.exports.fibonacci=function(e){return new r(new o(e))},t.exports.exponential=function(e){return new r(new i(e))},t.exports.call=function(e,t,n){var r=Array.prototype.slice.call(arguments);return e=r[0],t=r.slice(1,r.length-1),n=r[r.length-1],new s(e,t,n)}},{"./lib/backoff":37,"./lib/function_call.js":38,"./lib/strategy/exponential":39,"./lib/strategy/fibonacci":40}],37:[function(e,t,n){function r(e){i.EventEmitter.call(this),this.backoffStrategy_=e,this.maxNumberOfRetry_=-1,this.backoffNumber_=0,this.backoffDelay_=0,this.timeoutID_=-1,this.handlers={backoff:this.onBackoff_.bind(this)}}
// Copyright (c) 2012 Mathieu Turcotte
// Licensed under the MIT license.
var i=e("events"),o=e("precond"),s=e("util");s.inherits(r,i.EventEmitter),r.prototype.failAfter=function(e){o.checkArgument(e>0,"Expected a maximum number of retry greater than 0 but got %s.",e),this.maxNumberOfRetry_=e},r.prototype.backoff=function(e){o.checkState(-1===this.timeoutID_,"Backoff in progress."),this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},r.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},r.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=r},{events:51,precond:59,util:93}],38:[function(e,t,n){function r(e,t,n){i.EventEmitter.call(this),o.checkIsFunction(e,"Expected fn to be a function."),o.checkIsArray(t,"Expected args to be an array."),o.checkIsFunction(n,"Expected callback to be a function."),this.function_=e,this.arguments_=t,this.callback_=n,this.lastResult_=[],this.numRetries_=0,this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.retryPredicate_=r.DEFAULT_RETRY_PREDICATE_,this.state_=r.State_.PENDING}
// Copyright (c) 2012 Mathieu Turcotte
// Licensed under the MIT license.
var i=e("events"),o=e("precond"),s=e("util"),a=e("./backoff"),u=e("./strategy/fibonacci");s.inherits(r,i.EventEmitter),r.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},r.DEFAULT_RETRY_PREDICATE_=function(e){return!0},r.prototype.isPending=function(){return this.state_==r.State_.PENDING},r.prototype.isRunning=function(){return this.state_==r.State_.RUNNING},r.prototype.isCompleted=function(){return this.state_==r.State_.COMPLETED},r.prototype.isAborted=function(){return this.state_==r.State_.ABORTED},r.prototype.setStrategy=function(e){return o.checkState(this.isPending(),"FunctionCall in progress."),this.strategy_=e,this},r.prototype.retryIf=function(e){return o.checkState(this.isPending(),"FunctionCall in progress."),this.retryPredicate_=e,this},r.prototype.getLastResult=function(){return this.lastResult_.concat()},r.prototype.getNumRetries=function(){return this.numRetries_},r.prototype.failAfter=function(e){return o.checkState(this.isPending(),"FunctionCall in progress."),this.failAfter_=e,this},r.prototype.abort=function(){this.isCompleted()||this.isAborted()||(this.isRunning()&&this.backoff_.reset(),this.state_=r.State_.ABORTED,this.lastResult_=[new Error("Backoff aborted.")],this.emit("abort"),this.doCallback_())},r.prototype.start=function(e){o.checkState(!this.isAborted(),"FunctionCall is aborted."),o.checkState(this.isPending(),"FunctionCall already started.");var t=this.strategy_||new u;this.backoff_=e?e(t):new a(t),this.backoff_.on("ready",this.doCall_.bind(this,!0)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=r.State_.RUNNING,this.doCall_(!1)},r.prototype.doCall_=function(e){e&&this.numRetries_++;var t=["call"].concat(this.arguments_);i.EventEmitter.prototype.emit.apply(this,t);var n=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(n))},r.prototype.doCallback_=function(){this.callback_.apply(null,this.lastResult_)},r.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.lastResult_=e,i.EventEmitter.prototype.emit.apply(this,["callback"].concat(e));var t=e[0];t&&this.retryPredicate_(t)?this.backoff_.backoff(t):(this.state_=r.State_.COMPLETED,this.doCallback_())}},r.prototype.handleBackoff_=function(e,t,n){this.emit("backoff",e,t,n)},t.exports=r},{"./backoff":37,"./strategy/fibonacci":40,events:51,precond:59,util:93}],39:[function(e,t,n){function r(e){s.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay(),this.factor_=r.DEFAULT_FACTOR,e&&void 0!==e.factor&&(o.checkArgument(e.factor>1,"Exponential factor should be greater than 1 but got %s.",e.factor),this.factor_=e.factor)}
// Copyright (c) 2012 Mathieu Turcotte
// Licensed under the MIT license.
var i=e("util"),o=e("precond"),s=e("./strategy");i.inherits(r,s),r.DEFAULT_FACTOR=2,r.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=this.backoffDelay_*this.factor_,this.backoffDelay_},r.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=r},{"./strategy":41,precond:59,util:93}],40:[function(e,t,n){function r(e){o.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}
// Copyright (c) 2012 Mathieu Turcotte
// Licensed under the MIT license.
var i=e("util"),o=e("./strategy");i.inherits(r,o),r.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},r.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=r},{"./strategy":41,util:93}],41:[function(e,t,n){function r(e){return void 0!==e&&null!==e}function i(e){if(e=e||{},r(e.initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(r(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(r(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}
// Copyright (c) 2012 Mathieu Turcotte
// Licensed under the MIT license.
e("events"),e("util");i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_,n=Math.round(e*t);return n},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:51,util:93}],42:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===l?62:t===a||t===h?63:u>t?-1:u+10>t?t-u+26+26:f+26>t?t-f:c+26>t?t-c+26:void 0}function n(e){function n(e){c[l++]=e}var r,i,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=e.length;u="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0,c=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var l=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),c}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),l="-".charCodeAt(0),h="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],43:[function(e,t,n){},{}],44:[function(e,t,n){arguments[4][43][0].apply(n,arguments)},{dup:43}],45:[function(e,t,n){(function(t){/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh
* @license MIT
*/
"use strict";function r(){function e(){}try{var t=new Uint8Array(1);return t.foo=function(){return 42},t.constructor=e,42===t.foo()&&t.constructor===e&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(n){return!1}}function i(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e){return this instanceof o?(o.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?s(this,e):"string"==typeof e?a(this,e,arguments.length>1?arguments[1]:"utf8"):u(this,e)):arguments.length>1?new o(e,arguments[1]):new o(e)}function s(e,t){if(e=y(e,0>t?0:0|m(t)),!o.TYPED_ARRAY_SUPPORT)for(var n=0;t>n;n++)e[n]=0;return e}function a(e,t,n){"string"==typeof n&&""!==n||(n="utf8");var r=0|g(t,n);return e=y(e,r),e.write(t,n),e}function u(e,t){if(o.isBuffer(t))return c(e,t);if(X(t))return f(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(t.buffer instanceof ArrayBuffer)return l(e,t);if(t instanceof ArrayBuffer)return h(e,t)}return t.length?p(e,t):d(e,t)}function c(e,t){var n=0|m(t.length);return e=y(e,n),t.copy(e,0,0,n),e}function f(e,t){var n=0|m(t.length);e=y(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function l(e,t){var n=0|m(t.length);e=y(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function h(e,t){return o.TYPED_ARRAY_SUPPORT?(t.byteLength,e=o._augment(new Uint8Array(t))):e=l(e,new Uint8Array(t)),e}function p(e,t){var n=0|m(t.length);e=y(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t){var n,r=0;"Buffer"===t.type&&X(t.data)&&(n=t.data,r=0|m(n.length)),e=y(e,r);for(var i=0;r>i;i+=1)e[i]=255&n[i];return e}function y(e,t){o.TYPED_ARRAY_SUPPORT?(e=o._augment(new Uint8Array(t)),e.__proto__=o.prototype):(e.length=t,e._isBuffer=!0);var n=0!==t&&t<=o.poolSize>>>1;return n&&(e.parent=V),e}function m(e){if(e>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function v(e,t){if(!(this instanceof v))return new v(e,t);var n=new o(e,t);return delete n.parent,n}function g(e,t){"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(e).length;default:if(r)return Y(e).length;t=(""+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if(t=0|t,n=void 0===n||n===1/0?this.length:0|n,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return U(this,t,n);case"utf8":case"utf-8":return R(this,t,n);case"ascii":return A(this,t,n);case"binary":return C(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function w(e,t,n,r){return J(Y(t,e.length-n),e,n,r)}function E(e,t,n,r){return J(H(t),e,n,r)}function S(e,t,n,r){return E(e,t,n,r)}function k(e,t,n,r){return J(G(t),e,n,r)}function x(e,t,n,r){return J(W(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?$.fromByteArray(e):$.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n>=i+a){var u,c,f,l;switch(a){case 1:128>o&&(s=o);break;case 2:u=e[i+1],128===(192&u)&&(l=(31&o)<<6|63&u,l>127&&(s=l));break;case 3:u=e[i+1],c=e[i+2],128===(192&u)&&128===(192&c)&&(l=(15&o)<<12|(63&u)<<6|63&c,l>2047&&(55296>l||l>57343)&&(s=l));break;case 4:u=e[i+1],c=e[i+2],f=e[i+3],128===(192&u)&&128===(192&c)&&128===(192&f)&&(l=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&f,l>65535&&1114112>l&&(s=l))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return I(r)}function I(e){var t=e.length;if(Z>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Z));return n}function A(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function C(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function U(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=z(e[o]);return i}function P(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function j(e,t,n,r,i,s){if(!o.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||s>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range")}function L(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function D(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function M(e,t,n,r,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function B(e,t,n,r,i){return i||M(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,i){return i||M(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(e,t,n,r,52,8),n+8}function q(e){if(e=F(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function F(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function z(e){return 16>e?"0"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function H(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function G(e){return $.toByteArray(q(e))}function J(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}var $=e("base64-js"),K=e("ieee754"),X=e("isarray");n.Buffer=o,n.SlowBuffer=v,n.INSPECT_MAX_BYTES=50,o.poolSize=8192;var V={};o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),o.TYPED_ARRAY_SUPPORT?(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array):(o.prototype.length=void 0,o.prototype.parent=void 0),o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);s>i&&e[i]===t[i];)++i;return i!==s&&(n=e[i],r=t[i]),r>n?-1:n>r?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!X(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new o(0);var n;if(void 0===t)for(t=0,n=0;n0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},o.prototype.compare=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:o.compare(this,e)},o.prototype.indexOf=function(e,t){function n(e,t,n){for(var r=-1,i=0;n+i2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(o.isBuffer(e))return n(this,e,t);if("number"==typeof e)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):n(this,[e],t);throw new TypeError("val must be string, number or Buffer")},o.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},o.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},o.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var i=r;r=t,t=0|n,n=i}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return E(this,e,t,n);case"binary":return S(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var r;if(o.TYPED_ARRAY_SUPPORT)r=o._augment(this.subarray(e,t));else{var i=t-e;r=new o(i,void 0);for(var s=0;i>s;s++)r[s]=this[s+e]}return r.length&&(r.parent=this.parent||this),r},o.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},o.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),K.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),K.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),K.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),K.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){e=+e,t=0|t,n=0|n,r||j(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);j(this,e,t,n,i-1,-i)}var o=0,s=1,a=0>e?1:0;for(this[t]=255&e;++o>0)-a&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);j(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0>e?1:0;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=(e/s>>0)-a&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t=0|t,n||j(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-tn&&r>t)for(i=s-1;i>=0;i--)e[i+t]=this[i+n];else if(1e3>s||!o.TYPED_ARRAY_SUPPORT)for(i=0;s>i;i++)e[i+t]=this[i+n];else e._set(this.subarray(n,n+s),t);return s},o.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=Y(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}},o.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(o.TYPED_ARRAY_SUPPORT)return new o(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Q=o.prototype;o._augment=function(e){return e.constructor=o,e._isBuffer=!0,e._set=e.set,e.get=Q.get,e.set=Q.set,e.write=Q.write,e.toString=Q.toString,e.toLocaleString=Q.toString,e.toJSON=Q.toJSON,e.equals=Q.equals,e.compare=Q.compare,e.indexOf=Q.indexOf,e.copy=Q.copy,e.slice=Q.slice,e.readUIntLE=Q.readUIntLE,e.readUIntBE=Q.readUIntBE,e.readUInt8=Q.readUInt8,e.readUInt16LE=Q.readUInt16LE,e.readUInt16BE=Q.readUInt16BE,e.readUInt32LE=Q.readUInt32LE,e.readUInt32BE=Q.readUInt32BE,e.readIntLE=Q.readIntLE,e.readIntBE=Q.readIntBE,e.readInt8=Q.readInt8,e.readInt16LE=Q.readInt16LE,e.readInt16BE=Q.readInt16BE,e.readInt32LE=Q.readInt32LE,e.readInt32BE=Q.readInt32BE,e.readFloatLE=Q.readFloatLE,e.readFloatBE=Q.readFloatBE,e.readDoubleLE=Q.readDoubleLE,e.readDoubleBE=Q.readDoubleBE,e.writeUInt8=Q.writeUInt8,e.writeUIntLE=Q.writeUIntLE,e.writeUIntBE=Q.writeUIntBE,e.writeUInt16LE=Q.writeUInt16LE,e.writeUInt16BE=Q.writeUInt16BE,e.writeUInt32LE=Q.writeUInt32LE,e.writeUInt32BE=Q.writeUInt32BE,e.writeIntLE=Q.writeIntLE,e.writeIntBE=Q.writeIntBE,e.writeInt8=Q.writeInt8,e.writeInt16LE=Q.writeInt16LE,e.writeInt16BE=Q.writeInt16BE,e.writeInt32LE=Q.writeInt32LE,e.writeInt32BE=Q.writeInt32BE,e.writeFloatLE=Q.writeFloatLE,e.writeFloatBE=Q.writeFloatBE,e.writeDoubleLE=Q.writeDoubleLE,e.writeDoubleBE=Q.writeDoubleBE,e.fill=Q.fill,e.inspect=Q.inspect,e.toArrayBuffer=Q.toArrayBuffer,e};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":42,ieee754:53,isarray:46}],46:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],47:[function(e,t,n){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],48:[function(e,t,n){(function(e){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function t(e){return Array.isArray?Array.isArray(e):"[object Array]"===m(e)}function r(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function f(e){return"[object RegExp]"===m(e)}function l(e){return"object"==typeof e&&null!==e}function h(e){return"[object Date]"===m(e)}function p(e){return"[object Error]"===m(e)||e instanceof Error}function d(e){return"function"==typeof e}function y(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function m(e){return Object.prototype.toString.call(e)}n.isArray=t,n.isBoolean=r,n.isNull=i,n.isNullOrUndefined=o,n.isNumber=s,n.isString=a,n.isSymbol=u,n.isUndefined=c,n.isRegExp=f,n.isObject=l,n.isDate=h,n.isError=p,n.isFunction=d,n.isPrimitive=y,n.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":55}],49:[function(e,t,n){t.exports=e("./lib")},{"./lib":50}],50:[function(e,t,n){function r(e){return void 0===e?0:parseInt(e,10)}var i=/^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/;n.fromSeconds=function(e){if("number"!=typeof e)throw new TypeError("Argument `seconds` must be a number");var t=e%60,n=(e-t)%3600;return{hours:(e-t-n)/3600,minutes:n/60,seconds:t}},n.fromString=function(e){if("string"!=typeof e)throw new TypeError("Argument `string` must be a string");var t=e.match(i);if(null===t||void 0===t[1]&&void 0===t[2]&&void 0===t[3])throw new Error('Could not parse "'+e+'" as a duration.');return{hours:r(t[1]),minutes:r(t[2]),seconds:r(t[3])}},n.toString=function(e){"number"==typeof e&&(e=n.fromSeconds(e));var t="PT";return e.hours>0&&(t+=e.hours+"H"),e.minutes>0&&(t+=e.minutes+"M"),e.seconds>0&&(t+=e.seconds+"S"),"PT"===t&&(t+="0S"),t},n.toSeconds=function(e){var t=e;return"string"==typeof e&&(t=n.fromString(e)),3600*t.hours+60*t.minutes+t.seconds}},{}],51:[function(e,t,n){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],a(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(s(n))for(o=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,u=0;r>u;u++)c[u].apply(this,o);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],52:[function(e,t,n){var r=e("http"),i=t.exports;for(var o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);i.request=function(e,t){return e||(e={}),e.scheme="https",e.protocol="https:",r.request.call(this,e,t)}},{http:81}],53:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<>1,f=-7,l=n?i-1:0,h=n?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,y=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*y}},{}],54:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],55:[function(e,t,n){/**
* Determine if an object is Buffer
*
* Author: Feross Aboukhadijeh
* License: MIT
*
* `npm install is-buffer`
*/
t.exports=function(e){return!(null==e||!(e._isBuffer||e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)))}},{}],56:[function(e,t,n){/*
Javascript State Machine Library - https://github.com/jakesgordon/javascript-state-machine
Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
Released under the MIT license - https://github.com/jakesgordon/javascript-state-machine/blob/master/LICENSE
*/
!function(){var e={VERSION:"2.3.5",Result:{SUCCEEDED:1,NOTRANSITION:2,CANCELLED:3,PENDING:4},Error:{INVALID_TRANSITION:100,PENDING_TRANSITION:200,INVALID_CALLBACK:300},WILDCARD:"*",ASYNC:"async",create:function(t,n){var r="string"==typeof t.initial?{state:t.initial}:t.initial,i=t.terminal||t["final"],o=n||t.target||{},s=t.events||[],a=t.callbacks||{},u={},c={},f=function(t){var n=t.from instanceof Array?t.from:t.from?[t.from]:[e.WILDCARD];u[t.name]=u[t.name]||{};for(var r=0;r=0:this.current===e},o.can=function(t){return!this.transition&&(u[t].hasOwnProperty(this.current)||u[t].hasOwnProperty(e.WILDCARD))},o.cannot=function(e){return!this.can(e)},o.transitions=function(){return c[this.current]},o.isFinished=function(){return this.is(i)},o.error=t.error||function(e,t,n,r,i,o,s){throw s||o},r&&!r.defer&&o[r.event](),o},doCallback:function(t,n,r,i,o,s){if(n)try{return n.apply(t,[r,i,o].concat(s))}catch(a){return t.error(r,i,o,s,e.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",a)}},beforeAnyEvent:function(t,n,r,i,o){return e.doCallback(t,t.onbeforeevent,n,r,i,o)},afterAnyEvent:function(t,n,r,i,o){return e.doCallback(t,t.onafterevent||t.onevent,n,r,i,o)},leaveAnyState:function(t,n,r,i,o){return e.doCallback(t,t.onleavestate,n,r,i,o)},enterAnyState:function(t,n,r,i,o){return e.doCallback(t,t.onenterstate||t.onstate,n,r,i,o)},changeState:function(t,n,r,i,o){return e.doCallback(t,t.onchangestate,n,r,i,o)},beforeThisEvent:function(t,n,r,i,o){return e.doCallback(t,t["onbefore"+n],n,r,i,o)},afterThisEvent:function(t,n,r,i,o){return e.doCallback(t,t["onafter"+n]||t["on"+n],n,r,i,o)},leaveThisState:function(t,n,r,i,o){return e.doCallback(t,t["onleave"+r],n,r,i,o)},enterThisState:function(t,n,r,i,o){return e.doCallback(t,t["onenter"+i]||t["on"+i],n,r,i,o)},beforeEvent:function(t,n,r,i,o){return!1===e.beforeThisEvent(t,n,r,i,o)||!1===e.beforeAnyEvent(t,n,r,i,o)?!1:void 0},afterEvent:function(t,n,r,i,o){e.afterThisEvent(t,n,r,i,o),e.afterAnyEvent(t,n,r,i,o)},leaveState:function(t,n,r,i,o){var s=e.leaveThisState(t,n,r,i,o),a=e.leaveAnyState(t,n,r,i,o);return!1===s||!1===a?!1:e.ASYNC===s||e.ASYNC===a?e.ASYNC:void 0},enterState:function(t,n,r,i,o){e.enterThisState(t,n,r,i,o),e.enterAnyState(t,n,r,i,o)},buildEvent:function(t,n){return function(){var r=this.current,i=n[r]||n[e.WILDCARD]||r,o=Array.prototype.slice.call(arguments);if(this.transition)return this.error(t,r,i,o,e.Error.PENDING_TRANSITION,"event "+t+" inappropriate because previous transition did not complete");if(this.cannot(t))return this.error(t,r,i,o,e.Error.INVALID_TRANSITION,"event "+t+" inappropriate in current state "+this.current);if(!1===e.beforeEvent(this,t,r,i,o))return e.Result.CANCELLED;if(r===i)return e.afterEvent(this,t,r,i,o),e.Result.NOTRANSITION;var s=this;this.transition=function(){return s.transition=null,s.current=i,e.enterState(s,t,r,i,o),e.changeState(s,t,r,i,o),e.afterEvent(s,t,r,i,o),e.Result.SUCCEEDED},this.transition.cancel=function(){s.transition=null,e.afterEvent(s,t,r,i,o)};var a=e.leaveState(this,t,r,i,o);return!1===a?(this.transition=null,e.Result.CANCELLED):e.ASYNC===a?e.Result.PENDING:this.transition?this.transition():void 0}}};"undefined"!=typeof n?("undefined"!=typeof t&&t.exports&&(n=t.exports=e),n.StateMachine=e):"function"==typeof define&&define.amd?define(function(t){return e}):"undefined"!=typeof window?window.StateMachine=e:"undefined"!=typeof self&&(self.StateMachine=e)}()},{}],57:[function(e,t,n){/*
* loglevel - https://github.com/pimterry/loglevel
*
* Copyright (c) 2013 Tim Perry
* Licensed under the MIT license.
*/
!function(n,r){"use strict";"object"==typeof t&&t.exports&&"function"==typeof e?t.exports=r():"function"==typeof define&&"object"==typeof define.amd?define(r):n.log=r()}(this,function(){"use strict";function e(e){return typeof console===a?!1:void 0!==console[e]?t(console,e):void 0!==console.log?t(console,"log"):s}function t(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(r){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function n(e,t,n){return function(){typeof console!==a&&(r.call(this,t,n),this[e].apply(this,arguments))}}function r(e,t){for(var n=0;nn?s:this.methodFactory(r,e,t)}}function i(t,r,i){return e(t)||n.apply(this,arguments)}function o(e,t,n){function o(e){var t=(u[e]||"silent").toUpperCase();try{return void(window.localStorage[l]=t)}catch(n){}try{window.document.cookie=encodeURIComponent(l)+"="+t+";"}catch(n){}}function s(){var e;try{e=window.localStorage[l]}catch(t){}if(typeof e===a)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(l)+"=");r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(t){}return void 0===f.levels[e]&&(e=void 0),e}var c,f=this,l="loglevel";e&&(l+=":"+e),f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=n||i,f.getLevel=function(){return c},f.setLevel=function(t,n){if("string"==typeof t&&void 0!==f.levels[t.toUpperCase()]&&(t=f.levels[t.toUpperCase()]),!("number"==typeof t&&t>=0&&t<=f.levels.SILENT))throw"log.setLevel() called with invalid level: "+t;return c=t,n!==!1&&o(t),r.call(f,t,e),typeof console===a&&t-1&&_>=r)for(;++n3?J=["WebKit"]:"Trident"!=J&&(T=/\bOpera\b/.test($)&&(/\bOPR\b/.test(e)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&"WebKit"||!J&&/\bMSIE\b/i.test(e)&&("Mac OS"==V?"Tasman":"Trident"))?J=[T]:/\bPlayStation\b(?! Vita\b)/i.test($)&&"WebKit"==J&&(J=["NetFront"]),"IE"==$&&(T=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?($+=" Mobile",V="Windows Phone "+(/\+$/.test(T)?T:T+".x"),Y.unshift("desktop mode")):/\bWPDesktop\b/i.test(e)?($="IE Mobile",V="Windows Phone 8+",Y.unshift("desktop mode"),G||(G=(/\brv:([\d.]+)/.exec(e)||0)[1])):"IE"!=$&&"Trident"==J&&(T=/\brv:([\d.]+)/.exec(e))?(/\bWPDesktop\b/i.test(e)||($&&Y.push("identifying as "+$+(G?" "+G:"")),$="IE"),G=T[1]):"Chrome"!=$&&"IE"==$||!(T=/\bEdge\/([\d.]+)/.exec(e))||($="Microsoft Edge",G=T[1],J=["Trident"]),W){if(c(b,"global"))if(L&&(T=L.lang.System,z=T.getProperty("os.arch"),V=V||T.getProperty("os.name")+" "+T.getProperty("os.version")),I&&c(b,"system")&&(T=[b.system])[0]){V||(V=T[0].os||null);try{T[1]=b.require("ringo/engine").version,G=T[1].join("."),$="RingoJS"}catch(Z){T[0].global.system==b.system&&($="Narwhal")}}else"object"==typeof b.process&&(T=b.process)?($="Node.js",z=T.arch,V=T.platform,G=/[\d.]+/.exec(T.version)[0]):D&&($="Rhino");else u(T=b.runtime)==U?($="Adobe AIR",V=T.flash.system.Capabilities.os):u(T=b.phantom)==j?($="PhantomJS",G=(T=T.version||null)&&T.major+"."+T.minor+"."+T.patch):"number"==typeof N.documentMode&&(T=/\bTrident\/(\d+)/i.exec(e))&&(G=[G,N.documentMode],(T=+T[1]+4)!=G[1]&&(Y.push("IE "+G[1]+" mode"),J&&(J[1]=""),G[1]=T),G="IE"==$?String(G[1].toFixed(1)):G[0]);V=V&&s(V)}G&&(T=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(G)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+";"+(W&&S.appMinorVersion))||/\bMinefield\b/i.test(e)&&"a")&&(H=/b/i.test(T)?"beta":"alpha",G=G.replace(RegExp(T+"\\+?$"),"")+("beta"==H?B:M)+(/\d+\+?/.exec(T)||"")),"Fennec"==$||"Firefox"==$&&/\b(?:Android|Firefox OS)\b/.test(V)?$="Firefox Mobile":"Maxthon"==$&&G?G=G.replace(/\.[\d.]+/,".x"):"Silk"==$?(/\bMobi/i.test(e)||(V="Android",Y.unshift("desktop mode")),/Accelerated *= *true/i.test(e)&&Y.unshift("accelerated")):/\bXbox\b/i.test(K)?(V=null,"Xbox 360"==K&&/\bIEMobile\b/.test(e)&&Y.unshift("mobile mode")):!/^(?:Chrome|IE|Opera)$/.test($)&&(!$||K||/Browser|Mobi/.test($))||"Windows CE"!=V&&!/Mobi/i.test(e)?"IE"==$&&W&&null===b.external?Y.unshift("platform preview"):(/\bBlackBerry\b/.test(K)||/\bBB10\b/.test(e))&&(T=(RegExp(K.replace(/ +/g," *")+"/([.\\d]+)","i").exec(e)||0)[1]||G)?(T=[T,/BB10/.test(e)],V=(T[1]?(K=null,X="BlackBerry"):"Device Software")+" "+T[0],G=null):this!=a&&"Wii"!=K&&(W&&q||/Opera/.test($)&&/\b(?:MSIE|Firefox)\b/i.test(e)||"Firefox"==$&&/\bOS X (?:\d+\.){2,}/.test(V)||"IE"==$&&(V&&!/^Win/.test(V)&&G>5.5||/\bWindows XP\b/.test(V)&&G>8||8==G&&!/\bTrident\b/.test(e)))&&!w.test(T=p.call(a,e.replace(w,"")+";"))&&T.name&&(T="ing as "+T.name+((T=T.version)?" "+T:""),w.test($)?(/\bIE\b/.test(T)&&"Mac OS"==V&&(V=null),T="identify"+T):(T="mask"+T,$=F?s(F.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(T)&&(V=null),W||(G=null)),J=["Presto"],Y.push(T)):$+=" Mobile",(T=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(T=[parseFloat(T.replace(/\.(\d)$/,".0$1")),T],"Safari"==$&&"+"==T[1].slice(-1)?($="WebKit Nightly",H="alpha",G=T[1].slice(0,-1)):G!=T[1]&&G!=(T[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1])||(G=null),T[1]=(/\bChrome\/([\d.]+)/i.exec(e)||0)[1],537.36==T[0]&&537.36==T[2]&&parseFloat(T[1])>=28&&"IE"!=$&&"Microsoft Edge"!=$&&(J=["Blink"]),W&&(A||T[1])?(J&&(J[1]="like Chrome"),T=T[1]||(T=T[0],530>T?1:532>T?2:532.05>T?3:533>T?4:534.03>T?5:534.07>T?6:534.1>T?7:534.13>T?8:534.16>T?9:534.24>T?10:534.3>T?11:535.01>T?12:535.02>T?"13+":535.07>T?15:535.11>T?16:535.19>T?17:536.05>T?18:536.1>T?19:537.01>T?20:537.11>T?"21+":537.13>T?23:537.18>T?24:537.24>T?25:537.36>T?26:"Blink"!=J?"27":"28")):(J&&(J[1]="like Safari"),T=T[0],T=400>T?1:500>T?2:526>T?3:533>T?4:534>T?"4+":535>T?5:537>T?6:538>T?7:601>T?8:"8"),J&&(J[1]+=" "+(T+="number"==typeof T?".x":/[.+]/.test(T)?"":"+")),"Safari"==$&&(!G||parseInt(G)>45)&&(G=T)),"Opera"==$&&(T=/\bzbov|zvav$/.exec(V))?($+=" ",Y.unshift("desktop mode"),"zvav"==T?($+="Mini",G=null):$+="Mobile",V=V.replace(RegExp(" *"+T+"$"),"")):"Safari"==$&&/\bChrome\b/.exec(J&&J[1])&&(Y.unshift("desktop mode"),$="Chrome Mobile",G=null,/\bOS X\b/.test(V)?(X="Apple",V="iOS 4.3+"):V=null),G&&0==G.indexOf(T=/[\d.]+$/.exec(V))&&e.indexOf("/"+T+"-")>-1&&(V=h(V.replace(T,""))),J&&!/\b(?:Avant|Nook)\b/.test($)&&(/Browser|Lunascape|Maxthon/.test($)||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Sleipnir|Web)/.test($)&&J[1])&&(T=J[J.length-1])&&Y.push(T),Y.length&&(Y=["("+Y.join("; ")+")"]),X&&K&&K.indexOf(X)<0&&Y.push("on "+X),K&&Y.push((/^on /.test(Y[Y.length-1])?"":"on ")+K),V&&(T=/ ([\d.+]+)$/.exec(V),R=T&&"/"==V.charAt(V.length-T[0].length-1),V={architecture:32,family:T&&!R?V.replace(T[0],""):V,version:T?T[1]:null,toString:function(){var e=this.version;return this.family+(e&&!R?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(T=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(z))&&!/\bi686\b/i.test(z)&&(V&&(V.architecture=64,V.family=V.family.replace(RegExp(" *"+T),"")),$&&(/\bWOW64\b/i.test(e)||W&&/\w(?:86|32)$/.test(S.cpuClass||S.platform)&&!/\bWin64; x64\b/i.test(e))&&Y.unshift("32-bit")),e||(e=null);var Q={};return Q.description=e,Q.layout=J&&J[0],Q.manufacturer=X,Q.name=$,Q.prerelease=H,Q.product=K,Q.ua=e,Q.version=$&&G,Q.os=V||{architecture:null,family:null,version:null,toString:function(){return"null"}},Q.parse=p,Q.toString=g,Q.version&&Y.unshift(G),Q.name&&Y.unshift($),V&&$&&(V!=String(V).split(" ")[0]||V!=$.split(" ")[0]&&!K)&&Y.push(K?"("+V+")":"on "+V),Y.length&&(Q.description=Y.join(" ")),Q}var d={"function":!0,object:!0},y=d[typeof window]&&window||this,m=y,v=d[typeof n]&&n,g=d[typeof t]&&t&&!t.nodeType&&t,b=v&&g&&"object"==typeof e&&e;!b||b.global!==b&&b.window!==b&&b.self!==b||(y=b);var _=Math.pow(2,53)-1,w=/\bOpera/,E=this,S=Object.prototype,k=S.hasOwnProperty,x=S.toString;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return p()}):v&&g?a(p(),function(e,t){v[t]=e}):y.platform=p()}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[function(e,t,n){/*
* Copyright (c) 2012 Mathieu Turcotte
* Licensed under the MIT license.
*/
t.exports=e("./lib/checks")},{"./lib/checks":60}],60:[function(e,t,n){function r(e,t,n,r){n=n||"";var i=u.format.apply(this,[n].concat(r)),o=new e(i);throw Error.captureStackTrace(o,t),o}function i(e,t,n){r(c.IllegalArgumentError,e,t,n)}function o(e,t,n){r(c.IllegalStateError,e,t,n)}function s(e){var t=typeof e;if("object"==t){if(!e)return"null";if(e instanceof Array)return"array"}return t}function a(e){return function(t,n){var r=s(t);return r==e?t:void i(arguments.callee,n||'Expected "'+e+'" but got "'+r+'".',Array.prototype.slice.call(arguments,2))}}/*
* Copyright (c) 2012 Mathieu Turcotte
* Licensed under the MIT license.
*/
var u=e("util"),c=t.exports=e("./errors");t.exports.checkArgument=function(e,t){e||i(arguments.callee,t,Array.prototype.slice.call(arguments,2))},t.exports.checkState=function(e,t){e||o(arguments.callee,t,Array.prototype.slice.call(arguments,2))},t.exports.checkIsDef=function(e,t){return void 0!==e?e:void i(arguments.callee,t||"Expected value to be defined but was undefined.",Array.prototype.slice.call(arguments,2))},t.exports.checkIsDefAndNotNull=function(e,t){return null!=e?e:void i(arguments.callee,t||'Expected value to be defined and not null but got "'+s(e)+'".',Array.prototype.slice.call(arguments,2))},t.exports.checkIsString=a("string"),t.exports.checkIsArray=a("array"),t.exports.checkIsNumber=a("number"),t.exports.checkIsBoolean=a("boolean"),t.exports.checkIsFunction=a("function"),t.exports.checkIsObject=a("object")},{"./errors":61,util:93}],61:[function(e,t,n){function r(e){Error.call(this,e),this.message=e}function i(e){Error.call(this,e),this.message=e}/*
* Copyright (c) 2012 Mathieu Turcotte
* Licensed under the MIT license.
*/
var o=e("util");o.inherits(r,Error),r.prototype.name="IllegalArgumentError",o.inherits(i,Error),i.prototype.name="IllegalStateError",t.exports.IllegalStateError=i,t.exports.IllegalArgumentError=r},{util:93}],62:[function(e,t,n){(function(e){"use strict";function n(t){for(var n=new Array(arguments.length-1),r=0;r1)for(var n=1;n1&&(r=n[0]+"@",e=n[1]),e=e.replace(P,".");var i=e.split("."),s=o(i,t).join(".");return r+s}function a(e){for(var t,n,r=[],i=0,o=e.length;o>i;)t=e.charCodeAt(i++),t>=55296&&56319>=t&&o>i?(n=e.charCodeAt(i++),56320==(64512&n)?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--)):r.push(t);return r}function u(e){return o(e,function(e){var t="";return e>65535&&(e-=65536,t+=D(e>>>10&1023|55296),e=56320|1023&e),t+=D(e)}).join("")}function c(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:E}function f(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function l(e,t,n){var r=0;for(e=n?L(e/T):e>>1,e+=L(e/t);e>j*k>>1;r+=E)e=L(e/j);return L(r+(j+1)*e/(e+x))}function h(e){var t,n,r,o,s,a,f,h,p,d,y=[],m=e.length,v=0,g=I,b=R;for(n=e.lastIndexOf(A),0>n&&(n=0),r=0;n>r;++r)e.charCodeAt(r)>=128&&i("not-basic"),y.push(e.charCodeAt(r));for(o=n>0?n+1:0;m>o;){for(s=v,a=1,f=E;o>=m&&i("invalid-input"),h=c(e.charCodeAt(o++)),(h>=E||h>L((w-v)/a))&&i("overflow"),v+=h*a,p=b>=f?S:f>=b+k?k:f-b,!(p>h);f+=E)d=E-p,a>L(w/d)&&i("overflow"),a*=d;t=y.length+1,b=l(v-s,t,0==s),L(v/t)>w-g&&i("overflow"),g+=L(v/t),v%=t,y.splice(v++,0,g)}return u(y)}function p(e){var t,n,r,o,s,u,c,h,p,d,y,m,v,g,b,_=[];for(e=a(e),m=e.length,t=I,n=0,s=R,u=0;m>u;++u)y=e[u],128>y&&_.push(D(y));for(r=o=_.length,o&&_.push(A);m>r;){for(c=w,u=0;m>u;++u)y=e[u],y>=t&&c>y&&(c=y);for(v=r+1,c-t>L((w-n)/v)&&i("overflow"),n+=(c-t)*v,t=c,u=0;m>u;++u)if(y=e[u],t>y&&++n>w&&i("overflow"),y==t){for(h=n,p=E;d=s>=p?S:p>=s+k?k:p-s,!(d>h);p+=E)b=h-d,g=E-d,_.push(D(f(d+b%g,0))),h=L(b/g);_.push(D(f(h,0))),s=l(n,v,r==o),n=0,++r}++n,++t}return _.join("")}function d(e){return s(e,function(e){return C.test(e)?h(e.slice(4).toLowerCase()):e})}function y(e){return s(e,function(e){return U.test(e)?"xn--"+p(e):e})}var m="object"==typeof n&&n&&!n.nodeType&&n,v="object"==typeof t&&t&&!t.nodeType&&t,g="object"==typeof e&&e;g.global!==g&&g.window!==g&&g.self!==g||(r=g);var b,_,w=2147483647,E=36,S=1,k=26,x=38,T=700,R=72,I=128,A="-",C=/^xn--/,U=/[^\x20-\x7E]/,P=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},j=E-S,L=Math.floor,D=String.fromCharCode;if(b={version:"1.3.2",ucs2:{decode:a,encode:u},decode:h,encode:p,toASCII:y,toUnicode:d},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return b});else if(m&&v)if(t.exports==m)v.exports=b;else for(_ in b)b.hasOwnProperty(_)&&(m[_]=b[_]);else r.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],65:[function(e,t,n){(function(e){/*!
*
* Copyright 2009-2012 Kris Kowal under the terms of the MIT
* license found at http://github.com/kriskowal/q/raw/master/LICENSE
*
* With parts by Tyler Close
* Copyright 2007-2009 Tyler Close under the terms of the MIT X license found
* at http://www.opensource.org/licenses/mit-license.html
* Forked at ref_send.js version: 2009-05-11
*
* With parts by Mark Miller
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
!function(e){"use strict";if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==typeof n&&"object"==typeof t)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var r="undefined"!=typeof window?window:self,i=r.Q;r.Q=e(),r.Q.noConflict=function(){return r.Q=i,this}}}(function(){"use strict";function t(e){return function(){return K.apply(e,arguments)}}function n(e){return e===Object(e)}function r(e){return"[object StopIteration]"===re(e)||e instanceof W}function i(e,t){if(z&&t.stack&&"object"==typeof e&&null!==e&&e.stack&&-1===e.stack.indexOf(ie)){for(var n=[],r=t;r;r=r.source)r.stack&&n.unshift(r.stack);n.unshift(e.stack);var i=n.join("\n"+ie+"\n");e.stack=o(i)}}function o(e){for(var t=e.split("\n"),n=[],r=0;r=G&&ce>=r}function c(){if(z)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=t[0].indexOf("@")>0?t[1]:t[2],r=a(n);if(!r)return;return H=r[0],r[1]}}function f(e,t,n){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t+" is deprecated, use "+n+" instead.",new Error("").stack),e.apply(e,arguments)}}function l(e){return e instanceof y?e:b(e)?I(e):R(e)}function h(){function e(e){t=e,o.source=e,V(n,function(t,n){l.nextTick(function(){e.promiseDispatch.apply(e,n)})},void 0),n=void 0,r=void 0}var t,n=[],r=[],i=ee(h.prototype),o=ee(y.prototype);if(o.promiseDispatch=function(e,i,o){var s=X(arguments);n?(n.push(s),"when"===i&&o[1]&&r.push(o[1])):l.nextTick(function(){t.promiseDispatch.apply(t,s)})},o.valueOf=function(){if(n)return o;var e=v(t);return g(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},l.longStackSupport&&z)try{throw new Error}catch(s){o.stack=s.stack.substring(s.stack.indexOf("\n")+1)}return i.promise=o,i.resolve=function(n){t||e(l(n))},i.fulfill=function(n){t||e(R(n))},i.reject=function(n){t||e(T(n))},i.notify=function(e){t||V(r,function(t,n){l.nextTick(function(){n(e)})},void 0)},i}function p(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=h();try{e(t.resolve,t.reject,t.notify)}catch(n){t.reject(n)}return t.promise}function d(e){return p(function(t,n){for(var r=0,i=e.length;i>r;r++)l(e[r]).then(t,n)})}function y(e,t,n){void 0===t&&(t=function(e){return T(new Error("Promise does not support operation: "+e))}),void 0===n&&(n=function(){return{state:"unknown"}});var r=ee(y.prototype);if(r.promiseDispatch=function(n,i,o){var s;try{s=e[i]?e[i].apply(r,o):t.call(r,i,o)}catch(a){s=T(a)}n&&n(s)},r.inspect=n,n){var i=n();"rejected"===i.state&&(r.exception=i.reason),r.valueOf=function(){var e=n();return"pending"===e.state||"rejected"===e.state?r:e.value}}return r}function m(e,t,n,r){return l(e).then(t,n,r)}function v(e){if(g(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function g(e){return e instanceof y}function b(e){return n(e)&&"function"==typeof e.then}function _(e){return g(e)&&"pending"===e.inspect().state}function w(e){return!g(e)||"fulfilled"===e.inspect().state}function E(e){return g(e)&&"rejected"===e.inspect().state}function S(){oe.length=0,se.length=0,ue||(ue=!0)}function k(t,n){ue&&("object"==typeof e&&"function"==typeof e.emit&&l.nextTick.runAfter(function(){-1!==Z(se,t)&&(e.emit("unhandledRejection",n,t),ae.push(t))}),se.push(t),n&&"undefined"!=typeof n.stack?oe.push(n.stack):oe.push("(no stack) "+n))}function x(t){if(ue){var n=Z(se,t);-1!==n&&("object"==typeof e&&"function"==typeof e.emit&&l.nextTick.runAfter(function(){var r=Z(ae,t);-1!==r&&(e.emit("rejectionHandled",oe[n],t),ae.splice(r,1))}),se.splice(n,1),oe.splice(n,1))}}function T(e){var t=y({when:function(t){return t&&x(this),t?t(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return k(t,e),t}function R(e){return y({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},"delete":function(t){delete e[t]},post:function(t,n){return null===t||void 0===t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return ne(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function I(e){var t=h();return l.nextTick(function(){try{e.then(t.resolve,t.reject,t.notify)}catch(n){t.reject(n)}}),t.promise}function A(e){return y({isDef:function(){}},function(t,n){return L(e,t,n)},function(){return l(e).inspect()})}function C(e,t,n){return l(e).spread(t,n)}function U(e){return function(){function t(e,t){var s;if("undefined"==typeof StopIteration){try{s=n[e](t)}catch(a){return T(a)}return s.done?l(s.value):m(s.value,i,o)}try{s=n[e](t)}catch(a){return r(a)?l(a.value):T(a)}return m(s,i,o)}var n=e.apply(this,arguments),i=t.bind(t,"next"),o=t.bind(t,"throw");return i()}}function P(e){l.done(l.async(e)())}function O(e){throw new W(e)}function j(e){return function(){return C([this,D(arguments)],function(t,n){return e.apply(t,n)})}}function L(e,t,n){return l(e).dispatch(t,n)}function D(e){return m(e,function(e){var t=0,n=h();return V(e,function(r,i,o){var s;g(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,m(i,function(r){e[o]=r,0===--t&&n.resolve(e)},n.reject,function(e){n.notify({index:o,value:e})}))},void 0),0===t&&n.resolve(e),n.promise})}function M(e){if(0===e.length)return l.resolve();var t=l.defer(),n=0;return V(e,function(r,i,o){function s(e){t.resolve(e)}function a(){n--,0===n&&t.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))}function u(e){t.notify({index:o,value:e})}var c=e[o];n++,m(c,s,a,u)},void 0),t.promise}function B(e){return m(e,function(e){return e=Q(e,l),m(D(Q(e,function(e){return m(e,J,J)})),function(){return e})})}function N(e){return l(e).allSettled()}function q(e,t){return l(e).then(void 0,void 0,t)}function F(e,t){return l(e).nodeify(t)}var z=!1;try{throw new Error}catch(Y){z=!!Y.stack}var H,W,G=c(),J=function(){},$=function(){function t(){for(var e,t;r.next;)r=r.next,e=r.task,r.task=void 0,t=r.domain,t&&(r.domain=void 0,t.enter()),n(e,t);for(;u.length;)e=u.pop(),n(e);o=!1}function n(e,n){try{e()}catch(r){if(a)throw n&&n.exit(),setTimeout(t,0),n&&n.enter(),r;setTimeout(function(){throw r},0)}n&&n.exit()}var r={task:void 0,next:null},i=r,o=!1,s=void 0,a=!1,u=[];if($=function(t){i=i.next={task:t,domain:a&&e.domain,next:null},o||(o=!0,s())},"object"==typeof e&&"[object process]"===e.toString()&&e.nextTick)a=!0,s=function(){e.nextTick(t)};else if("function"==typeof setImmediate)s="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){s=f,c.port1.onmessage=t,t()};var f=function(){c.port2.postMessage(0)};s=function(){setTimeout(t,0),f()}}else s=function(){setTimeout(t,0)};return $.runAfter=function(e){u.push(e),o||(o=!0,s())},$}(),K=Function.call,X=t(Array.prototype.slice),V=t(Array.prototype.reduce||function(e,t){var n=0,r=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=r)throw new TypeError}for(;r>n;n++)n in this&&(t=e(t,this[n],n));return t}),Z=t(Array.prototype.indexOf||function(e){for(var t=0;t2?e.resolve(X(arguments,1)):e.resolve(n)}},l.Promise=p,l.promise=p,p.race=d,p.all=D,p.reject=T,p.resolve=l,l.passByCopy=function(e){return e},y.prototype.passByCopy=function(){return this},l.join=function(e,t){return l(e).join(t)},y.prototype.join=function(e){return l([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},l.race=d,y.prototype.race=function(){return this.then(l.race)},l.makePromise=y,y.prototype.toString=function(){return"[object Promise]"},y.prototype.then=function(e,t,n){function r(t){try{return"function"==typeof e?e(t):t}catch(n){return T(n)}}function o(e){if("function"==typeof t){i(e,a);try{return t(e)}catch(n){return T(n)}}return T(e)}function s(e){return"function"==typeof n?n(e):e}var a=this,u=h(),c=!1;return l.nextTick(function(){a.promiseDispatch(function(e){c||(c=!0,u.resolve(r(e)))},"when",[function(e){c||(c=!0,u.resolve(o(e)))}])}),a.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=s(e)}catch(r){if(n=!0,!l.onerror)throw r;l.onerror(r)}n||u.notify(t)}]),u.promise},l.tap=function(e,t){return l(e).tap(t)},y.prototype.tap=function(e){return e=l(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},l.when=m,y.prototype.thenResolve=function(e){return this.then(function(){return e})},l.thenResolve=function(e,t){return l(e).thenResolve(t)},y.prototype.thenReject=function(e){return this.then(function(){throw e})},l.thenReject=function(e,t){return l(e).thenReject(t)},l.nearer=v,l.isPromise=g,l.isPromiseAlike=b,l.isPending=_,y.prototype.isPending=function(){return"pending"===this.inspect().state},l.isFulfilled=w,y.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},l.isRejected=E,y.prototype.isRejected=function(){return"rejected"===this.inspect().state};var oe=[],se=[],ae=[],ue=!0;l.resetUnhandledRejections=S,l.getUnhandledReasons=function(){return oe.slice()},l.stopUnhandledRejectionTracking=function(){S(),ue=!1},S(),l.reject=T,l.fulfill=R,l.master=A,l.spread=C,y.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},l.async=U,l.spawn=P,l["return"]=O,l.promised=j,l.dispatch=L,y.prototype.dispatch=function(e,t){var n=this,r=h();return l.nextTick(function(){n.promiseDispatch(r.resolve,e,t)}),r.promise},l.get=function(e,t){return l(e).dispatch("get",[t])},y.prototype.get=function(e){return this.dispatch("get",[e])},l.set=function(e,t,n){return l(e).dispatch("set",[t,n])},y.prototype.set=function(e,t){return this.dispatch("set",[e,t])},l.del=l["delete"]=function(e,t){return l(e).dispatch("delete",[t])},y.prototype.del=y.prototype["delete"]=function(e){return this.dispatch("delete",[e])},l.mapply=l.post=function(e,t,n){return l(e).dispatch("post",[t,n])},y.prototype.mapply=y.prototype.post=function(e,t){return this.dispatch("post",[e,t])},l.send=l.mcall=l.invoke=function(e,t){return l(e).dispatch("post",[t,X(arguments,2)])},y.prototype.send=y.prototype.mcall=y.prototype.invoke=function(e){return this.dispatch("post",[e,X(arguments,1)])},l.fapply=function(e,t){return l(e).dispatch("apply",[void 0,t])},y.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},l["try"]=l.fcall=function(e){return l(e).dispatch("apply",[void 0,X(arguments,1)])},y.prototype.fcall=function(){return this.dispatch("apply",[void 0,X(arguments)])},l.fbind=function(e){var t=l(e),n=X(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(X(arguments))])}},y.prototype.fbind=function(){var e=this,t=X(arguments);return function(){return e.dispatch("apply",[this,t.concat(X(arguments))])}},l.keys=function(e){return l(e).dispatch("keys",[])},y.prototype.keys=function(){return this.dispatch("keys",[])},l.all=D,y.prototype.all=function(){return D(this)},l.any=M,y.prototype.any=function(){return M(this)},l.allResolved=f(B,"allResolved","allSettled"),y.prototype.allResolved=function(){return B(this)},l.allSettled=N,y.prototype.allSettled=function(){return this.then(function(e){return D(Q(e,function(e){function t(){return e.inspect()}return e=l(e),e.then(t,t)}))})},l.fail=l["catch"]=function(e,t){return l(e).then(void 0,t)},y.prototype.fail=y.prototype["catch"]=function(e){return this.then(void 0,e)},l.progress=q,y.prototype.progress=function(e){return this.then(void 0,void 0,e)},l.fin=l["finally"]=function(e,t){return l(e)["finally"](t)},y.prototype.fin=y.prototype["finally"]=function(e){return e=l(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},l.done=function(e,t,n,r){return l(e).done(t,n,r)},y.prototype.done=function(t,n,r){var o=function(e){l.nextTick(function(){if(i(e,s),!l.onerror)throw e;l.onerror(e)})},s=t||n||r?this.then(t,n,r):this;"object"==typeof e&&e&&e.domain&&(o=e.domain.bind(o)),s.then(void 0,o)},l.timeout=function(e,t,n){return l(e).timeout(t,n)},y.prototype.timeout=function(e,t){var n=h(),r=setTimeout(function(){t&&"string"!=typeof t||(t=new Error(t||"Timed out after "+e+" ms"),t.code="ETIMEDOUT"),n.reject(t)},e);return this.then(function(e){clearTimeout(r),n.resolve(e)},function(e){clearTimeout(r),n.reject(e)},n.notify),n.promise},l.delay=function(e,t){return void 0===t&&(t=e,e=void 0),l(e).delay(t)},y.prototype.delay=function(e){return this.then(function(t){var n=h();return setTimeout(function(){n.resolve(t)},e),n.promise})},l.nfapply=function(e,t){return l(e).nfapply(t)},y.prototype.nfapply=function(e){var t=h(),n=X(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},l.nfcall=function(e){var t=X(arguments,1);return l(e).nfapply(t)},y.prototype.nfcall=function(){var e=X(arguments),t=h();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},l.nfbind=l.denodeify=function(e){var t=X(arguments,1);return function(){var n=t.concat(X(arguments)),r=h();return n.push(r.makeNodeResolver()),l(e).fapply(n).fail(r.reject),r.promise}},y.prototype.nfbind=y.prototype.denodeify=function(){var e=X(arguments);return e.unshift(this),l.denodeify.apply(void 0,e)},l.nbind=function(e,t){var n=X(arguments,2);return function(){function r(){return e.apply(t,arguments)}var i=n.concat(X(arguments)),o=h();return i.push(o.makeNodeResolver()),l(r).fapply(i).fail(o.reject),o.promise}},y.prototype.nbind=function(){var e=X(arguments,0);return e.unshift(this),l.nbind.apply(void 0,e)},l.nmapply=l.npost=function(e,t,n){return l(e).npost(t,n)},y.prototype.nmapply=y.prototype.npost=function(e,t){var n=X(t||[]),r=h();return n.push(r.makeNodeResolver()),this.dispatch("post",[e,n]).fail(r.reject),r.promise},l.nsend=l.nmcall=l.ninvoke=function(e,t){var n=X(arguments,2),r=h();return n.push(r.makeNodeResolver()),l(e).dispatch("post",[t,n]).fail(r.reject),r.promise},y.prototype.nsend=y.prototype.nmcall=y.prototype.ninvoke=function(e){var t=X(arguments,1),n=h();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},l.nodeify=F,y.prototype.nodeify=function(e){return e?void this.then(function(t){l.nextTick(function(){e(null,t)})},function(t){l.nextTick(function(){e(t)})}):this},l.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ce=c();return l})}).call(this,e("_process"))},{_process:63}],66:[function(e,t,n){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,o){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;c>f;++f){var l,h,p,d,y=e[f].replace(a,"%20"),m=y.indexOf(n);m>=0?(l=y.substr(0,m),h=y.substr(m+1)):(l=y,h=""),p=decodeURIComponent(l),d=decodeURIComponent(h),r(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],67:[function(e,t,n){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
"use strict";function r(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var u;!t.decoder||i||r||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&l(e))),p(e,t)}else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length=L?e=L:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var n=null;return R.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function f(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,l(e)}}function l(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(P("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?x(h,e):h(e))}function h(e){P("emit readable"),e.emit("readable"),b(e)}function p(e,t){t.readingMore||(t.readingMore=!0,x(d,e,t))}function d(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=i)n=o?r.join(""):1===r.length?r[0]:R.concat(r,i),r.length=0;else if(ec&&e>u;c++){var a=r[0],l=Math.min(e-u,a.length);o?n+=a.slice(0,l):a.copy(n,u,0,l),l0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,x(E,t,e))}function E(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function S(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function k(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}t.exports=i;var x=e("process-nextick-args"),T=e("isarray"),R=e("buffer").Buffer;i.ReadableState=r;var I,A=(e("events"),function(e,t){return e.listeners(t).length});!function(){try{I=e("stream")}catch(t){}finally{I||(I=e("events").EventEmitter)}}();var R=e("buffer").Buffer,C=e("core-util-is");C.inherits=e("inherits");var U=e("util"),P=void 0;P=U&&U.debuglog?U.debuglog("stream"):function(){};var O;C.inherits(i,I);var j,j;i.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new R(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.isPaused=function(){return this._readableState.flowing===!1},i.prototype.setEncoding=function(t){return O||(O=e("string_decoder/").StringDecoder),this._readableState.decoder=new O(t),this._readableState.encoding=t,this};var L=8388608;i.prototype.read=function(e){P("read",e);var t=this._readableState,n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return P("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?w(this):l(this),null;if(e=u(e,t),0===e&&t.ended)return 0===t.length&&w(this),null;var r=t.needReadable;P("need readable",r),(0===t.length||t.length-e0?_(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),n!==e&&t.ended&&0===t.length&&w(this),null!==i&&this.emit("data",i),i},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function r(e){P("onunpipe"),e===l&&o()}function i(){P("onend"),e.end()}function o(){P("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",m),e.removeListener("error",a),e.removeListener("unpipe",r),l.removeListener("end",i),l.removeListener("end",o),l.removeListener("data",s),v=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||m()}function s(t){P("ondata");var n=e.write(t);!1===n&&(1!==h.pipesCount||h.pipes[0]!==e||1!==l.listenerCount("data")||v||(P("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++),l.pause())}function a(t){P("onerror",t),f(),e.removeListener("error",a),0===A(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),f()}function c(){P("onfinish"),e.removeListener("close",u),f()}function f(){P("unpipe"),l.unpipe(e)}var l=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,P("pipe count=%d opts=%j",h.pipesCount,t);var p=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,d=p?i:o;h.endEmitted?x(d):l.once("end",d),e.on("unpipe",r);var m=y(l);e.on("drain",m);var v=!1;return l.on("data",s),e._events&&e._events.error?T(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",l),h.flowing||(P("pipe resume"),l.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var o=k(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=I.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&!this._readableState.endEmitted){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&l(this,r):x(m,this))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var e=this._readableState;return e.flowing||(P("resume"),e.flowing=!0,v(this,e)),this},i.prototype.pause=function(){return P("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(P("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(P("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(P("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return S(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){P("wrapped _read",t),n&&(n=!1,e.resume())},r},i._fromList=_}).call(this,e("_process"))},{"./_stream_duplex":72,_process:63,buffer:45,"core-util-is":48,events:51,inherits:54,isarray:70,"process-nextick-args":62,"string_decoder/":85,util:43}],75:[function(e,t,n){"use strict";function r(e){this.afterTransform=function(t,n){return i(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function i(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length-1?setImmediate:S,x=e("buffer").Buffer;s.WritableState=o;var T=e("core-util-is");T.inherits=e("inherits");var R,I={deprecate:e("util-deprecate")};!function(){try{R=e("stream")}catch(t){}finally{R||(R=e("events").EventEmitter)}}();var x=e("buffer").Buffer;T.inherits(s,R);var A;o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:I.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var A;s.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},s.prototype.write=function(e,t,n){var i=this._writableState,o=!1;return"function"==typeof t&&(n=t,t=null),x.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=r),i.ended?a(this,n):u(this,i,e,n)&&(i.pendingcb++,o=f(this,i,e,t,n)),o},s.prototype.cork=function(){var e=this._writableState;e.corked++},s.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||v(this,e))},s.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e},s.prototype._write=function(e,t,n){n(new Error("not implemented"))},s.prototype._writev=null,s.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||w(this,r,n)}}).call(this,e("_process"))},{"./_stream_duplex":72,_process:63,buffer:45,"core-util-is":48,events:51,inherits:54,"process-nextick-args":62,"util-deprecate":91}],77:[function(e,t,n){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":73}],78:[function(e,t,n){var r=function(){try{return e("stream")}catch(t){}}();n=t.exports=e("./lib/_stream_readable.js"),n.Stream=r||n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":72,"./lib/_stream_passthrough.js":73,"./lib/_stream_readable.js":74,"./lib/_stream_transform.js":75,"./lib/_stream_writable.js":76}],79:[function(e,t,n){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":75}],80:[function(e,t,n){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":76}],81:[function(e,t,n){(function(t){var r=e("./lib/request"),i=e("xtend"),o=e("builtin-status-codes"),s=e("url"),a=n;a.request=function(e,n){e="string"==typeof e?s.parse(e):i(e);var o=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||o,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var l=new r(e);return n&&l.on("response",n),l},a.get=function(e,t){var n=a.request(e,t);return n.end(),n},a.Agent=function(){},a.Agent.defaultMaxSockets=4,a.STATUS_CODES=o,a.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":83,"builtin-status-codes":47,url:89,xtend:96}],82:[function(e,t,n){(function(e){function t(e){try{return o.responseType=e,o.responseType===e}catch(t){}return!1}function r(e){return"function"==typeof e}n.fetch=r(e.fetch)&&r(e.ReadableByteStream),n.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),n.blobConstructor=!0}catch(i){}var o=new e.XMLHttpRequest;o.open("GET",e.location.host?"/":"https://example.com");var s="undefined"!=typeof e.ArrayBuffer,a=s&&r(e.ArrayBuffer.prototype.slice);n.arraybuffer=s&&t("arraybuffer"),n.msstream=!n.fetch&&a&&t("ms-stream"),n.mozchunkedarraybuffer=!n.fetch&&s&&t("moz-chunked-arraybuffer"),n.overrideMimeType=r(o.overrideMimeType),n.vbArray=r(e.VBArray),o=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],83:[function(e,t,n){(function(n,r,i){function o(e){return a.fetch?"fetch":a.mozchunkedarraybuffer?"moz-chunked-arraybuffer":a.msstream?"ms-stream":a.arraybuffer&&e?"arraybuffer":a.vbArray&&e?"text:vbarray":"text"}function s(e){try{var t=e.status;return null!==t&&0!==t}catch(n){return!1}}var a=e("./capability"),u=e("inherits"),c=e("./response"),f=e("stream"),l=e("to-arraybuffer"),h=c.IncomingMessage,p=c.readyStates,d=t.exports=function(e){var t=this;f.Writable.call(t),t._opts=e,t._body=[],t._headers={},e.auth&&t.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(n){t.setHeader(n,e.headers[n])});var n;if("prefer-streaming"===e.mode)n=!1;else if("allow-wrong-content-type"===e.mode)n=!a.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");n=!0}t._mode=o(n),t.on("finish",function(){t._onFinish()})};u(d,f.Writable),d.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1===y.indexOf(r)&&(n._headers[r]={name:e,value:t})},d.prototype.getHeader=function(e){var t=this;return t._headers[e.toLowerCase()].value},d.prototype.removeHeader=function(e){var t=this;delete t._headers[e.toLowerCase()]},d.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t,o=e._opts,s=e._headers;if("POST"!==o.method&&"PUT"!==o.method&&"PATCH"!==o.method||(t=a.blobConstructor?new r.Blob(e._body.map(function(e){return l(e)}),{type:(s["content-type"]||{}).value||""}):i.concat(e._body).toString()),"fetch"===e._mode){var u=Object.keys(s).map(function(e){return[s[e].name,s[e].value]});r.fetch(e._opts.url,{method:e._opts.method,headers:u,body:t,mode:"cors",credentials:o.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{var c=e._xhr=new r.XMLHttpRequest;try{c.open(e._opts.method,e._opts.url,!0)}catch(f){return void n.nextTick(function(){e.emit("error",f)})}"responseType"in c&&(c.responseType=e._mode.split(":")[0]),"withCredentials"in c&&(c.withCredentials=!!o.withCredentials),"text"===e._mode&&"overrideMimeType"in c&&c.overrideMimeType("text/plain; charset=x-user-defined"),Object.keys(s).forEach(function(e){c.setRequestHeader(s[e].name,s[e].value)}),e._response=null,c.onreadystatechange=function(){switch(c.readyState){case p.LOADING:case p.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(c.onprogress=function(){e._onXHRProgress()}),c.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{c.send(t)}catch(f){return void n.nextTick(function(){e.emit("error",f)})}}}},d.prototype._onXHRProgress=function(){var e=this;s(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},d.prototype._connect=function(){var e=this;e._destroyed||(e._response=new h(e._xhr,e._fetchResponse,e._mode),e.emit("response",e._response))},d.prototype._write=function(e,t,n){var r=this;r._body.push(e),n()},d.prototype.abort=d.prototype.destroy=function(){var e=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},d.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),f.Writable.prototype.end.call(r,e,t,n)},d.prototype.flushHeaders=function(){},d.prototype.setTimeout=function(){},d.prototype.setNoDelay=function(){},d.prototype.setSocketKeepAlive=function(){};var y=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":82,"./response":84,_process:63,buffer:45,inherits:54,stream:69,"to-arraybuffer":86}],84:[function(e,t,n){(function(t,r,i){var o=e("./capability"),s=e("inherits"),a=e("stream"),u=n.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=n.IncomingMessage=function(e,n,r){function s(){h.read().then(function(e){if(!u._destroyed){if(e.done)return void u.push(null);u.push(new i(e.value)),s()}})}var u=this;if(a.Readable.call(u),u._mode=r,u.headers={},u.rawHeaders=[],u.trailers={},u.rawTrailers=[],u.on("end",function(){t.nextTick(function(){u.emit("close")})}),"fetch"===r){u._fetchResponse=n,u.statusCode=n.status,u.statusMessage=n.statusText;for(var c,f,l=n.headers[Symbol.iterator]();c=(f=l.next()).value,!f.done;)u.headers[c[0].toLowerCase()]=c[1],u.rawHeaders.push(c[0],c[1]);var h=n.body.getReader();s()}else{u._xhr=e,u._pos=0,u.statusCode=e.status,u.statusMessage=e.statusText;var p=e.getAllResponseHeaders().split(/\r?\n/);if(p.forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===u.headers[n]&&(u.headers[n]=[]),u.headers[n].push(t[2])):void 0!==u.headers[n]?u.headers[n]+=", "+t[2]:u.headers[n]=t[2],u.rawHeaders.push(t[1],t[2])}}),u._charset="x-user-defined",!o.overrideMimeType){var d=u.rawHeaders["mime-type"];if(d){var y=d.match(/;\s*charset=([^;])(;|$)/);y&&(u._charset=y[1].toLowerCase())}u._charset||(u._charset="utf-8")}}};s(c,a.Readable),c.prototype._read=function(){},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,n=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{n=new r.VBArray(t.responseBody).toArray()}catch(o){}if(null!==n){e.push(new i(n));break}case"text":try{n=t.responseText}catch(o){e._mode="text:vbarray";break}if(n.length>e._pos){var s=n.substr(e._pos);if("x-user-defined"===e._charset){for(var a=new i(s.length),c=0;ce._pos&&(e.push(new i(new Uint8Array(f.result.slice(e._pos)))),e._pos=f.result.byteLength)},f.onload=function(){e.push(null)},f.readAsArrayBuffer(n)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":82,_process:63,buffer:45,inherits:54,stream:69}],85:[function(e,t,n){function r(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var a=e("buffer").Buffer,u=a.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},c=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&56319>=r)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,r=t.charCodeAt(i);if(r>=55296&&56319>=r){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},c.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},{buffer:45}],86:[function(e,t,n){var r=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(r.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,i=0;n>i;i++)t[i]=e[i];return t.buffer}throw new Error("Argument must be a Buffer")}},{buffer:45}],87:[function(e,t,n){(function(n){"use strict";function r(e){if(!(this instanceof r))return new r(e);l.call(this);var t=null,n=null,i=!1,o=null,s=e,a=null,u=null,c=null;Object.defineProperties(this,{_expires:{get:function(){return t},set:function(e){t=e}},_identity:{get:function(){return n},set:function(e){n=e}},_isExpired:{get:function(){return i},set:function(e){i=e}},_pendingUpdate:{get:function(){return o},set:function(e){o=e}},_token:{get:function(){return s},set:function(e){s=e}},_tokenExpiredTimer:{get:function(){return a},set:function(e){a=e}},_tokenUpdatedTimer:{get:function(){return u},set:function(e){u=e}},_tokenPayload:{get:function(){return c},set:function(e){c=e}},expires:{enumerable:!0,get:function(){return t}},identity:{enumerable:!0,get:function(){return n}},isExpired:{enumerable:!0,get:function(){return i}},token:{enumerable:!0,get:function(){return s}}});var f=this.updateToken(e);f["catch"](function(e){this._pendingUpdate===f&&this.emit("error",e)}.bind(this))}function i(e){var t=e.split(".");if(3!==t.length)throw new Error("Token is invalid or malformed");var n=t[1],r=o(n),i=JSON.parse(r);return i}function o(e){var t=e.length%4;if(t>0){var n=4-t;e+=new Array(n+1).join("=")}return e=e.replace(/-/g,"+").replace(/_/g,"/"),s(e)}function s(e){return new n(e,"base64").toString()}function a(e){var t=null;return!e.grants&&e.scope?t=u(e.scope):e.grants instanceof Array?t=c(e.grants):"object"==typeof e.grants&&(t=f(e.grants)),t}function u(e){var t=decodeURIComponent(e).match(/identity=(.*?)(&|$)/i);return t&&decodeURIComponent(t[1])}function c(e){for(var t=null,n=0;n=t.expires,clearTimeout(t._tokenExpiredTimer),t._tokenExpiredTimer=setTimeout(function(){t._isExpired=!0,t._tokenExpiredTimer=null,t.emit("tokenExpired",t)},t.expires-Date.now()),t._token=e,t._tokenPayload=r,n(t)});return this._pendingUpdate=n,n},t.exports=r}).call(this,e("buffer").Buffer)},{buffer:45,events:51,util:93}],88:[function(e,t,n){"use strict";t.exports.AccessManager=e("./accessmanager")},{"./accessmanager":87}],89:[function(e,t,n){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
"use strict";function r(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(e,t,n){if(e&&c.isObject(e)&&e instanceof r)return e;var i=new r;return i.parse(e,t,n),i}function o(e){return c.isString(e)&&(e=i(e)),e instanceof r?e.format():r.prototype.format.call(e)}function s(e,t){return i(e,!1,!0).resolve(t)}function a(e,t){return e?i(e,!1,!0).resolveObject(t):t}var u=e("punycode"),c=e("./util");n.parse=i,n.resolve=s,n.resolveObject=a,n.format=o,n.Url=r;var f=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,h=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["<",">",'"',"`"," ","\r","\n"," "],d=["{","}","|","\\","^","`"].concat(p),y=["'"].concat(d),m=["%","/","?",";","#"].concat(y),v=["/","?","#"],g=255,b=/^[+a-z0-9A-Z_-]{0,63}$/,_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},S={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},k=e("querystring");r.prototype.parse=function(e,t,n){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),i=-1!==r&&rI)&&(T=I)}var A,C;C=-1===T?a.lastIndexOf("@"):a.lastIndexOf("@",T),-1!==C&&(A=a.slice(0,C),a=a.slice(C+1),this.auth=decodeURIComponent(A)),T=-1;for(var R=0;RI)&&(T=I)}-1===T&&(T=a.length),this.host=a.slice(0,T),a=a.slice(T),this.parseHost(),this.hostname=this.hostname||"";var U="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!U)for(var P=this.hostname.split(/\./),R=0,O=P.length;O>R;R++){var j=P[R];if(j&&!j.match(b)){for(var L="",D=0,M=j.length;M>D;D++)L+=j.charCodeAt(D)>127?"x":j[D];if(!L.match(b)){var B=P.slice(0,R),N=P.slice(R+1),q=j.match(_);q&&(B.push(q[1]),N.unshift(q[2])),N.length&&(a="/"+N.join(".")+a),this.hostname=B.join(".");break}}}this.hostname.length>g?this.hostname="":this.hostname=this.hostname.toLowerCase(),U||(this.hostname=u.toASCII(this.hostname));var F=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+F,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[d])for(var R=0,O=y.length;O>R;R++){var Y=y[R];if(-1!==a.indexOf(Y)){var H=encodeURIComponent(Y);H===Y&&(H=escape(Y)),a=a.split(Y).join(H)}}var W=a.indexOf("#");-1!==W&&(this.hash=a.substr(W),a=a.slice(0,W));var G=a.indexOf("?");if(-1!==G?(this.search=a.substr(G),this.query=a.substr(G+1),t&&(this.query=k.parse(this.query)),a=a.slice(0,G)):t&&(this.search="",this.query={}),a&&(this.pathname=a),S[d]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var F=this.pathname||"",J=this.search||"";this.path=F+J}return this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,o="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&c.isObject(this.query)&&Object.keys(this.query).length&&(o=k.stringify(this.query));var s=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||S[t])&&i!==!1?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),s&&"?"!==s.charAt(0)&&(s="?"+s),n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),s=s.replace("#","%23"),t+i+n+s+r},r.prototype.resolve=function(e){return this.resolveObject(i(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(c.isString(e)){var t=new r;t.parse(e,!1,!0),e=t}for(var n=new r,i=Object.keys(this),o=0;o0?n.host.split("@"):!1;x&&(n.auth=x.shift(),n.host=n.hostname=x.shift())}return n.search=e.search,n.query=e.query,c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!w.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var T=w.slice(-1)[0],R=(n.host||e.host||w.length>1)&&("."===T||".."===T)||""===T,I=0,A=w.length;A>=0;A--)T=w[A],"."===T?w.splice(A,1):".."===T?(w.splice(A,1),I++):I&&(w.splice(A,1),I--);if(!b&&!_)for(;I--;I)w.unshift("..");!b||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),R&&"/"!==w.join("/").substr(-1)&&w.push("");var C=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(k){n.hostname=n.host=C?"":w.length?w.shift():"";var x=n.host&&n.host.indexOf("@")>0?n.host.split("@"):!1;x&&(n.auth=x.shift(),n.host=n.hostname=x.shift())}return b=b||n.host&&w.length,b&&!C&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var e=this.host,t=l.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":90,punycode:64,querystring:68}],90:[function(e,t,n){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],91:[function(e,t,n){(function(e){function n(e,t){function n(){if(!i){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}if(r("noDeprecation"))return e;var i=!1;return n}function r(t){try{if(!e.localStorage)return!1}catch(n){return!1}var r=e.localStorage[t];return null==r?!1:"true"===String(r).toLowerCase()}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],92:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],93:[function(e,t,n){(function(t,r){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),y(t)?r.showHidden=t:t&&n._extend(r,t),w(r.showHidden)&&(r.showHidden=!1),w(r.depth)&&(r.depth=2),w(r.colors)&&(r.colors=!1),w(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&T(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return b(i)||(i=u(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),y=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),x(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(t);if(0===s.length){if(T(t)){var m=t.name?": "+t.name:"";return e.stylize("[Function"+m+"]","special")}if(E(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(k(t))return e.stylize(Date.prototype.toString.call(t),"date");if(x(t))return f(t)}var v="",g=!1,_=["{","}"];if(d(t)&&(g=!0,_=["[","]"]),T(t)){var w=t.name?": "+t.name:"";v=" [Function"+w+"]"}if(E(t)&&(v=" "+RegExp.prototype.toString.call(t)),k(t)&&(v=" "+Date.prototype.toUTCString.call(t)),x(t)&&(v=" "+f(t)),0===s.length&&(!g||0==t.length))return _[0]+v+_[1];if(0>r)return E(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var S;return S=g?l(e,t,r,y,s):s.map(function(n){return h(e,t,r,y,n,g)}),e.seen.pop(),p(S,v,_)}function c(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return g(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)U(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}function h(e,t,n,r,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),U(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function y(e){return"boolean"==typeof e}function m(e){return null===e}function v(e){return null==e}function g(e){return"number"==typeof e}function b(e){return"string"==typeof e}function _(e){return"symbol"==typeof e}function w(e){return void 0===e}function E(e){return S(e)&&"[object RegExp]"===I(e)}function S(e){return"object"==typeof e&&null!==e}function k(e){return S(e)&&"[object Date]"===I(e)}function x(e){return S(e)&&("[object Error]"===I(e)||e instanceof Error)}function T(e){return"function"==typeof e}function R(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function I(e){return Object.prototype.toString.call(e)}function A(e){return 10>e?"0"+e.toString(10):e.toString(10)}function C(){var e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var P=/%[sdj%]/g;n.format=function(e){if(!b(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=m(a)||!S(a)?" "+a:" "+i(a);return s},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(w(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var O,j={};n.debuglog=function(e){if(w(O)&&(O=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!j[e])if(new RegExp("\\b"+e+"\\b","i").test(O)){var r=t.pid;j[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else j[e]=function(){};return j[e]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=d,n.isBoolean=y,n.isNull=m,n.isNullOrUndefined=v,n.isNumber=g,n.isString=b,n.isSymbol=_,n.isUndefined=w,n.isRegExp=E,n.isObject=S,n.isDate=k,n.isError=x,n.isFunction=T,n.isPrimitive=R,n.isBuffer=e("./support/isBuffer");var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",C(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":92,_process:63,inherits:54}],94:[function(e,t,n){function r(e,t,n){var r;return r=t?new o(e,t):new o(e)}var i=function(){return this}(),o=i.WebSocket||i.MozWebSocket;t.exports=o?r:null,o&&(r.prototype=o.prototype)},{}],95:[function(e,t,n){(function(t,r){/**
* Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.
*
* This can be used with JS designed for browsers to improve reuse of code and
* allow the use of existing libraries.
*
* Usage: include("XMLHttpRequest.js") and use XMLHttpRequest per W3C specs.
*
* @author Dan DeFelippi
* @contributor David Ellis
* @license MIT
*/
var i=e("url"),o=e("child_process").spawn,s=e("fs");n.XMLHttpRequest=function(){"use strict";var n,a,u=this,c=e("http"),f=e("https"),l={},h=!1,p={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},d={},y={},m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],v=["TRACE","TRACK","CONNECT"],g=!1,b=!1,_={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null,this.withCredentials=!1;var w=function(e){return h||e&&-1===m.indexOf(e.toLowerCase())},E=function(e){return e&&-1===v.indexOf(e)};this.open=function(e,t,n,r,i){if(this.abort(),b=!1,!E(e))throw new Error("SecurityError: Request method not allowed");l={method:e,url:t.toString(),async:"boolean"!=typeof n?!0:n,user:r||null,password:i||null},S(this.OPENED)},this.setDisableHeaderCheck=function(e){h=e},this.setRequestHeader=function(e,t){if(this.readyState!==this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!w(e))return void console.warn('Refused to set unsafe header "'+e+'"');if(g)throw new Error("INVALID_STATE_ERR: send flag is true");e=y[e.toLowerCase()]||e,y[e.toLowerCase()]=e,d[e]=d[e]?d[e]+", "+t:t},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&a&&a.headers&&a.headers[e.toLowerCase()]&&!b?a.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyStatet;t++)_[e][t].call(u)};var S=function(e){e!=u.LOADING&&u.readyState===e||(u.readyState=e,(l.async||u.readyState=0.12"}}},{}]},{},[35])(35)})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],13:[function(e,t,n){(function(t){!function(t){if("function"==typeof define&&define.amd)define([],function(){return e("./twilio-ip-messaging-bundle.js")});else{var n=t.Twilio=t.Twilio||{};n.AccessManager=n.AccessManager||e("twilio-common").AccessManager,n.IPMessaging=n.IPMessaging||e("./twilio-ip-messaging-bundle.js")}}("undefined"!=typeof window?window:"undefined"!=typeof t?t:this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./twilio-ip-messaging-bundle.js":12,"twilio-common":9}]},{},[13]);