!function(){return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){return i(t[s][1][e]||e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}}()({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=s(e("url-template")),o=s(e("./lib/apiGatewayCore/apiGatewayClient"));
/*
                                                                                                                                                                                                                                                                               * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
                                                                                                                                                                                                                                                                               *
                                                                                                                                                                                                                                                                               * Licensed under the Apache License, Version 2.0 (the "License").
                                                                                                                                                                                                                                                                               * You may not use this file except in compliance with the License.
                                                                                                                                                                                                                                                                               * A copy of the License is located at
                                                                                                                                                                                                                                                                               *
                                                                                                                                                                                                                                                                               *  http://aws.amazon.com/apache2.0
                                                                                                                                                                                                                                                                               *
                                                                                                                                                                                                                                                                               * or in the "license" file accompanying this file. This file 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 s(e){return e&&e.__esModule?e:{default:e}}var a={};a.newClient=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={},n=(e=Object.assign({accessKey:"",secretKey:"",sessionToken:"",region:"",apiKey:"",invokeUrl:"",service:"execute-api",defaultContentType:"application/json",defaultAcceptType:"application/json",systemClockOffset:0,headers:{},host:void 0},function e(t){return Object.keys(t).forEach(function(n){return t[n]&&"object"===r(t[n])&&e(t[n])||void 0===t[n]&&delete t[n]}),t}(e))).invokeUrl,s=/(^https?:\/\/[^\/]+)/g.exec(n)[1],a=n.substring(s.length),c={accessKey:e.accessKey,secretKey:e.secretKey,sessionToken:e.sessionToken,serviceName:e.service,region:e.region,endpoint:s,defaultContentType:e.defaultContentType,defaultAcceptType:e.defaultAcceptType,systemClockOffset:e.systemClockOffset,retries:e.retries,retryCondition:e.retryCondition,host:e.host},u="NONE";void 0!==c.accessKey&&""!==c.accessKey&&void 0!==c.secretKey&&""!==c.secretKey&&(u="AWS_IAM");var l={endpoint:s,defaultContentType:e.defaultContentType,defaultAcceptType:e.defaultAcceptType,retries:e.retries,retryCondition:e.retryCondition,headers:e.headers},f=o.default.newClient(l,c);return t.invokeApi=function(t,n,r,o,s){void 0===o&&(o={}),void 0===s&&(s="");var c={verb:r.toUpperCase(),path:a+i.default.parse(n).expand(t),headers:o.headers||{},timeout:o.timeout||0,queryParams:o.queryParams,body:s};return f.makeRequest(c,u,o,e.apiKey)},t},n.default=a},{"./lib/apiGatewayCore/apiGatewayClient":2,"url-template":217}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=s(e("./utils")),i=s(e("./sigV4Client.js")),o=s(e("./simpleHttpClient.js"));function s(e){return e&&e.__esModule?e:{default:e}}var a={
/*
                                   * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
                                   *
                                   * Licensed under the Apache License, Version 2.0 (the "License").
                                   * You may not use this file except in compliance with the License.
                                   * A copy of the License is located at
                                   *
                                   *  http://aws.amazon.com/apache2.0
                                   *
                                   * or in the "license" file accompanying this file. This file 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.
                                   */
newClient:function(e,t){var n={},s=i.default.newClient(t),a=o.default.newClient(e);return n.makeRequest=function(e,t,n,i){var o=a;return void 0!==i&&""!==i&&null!==i&&(e.headers["x-api-key"]=i),void 0!==e.body&&""!==e.body&&null!==e.body&&0!==Object.keys(e.body).length||(e.body=void 0),e.headers=r.default.mergeInto(e.headers,n.headers),e.queryParams=r.default.mergeInto(e.queryParams,n.queryParams),e.timeout=r.default.mergeInto(e.timeout,n.timeout),"AWS_IAM"===t&&(o=s),o.makeRequest(e)},n}};n.default=a},{"./sigV4Client.js":3,"./simpleHttpClient.js":4,"./utils":5}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=l(e("axios")),i=l(e("axios-retry")),o=l(e("crypto-js/sha256")),s=l(e("crypto-js/enc-hex")),a=l(e("crypto-js/hmac-sha256")),c=l(e("url")),u=l(e("./utils"));function l(e){return e&&e.__esModule?e:{default:e}}var f={};
/*
                              * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
                              *
                              * Licensed under the Apache License, Version 2.0 (the "License").
                              * You may not use this file except in compliance with the License.
                              * A copy of the License is located at
                              *
                              *  http://aws.amazon.com/apache2.0
                              *
                              * or in the "license" file accompanying this file. This file 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.
                              */f.newClient=function(e){var t="AWS4-HMAC-SHA256",n="aws4_request",l="AWS4";function f(e){return(0,o.default)(e)}function h(e){return e.toString(s.default)}function p(e,t){return(0,a.default)(t,e,{asBytes:!0})}function d(e,t,n,r,i){return e+"\n"+encodeURI(t)+"\n"+_(n)+"\n"+function(e){var t="",n=[];for(var r in e)e.hasOwnProperty(r)&&n.push(r);n.sort();for(var i=0;i<n.length;i++)t+=n[i].toLowerCase()+":"+e[n[i]]+"\n";return t}(r)+"\n"+g(r)+"\n"+h(f(i))}function _(e){if(Object.keys(e).length<1)return"";var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);t.sort();for(var r,i="",o=0;o<t.length;o++)i+=t[o]+"="+(r=e[t[o]],encodeURIComponent(r).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16)}))+"&";return i.substr(0,i.length-1)}function g(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n.toLowerCase());return t.sort(),t.join(";")}var v={};return void 0===e.accessKey||void 0===e.secretKey?v:(v.accessKey=u.default.assertDefined(e.accessKey,"accessKey"),v.secretKey=u.default.assertDefined(e.secretKey,"secretKey"),v.sessionToken=e.sessionToken,v.serviceName=u.default.assertDefined(e.serviceName,"serviceName"),v.region=u.default.assertDefined(e.region,"region"),v.endpoint=u.default.assertDefined(e.endpoint,"endpoint"),v.retries=e.retries,v.retryCondition=e.retryCondition,v.host=e.host,v.makeRequest=function(o){var s=u.default.assertDefined(o.verb,"verb"),a=u.default.assertDefined(o.path,"path"),m=u.default.copy(o.queryParams),y=u.default.copy(o.timeout);void 0===m&&(m={}),void 0===y&&(y=0);var E=u.default.copy(o.headers);void 0===E&&(E={}),void 0===E["Content-Type"]&&(E["Content-Type"]=e.defaultContentType),void 0===E.Accept&&(E.Accept=e.defaultAcceptType);var b=u.default.copy(o.body);b&&E["Content-Type"]&&"application/json"===E["Content-Type"]&&(b=JSON.stringify(b)),""!==b&&void 0!==b&&null!==b||delete E["Content-Type"];var C=new Date((new Date).getTime()+e.systemClockOffset).toISOString().replace(/\.\d{3}Z$/,"Z").replace(/[:\-]|\.\d{3}/g,"");if(E["x-amz-date"]=C,v.host)E.host=v.host;else{var w=c.default.parse(v.endpoint);E.host=w.host}var T=function(e){return h(f(e))}(d(s,a,m,E,b)),R=function(e,t,r){return e.substr(0,8)+"/"+t+"/"+r+"/"+n}(C,v.region,v.serviceName),S=function(e,n,r){return t+"\n"+e+"\n"+n+"\n"+r}(C,R,T),I=function(e,t){return h(p(e,t))}(function(e,t,r,i){return p(p(p(p(l+e,t.substr(0,8)),r),i),n)}(v.secretKey,C,v.region,v.serviceName),S);E.Authorization=function(e,n,r,i){return t+" Credential="+e+"/"+n+", SignedHeaders="+g(r)+", Signature="+i}(v.accessKey,R,E,I),void 0!==v.sessionToken&&""!==v.sessionToken&&(E["x-amz-security-token"]=v.sessionToken),delete E.host;var N=e.endpoint+a,O=_(m);""!==O&&(N+="?"+O),void 0===E["Content-Type"]&&(E["Content-Type"]=e.defaultContentType);var A={headers:E,timeout:y,data:b};if(void 0!==e.retries){A.baseURL=N;var x=r.default.create(A);return(0,i.default)(x,{retries:e.retries,retryCondition:e.retryCondition}),x.request({method:s})}return A.method=s,A.url=N,(0,r.default)(A)},v)},n.default=f},{"./utils":5,axios:20,"axios-retry":18,"crypto-js/enc-hex":76,"crypto-js/hmac-sha256":77,"crypto-js/sha256":79,url:218}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i=a(e("axios")),o=a(e("axios-retry")),s=a(e("./utils"));
/*
                                                                                                                                                                                                                                                                   * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
                                                                                                                                                                                                                                                                   *
                                                                                                                                                                                                                                                                   * Licensed under the Apache License, Version 2.0 (the "License").
                                                                                                                                                                                                                                                                   * You may not use this file except in compliance with the License.
                                                                                                                                                                                                                                                                   * A copy of the License is located at
                                                                                                                                                                                                                                                                   *
                                                                                                                                                                                                                                                                   *  http://aws.amazon.com/apache2.0
                                                                                                                                                                                                                                                                   *
                                                                                                                                                                                                                                                                   * or in the "license" file accompanying this file. This file 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 a(e){return e&&e.__esModule?e:{default:e}}var c={};c.newClient=function(e){var t={};return t.endpoint=s.default.assertDefined(e.endpoint,"endpoint"),t.makeRequest=function(t){var n=s.default.assertDefined(t.verb,"verb"),a=s.default.assertDefined(t.path,"path"),c=s.default.copy(t.queryParams),u=s.default.copy(t.timeout);void 0===c&&(c={}),void 0===u&&(u=0);var l=r({},s.default.copy(t.headers),e.headers);void 0===l["Content-Type"]&&(l["Content-Type"]=e.defaultContentType),void 0===l.Accept&&(l.Accept=e.defaultAcceptType);var f=s.default.copy(t.body),h=e.endpoint+a,p=function(e){if(Object.keys(e).length<1)return"";var t="";for(var n in e)e.hasOwnProperty(n)&&(t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n])+"&");return t.substr(0,t.length-1)}(c);""!==p&&(h+="?"+p);var d={headers:l,timeout:u,data:f};if(void 0!==e.retries){d.baseURL=h;var _=i.default.create(d);return(0,o.default)(_,{retries:e.retries,retryCondition:e.retryCondition}),_.request({method:n})}return d.method=n,d.url=h,(0,i.default)(d)},t},n.default=c},{"./utils":5,axios:20,"axios-retry":18}],5:[function(e,t,n){(function(e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r={assertDefined:function(e,t){if(void 0===e)throw new Error(t+" must be defined");return e},assertParametersDefined:function(e,t,n){if(void 0!==t){t.length>0&&void 0===e&&(e={});for(var i=0;i<t.length;i++)r.contains(n,t[i])||r.assertDefined(e[t[i]],t[i])}},parseParametersToObject:function(e,t){if(void 0===e)return{};for(var n={},r=0;r<t.length;r++)n[t[r]]=e[t[r]];return n},contains:function(e,t){if(void 0===e)return!1;for(var n=e.length;n--;)if(e[n]===t)return!0;return!1},copy:function(n){if(null===n||"object"!==(void 0===n?"undefined":t(n)))return n;if(e.isBuffer(n))return e.from(n);var r=n.constructor(),i=null;for(i in n)n.hasOwnProperty(i)&&(r[i]=n[i]);return r},mergeInto:function(e,n){if(null===e||"object"!==(void 0===e?"undefined":t(e)))return e;var r=e.constructor(),i=null;for(i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);if(null==n||"object"!=(void 0===n?"undefined":t(n)))return e;for(i in n)n.hasOwnProperty(i)&&(r[i]=n[i]);return r}};
/*
 * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */n.default=r}).call(this,e("buffer").Buffer)},{buffer:48}],6:[function(e,t,n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
t.exports={NO_KEY_OPTION:'No "keyPath" or "privateKey" option supplied.',NO_CERT_OPTION:'No "certPath" or "clientCert" option supplied.',NO_CA_OPTION:'No "caPath" or "caCert" option supplied.',INVALID_KEY_PATH_OPTION:'Invalid "keyPath" option supplied.',INVALID_CERT_PATH_OPTION:'Invalid "certPath" option supplied.',INVALID_CA_PATH_OPTION:'Invalid "caPath" option supplied.',INVALID_CLIENT_CERT_OPTION:'Invalid "clientCert" option supplied.',INVALID_PRIVATE_KEY_OPTION:'Invalid "privateKey" option supplied.',INVALID_CA_CERT_OPTION:'Invalid "caCert" option supplied.'}},{}],7:[function(e,t,n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
t.exports=function(e){return void 0===e||null===e}},{}],8:[function(e,t,n){(function(n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
var r=e("fs"),i=e("./is-undefined"),o=e("./exceptions");t.exports=function(e){if(i(e.keyPath)&&i(e.privateKey))throw new Error(o.NO_KEY_OPTION);if(i(e.certPath)&&i(e.clientCert))throw new Error(o.NO_CERT_OPTION);if(i(e.caPath)&&i(e.caCert))throw new Error(o.NO_CA_OPTION);if(!i(e.caCert))if(n.isBuffer(e.caCert))e.ca=e.caCert;else{if(!r.existsSync(e.caCert))throw new Error(o.INVALID_CA_CERT_OPTION);e.ca=r.readFileSync(e.caCert)}if(!i(e.privateKey))if(n.isBuffer(e.privateKey))e.key=e.privateKey;else{if(!r.existsSync(e.privateKey))throw new Error(o.INVALID_PRIVATE_KEY_OPTION);e.key=r.readFileSync(e.privateKey)}if(!i(e.clientCert))if(n.isBuffer(e.clientCert))e.cert=e.clientCert;else{if(!r.existsSync(e.clientCert))throw new Error(o.INVALID_CLIENT_CERT_OPTION);e.cert=r.readFileSync(e.clientCert)}if(r.existsSync(e.keyPath))e.key=r.readFileSync(e.keyPath);else if(!i(e.keyPath))throw new Error(o.INVALID_KEY_PATH_OPTION);if(r.existsSync(e.certPath))e.cert=r.readFileSync(e.certPath);else if(!i(e.certPath))throw new Error(o.INVALID_CERT_PATH_OPTION);if(r.existsSync(e.caPath))e.ca=r.readFileSync(e.caPath);else if(!i(e.caPath))throw new Error(o.INVALID_CA_PATH_OPTION);e.requestCert=!0,e.rejectUnauthorized=!0}}).call(this,{isBuffer:e("../../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../insert-module-globals/node_modules/is-buffer/index.js":154,"./exceptions":6,"./is-undefined":7,fs:47}],9:[function(e,t,n){(function(n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
var r=e("events"),i=e("util").inherits,o=e("mqtt"),s=e("crypto-js/hmac-sha256"),a=e("crypto-js/sha256"),c=e("./lib/exceptions"),u=e("../common/lib/is-undefined"),l=e("../common/lib/tls-reader"),f=e("path"),h=e("fs");function p(e){return e>9?e:"0"+e}function d(e,t,n,r,i,o,c,l,f,h,p,d,_,g){var v=e+"\n"+r+"\n"+i+"\n"+("host:"+n.toLowerCase()+"\n")+"\nhost\n"+a(h,{asBytes:!0});!0===_&&console.log("canonical request: "+v+"\n");var m=a(v,{asBytes:!0});!0===_&&console.log("hashed canonical request: "+m+"\n");var y="AWS4-HMAC-SHA256\n"+d+"\n"+p+"/"+l+"/"+f+"/aws4_request\n"+m;!0===_&&console.log("string to sign: "+y+"\n");var E=function(e,t,n,r){var i=s(t,"AWS4"+e,{asBytes:!0}),o=s(n,i,{asBytes:!0}),a=s(r,o,{asBytes:!0});return s("aws4_request",a,{asBytes:!0})}(c,p,l,f);!0===_&&console.log("signing key: "+E+"\n");var b=s(y,E,{asBytes:!0});!0===_&&console.log("signature: "+b+"\n");var C=i+"&X-Amz-Signature="+b;u(g)||(C+="&X-Amz-Security-Token="+encodeURIComponent(g));var w=t+n+r+"?"+C;return!0===_&&console.log("url: "+w+"\n"),w}function _(e,t,n,r){var i,o,s=(i=new Date).getUTCFullYear()+""+p(i.getUTCMonth()+1)+p(i.getUTCDate())+"T"+p(i.getUTCHours())+p(i.getUTCMinutes())+p(i.getUTCSeconds())+"Z",a=(o=s).substring(0,o.indexOf("T")),c="X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential="+t+"%2F"+a+"%2F"+e.region+"%2Fiotdevicegateway%2Faws4_request&X-Amz-Date="+s+"&X-Amz-SignedHeaders=host",l=e.host;return u(e.port)||443===e.port||(l=e.host+":"+e.port),d("GET","wss://",l,"/mqtt",c,0,n,e.region,"iotdevicegateway","",a,s,e.debug,r)}function g(e){var t=e.host;return u(e.port)||443===e.port||(t=e.host+":"+e.port),"wss://"+t+"/mqtt"}function v(e){var t={},n={};return function(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.call(this,e[n],parseInt(n,10))}(e.split(/\r?\n/),function(e){var r=(e=e.split(/(^|\s)[;#]/)[0]).match(/^\s*\[([^\[\]]+)\]\s*$/);if(r)n=r[1];else if(n){var i=e.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/);i&&(t[n]=t[n]||{},t[n][i[1]]=i[2])}}),t}function m(t){if(!(this instanceof m))return new m(t);var r=this,i=[],s=!0,a=0,p="oldest";i.length=0;var d=[];d.length=0;var y=[],E=!0;y.length=0;var b=[];b.length=0;var C,w,T,R,S,I="inactive",N=null,O=250,A=1e3,x=2e4,B=128e3,k=null,P="?SDK=JavaScript&Version="+e("../package.json").version;if(u(t)||0===Object.keys(t).length)throw new Error(c.INVALID_CONNECT_OPTIONS);if(u(t.keepalive)&&(t.keepalive=300),(u(t.enableMetrics)||!0===t.enableMetrics)&&(u(t.username)?t.username=P:t.username+=P),u(t.baseReconnectTimeMs)||(A=t.baseReconnectTimeMs),u(t.minimumConnectionTimeMs)||(x=t.minimumConnectionTimeMs),u(t.maximumReconnectTimeMs)||(B=t.maximumReconnectTimeMs),u(t.drainTimeMs)||(O=t.drainTimeMs),u(t.autoResubscribe)||(E=t.autoResubscribe),u(t.offlineQueueing)||(s=t.offlineQueueing),u(t.offlineQueueMaxSize)||(a=t.offlineQueueMaxSize),u(t.offlineQueueDropBehavior)||(p=t.offlineQueueDropBehavior),C=A,t.reconnectPeriod=C,t.fastDisconnectDetection=!0,t.resubscribe=!1,t.baseReconnectTimeMs<=0)throw new Error(c.INVALID_RECONNECT_TIMING);if(B<A)throw new Error(c.INVALID_RECONNECT_TIMING);if(x<A)throw new Error(c.INVALID_RECONNECT_TIMING);if("newest"!==p&&"oldest"!==p)throw new Error(c.INVALID_OFFLINE_QUEUEING_PARAMETERS);if(a<0)throw new Error(c.INVALID_OFFLINE_QUEUEING_PARAMETERS);if(u(t.protocol)&&(t.protocol="mqtts"),u(t.host))throw new Error(c.INVALID_CONNECT_OPTIONS);if("mqtts"===t.protocol)u(t.port)&&(t.port=8883),l(t);else if("wss"===t.protocol||"wss-custom-auth"===t.protocol){if("wss"===t.protocol){var D;if(w=u(t.accessKeyId)?n.env.AWS_ACCESS_KEY_ID:t.accessKeyId,T=u(t.secretKey)?n.env.AWS_SECRET_ACCESS_KEY:t.secretKey,R=u(t.sessionToken)?n.env.AWS_SESSION_TOKEN:t.sessionToken,u(w)||u(T))try{u(t.filename)?(S=n.env.HOME||n.env.USERPROFILE||(n.env.HOMEPATH?(n.env.HOMEDRIVE||"C:/")+n.env.HOMEPATH:null),D=f.join(S,".aws","credentials")):D=t.filename;var L=t.profile||n.env.AWS_PROFILE||"default",W=v(h.readFileSync(D,"utf-8"))[L];w=W.aws_access_key_id,T=W.aws_secret_access_key,R=W.aws_session_token}catch(e){console.log(e),console.log("Failed to read credentials from "+D)}if(u(w)||u(T))throw console.log("To connect via WebSocket/SigV4, AWS Access Key ID and AWS Secret Key must be passed either in options or as environment variables; see README.md"),new Error(c.INVALID_CONNECT_OPTIONS)}else if(u(t.customAuthHeaders))throw console.log("To authenticate with a custom authorizer, you must provide the required HTTP headers; see README.md"),new Error(c.INVALID_CONNECT_OPTIONS);if(!u(t.host)&&u(t.region)){var j=/[a-zA-Z0-9]+\.iot\.([a-z]+-[a-z]+-[0-9]+)\.amazonaws\..+/.exec(t.host);if(null===j)throw console.log("Host endpoint is not valid"),new Error(c.INVALID_CONNECT_OPTIONS);t.region=j[1]}u(t.port)&&(t.port=443),u(t.websocketOptions)?t.websocketOptions={protocol:"mqttv3.1"}:t.websocketOptions.protocol="mqttv3.1","wss-custom-auth"===t.protocol&&(t.websocketOptions.headers=t.customAuthHeaders)}u(t)||!0!==t.debug||(console.log(t),console.log("attempting new mqtt connection..."));var M={};function U(e,t){0===y.filter(function(t){return t.topic===e}).length&&y.push({topic:e,options:t})}function F(e,t){var n=y.filter(function(t){return t.topic!==e});y=n}function G(e,t,n){var r=null;!1!==E&&("subscribe"===e?r=U:"unsubscribe"===e&&(r=F),"[object Array]"===Object.prototype.toString.call(t)?t.forEach(function(e,t,i){r(e,n)}):r(t,n))}function q(){return"inactive"===I}M.mqtts=e("./lib/tls"),M.wss=e("./lib/ws");var H=new o.MqttClient(function(e){var n,r=t.protocol;return"wss"===r?(n=""===w||""===T?"wss://no-credentials-available":_(t,w,T,R),!0===t.debug&&console.log("using websockets, will connect to '"+n+"'..."),t.url=n):"wss-custom-auth"===r&&(t.url=g(t),!0===t.debug&&console.log("using websockets custom auth, will connect to '"+t.url+"'..."),r="wss"),M[r](e,t)},t);function V(){C=A,H.options.reconnectPeriod=C,k=null,I="stable"}function z(){var e=b.shift();if(u(e)){var t=d.shift();if(u(t)){var n=i.shift();u(n)||H.publish(n.topic,n.message,n.options,n.callback),0===i.length&&(clearInterval(N),N=null)}else G(t.type,t.topics,t.options),"subscribe"===t.type?u(t.callback)?H.subscribe(t.topics,t.options):H.subscribe(t.topics,t.options,t.callback):"unsubscribe"===t.type&&H.unsubscribe(t.topics,t.callback)}else u(e.callback)?H.subscribe(e.topic,e.options):H.subscribe(e.topic,e.options,e.callback)}H.on("connect",function(e){null===k&&(k=setTimeout(V,x)),I="established",null===N&&(b=y.slice(0),N=setInterval(z,O)),r.emit("connect",e)}),H.on("close",function(e){u(e)||r.emit("error",e),u(t)||!0!==t.debug||console.log("connection lost - will attempt reconnection in "+H.options.reconnectPeriod/1e3+" seconds..."),clearTimeout(k),k=null,clearInterval(N),N=null,I="inactive",r.emit("close")}),H.on("reconnect",function(){C*=2,C=Math.min(B,C),H.options.reconnectPeriod=C,r.emit("reconnect")}),H.on("offline",function(){r.emit("offline")}),H.on("error",function(e){r.emit("error",e)}),H.on("packetsend",function(e){r.emit("packetsend",e)}),H.on("packetreceive",function(e){r.emit("packetreceive",e)}),H.on("message",function(e,t,n){r.emit("message",e,t,n)}),this.publish=function(e,t,n,r){var o;!0!==s||!q()&&null===N?!0!==s&&q()||H.publish(e,t,n,r):(o=!0,a>0&&i.length>=a&&("oldest"===p?i.shift():o=!1),o&&i.push({topic:e,message:t,options:n,callback:r}))},this.subscribe=function(e,t,n){q()&&!1!==E?d.length<50?d.push({type:"subscribe",topics:e,options:t,callback:n}):r.emit("error",new Error("Maximum queued offline subscription reached")):(G("subscribe",e,t),u(n)?H.subscribe(e,t):H.subscribe(e,t,n))},this.unsubscribe=function(e,n){q()&&!1!==E?d.length<50&&d.push({type:"unsubscribe",topics:e,options:t,callback:n}):(G("unsubscribe",e),H.unsubscribe(e,n))},this.end=function(e,t){H.end(e,t)},this.handleMessage=H.handleMessage.bind(H),H.handleMessage=function(e,t){r.handleMessage(e,t)},this.updateWebSocketCredentials=function(e,t,n,r){w=e,T=t,R=n},this.getWebsocketHeaders=function(){return t.websocketOptions.headers},this.updateCustomAuthHeaders=function(e){t.websocketOptions.headers=e},this.simulateNetworkFailure=function(){H.stream.emit("error",new Error("simulated connection error")),H.stream.end()}}i(m,r.EventEmitter),t.exports=m,t.exports.DeviceClient=m,t.exports.prepareWebSocketUrl=_,t.exports.prepareWebSocketCustomAuthUrl=g}).call(this,e("_process"))},{"../common/lib/is-undefined":7,"../common/lib/tls-reader":8,"../package.json":17,"./lib/exceptions":10,"./lib/tls":11,"./lib/ws":12,_process:181,"crypto-js/hmac-sha256":14,"crypto-js/sha256":16,events:148,fs:47,mqtt:167,path:179,util:223}],10:[function(e,t,n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
t.exports={INVALID_CONNECT_OPTIONS:"Invalid connect options supplied.",INVALID_CLIENT_ID_OPTION:'Invalid "clientId" (mqtt client id) option supplied.',INVALID_RECONNECT_TIMING:"Invalid reconnect timing options supplied.",INVALID_OFFLINE_QUEUEING_PARAMETERS:"Invalid offline queueing options supplied."}},{}],11:[function(e,t,n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
var r=e("tls");t.exports=function(e,t){var n;function i(t){e.emit("error",t),n.end()}return(n=r.connect(t)).on("secureConnect",function(){n.authorized?n.removeListener("error",i):n.emit("error",new Error("TLS not authorized"))}),n.on("error",i),n}},{tls:47}],12:[function(e,t,n){
/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
const r=e("websocket-stream");t.exports=function(e,t){return r(t.url,["mqttv3.1"],t.websocketOptions)}},{"websocket-stream":233}],13:[function(e,t,n){var r,i;r=this,i=function(){var e=e||function(e,t){var n={},r=n.lib={},i=r.Base=function(){function e(){}return{extend:function(t){e.prototype=this;var n=new e;return t&&n.mixIn(t),n.hasOwnProperty("init")||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),o=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||a).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)t[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],i=function(t){t=t;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},s=0;s<t;s+=4){var a=i(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new o.init(r,t)}}),s=n.enc={},a=s.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new o.init(n,t/2)}},c=s.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new o.init(n,t)}},u=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,s=this.blockSize,a=i/(4*s),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=s)this._doProcessBlock(r,l);var f=r.splice(0,c);n.sigBytes-=u}return new o.init(f,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(r.Hasher=l.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new f.HMAC.init(e,n).finalize(t)}}}),n.algo={});return n}(Math);return e},"object"==typeof n?t.exports=n=i():"function"==typeof define&&define.amd?define([],i):r.CryptoJS=i()},{}],14:[function(e,t,n){var r,i;r=this,i=function(e){return e.HmacSHA256},"object"==typeof n?t.exports=n=i(e("./core"),e("./sha256"),e("./hmac")):"function"==typeof define&&define.amd?define(["./core","./sha256","./hmac"],i):i(r.CryptoJS)},{"./core":13,"./hmac":15,"./sha256":16}],15:[function(e,t,n){var r,i;r=this,i=function(e){var t,n,r;n=(t=e).lib.Base,r=t.enc.Utf8,t.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,i=4*n;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=s.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})},"object"==typeof n?t.exports=n=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)},{"./core":13}],16:[function(e,t,n){var r,i;r=this,i=function(e){return function(t){var n=e,r=n.lib,i=r.WordArray,o=r.Hasher,s=n.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)e(r)&&(i<8&&(a[i]=n(t.pow(r,.5))),c[i]=n(t.pow(r,1/3)),i++),r++}();var u=[],l=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],l=n[5],f=n[6],h=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var d=u[p-15],_=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=_+u[p-7]+v+u[p-16]}var m=r&i^r&o^i&o,y=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),E=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&f)+c[p]+u[p];h=f,f=l,l=a,a=s+E|0,s=o,o=i,i=r,r=E+(y+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+l|0,n[6]=n[6]+f|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=o._createHelper(l),n.HmacSHA256=o._createHmacHelper(l)}(Math),e.SHA256},"object"==typeof n?t.exports=n=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)},{"./core":13}],17:[function(e,t,n){t.exports={_args:[["aws-iot-device-sdk@2.2.6","/usr/app"]],_from:"aws-iot-device-sdk@2.2.6",_id:"aws-iot-device-sdk@2.2.6",_inBundle:!1,_integrity:"sha512-W481pAghXqF2PDrsFwQ6o0ngQfp0TOq78z8JuEHSrI2jhOynvsQzT2uTSl3lc2/rB8nLxJh6Ev7L/Xs+QD8NFQ==",_location:"/aws-iot-device-sdk",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"aws-iot-device-sdk@2.2.6",name:"aws-iot-device-sdk",escapedName:"aws-iot-device-sdk",rawSpec:"2.2.6",saveSpec:null,fetchSpec:"2.2.6"},_requiredBy:["/","/common-webrtc"],_resolved:"https://registry.npmjs.org/aws-iot-device-sdk/-/aws-iot-device-sdk-2.2.6.tgz",_spec:"2.2.6",_where:"/usr/app",author:{name:"Amazon Web Services",url:"http://aws.amazon.com"},bugs:{url:"http://github.com/aws/aws-iot-device-sdk-js/issues"},dependencies:{"crypto-js":"3.1.6",minimist:"1.2.5",mqtt:"2.18.8","websocket-stream":"^5.0.1"},description:"AWS IoT Node.js SDK for Embedded Devices",devDependencies:{gulp:"^3.9.0","gulp-beautify":"^2.0.0","gulp-concat":"^2.6.0","gulp-coverage":"^0.3.38","gulp-jscs":"^4.0.0","gulp-jshint":"^2.0.0","gulp-mocha":"^3.0.1",jshint:"^2.9.1","jshint-stylish":"^2.2.1",rewire:"^2.5.1",sinon:"^1.17.3"},engines:{node:">=4.0.0"},homepage:"https://github.com/aws/aws-iot-device-sdk-js",keywords:["api","amazon","aws","iot","mqtt"],license:"Apache-2.0",main:"index.js",name:"aws-iot-device-sdk",repository:{type:"git",url:"git://github.com/aws/aws-iot-device-sdk-js.git"},scripts:{beautify:"node ./node_modules/gulp/bin/gulp.js beautify",browserize:"./scripts/browserize.sh",test:"node ./node_modules/gulp/bin/gulp.js test --verbose"},version:"2.2.6"}},{}],18:[function(e,t,n){t.exports=e("./lib/index").default},{"./lib/index":19}],19:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.isNetworkError=a,n.isRetryableError=l,n.isSafeRequestError=f,n.isIdempotentRequestError=h,n.isNetworkOrIdempotentRequestError=p,n.exponentialDelay=_,n.default=v;var r,i=e("is-retry-allowed"),o=(r=i)&&r.__esModule?r:{default:r};var s="axios-retry";function a(e){return!e.response&&Boolean(e.code)&&"ECONNABORTED"!==e.code&&(0,o.default)(e)}var c=["get","head","options"],u=c.concat(["put","delete"]);function l(e){return"ECONNABORTED"!==e.code&&(!e.response||e.response.status>=500&&e.response.status<=599)}function f(e){return!!e.config&&(l(e)&&-1!==c.indexOf(e.config.method))}function h(e){return!!e.config&&(l(e)&&-1!==u.indexOf(e.config.method))}function p(e){return a(e)||h(e)}function d(){return 0}function _(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=100*Math.pow(2,e);return t+.2*t*Math.random()}function g(e){var t=e[s]||{};return t.retryCount=t.retryCount||0,e[s]=t,t}function v(e,t){e.interceptors.request.use(function(e){return g(e).lastRequestTime=Date.now(),e}),e.interceptors.response.use(null,function(n){var r=n.config;if(!r)return Promise.reject(n);var i=function(e,t){return Object.assign({},t,e[s])}(r,t),o=i.retries,a=void 0===o?3:o,c=i.retryCondition,u=void 0===c?p:c,l=i.retryDelay,f=void 0===l?d:l,h=i.shouldResetTimeout,_=void 0!==h&&h,v=g(r);if(u(n)&&v.retryCount<a){v.retryCount+=1;var m=f(v.retryCount,n);if(function(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}(e,r),!_&&r.timeout&&v.lastRequestTime){var y=Date.now()-v.lastRequestTime;r.timeout=Math.max(r.timeout-y-m,1)}return r.transformRequest=[function(e){return e}],new Promise(function(t){return setTimeout(function(){return t(e(r))},m)})}return Promise.reject(n)})}v.isNetworkError=a,v.isSafeRequestError=f,v.isIdempotentRequestError=h,v.isNetworkOrIdempotentRequestError=p,v.exponentialDelay=_,v.isRetryableError=l},{"is-retry-allowed":156}],20:[function(e,t,n){t.exports=e("./lib/axios")},{"./lib/axios":22}],21:[function(e,t,n){"use strict";var r=e("./../utils"),i=e("./../core/settle"),o=e("./../helpers/buildURL"),s=e("./../helpers/parseHeaders"),a=e("./../helpers/isURLSameOrigin"),c=e("../core/createError");t.exports=function(t){return new Promise(function(n,u){var l=t.data,f=t.headers;r.isFormData(l)&&delete f["Content-Type"];var h=new XMLHttpRequest;if(t.auth){var p=t.auth.username||"",d=t.auth.password||"";f.Authorization="Basic "+btoa(p+":"+d)}if(h.open(t.method.toUpperCase(),o(t.url,t.params,t.paramsSerializer),!0),h.timeout=t.timeout,h.onreadystatechange=function(){if(h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var e="getAllResponseHeaders"in h?s(h.getAllResponseHeaders()):null,r={data:t.responseType&&"text"!==t.responseType?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:e,config:t,request:h};i(n,u,r),h=null}},h.onerror=function(){u(c("Network Error",t,null,h)),h=null},h.ontimeout=function(){u(c("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED",h)),h=null},r.isStandardBrowserEnv()){var _=e("./../helpers/cookies"),g=(t.withCredentials||a(t.url))&&t.xsrfCookieName?_.read(t.xsrfCookieName):void 0;g&&(f[t.xsrfHeaderName]=g)}if("setRequestHeader"in h&&r.forEach(f,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete f[t]:h.setRequestHeader(t,e)}),t.withCredentials&&(h.withCredentials=!0),t.responseType)try{h.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&h.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then(function(e){h&&(h.abort(),u(e),h=null)}),void 0===l&&(l=null),h.send(l)})}},{"../core/createError":28,"./../core/settle":31,"./../helpers/buildURL":35,"./../helpers/cookies":37,"./../helpers/isURLSameOrigin":39,"./../helpers/parseHeaders":41,"./../utils":43}],22:[function(e,t,n){"use strict";var r=e("./utils"),i=e("./helpers/bind"),o=e("./core/Axios"),s=e("./defaults");function a(e){var t=new o(e),n=i(o.prototype.request,t);return r.extend(n,o.prototype,t),r.extend(n,t),n}var c=a(s);c.Axios=o,c.create=function(e){return a(r.merge(s,e))},c.Cancel=e("./cancel/Cancel"),c.CancelToken=e("./cancel/CancelToken"),c.isCancel=e("./cancel/isCancel"),c.all=function(e){return Promise.all(e)},c.spread=e("./helpers/spread"),t.exports=c,t.exports.default=c},{"./cancel/Cancel":23,"./cancel/CancelToken":24,"./cancel/isCancel":25,"./core/Axios":26,"./defaults":33,"./helpers/bind":34,"./helpers/spread":42,"./utils":43}],23:[function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,t.exports=r},{}],24:[function(e,t,n){"use strict";var r=e("./Cancel");function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new r(e),t(n.reason))})}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i(function(t){e=t}),cancel:e}},t.exports=i},{"./Cancel":23}],25:[function(e,t,n){"use strict";t.exports=function(e){return!(!e||!e.__CANCEL__)}},{}],26:[function(e,t,n){"use strict";var r=e("./../defaults"),i=e("./../utils"),o=e("./InterceptorManager"),s=e("./dispatchRequest");function a(e){this.defaults=e,this.interceptors={request:new o,response:new o}}a.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),(e=i.merge(r,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[s,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){a.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){a.prototype[e]=function(t,n,r){return this.request(i.merge(r||{},{method:e,url:t,data:n}))}}),t.exports=a},{"./../defaults":33,"./../utils":43,"./InterceptorManager":27,"./dispatchRequest":29}],27:[function(e,t,n){"use strict";var r=e("./../utils");function i(){this.handlers=[]}i.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){r.forEach(this.handlers,function(t){null!==t&&e(t)})},t.exports=i},{"./../utils":43}],28:[function(e,t,n){"use strict";var r=e("./enhanceError");t.exports=function(e,t,n,i,o){var s=new Error(e);return r(s,t,n,i,o)}},{"./enhanceError":30}],29:[function(e,t,n){"use strict";var r=e("./../utils"),i=e("./transformData"),o=e("../cancel/isCancel"),s=e("../defaults"),a=e("./../helpers/isAbsoluteURL"),c=e("./../helpers/combineURLs");function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}t.exports=function(e){return u(e),e.baseURL&&!a(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||s.adapter)(e).then(function(t){return u(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},{"../cancel/isCancel":25,"../defaults":33,"./../helpers/combineURLs":36,"./../helpers/isAbsoluteURL":38,"./../utils":43,"./transformData":32}],30:[function(e,t,n){"use strict";t.exports=function(e,t,n,r,i){return e.config=t,n&&(e.code=n),e.request=r,e.response=i,e}},{}],31:[function(e,t,n){"use strict";var r=e("./createError");t.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},{"./createError":28}],32:[function(e,t,n){"use strict";var r=e("./../utils");t.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},{"./../utils":43}],33:[function(e,t,n){(function(n){"use strict";var r=e("./utils"),i=e("./helpers/normalizeHeaderName"),o={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,c={adapter:("undefined"!=typeof XMLHttpRequest?a=e("./adapters/xhr"):void 0!==n&&(a=e("./adapters/http")),a),transformRequest:[function(e,t){return i(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(s(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],function(e){c.headers[e]={}}),r.forEach(["post","put","patch"],function(e){c.headers[e]=r.merge(o)}),t.exports=c}).call(this,e("_process"))},{"./adapters/http":21,"./adapters/xhr":21,"./helpers/normalizeHeaderName":40,"./utils":43,_process:181}],34:[function(e,t,n){"use strict";t.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},{}],35:[function(e,t,n){"use strict";var r=e("./../utils");function i(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(r.isURLSearchParams(t))o=t.toString();else{var s=[];r.forEach(t,function(e,t){null!==e&&void 0!==e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(i(t)+"="+i(e))}))}),o=s.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},{"./../utils":43}],36:[function(e,t,n){"use strict";t.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},{}],37:[function(e,t,n){"use strict";var r=e("./../utils");t.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,i,o,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},{"./../utils":43}],38:[function(e,t,n){"use strict";t.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},{}],39:[function(e,t,n){"use strict";var r=e("./../utils");t.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=r.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},{"./../utils":43}],40:[function(e,t,n){"use strict";var r=e("../utils");t.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},{"../utils":43}],41:[function(e,t,n){"use strict";var r=e("./../utils"),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(e){var t,n,o,s={};return e?(r.forEach(e.split("\n"),function(e){if(o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t){if(s[t]&&i.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}}),s):s}},{"./../utils":43}],42:[function(e,t,n){"use strict";t.exports=function(e){return function(t){return e.apply(null,t)}}},{}],43:[function(e,t,n){"use strict";var r=e("./helpers/bind"),i=e("is-buffer"),o=Object.prototype.toString;function s(e){return"[object Array]"===o.call(e)}function a(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===o.call(e)}function u(e,t){if(null!==e&&void 0!==e)if("object"!=typeof e&&(e=[e]),s(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}t.exports={isArray:s,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:i,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,i=arguments.length;r<i;r++)u(arguments[r],n);return t},extend:function(e,t,n){return u(t,function(t,i){e[i]=n&&"function"==typeof t?r(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},{"./helpers/bind":34,"is-buffer":155}],44:[function(e,t,n){"use strict";n.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),l=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[l++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(l(e,s,s+16383>a?a:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],45:[function(e,t,n){var r=e("readable-stream/duplex"),i=e("util"),o=e("safe-buffer").Buffer;function s(e){if(!(this instanceof s))return new s(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",function(e){e.on("error",t)}),this.on("unpipe",function(e){e.removeListener("error",t)})}else this.append(e);r.call(this)}i.inherits(s,r),s.prototype._offset=function(e){var t,n=0,r=0;if(0===e)return[0,0];for(;r<this._bufs.length;r++){if(e<(t=n+this._bufs[r].length)||r==this._bufs.length-1)return[r,e-n];n=t}},s.prototype.append=function(e){var t=0;if(o.isBuffer(e))this._appendBuffer(e);else if(Array.isArray(e))for(;t<e.length;t++)this.append(e[t]);else if(e instanceof s)for(;t<e._bufs.length;t++)this.append(e._bufs[t]);else null!=e&&("number"==typeof e&&(e=e.toString()),this._appendBuffer(o.from(e)));return this},s.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype.get=function(e){return this.slice(e,e+1)[0]},s.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},s.prototype.copy=function(e,t,n,r){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof r||r>this.length)&&(r=this.length),n>=this.length)return e||o.alloc(0);if(r<=0)return e||o.alloc(0);var i,s,a=!!e,c=this._offset(n),u=r-n,l=u,f=a&&t||0,h=c[1];if(0===n&&r==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:o.concat(this._bufs,this.length);for(s=0;s<this._bufs.length;s++)this._bufs[s].copy(e,f),f+=this._bufs[s].length;return e}if(l<=this._bufs[c[0]].length-h)return a?this._bufs[c[0]].copy(e,t,h,h+l):this._bufs[c[0]].slice(h,h+l);for(a||(e=o.allocUnsafe(u)),s=c[0];s<this._bufs.length;s++){if(!(l>(i=this._bufs[s].length-h))){this._bufs[s].copy(e,f,h,h+l);break}this._bufs[s].copy(e,f,h),f+=i,l-=i,h&&(h=0)}return e},s.prototype.shallowSlice=function(e,t){e=e||0,t=t||this.length,e<0&&(e+=this.length),t<0&&(t+=this.length);var n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return 0==r[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),0!=n[1]&&(i[0]=i[0].slice(n[1])),new s(i)},s.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},s.prototype.consume=function(e){for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function(){for(var e=0,t=new s;e<this._bufs.length;e++)t.append(this._bufs[e]);return t},s.prototype.destroy=function(){this._bufs.length=0,this.length=0,this.push(null)},function(){var e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1};for(var t in e)!function(t){s.prototype[t]=function(n){return this.slice(n,n+e[t])[t](0)}}(t)}(),t.exports=s},{"readable-stream/duplex":187,"safe-buffer":200,util:223}],46:[function(e,t,n){},{}],47:[function(e,t,n){arguments[4][46][0].apply(n,arguments)},{dup:46}],48:[function(e,t,n){(function(t){
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
"use strict";var r=e("base64-js"),i=e("ieee754");n.Buffer=t,n.SlowBuffer=function(e){+e!=e&&(e=0);return t.alloc(+e)},n.INSPECT_MAX_BYTES=50;var o=2147483647;function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=new Uint8Array(e);return n.__proto__=t.prototype,n}function t(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return a(e,t,n)}function a(e,n,r){if("string"==typeof e)return function(e,n){"string"==typeof n&&""!==n||(n="utf8");if(!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var r=0|h(e,n),i=s(r),o=i.write(e,n);o!==r&&(i=i.slice(0,o));return i}(e,n);if(ArrayBuffer.isView(e))return l(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(M(e,ArrayBuffer)||e&&M(e.buffer,ArrayBuffer))return function(e,n,r){if(n<0||e.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<n+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);return i.__proto__=t.prototype,i}(e,n,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return t.from(i,n,r);var o=function(e){if(t.isBuffer(e)){var n=0|f(e.length),r=s(n);return 0===r.length?r:(e.copy(r,0,0,n),r)}if(void 0!==e.length)return"number"!=typeof e.length||U(e.length)?s(0):l(e);if("Buffer"===e.type&&Array.isArray(e.data))return l(e.data)}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return t.from(e[Symbol.toPrimitive]("string"),n,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return c(e),s(e<0?0:0|f(e))}function l(e){for(var t=e.length<0?0:0|f(e.length),n=s(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function f(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function h(e,n){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||M(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var o=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(o)return i?-1:L(e).length;n=(""+n).toLowerCase(),o=!0}}function p(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function d(e,n,r,i,o){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof n&&(n=t.from(n,i)),t.isBuffer(n))return 0===n.length?-1:_(e,n,r,i,o);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,n,r):Uint8Array.prototype.lastIndexOf.call(e,n,r):_(e,[n],r,i,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=n;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var f=!0,h=0;h<c;h++)if(u(e,o+h)!==u(t,h)){f=!1;break}if(f)return o}return-1}function g(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(U(a))return s;e[n+s]=a}return s}function v(e,t,n,r){return j(L(t,e.length-n),e,n,r)}function m(e,t,n,r){return j(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function y(e,t,n,r){return m(e,t,n,r)}function E(e,t,n,r){return j(W(t),e,n,r)}function b(e,t,n,r){return j(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function w(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,u=e[i],l=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=n)switch(f){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=f}return function(e){var t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=T));return n}(r)}n.kMaxLength=o,t.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),t.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(t.prototype,"parent",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.buffer}}),Object.defineProperty(t.prototype,"offset",{enumerable:!0,get:function(){if(t.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),t.poolSize=8192,t.from=function(e,t,n){return a(e,t,n)},t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,t.alloc=function(e,t,n){return function(e,t,n){return c(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}(e,t,n)},t.allocUnsafe=function(e){return u(e)},t.allocUnsafeSlow=function(e){return u(e)},t.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==t.prototype},t.compare=function(e,n){if(M(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),M(n,Uint8Array)&&(n=t.from(n,n.offset,n.byteLength)),!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;for(var r=e.length,i=n.length,o=0,s=Math.min(r,i);o<s;++o)if(e[o]!==n[o]){r=e[o],i=n[o];break}return r<i?-1:i<r?1:0},t.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},t.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return t.alloc(0);var r;if(void 0===n)for(n=0,r=0;r<e.length;++r)n+=e[r].length;var i=t.allocUnsafe(n),o=0;for(r=0;r<e.length;++r){var s=e[r];if(M(s,Uint8Array)&&(s=t.from(s)),!t.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i},t.byteLength=h,t.prototype._isBuffer=!0,t.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)p(this,t,t+1);return this},t.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)p(this,t,t+3),p(this,t+1,t+2);return this},t.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)p(this,t,t+7),p(this,t+1,t+6),p(this,t+2,t+5),p(this,t+3,t+4);return this},t.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?w(this,0,e):function(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return w(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return S(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===t.compare(this,e)},t.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},t.prototype.compare=function(e,n,r,i,o){if(M(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),n<0||r>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&n>=r)return 0;if(i>=o)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var s=o-i,a=r-n,c=Math.min(s,a),u=this.slice(i,o),l=e.slice(n,r),f=0;f<c;++f)if(u[f]!==l[f]){s=u[f],a=l[f];break}return s<a?-1:a<s?1:0},t.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},t.prototype.indexOf=function(e,t,n){return d(this,e,t,n,!0)},t.prototype.lastIndexOf=function(e,t,n){return d(this,e,t,n,!1)},t.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))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return g(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":return m(this,e,t,n);case"latin1":case"binary":return y(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function R(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function S(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=D(e[o]);return i}function N(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function O(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(e,n,r,i,o,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>o||n<s)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function x(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(e,t,n,r,o){return t=+t,n>>>=0,o||x(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function k(e,t,n,r,o){return t=+t,n>>>=0,o||x(e,0,n,8),i.write(e,t,n,r,52,8),n+8}t.prototype.slice=function(e,n){var r=this.length;e=~~e,n=void 0===n?r:~~n,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),n<0?(n+=r)<0&&(n=0):n>r&&(n=r),n<e&&(n=e);var i=this.subarray(e,n);return i.__proto__=t.prototype,i},t.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},t.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},t.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},t.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,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 o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},t.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),i.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),i.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),i.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),i.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},t.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},t.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},t.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},t.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},t.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},t.prototype.writeDoubleLE=function(e,t,n){return k(this,e,t,!0,n)},t.prototype.writeDoubleBE=function(e,t,n){return k(this,e,t,!1,n)},t.prototype.copy=function(e,n,r,i){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),n>=e.length&&(n=e.length),n||(n=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-n<i-r&&(i=e.length-n+r);var o=i-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(n,r,i);else if(this===e&&r<n&&n<i)for(var s=o-1;s>=0;--s)e[s+n]=this[s+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),n);return o},t.prototype.fill=function(e,n,r,i){if("string"==typeof e){if("string"==typeof n?(i=n,n=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var o=e.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(e=o)}}else"number"==typeof e&&(e&=255);if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;var s;if(n>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=n;s<r;++s)this[s]=e;else{var a=t.isBuffer(e)?e:t.from(e,i),c=a.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-n;++s)this[s+n]=a[s%c]}return this};var P=/[^+/0-9A-Za-z-_]/g;function D(e){return e<16?"0"+e.toString(16):e.toString(16)}function L(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){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(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))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 W(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function j(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function M(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function U(e){return e!=e}}).call(this,e("buffer").Buffer)},{"base64-js":44,buffer:48,ieee754:152}],49:[function(e,t,n){"use strict";t.exports={DATA_CHANNEL_SEND_REQUEST_TIMEOUT:6e4,DATA_CHANNEL_OPEN_TIMEOUT:3e4,WAIT_FOR_NEW_ICE_CANDIDATES_DELAY:500,DEFAULT_API_CHANNEL_NAME:"api"}},{}],50:[function(e,t,n){t.exports={WEBRTC_CLOSED:"WEBRTC_CLOSED",WEBRTC_CONNECTED:"WEBRTC_CONNECTED",WEBRTC_CONNECTION_ERROR:"WEBRTC_CONNECTION_ERROR",WEBRTC_CREATE_ANSWER:"WEBRTC_CREATE_ANSWER",WEBRTC_CREATE_ANSWER_ERROR:"WEBRTC_CREATE_ANSWER_ERROR",WEBRTC_CREATE_OFFER:"WEBRTC_CREATE_OFFER",WEBRTC_CREATE_OFFER_ERROR:"WEBRTC_CREATE_OFFER_ERROR",WEBRTC_DATA_CHANNELS_OPEN:"WEBRTC_DATA_CHANNELS_OPEN",WEBRTC_DEVICE_OFFLINE:"WEBRTC_DEVICE_OFFLINE",WEBRTC_DISCONNECTED:"WEBRTC_DISCONNECTED",WEBRTC_INITIALIZED:"WEBRTC_INITIALIZED",WEBRTC_RECONNECTED:"WEBRTC_RECONNECTED",WEBRTC_RECONNECTING:"WEBRTC_RECONNECTING",WEBRTC_WILL_RECONNECT_ON:"WEBRTC_WILL_RECONNECT_ON",WEBRTC_RETRY_CONNECTION:"WEBRTC_RETRY_CONNECTION",WEBRTC_SDP_RECEIVED:"WEBRTC_SDP_RECEIVED",WEBRTC_SDP_RECEIVING_ERROR:"WEBRTC_SDP_RECEIVING_ERROR",WEBRTC_SDP_REQUESTING:"WEBRTC_SDP_REQUESTING",WEBRTC_SDP_SENDING:"WEBRTC_SDP_SENDING",WEBRTC_SDP_SENDING_ERROR:"WEBRTC_SDP_SENDING_ERROR",WEBRTC_SDP_SENT:"WEBRTC_SDP_SENT",WEBRTC_SET_LOCAL_DESCRIPTION:"WEBRTC_SET_LOCAL_DESCRIPTION",WEBRTC_SET_LOCAL_DESCRIPTION_ERROR:"WEBRTC_SET_LOCAL_DESCRIPTION_ERROR",WEBRTC_SET_REMOTE_DESCRIPTION:"WEBRTC_SET_REMOTE_DESCRIPTION",WEBRTC_SET_REMOTE_DESCRIPTION_ERROR:"WEBRTC_SET_REMOTE_DESCRIPTION_ERROR",WEBRTC_WS_CLOSED:"WEBRTC_WS_CLOSED",WEBRTC_WS_CONNECTED:"WEBRTC_WS_CONNECTED",WEBRTC_WS_OPENING:"WEBRTC_WS_OPENING",WEBRTC_WS_OPENING_ERROR:"WEBRTC_WS_OPENING_ERROR",WEBRTC_CREATING_API_GATEWAY_CLIENT:"WEBRTC_CREATING_API_GATEWAY_CLIENT",WEBRTC_AWS_CLOSED:"WEBRTC_AWS_CLOSED",WEBRTC_AWS_CONNECTED:"WEBRTC_AWS_CONNECTED",WEBRTC_AWS_OPENING:"WEBRTC_AWS_OPENING",WEBRTC_AWS_OPENING_ERROR:"WEBRTC_AWS_OPENING_ERROR",WEBRTC_AWS_IOT_CONNECTING:"WEBRTC_AWS_IOT_CONNECTING"}},{}],51:[function(e,t,n){t.exports={WEBRTC_API_CHANNEL_CONFLICT:"WEBRTC_API_CHANNEL_CONFLICT",WEBRTC_DATA_CHANNEL_CLOSE:"WEBRTC_DATA_CHANNEL_CLOSE",WEBRTC_DATA_CHANNEL_ERROR:"WEBRTC_DATA_CHANNEL_ERROR",WEBRTC_DATA_CHANNEL_NOT_AVAILABLE:"WEBRTC_DATA_CHANNEL_NOT_AVAILABLE",WEBRTC_DATA_CHANNEL_OPENING:"WEBRTC_DATA_CHANNEL_OPENING",WEBRTC_DATA_CHANNEL_READY:"WEBRTC_DATA_CHANNEL_READY",WEBRTC_DATA_CHANNEL_SEND_REQUEST_TIMEOUT:"WEBRTC_DATA_CHANNEL_SEND_REQUEST_TIMEOUT",WEBRTC_DATA_CHANNEL_SEND_REQUEST_ERROR:"WEBRTC_DATA_CHANNEL_SEND_REQUEST_ERROR",WEBRTC_DATA_CHANNEL_TIMEOUT:"WEBRTC_DATA_CHANNEL_TIMEOUT",WEBRTC_HTTPS_RESPONSE_ERROR:"WEBRTC_HTTPS_RESPONSE_ERROR",WEBRTC_HTTPS_SENDING:"WEBRTC_HTTPS_SENDING",WEBRTC_HTTPS_SEND_ERROR:"WEBRTC_HTTPS_SEND_ERROR",WEBRTC_ICE_CANDIDATE:"WEBRTC_ICE_CANDIDATE",WEBRTC_ICE_CANDIDATE_SEND_UNSUPPORTED:"WEBRTC_ICE_CANDIDATE_SEND_UNSUPPORTED",WEBRTC_ICE_CANDIDATE_SENDING:"WEBRTC_ICE_CANDIDATE_SENDING",WEBRTC_ICE_CANDIDATES_GATHERED:"WEBRTC_ICE_CANDIDATES_GATHERED",WEBRTC_ICE_CONNECTION_STATE:"WEBRTC_ICE_CONNECTION_STATE",WEBRTC_ICE_CONNECTION_STATE_ERROR:"WEBRTC_ICE_CONNECTION_STATE_ERROR",WEBRTC_ICE_GATHERING_STATE:"WEBRTC_ICE_GATHERING_STATE",WEBRTC_NEGOTIATION_NEEDED:"WEBRTC_NEGOTIATION_NEEDED",WEBRTC_NOT_CONNECTED:"WEBRTC_NOT_CONNECTED",WEBRTC_NOT_INITIALIZED:"WEBRTC_NOT_INITIALIZED",WEBRTC_TURN_CREDENTIALS:"WEBRTC_TURN_CREDENTIALS",WEBRTC_WS_ACTION_TIMEOUT:"WEBRTC_WS_ACTION_TIMEOUT",WEBRTC_WS_SENDING:"WEBRTC_WS_SENDING",WEBRTC_CLOSED:"WEBRTC_CLOSED",WEBRTC_AWS_SENDING:"WEBRTC_AWS_SENDING",WEBRTC_AWS_ACTION_TIMEOUT:"WEBRTC_AWS_ACTION_TIMEOUT",WEBRTC_AWS_SUBSCRIBE_ERROR:"WEBRTC_AWS_SUBSCRIBE_ERROR",WEBRTC_DATA_BEGINNING:"WEBRTC_DATA_BEGINNING",WEBRTC_DATA_BUFFER_WRITE:"WEBRTC_DATA_BUFFER_WRITE",WEBRTC_DATA_EVENT:"WEBRTC_DATA_EVENT",WEBRTC_DATA_EVENT_PROCESS:"WEBRTC_DATA_EVENT_PROCESS",WEBRTC_DATA_RECEIVED:"WEBRTC_DATA_RECEIVED",WEBRTC_DATA_RECEIVE_ERROR:"WEBRTC_DATA_RECEIVE_ERROR",WEBRTC_DATA_RECEIVED_API_RESPONSE:"WEBRTC_DATA_RECEIVED_API_RESPONSE",WEBRTC_DATA_RECEIVED_MESSAGE:"WEBRTC_DATA_RECEIVED_MESSAGE",WEBRTC_DATA_SENDING:"WEBRTC_DATA_SENDING",WEBRTC_DATA_SENDING_API_REQUEST:"WEBRTC_DATA_SENDING_API_REQUEST",WEBRTC_DATA_NO_PENDING_PROMISE_OR_ONMESSAGE_CALLBACK:"WEBRTC_DATA_NO_PENDING_PROMISE_OR_ONMESSAGE_CALLBACK"}},{}],52:[function(e,t,n){"use strict";t.exports={REQUEST_TIMEOUT:6e4,PING_INTERVAL:45e3,PONG_TIMEOUT:2e4}},{}],53:[function(e,t,n){"use strict";t.exports={convert:function(e){for(var t=new DataView(e),n=new Uint8Array(e.byteLength),r=n.length,i=0;i<r;i++)n[i]=t.getUint8(i);return n}}},{}],54:[function(e,t,n){"use strict";t.exports={convert:function(e){for(var t=0,n=0;n<e.length;n++)t+=Math.pow(256,e.length-n-1)*e[n];return t}}},{}],55:[function(e,t,n){"use strict";t.exports={convert:function e(t){if(!function(e){return null!==e&&"object"==typeof e}(t))return null===t?"":t.toString();var n,r,i,o,s,a,c="";for(n in t)if(t.hasOwnProperty(n))if((r=t[n])instanceof Array)for(a in r)r.hasOwnProperty(a)&&(o=r[a],(s={})[n+"["+a+"]"]=o,c+=e(s)+"&");else if(r instanceof Object)for(i in r)r.hasOwnProperty(i)&&(o=r[i],(s={})[n+"["+i+"]"]=o,c+=e(s)+"&");else void 0!==r&&null!==r&&(c+=encodeURIComponent(n)+"="+encodeURIComponent(r)+"&");return c.length?c.substr(0,c.length-1):c}}},{}],56:[function(e,t,n){"use strict";t.exports={convert:function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):(n++,r=65536+((1023&r)<<10|1023&e.charCodeAt(n)),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r))}return t}}},{}],57:[function(e,t,n){"use strict";t.exports={convert:function(e){return(new TextDecoder).decode(e)}}},{}],58:[function(e,t,n){"use strict";t.exports={convert:function(e,t){for(var n=new ArrayBuffer(t),r=new Uint8Array(n),i=e,o=t-1;o>=0;--o){r[o]=255&i;for(var s=0;s<8;++s)i/=2}return r}}},{}],59:[function(e,t,n){"use strict";t.exports=function(){if("undefined"!=typeof Promise&&Promise.defer)return Promise.defer();this.resolve=null,this.reject=null,this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),Object.freeze(this)}},{}],60:[function(e,t,n){"use strict";t.exports=function(e,t){e.forEach(function(e){if(void 0===t[e]){var n="Option `"+e+"` is required.";throw console.error(n),new Error(n)}})}},{}],61:[function(e,t,n){"use strict";t.exports={uuid:function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}}},{}],62:[function(e,t,n){"use strict";t.exports={factory:function(){var t=e("./SignallingChannelAWSConnector"),n=e("./SignallingChannelWsConnector"),r=e("./SignallingChannelHttpsConnector");function i(e){this.config=e,this.connector=null}return i.connectorFactory=function(e){switch(e.type){case"WS":return new n(e);case"HTTPS":return new r(e);case"AWS":return new t(e);default:var i="Unknown connector type: "+e.type;throw console.error(i),new Error(i)}},i.prototype.open=function(e){return this.connector||(this.connector=i.connectorFactory(this.config)),this.connector.connect(e)},i.prototype.close=function(){this.connector.close()},i.prototype.requestSdpOffer=function(e){return this.sendActionRequest("sdp_exchange",{device_id:e.deviceId,payload:{password:e.turnCredentials.credential,stunUri:e.stunUri,ttl:e.turnCredentials.ttl,turnUri:e.turnUri,type:"OFFER",username:e.turnCredentials.username}})},i.prototype.sendSdpOffer=function(e){return this.sendActionRequest("sdp_exchange",{device_id:e.deviceId,payload:{password:e.turnCredentials.credential,sdpOffer:e.sdp,stunUri:e.stunUri,ttl:e.turnCredentials.ttl,turnUri:e.turnUri,type:"OFFER",username:e.turnCredentials.username}})},i.prototype.sendSdpAnswer=function(e){return this.sendActionRequest("sdp_exchange",{device_id:e.deviceId,payload:{sdpAnswer:e.sdp,type:"ANSWER",webRtcId:e.webRtcId}})},i.prototype.sendActionRequest=function(e,t){return this.connector.sendActionRequest(e,t)},i.prototype.sendIceCandidate=function(e,t){throw console.error("Not implemented yet."),new Error("Not implemented yet.")},i.prototype.closeSession=function(e){this.connector.close()},i}}},{"./SignallingChannelAWSConnector":63,"./SignallingChannelHttpsConnector":64,"./SignallingChannelWsConnector":65}],63:[function(e,t,n){"use strict";var r=e("../deferred"),i=e("../../constants/webrtcEvents"),o=e("../../constants/webrtcMessages"),s=e("../../constants/ws"),a=e("../../service/provider"),c=a.get("eventBusService"),u=a.get("loggerService"),l=e("../uuidGenerator"),f=e("aws-iot-device-sdk/device"),h=e("aws-api-gateway-client").default,p=function(){this.pendingRequests={},this.init()};p.prototype.init=function(){this.apigClient=null,this.awsIotClient=null,this.identityId=null,this.credentials=null,this.connectivityDetails=null},p.prototype.makeSureIsConnected=function(){return this.awsIotClient||this.close(),this.connect()},p.prototype.connect=function(e){return this.awsIotClient?window.Promise.resolve(this):(c.emit(i.WEBRTC_AWS_OPENING),u.info(i.WEBRTC_AWS_OPENING),this.configure(e),this.createApiGatewayClient(),this.mqttConnect())},p.prototype.configure=function(e){this.connectivityDetails=e.connectivityDetails,this.identityId=e.credentials.identityId,this.credentials={AccessKeyId:e.credentials.accessKeyId,SecretAccessKey:e.credentials.secretKey,SessionToken:e.credentials.sessionToken,region:e.credentials.region}},p.prototype.createApiGatewayClient=function(){c.emit(i.WEBRTC_CREATING_API_GATEWAY_CLIENT),u.info(i.WEBRTC_CREATING_API_GATEWAY_CLIENT),this.apigClient=h.newClient({accessKey:this.credentials.AccessKeyId,secretKey:this.credentials.SecretAccessKey,sessionToken:this.credentials.SessionToken,region:this.credentials.region||this.connectivityDetails.unifiCloudAccess.region,invokeUrl:this.connectivityDetails.unifiCloudAccess.apiGatewayUI.url})},p.prototype.mqttConnect=function(){var e=new r;return c.emit(i.WEBRTC_AWS_IOT_CONNECTING),u.info(i.WEBRTC_AWS_IOT_CONNECTING),this.awsIotClient=f({region:this.connectivityDetails.unifiCloudAccess.region,host:this.connectivityDetails.unifiCloudAccess.iot.host,protocol:"wss",accessKeyId:this.credentials.AccessKeyId,secretKey:this.credentials.SecretAccessKey,sessionToken:this.credentials.SessionToken}),this.awsIotClient.on("connect",function(){c.emit(i.WEBRTC_AWS_CONNECTED,this.connectivityDetails.unifiCloudAccess.iot.host),u.info(i.WEBRTC_AWS_CONNECTED,this.connectivityDetails.unifiCloudAccess.iot.host),e.resolve(this)}.bind(this)),this.awsIotClient.on("close",function(){c.emit(i.WEBRTC_AWS_CLOSED),u.info(i.WEBRTC_AWS_CLOSED),this.close()}.bind(this)),this.awsIotClient.on("error",function(t){c.emit(i.WEBRTC_AWS_OPENING_ERROR,t),u.error(i.WEBRTC_AWS_OPENING_ERROR,t),e.reject(i.WEBRTC_AWS_OPENING_ERROR),this.close()}.bind(this)),this.awsIotClient.on("offline",function(t){c.emit(i.WEBRTC_AWS_OPENING_ERROR,t),u.error(i.WEBRTC_AWS_OPENING_ERROR,t),e.reject(i.WEBRTC_AWS_OPENING_ERROR),this.close()}.bind(this)),this.awsIotClient.on("message",this.onMessage.bind(this)),e.promise},p.prototype.send=function(e){return this.makeSureIsConnected().then(function(){var t="client/"+this.identityId+"/"+e.deviceId;return this.awsIotClient.subscribe(t,{},function(e){e&&u.warn(o.WEBRTC_AWS_SUBSCRIBE_ERROR,e)}),u.debug(o.WEBRTC_AWS_SENDING,e),this.apigClient.invokeApi({},"/post-message","POST",{},e)}.bind(this))},p.prototype.sendAction=function(e,t,n){var i=l.uuid(),a=new r,c=Object.assign({cmd:e,deviceId:t.device_id,requestId:i},t);return this.pendingRequests[i]={requiresResponse:n,deferred:a,timeout:setTimeout(function(){u.warn(o.WEBRTC_AWS_ACTION_TIMEOUT,c),a.reject(o.WEBRTC_AWS_ACTION_TIMEOUT)}.bind(this),s.REQUEST_TIMEOUT)},this.send(c).then(function(){return a.promise})},p.prototype.sendActionRequest=function(e,t){return this.sendAction(e,t,!0)},p.prototype.onMessage=function(e,t){var n=new TextDecoder("utf-8").decode(t),r=JSON.parse(n),i=r.requestId,o=this.pendingRequests[i];o&&(clearTimeout(o.timeout),o.deferred.resolve(r),delete this.pendingRequests[i])},p.prototype.close=function(){this.awsIotClient&&(this.awsIotClient.end(),this.awsIotClient=null)},t.exports=p},{"../../constants/webrtcEvents":50,"../../constants/webrtcMessages":51,"../../constants/ws":52,"../../service/provider":72,"../deferred":59,"../uuidGenerator":61,"aws-api-gateway-client":1,"aws-iot-device-sdk/device":9}],64:[function(e,t,n){"use strict";var r=e("../deferred"),i=e("../../constants/webrtcMessages"),o=e("../../service/provider").get("loggerService"),s=e("../utils/checkRequiredOptions"),a=function(e){s(a.REQUIRED_CONFIG_OPTIONS,e),this.uri=e.host+e.endpoint};a.REQUIRED_CONFIG_OPTIONS=["host","endpoint"],a.prototype.connect=function(){return window.Promise.resolve(this)},a.prototype.close=function(){},a.prototype.send=function(e){o.debug(i.WEBRTC_HTTPS_SENDING,e);var t=new r,n=new XMLHttpRequest;return n.addEventListener("load",function(e){try{var n=JSON.parse(e.currentTarget.response);n.error?t.reject(n.error):t.resolve(n)}catch(e){o.warn(i.WEBRTC_HTTPS_RESPONSE_ERROR,e),t.reject(i.WEBRTC_HTTPS_RESPONSE_ERROR)}},!1),n.addEventListener("error",function(e,n,r){o.error(i.WEBRTC_HTTPS_SEND_ERROR,r),t.reject(i.WEBRTC_HTTPS_SEND_ERROR)},!1),n.open("POST",this.uri),n.withCredentials=!0,n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(e)),t.promise},a.prototype.sendActionRequest=function(e,t){var n=Object.assign({action:e},t);return this.send(n)},t.exports=a},{"../../constants/webrtcMessages":51,"../../service/provider":72,"../deferred":59,"../utils/checkRequiredOptions":60}],65:[function(e,t,n){"use strict";var r=e("../deferred"),i=e("../../constants/webrtcEvents"),o=e("../../constants/webrtcMessages"),s=e("../../constants/ws"),a=e("../../service/provider"),c=a.get("eventBusService"),u=a.get("loggerService"),l=e("../utils/checkRequiredOptions"),f=e("../uuidGenerator"),h=function(e){l(h.REQUIRED_CONFIG_OPTIONS,e),this.actions={},this.uri=e.host+e.endpoint,this.pingTimer=null,this.pongTimer=null,this.ws=null};h.REQUIRED_CONFIG_OPTIONS=["host","endpoint"],h.prototype.makeSureIsConnected=function(){return this.ws&&-1!==[this.ws.CLOSING,this.ws.CLOSED].indexOf(this.ws.readyState)&&this.close(),this.connect()},h.prototype.connect=function(){if(this.ws)return window.Promise.resolve(this);var e=new r;return c.emit(i.WEBRTC_WS_OPENING,this.uri),u.info(i.WEBRTC_WS_OPENING,this.uri),this.ws=new WebSocket(this.uri),this.ws.onmessage=this.onMessage.bind(this),this.ws.onopen=function(){c.emit(i.WEBRTC_WS_CONNECTED,this.uri),u.info(i.WEBRTC_WS_CONNECTED,this.uri),setTimeout(this.ping.bind(this),s.PING_INTERVAL),e.resolve(this)}.bind(this),this.ws.onclose=function(){c.emit(i.WEBRTC_WS_CLOSED),u.info(i.WEBRTC_WS_CLOSED),this.close()}.bind(this),this.ws.onerror=function(t){c.emit(i.WEBRTC_WS_OPENING_ERROR,t),u.error(i.WEBRTC_WS_OPENING_ERROR,t),e.reject(i.WEBRTC_WS_OPENING_ERROR),this.close()}.bind(this),e.promise},h.prototype.close=function(){this.ws&&(this.ws.close(),this.ws=null),clearTimeout(this.pongTimer),clearTimeout(this.pingTimer)},h.prototype.send=function(e){return this.makeSureIsConnected().then(function(){return u.debug(o.WEBRTC_WS_SENDING,e),this.ws.send(JSON.stringify(e)),!0}.bind(this))},h.prototype.sendAction=function(e,t,n){var i=f.uuid(),a=new r,c={message:"action:request",action:e,action_id:i,args:t};return this.actions[i]={requiresResponse:n,deferred:a,timeout:setTimeout(function(){u.warn(o.WEBRTC_WS_ACTION_TIMEOUT,c),a.reject(o.WEBRTC_WS_ACTION_TIMEOUT)}.bind(this),s.REQUEST_TIMEOUT)},this.send(c).then(function(){return a.promise})},h.prototype.sendActionRequest=function(e,t){return this.sendAction(e,t,!0)},h.prototype.ping=function(){this.makeSureIsConnected().then(function(){this.ws.send("ping"),this.pongTimer=setTimeout(this.makeSureIsConnected.bind(this),s.PONG_TIMEOUT)}.bind(this))},h.prototype.onActionMessage=function(e){var t=this.actions[e.action_id];"action:response"!==e.message&&"action:validation"!==e.message&&"action:error"!==e.message&&this.actions[e.action_id].requiresResponse||("action:response"===e.message?(delete this.actions[e.action_id],clearTimeout(t.timeout),t.deferred.resolve(e.response)):"action:validation"===e.message?e.errors&&(delete this.actions[e.action_id],clearTimeout(t.timeout),t.deferred.reject(e.errors)):"action:error"===e.message?(delete this.actions[e.action_id],clearTimeout(t.timeout),t.deferred.reject(e.error)):(delete this.actions[e.action_id],clearTimeout(t.timeout),t.deferred.resolve()))},h.prototype.onMessage=function(e){var t;if("pong"===e.data)return clearTimeout(this.pongTimer),void(this.pingTimer=setTimeout(this.ping.bind(this),s.PING_INTERVAL));(t=JSON.parse(e.data)).message&&this.actions[t.action_id]&&this.onActionMessage(t)},t.exports=h},{"../../constants/webrtcEvents":50,"../../constants/webrtcMessages":51,"../../constants/ws":52,"../../service/provider":72,"../deferred":59,"../utils/checkRequiredOptions":60,"../uuidGenerator":61}],66:[function(e,t,n){"use strict";var r=e("../deferred"),i=e("../../service/provider"),o=i.get("timeoutService"),s=i.get("loggerService"),a=e("../../constants/webrtc"),c=e("../../constants/webrtcMessages"),u=65450;u-=u%3;var l=e("../converters/arrayBufferToUint8Array"),f=e("../converters/byteArrayToValue"),h=e("../converters/params"),p=e("../converters/stringToUTF8Array"),d=e("../converters/uint8ArrayToBinary"),_=e("../converters/valueToUint8Array");function g(e,t){if(void 0===e)throw new Error("RTCDataChannel cannot be undefined.");this.channelLabel=e.label+"_"+e.id,this.rtcDataChannel=e,this.parser=t,this.pendingRequests={},this.WEBRTC_MESSAGE_ID=1,this._messageOffset=0,this._messageSize=0,this._messageBuffer=null,this.onmessageCallback=null,this.oncloseCallback=null,this.promiseQueue=[],this.deferredCloseChannel=null,this.init()}g.prototype.init=function(){this.rtcDataChannel.onmessage=this.handleChannelMessage.bind(this),this.rtcDataChannel.onclose=this.handleChannelClose.bind(this)},g.prototype.close=function(){return this.deferredCloseChannel=new r,"closed"!==this.rtcDataChannel.readyState&&this.rtcDataChannel.close(),this.deferredCloseChannel.promise},g.prototype.handleChannelMessage=function(e){this.scheduleMessageHandling(this.handleMessageChain.bind(this,e))},g.prototype.scheduleMessageHandling=function(e){var t=this.promiseQueue[this.promiseQueue.length-1];t||(t=window.Promise.resolve());var n=t.then(function(){return e()}).then(function(){this.promiseQueue.shift()}.bind(this));return this.promiseQueue.push(n),n},g.prototype.handleMessageChain=function(e){var t=e.target.label+"_"+e.target.id,n=new r;return this.convertEventToData(e).then(function(e){this.parser?this.customHandleChannelMessageData(t,e):this.handleChannelMessageData(t,e)}.bind(this)).then(function(){n.resolve()}),n.promise},g.prototype.customHandleChannelMessageData=function(e,t){var n=this.parser(e,t);this.onmessageCallback&&this.onmessageCallback(n)},g.prototype.handleChannelClose=function(e){s.debug(c.WEBRTC_DATA_CHANNEL_CLOSE,"channel:"+this.channelLabel,e),Object.keys(this.pendingRequests).forEach(function(e){this.pendingRequests[e].reject(c.WEBRTC_DATA_CHANNEL_SEND_REQUEST_ERROR)}.bind(this)),this.onmessageCallback=null,this.oncloseCallback&&(this.oncloseCallback(e),this.oncloseCallback=null),this.deferredCloseChannel&&this.deferredCloseChannel.resolve(c.WEBRTC_DATA_CHANNEL_CLOSE,"channel:"+this.channelLabel,e)},g.prototype.convertEventToData=function(e){var t=new r;if(e.data instanceof Blob){var n=new FileReader;n.onload=function(){t.resolve(this.result)},n.onerror=function(e){t.reject(e)},n.readAsArrayBuffer(e.data)}else t.resolve(e.data);return t.promise},g.prototype.handleChannelMessageData=function(e,t){var n=t.byteLength?t.byteLength:t.size||0,r=0;for(s.debug(c.WEBRTC_DATA_EVENT,"channel:"+this.channelLabel,"event size: "+n);r<n;){s.debug(c.WEBRTC_DATA_EVENT_PROCESS,"channel:"+this.channelLabel,"event data offset: "+r,"event data size: "+n),this._messageBuffer||(this._messageSize=f.convert(new Uint8Array(t,r,4)),this._messageOffset=0,this._messageBuffer=new Uint8Array(this._messageSize),r+=4);var i=Math.min(this._messageSize-this._messageOffset,n-r),o=new Uint8Array(t,r,i);try{if(s.debug(c.WEBRTC_DATA_BUFFER_WRITE,"channel:"+this.channelLabel,"message size: "+this._messageSize,"message offset: "+this._messageOffset,"message chunk size: "+i,"buffer capacity: "+this._messageBuffer.byteLength),this._messageBuffer.set(o,this._messageOffset),this._messageOffset+=i,r+=i,s.debug(c.WEBRTC_DATA_RECEIVED,"channel:"+this.channelLabel,"message size: "+this._messageSize,"message received: "+this._messageSize,"message left: "+(this._messageSize-this._messageOffset)),this._messageOffset>=this._messageSize)this.handleWebRtcResponse(this._messageBuffer),this._messageBuffer=null;else{var a=this.parseWebRtcResponseId(this._messageBuffer);this.setRequestTimeout(this.pendingRequests[a])}}catch(e){this._messageBuffer=null,this.close();break}}},g.prototype.setRequestTimeout=function(e){e&&(e.timeout&&o.cancel(e.timeout),e.timeout=o(function(){s.error(c.WEBRTC_DATA_CHANNEL_SEND_REQUEST_TIMEOUT,"messageId:"+e.id,"channel:"+this.channelLabel),e.reject(c.WEBRTC_DATA_CHANNEL_SEND_REQUEST_TIMEOUT),this.close()}.bind(this),e.timeoutParam||a.DATA_CHANNEL_SEND_REQUEST_TIMEOUT))},g.prototype.sendBinaryApiRequest=function(e,t,n,r){var i,a,f,h,d,g,v,m,y=JSON.stringify(t),E=y.length,b=0,C=u-E;!n||n instanceof ArrayBuffer||"string"==typeof n||(n=JSON.stringify(n)),f=typeof n,r||"string"!==f||(n=Array.from(n||"").reduce(function(e,t){return e.concat(p.convert(t))},[])),r&&(n=atob(n.slice(n.indexOf(",")+1))),a=n?n.length||n.byteLength:0;var w=function(){var t=this.pendingRequests[e];for(this.setRequestTimeout(t),v=n?n.slice(b,b+C):null,m=v?v.length||v.byteLength:0,h=12+E+a,d=new ArrayBuffer(4+(12+E+m)),(g=new Uint8Array(d)).set(_.convert(h,4),0),g.set(_.convert(e,8),4),g.set(_.convert(E,4),12),i=0;i<E;i++)g[i+16]=y.charCodeAt(i);if(v)if(r)for(i=0;i<a;i++)g[i+16+E]=v.charCodeAt(i);else if("string"===f)for(i=0;i<a;i++)g[i+16+E]=v[i];else g.set(l.convert(v),16+E);s.debug(c.WEBRTC_DATA_SENDING,"messageId:"+e,"channel:"+this.channelLabel,"bytes to send "+h),this.send(d),a-=m,b+=m,T()}.bind(this),T=function(e){(e||a>0)&&o(w,15)}.bind(this);T(!0)},g.prototype.send=function(e){return this.rtcDataChannel.send(e),window.Promise.resolve()},g.prototype.sendApiRequest=function(e,t){var n=Object.assign({},t);e.startsWith("/upload")&&(n.data=null,delete n.data);var i,o=this.WEBRTC_MESSAGE_ID++,a=new r,u=(t=t||{}).type||t.method;i={path:e,method:u?u.toUpperCase():"GET",contentType:t.contentType};var l=function(r){this.pendingRequests[o]={id:o,resolve:a.resolve,reject:a.reject,success:t.success,error:t.error,timeoutParam:t.timeout,headers:i},i["Accept-Encoding"]="gzip",s.debug(c.WEBRTC_DATA_SENDING_API_REQUEST,this.channelLabel,o,i.method,e,"length: "+(r&&r.length?r.length:0),n),this.sendBinaryApiRequest(o,i,r,t.convertToBinary)}.bind(this);switch(i.method){case"GET":case"DELETE":var f=e.split("?");f.length>1?(i.path=f[0],i.queryString=f[1]):t.data&&(i.queryString=h.convert(t.data)),l();break;default:if(t.data&&l(t.data),t.file){var p=new FileReader;p.readAsArrayBuffer(t.file),p.onload=function(){i.filename=t.file.name,i.contentType=t.file.type,l(p.result)}}}return a.promise},g.prototype.parseWebRtcResponseId=function(e){return f.convert(e.subarray(0,8))},g.prototype.parseWebRtcResponse=function(e){var t=f.convert(e.subarray(8,12)),n=JSON.parse(String.fromCharCode.apply(null,e.subarray(12,12+t)));return n.id=f.convert(e.subarray(0,8)),n.content=e.subarray(12+t),n},g.prototype.handleWebRtcResponse=function(e){var t=this.parseWebRtcResponse(e);"gzip"===t["Content-Encoding"]&&(t.content=window.pako.inflate(t.content));var n,r,i=this.pendingRequests[t.id];switch(t.contentType){case"application/json":var a=Object.assign({},t);delete a.content,delete a.headers,delete a.contentType,delete a.statusCode,delete a.contentType,delete a["content-type"],r=n={contentType:t.contentType,"content-type":t["content-type"],headers:t.headers,status:t.statusCode,data:JSON.parse(d.convert(t.content)),msg:t.msg};break;case"application/octet-stream":n={arraybuffer:t.content};break;default:var u=new Blob([t.content],{type:t.contentType});n=window.URL.createObjectURL(u)}i?(delete this.pendingRequests[t.id],o.cancel(i.timeout),s.debug(c.WEBRTC_DATA_RECEIVED_API_RESPONSE,"channel:"+this.channelLabel,"responseId:"+t.id,i?"for "+i.headers.method+" "+i.headers.path:"","length "+(t.content&&t.content.length?t.content.length:0)+" bytes.",r),t.statusCode>=200&&t.statusCode<300?i.resolve(n):i.reject(n)):this.onmessageCallback?(this.onmessageCallback(n),s.debug(c.WEBRTC_DATA_RECEIVED_MESSAGE,"channel:"+this.channelLabel," length "+(t.content&&t.content.length?t.content.length:0)+" bytes.",r)):s.error(c.WEBRTC_DATA_NO_PENDING_PROMISE_OR_ONMESSAGE_CALLBACK,"channel:"+this.channelLabel,"responseId:"+t.id,r)},t.exports=g},{"../../constants/webrtc":49,"../../constants/webrtcMessages":51,"../../service/provider":72,"../converters/arrayBufferToUint8Array":53,"../converters/byteArrayToValue":54,"../converters/params":55,"../converters/stringToUTF8Array":56,"../converters/uint8ArrayToBinary":57,"../converters/valueToUint8Array":58,"../deferred":59}],67:[function(e,t,n){"use strict";t.exports={factory:function(t){var n=(t=t||{}).provider||e("../../service/provider"),r=n.get("eventBusService"),i=n.get("loggerService"),o=t.checkRequiredOptions||e("./../utils/checkRequiredOptions"),s=t.WebRtcPeer||e("./WebRtcPeer"),a=t.WEBRTC_EVENTS||e("../../constants/webrtcEvents"),c=t.WEBRTC_MESSAGES||e("../../constants/webrtcMessages");function u(e){this.reconfigure(e)}return u.REQUIRED_CONFIG_OPTIONS=["signallingChannel","startAsCaller"],u.prototype.reconfigure=function(e){o(u.REQUIRED_CONFIG_OPTIONS,e),this.config=e,this.signallingChannel&&this.signallingChannel.close(),this.signallingChannel=e.signallingChannel,this.eventBusService=e.eventBusService||r,this.p2pConnector&&this.p2pConnector.close(),this.connected=!1,this.onMessageCallbacks={}},u.prototype.establishConnection=function(e){return this.tryOpenConnection(e,this.config.numberOfRetries)},u.prototype.tryOpenConnection=function(e,t){return this.openConnection(e).catch(function(n){return t>0?(this.eventBusService.emit(a.WEBRTC_RETRY_CONNECTION,t),i.warn(a.WEBRTC_RETRY_CONNECTION,t),t--,this.tryOpenConnection(e,t)):window.Promise.reject(n)}.bind(this))},u.prototype.reconnect=function(e,t,n){this.eventBusService.emit(a.WEBRTC_RECONNECTING),i.warn(a.WEBRTC_RECONNECTING),this.establishConnection(e).then(this.reassignOnMessageCallbacks.bind(this)).then(function(){this.eventBusService.emit(a.WEBRTC_RECONNECTED),i.info(a.WEBRTC_RECONNECTED)}.bind(this)).catch(function(){var r=(n||1)+(t||1),i=1e3*Math.min(r,this.config.autoReconnectMinDelay||60);this.eventBusService.emit(a.WEBRTC_WILL_RECONNECT_ON,Date.now()+i),setTimeout(function(){this.reconnect(e,r,t)}.bind(this),i)}.bind(this))},u.prototype.openConnection=function(e){return o(u.REQUIRED_CONNECTION_OPTIONS,e),this.p2pConnector=new s(this.signallingChannel,this.eventBusService,{channelNames:e.channelNames&&e.channelNames.length>0?e.channelNames:["__empty__"],turnCredentials:Object.assign({},e.turnCredentials),ondatachannel:this.config.ondatachannel,dataChannelOptions:e.dataChannelOptions,oncloseCallback:this.config.autoReconnect?function(){this.reconnect(e)}.bind(this):function(){}}),this.signallingChannel.open(e).then(function(){var t=this.config.startAsCaller?"startAsCaller":"startAsCalled";return this.p2pConnector[t](e.deviceId)}.bind(this)).then(function(){return this.eventBusService.emit(a.WEBRTC_CONNECTED,this.p2pConnector),i.info(a.WEBRTC_CONNECTED,this.p2pConnector),this.signallingChannel.close(),this.connected=!0,this.p2pConnector}.bind(this)).catch(this.mapOfflineError.bind(this,e.deviceId)).catch(function(e){return this.eventBusService.emit(a.WEBRTC_CONNECTION_ERROR,e),i.error(a.WEBRTC_CONNECTION_ERROR,e),this.signallingChannel.close(),this.connected=!1,window.Promise.reject(e)}.bind(this))},u.REQUIRED_CONNECTION_OPTIONS=["deviceId","turnCredentials"],u.prototype.mapOfflineError=function(e,t){if(t){var n=t[0]&&"device_offline"===t[0].error_code,r=t.response&&t.response.data&&"Device offline"===t.response.data.exception;if("offline"===t||n||r)return this.eventBusService.emit(a.WEBRTC_DEVICE_OFFLINE,e),i.error(a.WEBRTC_DEVICE_OFFLINE,e),window.Promise.reject(a.WEBRTC_DEVICE_OFFLINE)}return window.Promise.reject(t)},u.prototype.sendApiRequest=function(e,t){return this.connected?this.p2pConnector.sendApiRequest(e,t):window.Promise.reject(c.WEBRTC_NOT_CONNECTED)},u.prototype.send=function(e,t){return this.connected?this.p2pConnector.send(e,t):window.Promise.reject(c.WEBRTC_NOT_CONNECTED)},u.prototype.openChannel=function(e,t){return this.p2pConnector?this.p2pConnector.openChannel(e,t):window.Promise.reject(c.WEBRTC_NOT_INITIALIZED)},u.prototype.closeChannel=function(e){return this.p2pConnector?this.p2pConnector.closeChannel(e):c.WEBRTC_NOT_INITIALIZED},u.prototype.on=function(e,t){return this.onMessageCallbacks[e]=t,this.p2pConnector?(this.p2pConnector.on(e,t),!0):c.WEBRTC_NOT_INITIALIZED},u.prototype.reassignOnMessageCallbacks=function(){Object.keys(this.onMessageCallbacks).forEach(function(e){this.on(e,this.onMessageCallbacks[e])}.bind(this))},u.prototype.getLogger=function(){return i},u.prototype.sendSignallingAction=function(e,t){return this.signallingChannel.open().then(function(){return this.signallingChannel.sendActionRequest(e,t)}.bind(this))},u.prototype.close=function(){this.signallingChannel.closeSession(),this.p2pConnector.close()},u}}},{"../../constants/webrtcEvents":50,"../../constants/webrtcMessages":51,"../../service/provider":72,"./../utils/checkRequiredOptions":60,"./WebRtcPeer":68}],68:[function(e,t,n){"use strict";var r=e("../deferred"),i=e("../../constants/webrtc"),o=e("../../constants/webrtcEvents"),s=e("../../constants/webrtcMessages"),a=e("../../service/provider"),c=a.get("loggerService"),u=a.get("timeoutService"),l=e("./WebRtcChannel"),f=e("./../utils/checkRequiredOptions"),h=function(e,t,n){f(h.REQUIRED_CONFIG_OPTIONS,n),this.channels={},this.apiChannels=[],this.apiChannelsCounter=0,this.config=n,this.deferredConnection=null,this.deferredGatheringIceCandidates=null,this.deviceId=null,this.signallingChannel=e,this.eventBusService=t,this.stunHost=null,this.turnHost=null,this.init()};function p(e){return e.label+"_"+e.id}h.REQUIRED_CONFIG_OPTIONS=["turnCredentials"],h.prototype.init=function(){this.printMaskedTurnCredentials(this.config.turnCredentials),this.config.turnCredentials&&(this.config.turnCredentials.uris&&(this.config.turnCredentials.urls=[],this.config.turnCredentials.uris.forEach(function(e){e.match("^stun:")&&(this.stunHost=e,this.config.turnCredentials.urls.push(e)),e.match("^turn:")&&e.match("\\?transport=udp")&&(this.turnHost||(this.turnHost=e,this.config.turnCredentials.urls.push(e)))}.bind(this)),delete this.config.turnCredentials.uris),this.config.turnCredentials.password&&(this.config.turnCredentials.credential=this.config.turnCredentials.password,delete this.config.turnCredentials.password)),this.initPeerConnection([this.config.turnCredentials])},h.prototype.printMaskedTurnCredentials=function(e){var t,n=["username","password"];e&&(t=Object.keys(e).reduce(function(t,r){return t[r]=-1!==n.indexOf(r)?"XXXXXXXX":e[r],t},{})),c.info(s.WEBRTC_TURN_CREDENTIALS,t)},h.prototype.initPeerConnection=function(e){this.pc=new window.RTCPeerConnection({iceServers:e},null),this.pc.onicecandidate=this.onIceCandidate.bind(this),this.pc.oniceconnectionstatechange=this.onIceConnectionStateChange.bind(this),this.pc.negotiationneeded=this.onNegotiationNeeded.bind(this),this.pc.ondatachannel=this.config.ondatachannel||this.onDataChannel.bind(this)},h.prototype.onDataChannel=function(e){var t=e.channel,n=t.label,r=this.channels[n];r||(r=new l(t),this.channels[n]=r);var i=this.config.dataChannelOptions;if(i)return i.onMessageCallback&&(r.onmessageCallback=i.onMessageCallback),i.onCloseCallback&&(r.oncloseCallback=i.onCloseCallback),i.parser&&(r.parser=i.parser),i.deferred&&i.deferred.resolve({channel:r,options:i})},h.prototype.onIceCandidate=function(e){c.info(s.WEBRTC_ICE_CANDIDATE,e.candidate),c.info(s.WEBRTC_ICE_GATHERING_STATE,this.pc.iceGatheringState),this.deferredGatheringIceCandidates&&this.delayedCheckIceGatheringState()},h.prototype.isIceCandidateUdp=function(e){return e&&-1===e.candidate.indexOf(" tcp ")},h.prototype.delayedCheckIceGatheringState=function(){u(function(){this.checkIceGatheringState()}.bind(this),i.WAIT_FOR_NEW_ICE_CANDIDATES_DELAY)},h.prototype.checkIceGatheringState=function(){"complete"===this.pc.iceGatheringState&&this.deferredGatheringIceCandidates&&(c.info(s.WEBRTC_ICE_CANDIDATES_GATHERED),this.deferredGatheringIceCandidates.resolve())},h.prototype.onNegotiationNeeded=function(e){c.info(s.WEBRTC_NEGOTIATION_NEEDED,e)},h.prototype.onIceConnectionStateChange=function(e){var t=(this.pc||e.target).iceConnectionState;switch(t){case"new":case"checking":case"closed":case"completed":c.info(s.WEBRTC_ICE_CONNECTION_STATE,t);break;case"connected":c.info(s.WEBRTC_ICE_CONNECTION_STATE,t),this.printStats("debug"),this.deferredConnection&&this.deferredConnection.resolve(t);break;case"disconnected":c.error(s.WEBRTC_ICE_CONNECTION_STATE,t),this.eventBusService.emit(o.WEBRTC_DISCONNECTED),this.close();break;default:this.printStats("info"),c.error(s.WEBRTC_ICE_CONNECTION_STATE_ERROR,t),this.deferredGatheringIceCandidates&&this.deferredGatheringIceCandidates.reject(t),this.deferredConnection&&this.deferredConnection.reject(t)}},h.prototype.printStats=function(e){try{this.pc.getStats().then(function(t){Object.keys(t).forEach(function(n){var r=t[n],i=r.names?r.names():Object.keys(r);c[e]("  "+n+":"),i.forEach(function(t){c[e]("    "+t+" = "+JSON.stringify(r.stat?r.stat(t):r[t]))})})})}catch(e){c.warn("cannot create webrtc stats: "+e)}},h.prototype.onStart=function(e){this.deviceId=e,this.deferredConnection=new r,this.deferredGatheringIceCandidates=new r},h.prototype.startAsCalled=function(e){return this.onStart(e),window.Promise.all([this.waitForConnection(),this.requestSdpOffer().then(this.setRemoteDescription.bind(this)).then(this.createSdpAnswer.bind(this)).then(this.setLocalDescription.bind(this)).then(this.waitForIceCandidates.bind(this)).then(this.sendSdpAnswer.bind(this)).then(this.openChannels.bind(this))])},h.prototype.startAsCaller=function(e){return this.onStart(e),window.Promise.all([this.waitForConnection(),this.openChannels(),this.createSdpOffer().then(this.setLocalDescription.bind(this)).then(this.waitForIceCandidates.bind(this)).then(this.sendSdpOffer.bind(this)).then(this.setRemoteDescription.bind(this))])},h.prototype.requestSdpOffer=function(){return this.eventBusService.emit(o.WEBRTC_SDP_REQUESTING),c.info(o.WEBRTC_SDP_REQUESTING),this.signallingChannel.requestSdpOffer({deviceId:this.deviceId,stunUri:this.stunHost,turnUri:this.turnHost,turnCredentials:this.config.turnCredentials}).then(function(e){return this.eventBusService.emit(o.WEBRTC_SDP_RECEIVED,e),c.info(o.WEBRTC_SDP_RECEIVED,e),this.webRtcId=e.webRtcId,new window.RTCSessionDescription({sdp:e.sdp,type:"offer"})}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_SDP_RECEIVING_ERROR,e),c.info(o.WEBRTC_SDP_RECEIVING_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.setRemoteDescription=function(e){return this.pc.setRemoteDescription(e).then(function(){this.eventBusService.emit(o.WEBRTC_SET_REMOTE_DESCRIPTION,e),c.info(o.WEBRTC_SET_REMOTE_DESCRIPTION,e)}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_SET_REMOTE_DESCRIPTION_ERROR,e),c.error(o.WEBRTC_SET_REMOTE_DESCRIPTION_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.createSdpAnswer=function(){return this.pc.createAnswer().then(function(e){return this.eventBusService.emit(o.WEBRTC_CREATE_ANSWER,e),c.info(o.WEBRTC_CREATE_ANSWER,e),e}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_CREATE_ANSWER_ERROR,e),c.error(o.WEBRTC_CREATE_ANSWER_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.sendSdpAnswer=function(){var e=this.filterOutTcpCandidates(this.pc.localDescription.sdp);return this.eventBusService.emit(o.WEBRTC_SDP_SENDING,e),c.info(o.WEBRTC_SDP_SENDING,e),this.signallingChannel.sendSdpAnswer({deviceId:this.deviceId,sdp:e,stunUri:this.stunHost,turnCredentials:this.config.turnCredentials,turnUri:this.turnHost,webRtcId:this.webRtcId}).then(function(e){this.eventBusService.emit(o.WEBRTC_SDP_SENT,e),c.info(o.WEBRTC_SDP_SENT,e)}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_SDP_SENDING_ERROR),c.error(o.WEBRTC_SDP_SENDING_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.createSdpOffer=function(){return this.pc.createOffer().then(function(e){return this.eventBusService.emit(o.WEBRTC_CREATE_OFFER,e),c.info(o.WEBRTC_CREATE_OFFER,e),e}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_CREATE_OFFER_ERROR,e),c.error(o.WEBRTC_CREATE_OFFER_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.setLocalDescription=function(e){return this.pc.setLocalDescription(e).then(function(){this.eventBusService.emit(o.WEBRTC_SET_LOCAL_DESCRIPTION,e),c.info(o.WEBRTC_SET_LOCAL_DESCRIPTION,e)}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_SET_LOCAL_DESCRIPTION_ERROR,e),c.error(o.WEBRTC_SET_LOCAL_DESCRIPTION_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.waitForIceCandidates=function(){return this.deferredGatheringIceCandidates.promise.then(function(){this.deferredGatheringIceCandidates=null}.bind(this)).catch(function(e){return this.deferredGatheringIceCandidates=null,window.Promise.reject(e)}.bind(this))},h.prototype.sendSdpOffer=function(){var e=this.filterOutTcpCandidates(this.pc.localDescription.sdp);return this.eventBusService.emit(o.WEBRTC_SDP_SENDING,e),c.info(o.WEBRTC_SDP_SENDING,e),this.signallingChannel.sendSdpOffer({deviceId:this.deviceId,sdp:e,stunUri:this.stunHost,turnCredentials:this.config.turnCredentials,turnUri:this.turnHost}).then(function(e){return this.eventBusService.emit(o.WEBRTC_SDP_RECEIVED,e),c.info(o.WEBRTC_SDP_RECEIVED,e),new window.RTCSessionDescription({sdp:e.sdp,type:"answer"})}.bind(this)).catch(function(e){return this.eventBusService.emit(o.WEBRTC_SDP_RECEIVING_ERROR),c.error(o.WEBRTC_SDP_RECEIVING_ERROR,e),window.Promise.reject(e)}.bind(this))},h.prototype.filterOutTcpCandidates=function(e){return e.replace(/a=candidate[^\n]*tcp[^\n]*\n/g,"")},h.prototype.waitForConnection=function(){return this.deferredConnection.promise.then(function(){this.deferredConnection=null}.bind(this)).catch(function(e){return this.deferredConnection=null,window.Promise.reject(e)}.bind(this))},h.prototype.openChannels=function(){this.eventBusService.emit(o.WEBRTC_DATA_CHANNELS_OPEN,this.config.channelNames),c.info(o.WEBRTC_DATA_CHANNELS_OPEN,this.config.channelNames);var e=this.config.channelNames.map(function(e){return this.openChannel(e)}.bind(this));return window.Promise.all(e).then(function(){this.eventBusService.emit(o.WEBRTC_INITIALIZED),c.info(o.WEBRTC_INITIALIZED)}.bind(this))},h.prototype.sendApiRequest=function(e,t){return this.getAvailableApiChannel().then(function(n){return n.sendApiRequest(e,t).then(function(e){return n.isBusy--,e}).catch(function(e){return n.isBusy--,window.Promise.reject(e)})})},h.prototype.send=function(e,t){var n=this.channels[e];return n?n.send(t):window.Promise.reject(new Error("Channel name `"+e+"` is not available."))},h.prototype.createNewApiChannel=function(){var e=this.config.apiChannelName||i.DEFAULT_API_CHANNEL_NAME;return this.apiChannelsCounter++,this.createChannel(e).then(function(e){return this.apiChannels.push(e),e.oncloseCallback=function(t){c.debug(s.WEBRTC_DATA_CHANNEL_CLOSE,e.channelLabel,t);var n=this.apiChannels.indexOf(e);n>=0&&(this.apiChannels.splice(n,1),this.apiChannelsCounter--)}.bind(this),e}.bind(this)).catch(function(e){return this.apiChannelsCounter--,window.Promise.reject(e)}.bind(this))},h.prototype.getAvailableApiChannel=function(){var e=this.getLeastBusyChannel();return!e||e.isBusy&&this.apiChannelsCounter<256?this.createNewApiChannel().then(function(e){return e.isBusy=1,e}):(e.isBusy++,window.Promise.resolve(e))},h.prototype.getLeastBusyChannel=function(){return this.apiChannels.reduce(function(e,t){return!e||t.isBusy<e.isBusy?t:e},null)},h.prototype.closeChannel=function(e){var t=this.channels[e];return t?(delete this.channels[e],t.close()):window.Promise.reject(new Error("Channel name `"+e+"` does not exist."))},h.prototype.openChannel=function(e,t){var n=this.config.apiChannelName||i.DEFAULT_API_CHANNEL_NAME;if(e===n)return c.error(s.WEBRTC_API_CHANNEL_CONFLICT,e),window.Promise.reject(new Error("Channel name `"+e+"` is reserved for API usage."));var r=this.channels[e];return r?window.Promise.resolve(r):this.createChannel(e,t).then(function(t){return this.channels[e]=t,t}.bind(this))},h.prototype.createChannel=function(e,t){c.info(s.WEBRTC_DATA_CHANNEL_OPENING,e);var n=new r;if("closed"===this.pc.signalingState)return c.error(s.WEBRTC_CLOSED,this.pc.signalingState,e),window.Promise.reject(s.WEBRTC_CLOSED);var o=this.pc.createDataChannel(e,{}),a=u(function(){"open"!==o.readyState&&(n.reject(s.WEBRTC_DATA_CHANNEL_TIMEOUT,p(o)),c.error(s.WEBRTC_DATA_CHANNEL_TIMEOUT,p(o)))},i.DATA_CHANNEL_OPEN_TIMEOUT);return o.onopen=function(){u.cancel(a),n.resolve(new l(o,t)),c.info(s.WEBRTC_DATA_CHANNEL_READY,p(o))}.bind(this),o.onerror=function(e){n.reject(s.WEBRTC_DATA_CHANNEL_ERROR,p(o),e),c.error(s.WEBRTC_DATA_CHANNEL_ERROR,p(o),e)},o.onclose=function(e){n.reject(s.WEBRTC_DATA_CHANNEL_CLOSE,p(o),e),c.error(s.WEBRTC_DATA_CHANNEL_CLOSE,p(o),e)},n.promise},h.prototype.on=function(e,t){var n=this.channels[e];n&&(n.onmessageCallback=t)},h.prototype.close=function(){this.pc&&"closed"!==this.pc.signalingState&&(this.eventBusService.emit(o.WEBRTC_CLOSED),c.info(o.WEBRTC_CLOSED),this.pc.close()),this.pc=null,this.config.oncloseCallback&&this.config.oncloseCallback()},t.exports=h},{"../../constants/webrtc":49,"../../constants/webrtcEvents":50,"../../constants/webrtcMessages":51,"../../service/provider":72,"../deferred":59,"./../utils/checkRequiredOptions":60,"./WebRtcChannel":66}],69:[function(e,t,n){"use strict";e("webrtc-adapter");var r=e("./service/provider");function i(){}i.prototype.withTimeoutService=function(e){return this.timeoutService=e,this},i.prototype.withLoggerService=function(e){return this.loggerService=e,this},i.prototype.withEventBusService=function(e){return this.eventBusService=e,this},i.prototype.build=function(){return r.service("timeoutService",this.timeoutService||e("./service/timeout")),r.service("loggerService",this.loggerService||e("./service/logger")),r.service("eventBusService",this.eventBusService||e("./service/eventBus")),{WebRtcConnector:e("./lib/webrtc/WebRtcConnector").factory(),SignallingChannel:e("./lib/webrtc/SignallingChannel").factory()}},t.exports={WEBRTC_EVENTS:e("./constants/webrtcEvents"),WEBRTC_MESSAGES:e("./constants/webrtcMessages"),builder:function(){return new i}}},{"./constants/webrtcEvents":50,"./constants/webrtcMessages":51,"./lib/webrtc/SignallingChannel":62,"./lib/webrtc/WebRtcConnector":67,"./service/eventBus":70,"./service/logger":71,"./service/provider":72,"./service/timeout":73,"webrtc-adapter":224}],70:[function(e,t,n){"use strict";function r(){}r.prototype.emit=function(e,t){},t.exports=new r},{}],71:[function(e,t,n){"use strict";function r(){if(!(this instanceof r))return new r;this.setLevel("info")}r.prototype.debug=function(){this._log("debug",arguments)},r.prototype.info=function(){this._log("info",arguments)},r.prototype.warn=function(){this._log("warn",arguments)},r.prototype.error=function(){this._log("error",arguments)},r.prototype.setLevel=function(e){this._level=e},r.prototype._log=function(e,t){if(r.LEVEL_PRIORITY[e]>=r.LEVEL_PRIORITY[this._level]){var n=this._serializeMessages(Array.prototype.slice.call(t));n.unshift((new Date).toUTCString()),n.unshift(performance.now().toFixed(4)+"ms"),this._print(e,n)}},r.prototype._serializeMessages=function(e){return e.map(function(e){if(e&&("object"!=typeof e||e instanceof Event))return e;if(void 0!==e)try{return JSON.parse(JSON.stringify(e))}catch(e){}})},r.prototype._print=function(e,t){console[e].apply(console,t)},r.LEVEL_PRIORITY={debug:0,info:1,warn:2,error:3},t.exports=new r},{}],72:[function(e,t,n){"use strict";function r(){this.services={}}r.prototype.service=function(e,t){return this.services[e]=t,t},r.prototype.get=function(e){var t=this.services[e];if(void 0===t)throw new Error("Service "+e+" is undefined.");return t},t.exports=new r},{}],73:[function(e,t,n){"use strict";var r=function(){return window.setTimeout.apply(window,arguments)};r.cancel=function(){window.clearTimeout.apply(window,arguments)},t.exports=r},{}],74:[function(e,t,n){(function(e){function t(e){return Object.prototype.toString.call(e)}n.isArray=
// distribute, sublicense, and/or sell copies of the Software, and to permit
function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},n.isBoolean=function(e){return"boolean"==typeof e},n.isNull=function(e){return null===e},n.isNullOrUndefined=function(e){return null==e},n.isNumber=function(e){return"number"==typeof e},n.isString=function(e){return"string"==typeof e},n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=function(e){return void 0===e},n.isRegExp=function(e){return"[object RegExp]"===t(e)},n.isObject=function(e){return"object"==typeof e&&null!==e},n.isDate=function(e){return"[object Date]"===t(e)},n.isError=function(e){return"[object Error]"===t(e)||e instanceof Error},n.isFunction=function(e){return"function"==typeof e},n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../insert-module-globals/node_modules/is-buffer/index.js":154}],75:[function(e,t,n){var r,i;r=this,i=function(){var e=e||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},i=r.lib={},o=i.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)t[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],i=function(t){t=t;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=i(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},f=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(r,l);var f=r.splice(0,c);n.sigBytes-=u}return new s.init(f,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h=(i.Hasher=f.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math);return e},"object"==typeof n?t.exports=n=i():"function"==typeof define&&define.amd?define([],i):r.CryptoJS=i()},{}],76:[function(e,t,n){var r,i;r=this,i=function(e){return e.enc.Hex},"object"==typeof n?t.exports=n=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(r.CryptoJS)},{"./core":75}],77:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{"./core":75,"./hmac":78,"./sha256":79,dup:14}],78:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./core":75,dup:15}],79:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./core":75,dup:16}],80:[function(e,t,n){"use strict";var r,i=e("type/value/is"),o=e("type/value/ensure"),s=e("type/plain-function/ensure"),a=e("es5-ext/object/copy"),c=e("es5-ext/object/normalize-options"),u=e("es5-ext/object/map"),l=Function.prototype.bind,f=Object.defineProperty,h=Object.prototype.hasOwnProperty;r=function(e,t,n){var r,i=o(t)&&s(t.value);return delete(r=a(t)).writable,delete r.value,r.get=function(){return!n.overwriteDefinition&&h.call(this,e)?i:(t.value=l.call(i,n.resolveContext?n.resolveContext(this):this),f(this,e,t),this[e])},r},t.exports=function(e){var t=c(arguments[1]);return i(t.resolveContext)&&s(t.resolveContext),u(e,function(e,n){return r(n,e,t)})}},{"es5-ext/object/copy":104,"es5-ext/object/map":112,"es5-ext/object/normalize-options":113,"type/plain-function/ensure":211,"type/value/ensure":215,"type/value/is":216}],81:[function(e,t,n){"use strict";var r=e("type/value/is"),i=e("type/plain-function/is"),o=e("es5-ext/object/assign"),s=e("es5-ext/object/normalize-options"),a=e("es5-ext/string/#/contains");(t.exports=function(e,t){var n,i,c,u,l;return arguments.length<2||"string"!=typeof e?(u=t,t=e,e=null):u=arguments[2],r(e)?(n=a.call(e,"c"),i=a.call(e,"e"),c=a.call(e,"w")):(n=c=!0,i=!1),l={value:t,configurable:n,enumerable:i,writable:c},u?o(s(u),l):l}).gs=function(e,t,n){var c,u,l,f;return"string"!=typeof e?(l=n,n=t,t=e,e=null):l=arguments[3],r(t)?i(t)?r(n)?i(n)||(l=n,n=void 0):n=void 0:(l=t,t=n=void 0):t=void 0,r(e)?(c=a.call(e,"c"),u=a.call(e,"e")):(c=!0,u=!1),f={get:t,set:n,configurable:c,enumerable:u},l?o(s(l),f):f}},{"es5-ext/object/assign":101,"es5-ext/object/normalize-options":113,"es5-ext/string/#/contains":120,"type/plain-function/is":212,"type/value/is":216}],82:[function(e,t,n){(function(n,r){var i=e("readable-stream"),o=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),u=function(e,t){e._corked?e.once("uncork",t):t()},l=function(e,t){return function(n){n?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},f=function(e,t,n){if(!(this instanceof f))return new f(e,t,n);i.Duplex.call(this,n),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!n||!1!==n.autoDestroy,this._forwardDestroy=!n||!1!==n.destroy,this._forwardEnd=!n||!1!==n.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(f,i.Duplex),f.obj=function(e,t,n){return n||(n={}),n.objectMode=!0,n.highWaterMark=16,new f(e,t,n)},f.prototype.cork=function(){1==++this._corked&&this.emit("cork")},f.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},f.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=o(e,{writable:!0,readable:!1},l(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),r()},this.uncork()}else this.end()},f.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,n=this,r=o(e,{writable:!1,readable:!0},l(this)),s=function(){n._forward()},a=function(){n.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new i.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",s),this._readable2.on("end",a),this._unread=function(){n._readable2.removeListener("readable",s),n._readable2.removeListener("end",a),r()},this._forward()}},f.prototype._read=function(){this._drained=!0,this._forward()},f.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},f.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;n.nextTick(function(){t._destroy(e)})}},f.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},f.prototype._write=function(e,t,n){return this.destroyed?n():this._corked?u(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:n()):n()},f.prototype._finish=function(e){var t=this;this.emit("preend"),u(this,function(){var n,r;n=t._forwardEnd&&t._writable,r=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),u(t,e)},n?n._writableState&&n._writableState.finished?r():n._writableState?n.end(r):(n.end(),r()):r()})},f.prototype.end=function(e,t,n){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(c),i.Writable.prototype.end.call(this,n))},t.exports=f}).call(this,e("_process"),e("buffer").Buffer)},{_process:181,buffer:48,"end-of-stream":83,inherits:153,"readable-stream":197,"stream-shift":202}],83:[function(e,t,n){(function(n){var r=e("once"),i=function(){},o=function(e,t,s){if("function"==typeof t)return o(e,null,t);t||(t={}),s=r(s||i);var a=e._writableState,c=e._readableState,u=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,f=!1,h=function(){e.writable||p()},p=function(){l=!1,u||s.call(e)},d=function(){u=!1,l||s.call(e)},_=function(t){s.call(e,t?new Error("exited with error code: "+t):null)},g=function(t){s.call(e,t)},v=function(){n.nextTick(m)},m=function(){if(!f)return(!u||c&&c.ended&&!c.destroyed)&&(!l||a&&a.ended&&!a.destroyed)?void 0:s.call(e,new Error("premature close"))},y=function(){e.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!a&&(e.on("end",h),e.on("close",h)):(e.on("complete",p),e.on("abort",v),e.req?y():e.on("request",y)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",_),e.on("end",d),e.on("finish",p),!1!==t.error&&e.on("error",g),e.on("close",v),function(){f=!0,e.removeListener("complete",p),e.removeListener("abort",v),e.removeListener("request",y),e.req&&e.req.removeListener("finish",p),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",p),e.removeListener("exit",_),e.removeListener("end",d),e.removeListener("error",g),e.removeListener("close",v)}};t.exports=o}).call(this,e("_process"))},{_process:181,once:178}],84:[function(e,t,n){"use strict";var r=e("../../object/valid-value");t.exports=function(){return r(this).length=0,this}},{"../../object/valid-value":119}],85:[function(e,t,n){"use strict";var r=e("../../number/is-nan"),i=e("../../number/to-pos-integer"),o=e("../../object/valid-value"),s=Array.prototype.indexOf,a=Object.prototype.hasOwnProperty,c=Math.abs,u=Math.floor;t.exports=function(e){var t,n,l,f;if(!r(e))return s.apply(this,arguments);for(n=i(o(this).length),l=arguments[1],t=l=isNaN(l)?0:l>=0?u(l):i(this.length)-u(c(l));t<n;++t)if(a.call(this,t)&&(f=this[t],r(f)))return t;return-1}},{"../../number/is-nan":95,"../../number/to-pos-integer":99,"../../object/valid-value":119}],86:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Array.from:e("./shim")},{"./is-implemented":87,"./shim":88}],87:[function(e,t,n){"use strict";t.exports=function(){var e,t,n=Array.from;return"function"==typeof n&&(t=n(e=["raz","dwa"]),Boolean(t&&t!==e&&"dwa"===t[1]))}},{}],88:[function(e,t,n){"use strict";var r=e("es6-symbol").iterator,i=e("../../function/is-arguments"),o=e("../../function/is-function"),s=e("../../number/to-pos-integer"),a=e("../../object/valid-callable"),c=e("../../object/valid-value"),u=e("../../object/is-value"),l=e("../../string/is-string"),f=Array.isArray,h=Function.prototype.call,p={configurable:!0,enumerable:!0,writable:!0,value:null},d=Object.defineProperty;t.exports=function(e){var t,n,_,g,v,m,y,E,b,C,w=arguments[1],T=arguments[2];if(e=Object(c(e)),u(w)&&a(w),this&&this!==Array&&o(this))t=this;else{if(!w){if(i(e))return 1!==(v=e.length)?Array.apply(null,e):((g=new Array(1))[0]=e[0],g);if(f(e)){for(g=new Array(v=e.length),n=0;n<v;++n)g[n]=e[n];return g}}g=[]}if(!f(e))if(void 0!==(b=e[r])){for(y=a(b).call(e),t&&(g=new t),E=y.next(),n=0;!E.done;)C=w?h.call(w,T,E.value,n):E.value,t?(p.value=C,d(g,n,p)):g[n]=C,E=y.next(),++n;v=n}else if(l(e)){for(v=e.length,t&&(g=new t),n=0,_=0;n<v;++n)C=e[n],n+1<v&&(m=C.charCodeAt(0))>=55296&&m<=56319&&(C+=e[++n]),C=w?h.call(w,T,C,_):C,t?(p.value=C,d(g,_,p)):g[_]=C,++_;v=_}if(void 0===v)for(v=s(e.length),t&&(g=new t(v)),n=0;n<v;++n)C=w?h.call(w,T,e[n],n):e[n],t?(p.value=C,d(g,n,p)):g[n]=C;return t&&(p.value=null,g.length=v),g}},{"../../function/is-arguments":89,"../../function/is-function":90,"../../number/to-pos-integer":99,"../../object/is-value":108,"../../object/valid-callable":118,"../../object/valid-value":119,"../../string/is-string":123,"es6-symbol":139}],89:[function(e,t,n){"use strict";var r=Object.prototype.toString,i=r.call(function(){return arguments}());t.exports=function(e){return r.call(e)===i}},{}],90:[function(e,t,n){"use strict";var r=Object.prototype.toString,i=RegExp.prototype.test.bind(/^[object [A-Za-z0-9]*Function]$/);t.exports=function(e){return"function"==typeof e&&i(r.call(e))}},{}],91:[function(e,t,n){"use strict";t.exports=function(){}},{}],92:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Math.sign:e("./shim")},{"./is-implemented":93,"./shim":94}],93:[function(e,t,n){"use strict";t.exports=function(){var e=Math.sign;return"function"==typeof e&&(1===e(10)&&-1===e(-20))}},{}],94:[function(e,t,n){"use strict";t.exports=function(e){return e=Number(e),isNaN(e)||0===e?e:e>0?1:-1}},{}],95:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Number.isNaN:e("./shim")},{"./is-implemented":96,"./shim":97}],96:[function(e,t,n){"use strict";t.exports=function(){var e=Number.isNaN;return"function"==typeof e&&(!e({})&&e(NaN)&&!e(34))}},{}],97:[function(e,t,n){"use strict";t.exports=function(e){return e!=e}},{}],98:[function(e,t,n){"use strict";var r=e("../math/sign"),i=Math.abs,o=Math.floor;t.exports=function(e){return isNaN(e)?0:0!==(e=Number(e))&&isFinite(e)?r(e)*o(i(e)):e}},{"../math/sign":92}],99:[function(e,t,n){"use strict";var r=e("./to-integer"),i=Math.max;t.exports=function(e){return i(0,r(e))}},{"./to-integer":98}],100:[function(e,t,n){"use strict";var r=e("./valid-callable"),i=e("./valid-value"),o=Function.prototype.bind,s=Function.prototype.call,a=Object.keys,c=Object.prototype.propertyIsEnumerable;t.exports=function(e,t){return function(n,u){var l,f=arguments[2],h=arguments[3];return n=Object(i(n)),r(u),l=a(n),h&&l.sort("function"==typeof h?o.call(h,n):void 0),"function"!=typeof e&&(e=l[e]),s.call(e,l,function(e,r){return c.call(n,e)?s.call(u,f,n[e],e,n,r):t})}}},{"./valid-callable":118,"./valid-value":119}],101:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Object.assign:e("./shim")},{"./is-implemented":102,"./shim":103}],102:[function(e,t,n){"use strict";t.exports=function(){var e,t=Object.assign;return"function"==typeof t&&(t(e={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},{}],103:[function(e,t,n){"use strict";var r=e("../keys"),i=e("../valid-value"),o=Math.max;t.exports=function(e,t){var n,s,a,c=o(arguments.length,2);for(e=Object(i(e)),a=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},s=1;s<c;++s)t=arguments[s],r(t).forEach(a);if(void 0!==n)throw n;return e}},{"../keys":109,"../valid-value":119}],104:[function(e,t,n){"use strict";var r=e("../array/from"),i=e("./assign"),o=e("./valid-value");t.exports=function(e){var t=Object(o(e)),n=arguments[1],s=Object(arguments[2]);if(t!==e&&!n)return t;var a={};return n?r(n,function(t){(s.ensure||t in e)&&(a[t]=e[t])}):i(a,e),a}},{"../array/from":86,"./assign":101,"./valid-value":119}],105:[function(e,t,n){"use strict";var r,i,o,s,a=Object.create;e("./set-prototype-of/is-implemented")()||(r=e("./set-prototype-of/shim")),t.exports=r?1!==r.level?a:(i={},o={},s={configurable:!1,enumerable:!1,writable:!0,value:void 0},Object.getOwnPropertyNames(Object.prototype).forEach(function(e){o[e]="__proto__"!==e?s:{configurable:!0,enumerable:!1,writable:!0,value:void 0}}),Object.defineProperties(i,o),Object.defineProperty(r,"nullPolyfill",{configurable:!1,enumerable:!1,writable:!1,value:i}),function(e,t){return a(null===e?i:e,t)}):a},{"./set-prototype-of/is-implemented":116,"./set-prototype-of/shim":117}],106:[function(e,t,n){"use strict";t.exports=e("./_iterate")("forEach")},{"./_iterate":100}],107:[function(e,t,n){"use strict";var r=e("./is-value"),i={function:!0,object:!0};t.exports=function(e){return r(e)&&i[typeof e]||!1}},{"./is-value":108}],108:[function(e,t,n){"use strict";var r=e("../function/noop")();t.exports=function(e){return e!==r&&null!==e}},{"../function/noop":91}],109:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Object.keys:e("./shim")},{"./is-implemented":110,"./shim":111}],110:[function(e,t,n){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},{}],111:[function(e,t,n){"use strict";var r=e("../is-value"),i=Object.keys;t.exports=function(e){return i(r(e)?Object(e):e)}},{"../is-value":108}],112:[function(e,t,n){"use strict";var r=e("./valid-callable"),i=e("./for-each"),o=Function.prototype.call;t.exports=function(e,t){var n={},s=arguments[2];return r(t),i(e,function(e,r,i,a){n[r]=o.call(t,s,e,r,i,a)}),n}},{"./for-each":106,"./valid-callable":118}],113:[function(e,t,n){"use strict";var r=e("./is-value"),i=Array.prototype.forEach,o=Object.create;t.exports=function(e){var t=o(null);return i.call(arguments,function(e){r(e)&&function(e,t){var n;for(n in e)t[n]=e[n]}(Object(e),t)}),t}},{"./is-value":108}],114:[function(e,t,n){"use strict";var r=Array.prototype.forEach,i=Object.create;t.exports=function(e){var t=i(null);return r.call(arguments,function(e){t[e]=!0}),t}},{}],115:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Object.setPrototypeOf:e("./shim")},{"./is-implemented":116,"./shim":117}],116:[function(e,t,n){"use strict";var r=Object.create,i=Object.getPrototypeOf,o={};t.exports=function(){var e=Object.setPrototypeOf,t=arguments[0]||r;return"function"==typeof e&&i(e(t(null),o))===o}},{}],117:[function(e,t,n){"use strict";var r,i,o,s,a=e("../is-object"),c=e("../valid-value"),u=Object.prototype.isPrototypeOf,l=Object.defineProperty,f={configurable:!0,enumerable:!1,writable:!0,value:void 0};r=function(e,t){if(c(e),null===t||a(t))return e;throw new TypeError("Prototype must be null or an object")},t.exports=(i=function(){var e,t=Object.create(null),n={},r=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__");if(r){try{(e=r.set).call(t,n)}catch(e){}if(Object.getPrototypeOf(t)===n)return{set:e,level:2}}return t.__proto__=n,Object.getPrototypeOf(t)===n?{level:2}:((t={}).__proto__=n,Object.getPrototypeOf(t)===n&&{level:1})}())?(2===i.level?i.set?(s=i.set,o=function(e,t){return s.call(r(e,t),t),e}):o=function(e,t){return r(e,t).__proto__=t,e}:o=function e(t,n){var i;return r(t,n),(i=u.call(e.nullPolyfill,t))&&delete e.nullPolyfill.__proto__,null===n&&(n=e.nullPolyfill),t.__proto__=n,i&&l(e.nullPolyfill,"__proto__",f),t},Object.defineProperty(o,"level",{configurable:!1,enumerable:!1,writable:!1,value:i.level})):null,e("../create")},{"../create":105,"../is-object":107,"../valid-value":119}],118:[function(e,t,n){"use strict";t.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},{}],119:[function(e,t,n){"use strict";var r=e("./is-value");t.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},{"./is-value":108}],120:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?String.prototype.contains:e("./shim")},{"./is-implemented":121,"./shim":122}],121:[function(e,t,n){"use strict";var r="razdwatrzy";t.exports=function(){return"function"==typeof r.contains&&(!0===r.contains("dwa")&&!1===r.contains("foo"))}},{}],122:[function(e,t,n){"use strict";var r=String.prototype.indexOf;t.exports=function(e){return r.call(this,e,arguments[1])>-1}},{}],123:[function(e,t,n){"use strict";var r=Object.prototype.toString,i=r.call("");t.exports=function(e){return"string"==typeof e||e&&"object"==typeof e&&(e instanceof String||r.call(e)===i)||!1}},{}],124:[function(e,t,n){(function(n){"use strict";var r=n.Promise||e("es6-promise").Promise;t.exports=function(){this.promise=new r(function(e,t){this.resolve=e,this.reject=t}.bind(this)),this.then=this.promise.then.bind(this.promise),this.catch=this.promise.catch.bind(this.promise)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"es6-promise":138}],125:[function(e,t,n){"use strict";var r,i=e("es5-ext/object/set-prototype-of"),o=e("es5-ext/string/#/contains"),s=e("d"),a=e("es6-symbol"),c=e("./"),u=Object.defineProperty;r=t.exports=function(e,t){if(!(this instanceof r))throw new TypeError("Constructor requires 'new'");c.call(this,e),t=t?o.call(t,"key+value")?"key+value":o.call(t,"key")?"key":"value":"value",u(this,"__kind__",s("",t))},i&&i(r,c),delete r.prototype.constructor,r.prototype=Object.create(c.prototype,{_resolve:s(function(e){return"value"===this.__kind__?this.__list__[e]:"key+value"===this.__kind__?[e,this.__list__[e]]:e})}),u(r.prototype,a.toStringTag,s("c","Array Iterator"))},{"./":128,d:81,"es5-ext/object/set-prototype-of":115,"es5-ext/string/#/contains":120,"es6-symbol":139}],126:[function(e,t,n){"use strict";var r=e("es5-ext/function/is-arguments"),i=e("es5-ext/object/valid-callable"),o=e("es5-ext/string/is-string"),s=e("./get"),a=Array.isArray,c=Function.prototype.call,u=Array.prototype.some;t.exports=function(e,t){var n,l,f,h,p,d,_,g,v=arguments[2];if(a(e)||r(e)?n="array":o(e)?n="string":e=s(e),i(t),f=function(){h=!0},"array"!==n)if("string"!==n)for(l=e.next();!l.done;){if(c.call(t,v,l.value,f),h)return;l=e.next()}else for(d=e.length,p=0;p<d&&(_=e[p],p+1<d&&(g=_.charCodeAt(0))>=55296&&g<=56319&&(_+=e[++p]),c.call(t,v,_,f),!h);++p);else u.call(e,function(e){return c.call(t,v,e,f),h})}},{"./get":127,"es5-ext/function/is-arguments":89,"es5-ext/object/valid-callable":118,"es5-ext/string/is-string":123}],127:[function(e,t,n){"use strict";var r=e("es5-ext/function/is-arguments"),i=e("es5-ext/string/is-string"),o=e("./array"),s=e("./string"),a=e("./valid-iterable"),c=e("es6-symbol").iterator;t.exports=function(e){return"function"==typeof a(e)[c]?e[c]():r(e)?new o(e):i(e)?new s(e):new o(e)}},{"./array":125,"./string":130,"./valid-iterable":131,"es5-ext/function/is-arguments":89,"es5-ext/string/is-string":123,"es6-symbol":139}],128:[function(e,t,n){"use strict";var r,i=e("es5-ext/array/#/clear"),o=e("es5-ext/object/assign"),s=e("es5-ext/object/valid-callable"),a=e("es5-ext/object/valid-value"),c=e("d"),u=e("d/auto-bind"),l=e("es6-symbol"),f=Object.defineProperty,h=Object.defineProperties;t.exports=r=function(e,t){if(!(this instanceof r))throw new TypeError("Constructor requires 'new'");h(this,{__list__:c("w",a(e)),__context__:c("w",t),__nextIndex__:c("w",0)}),t&&(s(t.on),t.on("_add",this._onAdd),t.on("_delete",this._onDelete),t.on("_clear",this._onClear))},delete r.prototype.constructor,h(r.prototype,o({_next:c(function(){var e;if(this.__list__)return this.__redo__&&void 0!==(e=this.__redo__.shift())?e:this.__nextIndex__<this.__list__.length?this.__nextIndex__++:void this._unBind()}),next:c(function(){return this._createResult(this._next())}),_createResult:c(function(e){return void 0===e?{done:!0,value:void 0}:{done:!1,value:this._resolve(e)}}),_resolve:c(function(e){return this.__list__[e]}),_unBind:c(function(){this.__list__=null,delete this.__redo__,this.__context__&&(this.__context__.off("_add",this._onAdd),this.__context__.off("_delete",this._onDelete),this.__context__.off("_clear",this._onClear),this.__context__=null)}),toString:c(function(){return"[object "+(this[l.toStringTag]||"Object")+"]"})},u({_onAdd:c(function(e){e>=this.__nextIndex__||(++this.__nextIndex__,this.__redo__?(this.__redo__.forEach(function(t,n){t>=e&&(this.__redo__[n]=++t)},this),this.__redo__.push(e)):f(this,"__redo__",c("c",[e])))}),_onDelete:c(function(e){var t;e>=this.__nextIndex__||(--this.__nextIndex__,this.__redo__&&(-1!==(t=this.__redo__.indexOf(e))&&this.__redo__.splice(t,1),this.__redo__.forEach(function(t,n){t>e&&(this.__redo__[n]=--t)},this)))}),_onClear:c(function(){this.__redo__&&i.call(this.__redo__),this.__nextIndex__=0})}))),f(r.prototype,l.iterator,c(function(){return this}))},{d:81,"d/auto-bind":80,"es5-ext/array/#/clear":84,"es5-ext/object/assign":101,"es5-ext/object/valid-callable":118,"es5-ext/object/valid-value":119,"es6-symbol":139}],129:[function(e,t,n){"use strict";var r=e("es5-ext/function/is-arguments"),i=e("es5-ext/object/is-value"),o=e("es5-ext/string/is-string"),s=e("es6-symbol").iterator,a=Array.isArray;t.exports=function(e){return!!i(e)&&(!!a(e)||(!!o(e)||(!!r(e)||"function"==typeof e[s])))}},{"es5-ext/function/is-arguments":89,"es5-ext/object/is-value":108,"es5-ext/string/is-string":123,"es6-symbol":139}],130:[function(e,t,n){"use strict";var r,i=e("es5-ext/object/set-prototype-of"),o=e("d"),s=e("es6-symbol"),a=e("./"),c=Object.defineProperty;r=t.exports=function(e){if(!(this instanceof r))throw new TypeError("Constructor requires 'new'");e=String(e),a.call(this,e),c(this,"__length__",o("",e.length))},i&&i(r,a),delete r.prototype.constructor,r.prototype=Object.create(a.prototype,{_next:o(function(){if(this.__list__)return this.__nextIndex__<this.__length__?this.__nextIndex__++:void this._unBind()}),_resolve:o(function(e){var t,n=this.__list__[e];return this.__nextIndex__===this.__length__?n:(t=n.charCodeAt(0))>=55296&&t<=56319?n+this.__list__[this.__nextIndex__++]:n})}),c(r.prototype,s.toStringTag,o("c","String Iterator"))},{"./":128,d:81,"es5-ext/object/set-prototype-of":115,"es6-symbol":139}],131:[function(e,t,n){"use strict";var r=e("./is-iterable");t.exports=function(e){if(!r(e))throw new TypeError(e+" is not iterable");return e}},{"./is-iterable":129}],132:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?Map:e("./polyfill")},{"./is-implemented":133,"./polyfill":137}],133:[function(e,t,n){"use strict";t.exports=function(){var e,t;if("function"!=typeof Map)return!1;try{e=new Map([["raz","one"],["dwa","two"],["trzy","three"]])}catch(e){return!1}return"[object Map]"===String(e)&&(3===e.size&&("function"==typeof e.clear&&("function"==typeof e.delete&&("function"==typeof e.entries&&("function"==typeof e.forEach&&("function"==typeof e.get&&("function"==typeof e.has&&("function"==typeof e.keys&&("function"==typeof e.set&&("function"==typeof e.values&&(!1===(t=e.entries().next()).done&&(!!t.value&&("raz"===t.value[0]&&"one"===t.value[1])))))))))))))}},{}],134:[function(e,t,n){"use strict";t.exports="undefined"!=typeof Map&&"[object Map]"===Object.prototype.toString.call(new Map)},{}],135:[function(e,t,n){"use strict";t.exports=e("es5-ext/object/primitive-set")("key","value","key+value")},{"es5-ext/object/primitive-set":114}],136:[function(e,t,n){"use strict";var r,i=e("es5-ext/object/set-prototype-of"),o=e("d"),s=e("es6-iterator"),a=e("es6-symbol").toStringTag,c=e("./iterator-kinds"),u=Object.defineProperties,l=s.prototype._unBind;r=t.exports=function(e,t){if(!(this instanceof r))return new r(e,t);s.call(this,e.__mapKeysData__,e),t&&c[t]||(t="key+value"),u(this,{__kind__:o("",t),__values__:o("w",e.__mapValuesData__)})},i&&i(r,s),r.prototype=Object.create(s.prototype,{constructor:o(r),_resolve:o(function(e){return"value"===this.__kind__?this.__values__[e]:"key"===this.__kind__?this.__list__[e]:[this.__list__[e],this.__values__[e]]}),_unBind:o(function(){this.__values__=null,l.call(this)}),toString:o(function(){return"[object Map Iterator]"})}),Object.defineProperty(r.prototype,a,o("c","Map Iterator"))},{"./iterator-kinds":135,d:81,"es5-ext/object/set-prototype-of":115,"es6-iterator":128,"es6-symbol":139}],137:[function(e,t,n){"use strict";var r,i=e("es5-ext/array/#/clear"),o=e("es5-ext/array/#/e-index-of"),s=e("es5-ext/object/set-prototype-of"),a=e("es5-ext/object/valid-callable"),c=e("es5-ext/object/valid-value"),u=e("d"),l=e("event-emitter"),f=e("es6-symbol"),h=e("es6-iterator/valid-iterable"),p=e("es6-iterator/for-of"),d=e("./lib/iterator"),_=e("./is-native-implemented"),g=Function.prototype.call,v=Object.defineProperties,m=Object.getPrototypeOf;t.exports=r=function(){var e,t,n,i=arguments[0];if(!(this instanceof r))throw new TypeError("Constructor requires 'new'");return n=_&&s&&Map!==r?s(new Map,m(this)):this,null!=i&&h(i),v(n,{__mapKeysData__:u("c",e=[]),__mapValuesData__:u("c",t=[])}),i?(p(i,function(n){var r=c(n)[0];n=n[1],-1===o.call(e,r)&&(e.push(r),t.push(n))},n),n):n},_&&(s&&s(r,Map),r.prototype=Object.create(Map.prototype,{constructor:u(r)})),l(v(r.prototype,{clear:u(function(){this.__mapKeysData__.length&&(i.call(this.__mapKeysData__),i.call(this.__mapValuesData__),this.emit("_clear"))}),delete:u(function(e){var t=o.call(this.__mapKeysData__,e);return-1!==t&&(this.__mapKeysData__.splice(t,1),this.__mapValuesData__.splice(t,1),this.emit("_delete",t,e),!0)}),entries:u(function(){return new d(this,"key+value")}),forEach:u(function(e){var t,n,r=arguments[1];for(a(e),n=(t=this.entries())._next();void 0!==n;)g.call(e,r,this.__mapValuesData__[n],this.__mapKeysData__[n],this),n=t._next()}),get:u(function(e){var t=o.call(this.__mapKeysData__,e);if(-1!==t)return this.__mapValuesData__[t]}),has:u(function(e){return-1!==o.call(this.__mapKeysData__,e)}),keys:u(function(){return new d(this,"key")}),set:u(function(e,t){var n,r=o.call(this.__mapKeysData__,e);return-1===r&&(r=this.__mapKeysData__.push(e)-1,n=!0),this.__mapValuesData__[r]=t,n&&this.emit("_add",r,e),this}),size:u.gs(function(){return this.__mapKeysData__.length}),values:u(function(){return new d(this,"value")}),toString:u(function(){return"[object Map]"})})),Object.defineProperty(r.prototype,f.iterator,u(function(){return this.entries()})),Object.defineProperty(r.prototype,f.toStringTag,u("c","Map"))},{"./is-native-implemented":134,"./lib/iterator":136,d:81,"es5-ext/array/#/clear":84,"es5-ext/array/#/e-index-of":85,"es5-ext/object/set-prototype-of":115,"es5-ext/object/valid-callable":118,"es5-ext/object/valid-value":119,"es6-iterator/for-of":126,"es6-iterator/valid-iterable":131,"es6-symbol":139,"event-emitter":147}],138:[function(e,t,n){(function(n,r,i){
/*!
 * @overview es6-promise - a tiny implementation of Promises/A+.
 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
 * @license   Licensed under MIT license
 *            See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
 * @version   2.3.0
 */
(function(){"use strict";function o(e){return"function"==typeof e}var s,a,c=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},u=0,l=function(e,t){T[u]=e,T[u+1]=t,2===(u+=2)&&(a?a(R):v())};var f="undefined"!=typeof window?window:void 0,h=f||{},p=h.MutationObserver||h.WebKitMutationObserver,d=void 0!==n&&"[object process]"==={}.toString.call(n),_="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function g(){return function(){setTimeout(R,1)}}var v,m,y,E,b,C,w,T=new Array(1e3);function R(){for(var e=0;e<u;e+=2){(0,T[e])(T[e+1]),T[e]=void 0,T[e+1]=void 0}u=0}function S(){}d?(C=n.nextTick,w=n.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/),Array.isArray(w)&&"0"===w[1]&&"10"===w[2]&&(C=i),v=function(){C(R)}):p?(y=0,E=new p(R),b=document.createTextNode(""),E.observe(b,{characterData:!0}),v=function(){b.data=y=++y%2}):_?((m=new MessageChannel).port1.onmessage=R,v=function(){m.port2.postMessage(0)}):v=void 0===f&&"function"==typeof e?function(){try{var t=e("vertx");return s=t.runOnLoop||t.runOnContext,function(){s(R)}}catch(e){return g()}}():g();var I=void 0,N=1,O=2,A=new j;function x(e,t){if(t.constructor===e.constructor)!function(e,t){t._state===N?P(e,t._result):t._state===O?D(e,t._result):L(t,void 0,function(t){B(e,t)},function(t){D(e,t)})}(e,t);else{var n=function(e){try{return e.then}catch(e){return A.error=e,A}}(t);n===A?D(e,A.error):void 0===n?P(e,t):o(n)?function(e,t,n){l(function(e){var r=!1,i=function(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}(n,t,function(n){r||(r=!0,t!==n?B(e,n):P(e,n))},function(t){r||(r=!0,D(e,t))},e._label);!r&&i&&(r=!0,D(e,i))},e)}(e,t,n):P(e,t)}}function B(e,t){var n;e===t?D(e,new TypeError("You cannot resolve a promise with itself")):"function"==typeof(n=t)||"object"==typeof n&&null!==n?x(e,t):P(e,t)}function k(e){e._onerror&&e._onerror(e._result),W(e)}function P(e,t){e._state===I&&(e._result=t,e._state=N,0!==e._subscribers.length&&l(W,e))}function D(e,t){e._state===I&&(e._state=O,e._result=t,l(k,e))}function L(e,t,n,r){var i=e._subscribers,o=i.length;e._onerror=null,i[o]=t,i[o+N]=n,i[o+O]=r,0===o&&e._state&&l(W,e)}function W(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r,i,o=e._result,s=0;s<t.length;s+=3)r=t[s],i=t[s+n],r?U(n,r,i,o):i(o);e._subscribers.length=0}}function j(){this.error=null}var M=new j;function U(e,t,n,r){var i,s,a,c,u=o(n);if(u){if((i=function(e,t){try{return e(t)}catch(e){return M.error=e,M}}(n,r))===M?(c=!0,s=i.error,i=null):a=!0,t===i)return void D(t,new TypeError("A promises callback cannot return that same promise."))}else i=r,a=!0;t._state!==I||(u&&a?B(t,i):c?D(t,s):e===N?P(t,i):e===O&&D(t,i))}function F(e,t){this._instanceConstructor=e,this.promise=new e(S),this._validateInput(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._init(),0===this.length?P(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&P(this.promise,this._result))):D(this.promise,this._validationError())}F.prototype._validateInput=function(e){return c(e)},F.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},F.prototype._init=function(){this._result=new Array(this.length)};var G=F;F.prototype._enumerate=function(){for(var e=this.length,t=this.promise,n=this._input,r=0;t._state===I&&r<e;r++)this._eachEntry(n[r],r)},F.prototype._eachEntry=function(e,t){var n,r=this._instanceConstructor;"object"==typeof(n=e)&&null!==n?e.constructor===r&&e._state!==I?(e._onerror=null,this._settledAt(e._state,t,e._result)):this._willSettleAt(r.resolve(e),t):(this._remaining--,this._result[t]=e)},F.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===I&&(this._remaining--,e===O?D(r,n):this._result[t]=n),0===this._remaining&&P(r,this._result)},F.prototype._willSettleAt=function(e,t){var n=this;L(e,void 0,function(e){n._settledAt(N,t,e)},function(e){n._settledAt(O,t,e)})};var q=function(e){return new G(this,e).promise};var H=function(e){var t=new this(S);if(!c(e))return D(t,new TypeError("You must pass an array to race.")),t;var n=e.length;function r(e){B(t,e)}function i(e){D(t,e)}for(var o=0;t._state===I&&o<n;o++)L(this.resolve(e[o]),void 0,r,i);return t};var V=function(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(S);return B(t,e),t};var z=function(e){var t=new this(S);return D(t,e),t},K=0;var Q=Y;function Y(e){this._id=K++,this._state=void 0,this._result=void 0,this._subscribers=[],S!==e&&(o(e)||function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof Y||function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}(),function(e,t){try{t(function(t){B(e,t)},function(t){D(e,t)})}catch(t){D(e,t)}}(this,e))}Y.all=q,Y.race=H,Y.resolve=V,Y.reject=z,Y._setScheduler=function(e){a=e},Y._setAsap=function(e){l=e},Y._asap=l,Y.prototype={constructor:Y,then:function(e,t){var n=this._state;if(n===N&&!e||n===O&&!t)return this;var r=new this.constructor(S),i=this._result;if(n){var o=arguments[n-1];l(function(){U(n,r,o,i)})}else L(this,r,e,t);return r},catch:function(e){return this.then(null,e)}};var J=function(){var e;if(void 0!==r)e=r;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;t&&"[object Promise]"===Object.prototype.toString.call(t.resolve())&&!t.cast||(e.Promise=Q)},Z={Promise:Q,polyfill:J};"function"==typeof define&&define.amd?define(function(){return Z}):void 0!==t&&t.exports?t.exports=Z:void 0!==this&&(this.ES6Promise=Z),J()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{_process:181,timers:205}],139:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?e("ext/global-this").Symbol:e("./polyfill")},{"./is-implemented":140,"./polyfill":145,"ext/global-this":150}],140:[function(e,t,n){"use strict";var r=e("ext/global-this"),i={object:!0,symbol:!0};t.exports=function(){var e,t=r.Symbol;if("function"!=typeof t)return!1;e=t("test symbol");try{String(e)}catch(e){return!1}return!!i[typeof t.iterator]&&(!!i[typeof t.toPrimitive]&&!!i[typeof t.toStringTag])}},{"ext/global-this":150}],141:[function(e,t,n){"use strict";t.exports=function(e){return!!e&&("symbol"==typeof e||!!e.constructor&&("Symbol"===e.constructor.name&&"Symbol"===e[e.constructor.toStringTag]))}},{}],142:[function(e,t,n){"use strict";var r=e("d"),i=Object.create,o=Object.defineProperty,s=Object.prototype,a=i(null);t.exports=function(e){for(var t,n,i=0;a[e+(i||"")];)++i;return a[e+=i||""]=!0,o(s,t="@@"+e,r.gs(null,function(e){n||(n=!0,o(this,t,r(e)),n=!1)})),t}},{d:81}],143:[function(e,t,n){"use strict";var r=e("d"),i=e("ext/global-this").Symbol;t.exports=function(e){return Object.defineProperties(e,{hasInstance:r("",i&&i.hasInstance||e("hasInstance")),isConcatSpreadable:r("",i&&i.isConcatSpreadable||e("isConcatSpreadable")),iterator:r("",i&&i.iterator||e("iterator")),match:r("",i&&i.match||e("match")),replace:r("",i&&i.replace||e("replace")),search:r("",i&&i.search||e("search")),species:r("",i&&i.species||e("species")),split:r("",i&&i.split||e("split")),toPrimitive:r("",i&&i.toPrimitive||e("toPrimitive")),toStringTag:r("",i&&i.toStringTag||e("toStringTag")),unscopables:r("",i&&i.unscopables||e("unscopables"))})}},{d:81,"ext/global-this":150}],144:[function(e,t,n){"use strict";var r=e("d"),i=e("../../../validate-symbol"),o=Object.create(null);t.exports=function(e){return Object.defineProperties(e,{for:r(function(t){return o[t]?o[t]:o[t]=e(String(t))}),keyFor:r(function(e){var t;for(t in i(e),o)if(o[t]===e)return t})})}},{"../../../validate-symbol":146,d:81}],145:[function(e,t,n){"use strict";var r,i,o,s=e("d"),a=e("./validate-symbol"),c=e("ext/global-this").Symbol,u=e("./lib/private/generate-name"),l=e("./lib/private/setup/standard-symbols"),f=e("./lib/private/setup/symbol-registry"),h=Object.create,p=Object.defineProperties,d=Object.defineProperty;if("function"==typeof c)try{String(c()),o=!0}catch(e){}else c=null;i=function(e){if(this instanceof i)throw new TypeError("Symbol is not a constructor");return r(e)},t.exports=r=function e(t){var n;if(this instanceof e)throw new TypeError("Symbol is not a constructor");return o?c(t):(n=h(i.prototype),t=void 0===t?"":String(t),p(n,{__description__:s("",t),__name__:s("",u(t))}))},l(r),f(r),p(i.prototype,{constructor:s(r),toString:s("",function(){return this.__name__})}),p(r.prototype,{toString:s(function(){return"Symbol ("+a(this).__description__+")"}),valueOf:s(function(){return a(this)})}),d(r.prototype,r.toPrimitive,s("",function(){var e=a(this);return"symbol"==typeof e?e:e.toString()})),d(r.prototype,r.toStringTag,s("c","Symbol")),d(i.prototype,r.toStringTag,s("c",r.prototype[r.toStringTag])),d(i.prototype,r.toPrimitive,s("c",r.prototype[r.toPrimitive]))},{"./lib/private/generate-name":142,"./lib/private/setup/standard-symbols":143,"./lib/private/setup/symbol-registry":144,"./validate-symbol":146,d:81,"ext/global-this":150}],146:[function(e,t,n){"use strict";var r=e("./is-symbol");t.exports=function(e){if(!r(e))throw new TypeError(e+" is not a symbol");return e}},{"./is-symbol":141}],147:[function(e,t,n){"use strict";var r,i,o,s,a,c,u,l=e("d"),f=e("es5-ext/object/valid-callable"),h=Function.prototype.apply,p=Function.prototype.call,d=Object.create,_=Object.defineProperty,g=Object.defineProperties,v=Object.prototype.hasOwnProperty,m={configurable:!0,enumerable:!1,writable:!0};a={on:r=function(e,t){var n;return f(t),v.call(this,"__ee__")?n=this.__ee__:(n=m.value=d(null),_(this,"__ee__",m),m.value=null),n[e]?"object"==typeof n[e]?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},once:i=function(e,t){var n,i;return f(t),i=this,r.call(this,e,n=function(){o.call(i,e,n),h.call(t,this,arguments)}),n.__eeOnceListener__=t,this},off:o=function(e,t){var n,r,i,o;if(f(t),!v.call(this,"__ee__"))return this;if(!(n=this.__ee__)[e])return this;if("object"==typeof(r=n[e]))for(o=0;i=r[o];++o)i!==t&&i.__eeOnceListener__!==t||(2===r.length?n[e]=r[o?0:1]:r.splice(o,1));else r!==t&&r.__eeOnceListener__!==t||delete n[e];return this},emit:s=function(e){var t,n,r,i,o;if(v.call(this,"__ee__")&&(i=this.__ee__[e]))if("object"==typeof i){for(n=arguments.length,o=new Array(n-1),t=1;t<n;++t)o[t-1]=arguments[t];for(i=i.slice(),t=0;r=i[t];++t)h.call(r,this,o)}else switch(arguments.length){case 1:p.call(i,this);break;case 2:p.call(i,this,arguments[1]);break;case 3:p.call(i,this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),t=1;t<n;++t)o[t-1]=arguments[t];h.call(i,this,o)}}},c={on:l(r),once:l(i),off:l(o),emit:l(s)},u=g({},c),t.exports=n=function(e){return null==e?d(u):g(Object(e),c)},n.methods=a},{d:81,"es5-ext/object/valid-callable":118}],148:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
var r=Object.create||function(e){var t=function(){};return t.prototype=e,new t},i=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},o=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),a=0===u.x}catch(e){a=!1}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function f(e,t,n,i){var o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),!a.warned&&(o=l(e))&&o>0&&a.length>o){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=o.call(h,r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(!r)return[];var i=r[t];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):g(i,i.length):[]}function _(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){var t,n,r,i,o,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=g(e,r),o=0;o<r;++o)i[o].call(n)}(n,u,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=g(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,u,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=g(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=g(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=g(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,u,this,i)}return!0},s.prototype.addListener=function(e,t){return f(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return f(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,i,o,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,o=s;break}if(o<0)return this;0===o?n.shift():function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,o),1===n.length&&(i[e]=n[0]),i.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,o;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=i(n);for(o=0;o<a.length;++o)"removeListener"!==(s=a[o])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):_.call(e,t)},s.prototype.listenerCount=_,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],149:[function(e,t,n){var r=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(e){return r()}try{return __global__||r()}finally{delete Object.prototype.__global__}}()},{}],150:[function(e,t,n){"use strict";t.exports=e("./is-implemented")()?globalThis:e("./implementation")},{"./implementation":149,"./is-implemented":151}],151:[function(e,t,n){"use strict";t.exports=function(){return"object"==typeof globalThis&&(!!globalThis&&globalThis.Array===Array)}},{}],152:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,u=c>>1,l=-7,f=n?i-1:0,h=n?-1:1,p=e[t+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+f],f+=h,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=u}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+f>=1?h/c:h*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*c-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[n+p]=255&s,p+=d,s/=256,u-=8);e[n+p-d]|=128*_}},{}],153:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],154:[function(e,t,n){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
/*!
 * Determine if an object is a Buffer
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
t.exports=function(e){return null!=e&&(r(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],155:[function(e,t,n){
/*!
 * Determine if an object is a Buffer
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
t.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},{}],156:[function(e,t,n){"use strict";var r=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ESOCKETTIMEDOUT","ECONNREFUSED","EPIPE","EHOSTUNREACH","EAI_AGAIN"],i=["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"];t.exports=function(e){return!e||!e.code||(-1!==r.indexOf(e.code)||-1===i.indexOf(e.code))}},{}],157:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],158:[function(e,t,n){
/*!
 * js-logger - http://github.com/jonnyreeves/js-logger
 * Jonny Reeves, http://jonnyreeves.co.uk/
 * js-logger may be freely distributed under the MIT license.
 */
!function(e){"use strict";var n,r={};r.VERSION="1.3.0";var i={},o=function(e,t){return function(){return t.apply(e,arguments)}},s=function(){var e,t,n=arguments,r=n[0];for(t=1;t<n.length;t++)for(e in n[t])e in r||!n[t].hasOwnProperty(e)||(r[e]=n[t][e]);return r},a=function(e,t){return{value:e,name:t}};r.DEBUG=a(1,"DEBUG"),r.INFO=a(2,"INFO"),r.TIME=a(3,"TIME"),r.WARN=a(4,"WARN"),r.ERROR=a(8,"ERROR"),r.OFF=a(99,"OFF");var c=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};c.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var t=this.context.filterLevel;return e.value>=t.value},debug:function(){this.invoke(r.DEBUG,arguments)},info:function(){this.invoke(r.INFO,arguments)},warn:function(){this.invoke(r.WARN,arguments)},error:function(){this.invoke(r.ERROR,arguments)},time:function(e){"string"==typeof e&&e.length>0&&this.invoke(r.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&e.length>0&&this.invoke(r.TIME,[e,"end"])},invoke:function(e,t){n&&this.enabledFor(e)&&n(t,s({level:e},this.context))}};var u,l=new c({filterLevel:r.OFF});(u=r).enabledFor=o(l,l.enabledFor),u.debug=o(l,l.debug),u.time=o(l,l.time),u.timeEnd=o(l,l.timeEnd),u.info=o(l,l.info),u.warn=o(l,l.warn),u.error=o(l,l.error),u.log=u.info,r.setHandler=function(e){n=e},r.setLevel=function(e){for(var t in l.setLevel(e),i)i.hasOwnProperty(t)&&i[t].setLevel(e)},r.getLevel=function(){return l.getLevel()},r.get=function(e){return i[e]||(i[e]=new c(s({name:e},l.context)))},r.createDefaultHandler=function(e){(e=e||{}).formatter=e.formatter||function(e,t){t.name&&e.unshift("["+t.name+"]")};var t={},n=function(e,t){Function.prototype.apply.call(e,console,t)};return"undefined"==typeof console?function(){}:function(i,o){i=Array.prototype.slice.call(i);var s,a=console.log;o.level===r.TIME?(s=(o.name?"["+o.name+"] ":"")+i[0],"start"===i[1]?console.time?console.time(s):t[s]=(new Date).getTime():console.timeEnd?console.timeEnd(s):n(a,[s+": "+((new Date).getTime()-t[s])+"ms"])):(o.level===r.WARN&&console.warn?a=console.warn:o.level===r.ERROR&&console.error?a=console.error:o.level===r.INFO&&console.info?a=console.info:o.level===r.DEBUG&&console.debug&&(a=console.debug),e.formatter(i,o),n(a,i))}},r.useDefaults=function(e){r.setLevel(e&&e.defaultLevel||r.DEBUG),r.setHandler(r.createDefaultHandler(e))},"function"==typeof define&&define.amd?define(r):void 0!==t&&t.exports?t.exports=r:(r._prevLogger=e.Logger,r.noConflict=function(){return e.Logger=r._prevLogger,r},e.Logger=r)}(this)},{}],159:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=t.exports;for(var o in i.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"reserved"},i.codes={},i.types){var s=i.types[o];i.codes[s]=o}function a(e){return[0,1,2].map(function(t){return[0,1].map(function(n){return[0,1].map(function(o){var s=new r(1);return s.writeUInt8(i.codes[e]<<i.CMD_SHIFT|(n?i.DUP_MASK:0)|t<<i.QOS_SHIFT|o,0,!0),s})})})}i.CMD_SHIFT=4,i.CMD_MASK=240,i.DUP_MASK=8,i.QOS_MASK=3,i.QOS_SHIFT=1,i.RETAIN_MASK=1,i.LENGTH_MASK=127,i.LENGTH_FIN_MASK=128,i.SESSIONPRESENT_MASK=1,i.SESSIONPRESENT_HEADER=r.from([i.SESSIONPRESENT_MASK]),i.CONNACK_HEADER=r.from([i.codes.connack<<i.CMD_SHIFT]),i.USERNAME_MASK=128,i.PASSWORD_MASK=64,i.WILL_RETAIN_MASK=32,i.WILL_QOS_MASK=24,i.WILL_QOS_SHIFT=3,i.WILL_FLAG_MASK=4,i.CLEAN_SESSION_MASK=2,i.CONNECT_HEADER=r.from([i.codes.connect<<i.CMD_SHIFT]),i.PUBLISH_HEADER=a("publish"),i.SUBSCRIBE_HEADER=a("subscribe"),i.UNSUBSCRIBE_HEADER=a("unsubscribe"),i.ACKS={unsuback:a("unsuback"),puback:a("puback"),pubcomp:a("pubcomp"),pubrel:a("pubrel"),pubrec:a("pubrec")},i.SUBACK_HEADER=r.from([i.codes.suback<<i.CMD_SHIFT]),i.VERSION3=r.from([3]),i.VERSION4=r.from([4]),i.QOS=[0,1,2].map(function(e){return r.from([e])}),i.EMPTY={pingreq:r.from([i.codes.pingreq<<4,0]),pingresp:r.from([i.codes.pingresp<<4,0]),disconnect:r.from([i.codes.disconnect<<4,0])}},{"safe-buffer":200}],160:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=e("./writeToStream"),o=e("events").EventEmitter;function s(){this._array=new Array(20),this._i=0}e("inherits")(s,o),s.prototype.write=function(e){return this._array[this._i++]=e,!0},s.prototype.concat=function(){var e,t,n=0,i=new Array(this._array.length),o=this._array,s=0;for(e=0;e<o.length&&void 0!==o[e];e++)"string"!=typeof o[e]?i[e]=o[e].length:i[e]=r.byteLength(o[e]),n+=i[e];for(t=r.allocUnsafe(n),e=0;e<o.length&&void 0!==o[e];e++)"string"!=typeof o[e]?(o[e].copy(t,s),s+=i[e]):(t.write(o[e],s),s+=i[e]);return t},t.exports=function(e){var t=new s;return i(e,t),t.concat()}},{"./writeToStream":165,events:148,inherits:153,"safe-buffer":200}],161:[function(e,t,n){"use strict";n.parser=e("./parser"),n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":160,"./parser":164,"./writeToStream":165}],162:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=65536,o={};function s(e){var t=r.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}t.exports={cache:o,generateCache:function(){for(var e=0;e<i;e++)o[e]=s(e)},generateNumber:s}},{"safe-buffer":200}],163:[function(e,t,n){t.exports=function(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}},{}],164:[function(e,t,n){"use strict";var r=e("bl"),i=e("inherits"),o=e("events").EventEmitter,s=e("./packet"),a=e("./constants");function c(){if(!(this instanceof c))return new c;this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState()}i(c,o),c.prototype._resetState=function(){this.packet=new s,this.error=null,this._list=r(),this._stateCounter=0},c.prototype.parse=function(e){for(this.error&&this._resetState(),this._list.append(e);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},c.prototype._parseHeader=function(){var e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!=(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!=(e&a.DUP_MASK),this._list.consume(1),!0},c.prototype._parseLength=function(){for(var e,t=0,n=1,r=0,i=!0;t<5&&(r+=n*((e=this._list.readUInt8(t++))&a.LENGTH_MASK),n*=128,0!=(e&a.LENGTH_FIN_MASK));)if(this._list.length<=t){i=!1;break}return i&&(this.packet.length=r,this._list.consume(t)),i},c.prototype._parsePayload=function(){var e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this._emitError(new Error("Not supported"))}e=!0}return e},c.prototype._parseConnect=function(){var e,t,n,r,i,o,s={},c=this.packet;if(null===(e=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==e&&"MQIsdp"!==e)return this._emitError(new Error("Invalid protocolId"));if(c.protocolId=e,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(c.protocolVersion=this._list.readUInt8(this._pos),3!==c.protocolVersion&&4!==c.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,s.will&&(c.will={},c.will.retain=0!=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),c.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),c.clean=0!=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,c.keepalive=this._parseNum(),-1===c.keepalive)return this._emitError(new Error("Packet too short"));if(null===(t=this._parseString()))return this._emitError(new Error("Packet too short"));if(c.clientId=t,s.will){if(null===(n=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(c.will.topic=n,null===(r=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));c.will.payload=r}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));c.username=o}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));c.password=i}return c},c.prototype._parseConnack=function(){var e=this.packet;return this._list.length<2?null:(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),e.returnCode=this._list.readUInt8(this._pos),-1===e.returnCode?this._emitError(new Error("Cannot parse return code")):void 0)},c.prototype._parsePublish=function(){var e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));e.qos>0&&!this._parseMessageId()||(e.payload=this._list.slice(this._pos,e.length))},c.prototype._parseSubscribe=function(){var e,t,n=this.packet;if(1!==n.qos)return this._emitError(new Error("Wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._pos<n.length;){if(null===(e=this._parseString()))return this._emitError(new Error("Cannot parse topic"));if(this._pos>=n.length)return this._emitError(new Error("Malformed Subscribe Payload"));t=this._list.readUInt8(this._pos++),n.subscriptions.push({topic:e,qos:t})}},c.prototype._parseSuback=function(){if(this.packet.granted=[],this._parseMessageId())for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))},c.prototype._parseUnsubscribe=function(){var e=this.packet;if(e.unsubscriptions=[],this._parseMessageId())for(;this._pos<e.length;){var t;if(null===(t=this._parseString()))return this._emitError(new Error("Cannot parse topic"));e.unsubscriptions.push(t)}},c.prototype._parseUnsuback=function(){if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"))},c.prototype._parseMessageId=function(){var e=this.packet;return e.messageId=this._parseNum(),null!==e.messageId||(this._emitError(new Error("Cannot parse messageId")),!1)},c.prototype._parseString=function(e){var t,n=this._parseNum(),r=n+this._pos;return-1===n||r>this._list.length||r>this.packet.length?null:(t=this._list.toString("utf8",this._pos,r),this._pos+=n,t)},c.prototype._parseBuffer=function(){var e,t=this._parseNum(),n=t+this._pos;return-1===t||n>this._list.length||n>this.packet.length?null:(e=this._list.slice(this._pos,n),this._pos+=t,e)},c.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var e=this._list.readUInt16BE(this._pos);return this._pos+=2,e},c.prototype._newPacket=function(){return this.packet&&(this._list.consume(this.packet.length),this.emit("packet",this.packet)),this.packet=new s,!0},c.prototype._emitError=function(e){this.error=e,this.emit("error",e)},t.exports=c},{"./constants":159,"./packet":163,bl:45,events:148,inherits:153}],165:[function(e,t,n){"use strict";var r=e("./constants"),i=e("safe-buffer").Buffer,o=i.allocUnsafe(0),s=i.from([0]),a=e("./numbers"),c=e("process-nextick-args").nextTick,u=a.cache,l=a.generateNumber,f=a.generateCache,h=y,p=!0;function d(e,t){switch(t.cork&&(t.cork(),c(_,t)),p&&(p=!1,f()),e.cmd){case"connect":return function(e,t){var n=e||{},o=n.protocolId||"MQTT",s=n.protocolVersion||4,a=n.will,c=n.clean,u=n.keepalive||0,l=n.clientId||"",f=n.username,p=n.password;void 0===c&&(c=!0);var d=0;if(!o||"string"!=typeof o&&!i.isBuffer(o))return t.emit("error",new Error("Invalid protocolId")),!1;d+=o.length+2;if(3!==s&&4!==s)return t.emit("error",new Error("Invalid protocol version")),!1;d+=1;if("string"!=typeof l&&!i.isBuffer(l)||!l&&4!==s||!l&&!c){if(s<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*c==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}else d+=l.length+2;if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;d+=2;if(d+=1,a){if("object"!=typeof a)return t.emit("error",new Error("Invalid will")),!1;if(!a.topic||"string"!=typeof a.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(d+=i.byteLength(a.topic)+2,a.payload&&a.payload){if(!(a.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof a.payload?d+=i.byteLength(a.payload)+2:d+=a.payload.length+2}else d+=2}var _=!1;if(null!=f){if(!w(f))return t.emit("error",new Error("Invalid username")),!1;_=!0,d+=i.byteLength(f)+2}if(null!=p){if(!_)return t.emit("error",new Error("Username is required to use password")),!1;if(!w(p))return t.emit("error",new Error("Invalid password")),!1;d+=C(p)+2}t.write(r.CONNECT_HEADER),v(t,d),b(t,o),t.write(4===s?r.VERSION4:r.VERSION3);var g=0;g|=null!=f?r.USERNAME_MASK:0,g|=null!=p?r.PASSWORD_MASK:0,g|=a&&a.retain?r.WILL_RETAIN_MASK:0,g|=a&&a.qos?a.qos<<r.WILL_QOS_SHIFT:0,g|=a?r.WILL_FLAG_MASK:0,g|=c?r.CLEAN_SESSION_MASK:0,t.write(i.from([g])),h(t,u),b(t,l),a&&(m(t,a.topic),b(t,a.payload));null!=f&&b(t,f);null!=p&&b(t,p);return!0}(e,t);case"connack":return function(e,t){var n=(e||{}).returnCode;if("number"!=typeof n)return t.emit("error",new Error("Invalid return code")),!1;return t.write(r.CONNACK_HEADER),v(t,2),t.write(e.sessionPresent?r.SESSIONPRESENT_HEADER:s),t.write(i.from([n]))}(e,t);case"publish":return function(e,t){var n=e||{},s=n.qos||0,a=n.retain?r.RETAIN_MASK:0,c=n.topic,u=n.payload||o,l=n.messageId,f=0;if("string"==typeof c)f+=i.byteLength(c)+2;else{if(!i.isBuffer(c))return t.emit("error",new Error("Invalid topic")),!1;f+=c.length+2}i.isBuffer(u)?f+=u.length:f+=i.byteLength(u);if(s&&"number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;s&&(f+=2);t.write(r.PUBLISH_HEADER[s][e.dup?1:0][a?1:0]),v(t,f),h(t,C(c)),t.write(c),s>0&&h(t,l);return t.write(u)}(e,t);case"puback":case"pubrec":case"pubrel":case"pubcomp":case"unsuback":return function(e,t){var n=e||{},i=n.cmd||"puback",o=n.messageId,s=n.dup&&"pubrel"===i?r.DUP_MASK:0,a=0;"pubrel"===i&&(a=1);if("number"!=typeof o)return t.emit("error",new Error("Invalid messageId")),!1;return t.write(r.ACKS[i][a][s][0]),v(t,2),h(t,o)}(e,t);case"subscribe":return function(e,t){var n=e||{},o=n.dup?r.DUP_MASK:0,s=n.messageId,a=n.subscriptions,c=0;if("number"!=typeof s)return t.emit("error",new Error("Invalid messageId")),!1;c+=2;if("object"!=typeof a||!a.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(var u=0;u<a.length;u+=1){var l=a[u].topic,f=a[u].qos;if("string"!=typeof l)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof f)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;c+=i.byteLength(l)+2+1}t.write(r.SUBSCRIBE_HEADER[1][o?1:0][0]),v(t,c),h(t,s);for(var p=!0,d=0;d<a.length;d++){var _=a[d],g=_.topic,y=_.qos;m(t,g),p=t.write(r.QOS[y])}return p}(e,t);case"suback":return function(e,t){var n=e||{},o=n.messageId,s=n.granted,a=0;if("number"!=typeof o)return t.emit("error",new Error("Invalid messageId")),!1;a+=2;if("object"!=typeof s||!s.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(var c=0;c<s.length;c+=1){if("number"!=typeof s[c])return t.emit("error",new Error("Invalid qos vector")),!1;a+=1}return t.write(r.SUBACK_HEADER),v(t,a),h(t,o),t.write(i.from(s))}(e,t);case"unsubscribe":return function(e,t){var n=e||{},o=n.messageId,s=n.dup?r.DUP_MASK:0,a=n.unsubscriptions,c=0;if("number"!=typeof o)return t.emit("error",new Error("Invalid messageId")),!1;c+=2;if("object"!=typeof a||!a.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(var u=0;u<a.length;u+=1){if("string"!=typeof a[u])return t.emit("error",new Error("Invalid unsubscriptions")),!1;c+=i.byteLength(a[u])+2}t.write(r.UNSUBSCRIBE_HEADER[1][s?1:0][0]),v(t,c),h(t,o);for(var l=!0,f=0;f<a.length;f++)l=m(t,a[f]);return l}(e,t);case"pingreq":case"pingresp":case"disconnect":return function(e,t){return t.write(r.EMPTY[e.cmd])}(e,t);default:return t.emit("error",new Error("Unknown command")),!1}}function _(e){e.uncork()}Object.defineProperty(d,"cacheNumbers",{get:function(){return h===y},set:function(e){e?(u&&0!==Object.keys(u).length||(p=!0),h=y):(p=!1,h=E)}});var g={};function v(e,t){var n=g[t];n||(n=function(e){var t=0,n=0,r=i.allocUnsafe(function(e){return e>=0&&e<128?1:e>=128&&e<16384?2:e>=16384&&e<2097152?3:e>=2097152&&e<268435456?4:0}(e));do{t=e%128|0,(e=e/128|0)>0&&(t|=128),r.writeUInt8(t,n++)}while(e>0);return r}(t),t<16384&&(g[t]=n)),e.write(n)}function m(e,t){var n=i.byteLength(t);h(e,n),e.write(t,"utf8")}function y(e,t){return e.write(u[t])}function E(e,t){return e.write(l(t))}function b(e,t){"string"==typeof t?m(e,t):t?(h(e,t.length),e.write(t)):h(e,0)}function C(e){return e?e instanceof i?e.length:i.byteLength(e):0}function w(e){return"string"==typeof e||e instanceof i}t.exports=d},{"./constants":159,"./numbers":162,"process-nextick-args":180,"safe-buffer":200}],166:[function(e,t,n){(function(n,r){"use strict";var i=e("events"),o=e("./store"),s=e("end-of-stream"),a=e("mqtt-packet"),c=e("readable-stream").Writable,u=e("inherits"),l=e("reinterval"),f=e("./validations"),h=e("xtend"),p=r.setImmediate||function(e){n.nextTick(e)},d={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0};function _(e,t,n){e.emit("packetsend",t),!a.writeToStream(t,e.stream)&&n?e.stream.once("drain",n):n&&n()}function g(e,t,n){e.outgoingStore.put(t,function(r){if(r)return n&&n(r);_(e,t,n)})}function v(){}function m(e,t){var n,r=this;if(!(this instanceof m))return new m(e,t);for(n in this.options=t||{},d)void 0===this.options[n]?this.options[n]=d[n]:this.options[n]=t[n];this.options.clientId="string"==typeof this.options.clientId?this.options.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),this.streamBuilder=e,this.outgoingStore=this.options.outgoingStore||new o,this.incomingStore=this.options.incomingStore||new o,this.queueQoSZero=void 0===this.options.queueQoSZero||this.options.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this.on("connect",function(){if(!this.disconnected){this.connected=!0;var e=this.outgoingStore.createStream();this.once("close",t),e.on("end",function(){r.removeListener("close",t)}),e.on("error",function(e){r.removeListener("close",t),r.emit("error",e)}),function t(){if(e){var n,i=e.read(1);i?r.disconnecting||r.reconnectTimer?e.destroy&&e.destroy():(n=r.outgoing[i.messageId],r.outgoing[i.messageId]=function(e,r){n&&n(e,r),t()},r._sendPacket(i)):e.once("readable",t)}}()}function t(){e.destroy(),e=null}}),this.on("close",function(){this.connected=!1,clearTimeout(this.connackTimer)}),this.on("connect",this._setupPingTimer),this.on("connect",function(){var e=this.queue;!function t(){var n,i=e.shift();i&&(n=i.packet,r._sendPacket(n,function(e){i.cb&&i.cb(e),t()}))}()});var s=!0;this.on("connect",function(){!s&&this.options.clean&&Object.keys(this._resubscribeTopics).length>0&&(this.options.resubscribe?(this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics)):this._resubscribeTopics={}),s=!1}),this.on("close",function(){null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null)}),this.on("close",this._setupReconnect),i.EventEmitter.call(this),this._setupStream()}u(m,i.EventEmitter),m.prototype._setupStream=function(){var e,t=this,r=new c,i=a.parser(this.options),o=null,u=[];function l(){n.nextTick(f)}function f(){var e=u.shift(),n=o;e?t._handlePacket(e,l):(o=null,n())}this._clearReconnect(),this.stream=this.streamBuilder(this),i.on("packet",function(e){u.push(e)}),r._write=function(e,t,n){o=n,i.parse(e),f()},this.stream.pipe(r),this.stream.on("error",v),s(this.stream,this.emit.bind(this,"close")),(e=Object.create(this.options)).cmd="connect",_(this,e),i.on("error",this.emit.bind(this,"error")),this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){t._cleanUp(!0)},this.options.connectTimeout)},m.prototype._handlePacket=function(e,t){switch(this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"pingresp":this._handlePingresp(e),t()}},m.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},m.prototype.publish=function(e,t,n,r){var i;"function"==typeof n&&(r=n,n=null);if(n=h({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(i={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},n.qos){case 1:case 2:this.outgoing[i.messageId]=r||v,this._sendPacket(i);break;default:this._sendPacket(i,r)}return this},m.prototype.subscribe=function(){var e,t,n=Array.prototype.slice.call(arguments),r=[],i=n.shift(),o=i.resubscribe,s=n.pop()||v,a=n.pop(),c=this;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof s&&(a=s,s=v),null!==(t=f.validateTopics(i)))return p(s,new Error("Invalid topic "+t)),this;if(this._checkDisconnecting(s))return this;if(a=h({qos:0},a),Array.isArray(i)?i.forEach(function(e){(c._resubscribeTopics[e]<a.qos||!c._resubscribeTopics.hasOwnProperty(e)||o)&&r.push({topic:e,qos:a.qos})}):Object.keys(i).forEach(function(e){(c._resubscribeTopics[e]<i[e]||!c._resubscribeTopics.hasOwnProperty(e)||o)&&r.push({topic:e,qos:i[e]})}),e={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:this._nextId()},r.length){if(this.options.resubscribe){var u=[];r.forEach(function(e){c.options.reconnectPeriod>0&&(c._resubscribeTopics[e.topic]=e.qos,u.push(e.topic))}),c.messageIdToTopic[e.messageId]=u}return this.outgoing[e.messageId]=function(e,t){if(!e)for(var n=t.granted,i=0;i<n.length;i+=1)r[i].qos=n[i];s(e,r)},this._sendPacket(e),this}s(null,[])},m.prototype.unsubscribe=function(e,t){var n={cmd:"unsubscribe",qos:1,messageId:this._nextId()},r=this;return t=t||v,this._checkDisconnecting(t)?this:("string"==typeof e?n.unsubscriptions=[e]:"object"==typeof e&&e.length&&(n.unsubscriptions=e),this.options.resubscribe&&n.unsubscriptions.forEach(function(e){delete r._resubscribeTopics[e]}),this.outgoing[n.messageId]=t,this._sendPacket(n),this)},m.prototype.end=function(e,t){var n=this;function r(){n.disconnected=!0,n.incomingStore.close(function(){n.outgoingStore.close(function(){t&&t.apply(null,arguments),n.emit("end")})}),n._deferredReconnect&&n._deferredReconnect()}function i(){n._cleanUp(e,p.bind(null,r))}return"function"==typeof e&&(t=e,e=!1),this.disconnecting?this:(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?this.once("outgoingEmpty",setTimeout.bind(null,i,10)):i(),this)},m.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e];return delete this.outgoing[e],this.outgoingStore.del({messageId:e},function(){t(new Error("Message removed"))}),this},m.prototype.reconnect=function(e){var t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},m.prototype._reconnect=function(){this.emit("reconnect"),this._setupStream()},m.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0&&(this.reconnecting||(this.emit("offline"),this.reconnecting=!0),e.reconnectTimer=setInterval(function(){e._reconnect()},e.options.reconnectPeriod))},m.prototype._clearReconnect=function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},m.prototype._cleanUp=function(e,t){var n;t&&this.stream.on("close",t),e?(0===this.options.reconnectPeriod&&this.options.clean&&(n=this.outgoing)&&Object.keys(n).forEach(function(e){"function"==typeof n[e]&&(n[e](new Error("Connection closed")),delete n[e])}),this.stream.destroy()):this._sendPacket({cmd:"disconnect"},p.bind(null,this.stream.end.bind(this.stream))),this.disconnecting||(this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(this.stream.removeListener("close",t),t())},m.prototype._sendPacket=function(e,t){if(this.connected){switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void g(this,e,t);default:return void _(this,e,t)}switch(e.qos){case 2:case 1:g(this,e,t);break;case 0:default:_(this,e,t)}}else 0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId],this.outgoingStore.put(e,function(e){if(e)return t&&t(e)})):t&&t(new Error("No connection to broker"))},m.prototype._setupPingTimer=function(){var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=l(function(){e._checkPing()},1e3*this.options.keepalive))},m.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},m.prototype._checkPing=function(){this.pingResp?(this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):this._cleanUp(!0)},m.prototype._handlePingresp=function(){this.pingResp=!0},m.prototype._handleConnack=function(e){var t=e.returnCode;if(clearTimeout(this.connackTimer),0===t)this.reconnecting=!1,this.emit("connect",e);else if(t>0){var n=new Error("Connection refused: "+["","Unacceptable protocol version","Identifier rejected","Server unavailable","Bad username or password","Not authorized"][t]);n.code=t,this.emit("error",n)}},m.prototype._handlePublish=function(e,t){t=void 0!==t?t:v;var n=e.topic.toString(),r=e.payload,i=e.qos,o=e.messageId,s=this;switch(i){case 2:this.incomingStore.put(e,function(e){if(e)return t(e);s._sendPacket({cmd:"pubrec",messageId:o},t)});break;case 1:this.emit("message",n,r,e),this.handleMessage(e,function(e){if(e)return t(e);s._sendPacket({cmd:"puback",messageId:o},t)});break;case 0:this.emit("message",n,r,e),this.handleMessage(e,t)}},m.prototype.handleMessage=function(e,t){t()},m.prototype._handleAck=function(e){var t=e.messageId,n=e.cmd,r=null,i=this.outgoing[t],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[t],this.outgoingStore.del(e,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:t},this._sendPacket(r);break;case"suback":if(delete this.outgoing[t],1===e.granted.length&&0!=(128&e.granted[0])){var s=this.messageIdToTopic[t];s&&s.forEach(function(e){delete o._resubscribeTopics[e]})}i(null,e);break;case"unsuback":delete this.outgoing[t],i(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}},m.prototype._handlePubrel=function(e,t){t=void 0!==t?t:v;var n=this,r={cmd:"pubcomp",messageId:e.messageId};n.incomingStore.get(e,function(i,o){i||"pubrel"===o.cmd?n._sendPacket(r,t):(n.emit("message",o.topic,o.payload,o),n.incomingStore.put(e,function(e){if(e)return t(e);n.handleMessage(o,function(e){if(e)return t(e);n._sendPacket(r,t)})}))})},m.prototype._nextId=function(){var e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},m.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},t.exports=m}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./store":172,"./validations":173,_process:181,"end-of-stream":83,events:148,inherits:153,"mqtt-packet":161,"readable-stream":197,reinterval:198,xtend:236}],167:[function(e,t,n){(function(n){"use strict";var r=e("../client"),i=e("../store"),o=e("url"),s=e("xtend"),a={};function c(e,t){if("object"!=typeof e||t||(t=e,e=null),t=t||{},e){var n=o.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!a[t.protocol]){var i=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs"].filter(function(e,t){return(!i||t%2!=0)&&"function"==typeof a[e]})[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");return t.protocol&&(t.defaultProtocol=t.protocol),new r(function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a[t.protocol](e,t)},t)}"browser"!==n.title?(a.mqtt=e("./tcp"),a.tcp=e("./tcp"),a.ssl=e("./tls"),a.tls=e("./tls"),a.mqtts=e("./tls")):(a.wx=e("./wx"),a.wxs=e("./wx")),a.ws=e("./ws"),a.wss=e("./ws"),t.exports=c,t.exports.connect=c,t.exports.MqttClient=r,t.exports.Store=i}).call(this,e("_process"))},{"../client":166,"../store":172,"./tcp":168,"./tls":169,"./ws":170,"./wx":171,_process:181,url:218,xtend:236}],168:[function(e,t,n){"use strict";var r=e("net");t.exports=function(e,t){var n,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",n=t.port,i=t.hostname,r.createConnection(n,i)}},{net:46}],169:[function(e,t,n){"use strict";var r=e("tls");t.exports=function(e,t){var n;function i(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,(n=r.connect(t)).on("secureConnect",function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",i)}),n.on("error",i),n}},{tls:46}],170:[function(e,t,n){(function(n){"use strict";var r=e("websocket-stream"),i=e("url"),o=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],s="browser"===n.title;function a(e,t){var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.port||("wss"===e.protocol?e.port=443:e.port=80),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={}),s||"wss"!==e.protocol||o.forEach(function(t){e.hasOwnProperty(t)&&!e.wsOptions.hasOwnProperty(t)&&(e.wsOptions[t]=e[t])})}(t);var i=function(e,t){var n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(t,e);return r(i,[n],t.wsOptions)}t.exports=s?function(e,t){if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");var n=i.parse(document.URL);t.hostname=n.hostname,t.port||(t.port=n.port)}return a(e,t)}:function(e,t){return a(e,t)}}).call(this,e("_process"))},{_process:181,url:218,"websocket-stream":233}],171:[function(e,t,n){"use strict";var r=!1,i=[];function o(e){r?wx.sendSocketMessage({data:e.buffer||e}):i.push(e)}var s=e("websocket-stream");function a(e,t){var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);var a=function(e,t){var n="wxs"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}(t,e);return s(function(e,t){var n={OPEN:1,CLOSING:2,CLOSED:3,readyState:r?1:0,send:o,close:wx.closeSocket,onopen:null,onmessage:null,onclose:null,onerror:null};return wx.connectSocket({url:e,protocols:t}),wx.onSocketOpen(function(e){n.readyState=n.OPEN,r=!0;for(var t=0;t<i.length;t++)o(i[t]);i=[],n.onopen&&n.onopen.apply(n,arguments)}),wx.onSocketMessage(function(e){n.onmessage&&n.onmessage.apply(n,arguments)}),wx.onSocketClose(function(){n.onclose&&n.onclose.apply(n,arguments),n.readyState=n.CLOSED,r=!1}),wx.onSocketError(function(){n.onerror&&n.onerror.apply(n,arguments),n.readyState=n.CLOSED,r=!1}),n}(a,[n]))}t.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");return a(e,t)}},{"websocket-stream":233}],172:[function(e,t,n){(function(n){"use strict";var r=e("xtend"),i=e("readable-stream").Readable,o={objectMode:!0},s={clean:!0},a=e("es6-map");function c(e){if(!(this instanceof c))return new c(e);this.options=e||{},this.options=r(s,e),this._inflights=new a}c.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},c.prototype.createStream=function(){var e=new i(o),t=!1,r=[],s=0;return this._inflights.forEach(function(e,t){r.push(e)}),e._read=function(){!t&&s<r.length?this.push(r[s++]):this.push(null)},e.destroy=function(){if(!t){var e=this;t=!0,n.nextTick(function(){e.emit("close")})}},e},c.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},c.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},c.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=c}).call(this,e("_process"))},{_process:181,"es6-map":132,"readable-stream":197,xtend:236}],173:[function(e,t,n){"use strict";function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}t.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}}},{}],174:[function(e,t,n){function r(e,t){if(!e)throw new Error(t||"AssertionError")}r.notEqual=function(e,t,n){r(e!=t,n)},r.notOk=function(e,t){r(!e,t)},r.equal=function(e,t,n){r(e==t,n)},r.ok=r,t.exports=r},{}],175:[function(e,t,n){var r=e("remove-array-items"),i=e("nanotiming"),o=e("assert");function s(e){if(!(this instanceof s))return new s(e);this._name=e||"nanobus",this._starListeners=[],this._listeners={}}t.exports=s,s.prototype.emit=function(e){o.ok("string"==typeof e||"symbol"==typeof e,"nanobus.emit: eventName should be type string or symbol");for(var t=[],n=1,r=arguments.length;n<r;n++)t.push(arguments[n]);var s=i(this._name+"('"+e.toString()+"')"),a=this._listeners[e];return a&&a.length>0&&this._emit(this._listeners[e],t),this._starListeners.length>0&&this._emit(this._starListeners,e,t,s.uuid),s(),this},s.prototype.on=s.prototype.addListener=function(e,t){return o.ok("string"==typeof e||"symbol"==typeof e,"nanobus.on: eventName should be type string or symbol"),o.equal(typeof t,"function","nanobus.on: listener should be type function"),"*"===e?this._starListeners.push(t):(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)),this},s.prototype.prependListener=function(e,t){return o.ok("string"==typeof e||"symbol"==typeof e,"nanobus.prependListener: eventName should be type string or symbol"),o.equal(typeof t,"function","nanobus.prependListener: listener should be type function"),"*"===e?this._starListeners.unshift(t):(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].unshift(t)),this},s.prototype.once=function(e,t){o.ok("string"==typeof e||"symbol"==typeof e,"nanobus.once: eventName should be type string or symbol"),o.equal(typeof t,"function","nanobus.once: listener should be type function");var n=this;return this.on(e,function r(){t.apply(n,arguments);n.removeListener(e,r)}),this},s.prototype.prependOnceListener=function(e,t){o.ok("string"==typeof e||"symbol"==typeof e,"nanobus.prependOnceListener: eventName should be type string or symbol"),o.equal(typeof t,"function","nanobus.prependOnceListener: listener should be type function");var n=this;return this.prependListener(e,function r(){t.apply(n,arguments);n.removeListener(e,r)}),this},s.prototype.removeListener=function(e,t){return o.ok("string"==typeof e||"symbol"==typeof e,"nanobus.removeListener: eventName should be type string or symbol"),o.equal(typeof t,"function","nanobus.removeListener: listener should be type function"),"*"===e?(this._starListeners=this._starListeners.slice(),n(this._starListeners,t)):(void 0!==this._listeners[e]&&(this._listeners[e]=this._listeners[e].slice()),n(this._listeners[e],t));function n(e,t){if(e){var n=e.indexOf(t);return-1!==n?(r(e,n,1),!0):void 0}}},s.prototype.removeAllListeners=function(e){return e?"*"===e?this._starListeners=[]:this._listeners[e]=[]:(this._starListeners=[],this._listeners={}),this},s.prototype.listeners=function(e){var t="*"!==e?this._listeners[e]:this._starListeners,n=[];if(t)for(var r=t.length,i=0;i<r;i++)n.push(t[i]);return n},s.prototype._emit=function(e,t,n,r){if(void 0!==e&&0!==e.length){void 0===n&&(n=t,t=null),t&&(n=void 0!==r?[t].concat(n,r):[t].concat(n));for(var i=e.length,o=0;o<i;o++){var s=e[o];s.apply(s,n)}}}},{assert:174,nanotiming:177,"remove-array-items":199}],176:[function(e,t,n){var r=e("assert"),i="undefined"!=typeof window;function o(e){this.hasWindow=e,this.hasIdle=this.hasWindow&&window.requestIdleCallback,this.method=this.hasIdle?window.requestIdleCallback.bind(window):this.setTimeout,this.scheduled=!1,this.queue=[]}o.prototype.push=function(e){r.equal(typeof e,"function","nanoscheduler.push: cb should be type function"),this.queue.push(e),this.schedule()},o.prototype.schedule=function(){if(!this.scheduled){this.scheduled=!0;var e=this;this.method(function(t){for(;e.queue.length&&t.timeRemaining()>0;)e.queue.shift()(t);e.scheduled=!1,e.queue.length&&e.schedule()})}},o.prototype.setTimeout=function(e){setTimeout(e,0,{timeRemaining:function(){return 1}})},t.exports=function(){var e;return i?(window._nanoScheduler||(window._nanoScheduler=new o(!0)),e=window._nanoScheduler):e=new o,e}},{assert:174}],177:[function(e,t,n){var r,i=e("nanoscheduler")(),o=e("assert");s.disabled=!0;try{r=window.performance,s.disabled="true"===window.localStorage.DISABLE_NANOTIMING||!r.mark}catch(e){}function s(e){if(o.equal(typeof e,"string","nanotiming: name should be type string"),s.disabled)return a;var t=(1e4*r.now()).toFixed()%Number.MAX_SAFE_INTEGER,n="start-"+t+"-"+e;function c(o){var s="end-"+t+"-"+e;r.mark(s),i.push(function(){var i=null;try{var a=e+" ["+t+"]";r.measure(a,n,s),r.clearMarks(n),r.clearMarks(s)}catch(e){i=e}o&&o(i,e)})}return r.mark(n),c.uuid=t,c}function a(e){e&&i.push(function(){e(new Error("nanotiming: performance API unavailable"))})}t.exports=s},{assert:174,nanoscheduler:176}],178:[function(e,t,n){var r=e("wrappy");function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(i),t.exports.strict=r(o),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},{wrappy:235}],179:[function(e,t,n){(function(e){
// distribute, sublicense, and/or sell copies of the Software, and to permit
function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var o=n.isAbsolute(e),s="/"===i(e,-1);return(e=t(r(e.split("/"),function(e){return!!e}),!o).join("/"))||o||(e="."),e&&s&&(e+="/"),(o?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),a=s,c=0;c<s;c++)if(i[c]!==o[c]){a=c;break}var u=[];for(c=a;c<i.length;c++)u.push("..");return(u=u.concat(o.slice(a))).join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,i=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!i){r=o;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,i=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!i){n=t+1;break}}else-1===r&&(i=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,i=!0,o=0,s=e.length-1;s>=0;--s){var a=e.charCodeAt(s);if(47!==a)-1===r&&(i=!1,r=s+1),46===a?-1===t?t=s:1!==o&&(o=1):-1!==t&&(o=-1);else if(!i){n=s+1;break}}return-1===t||-1===r||0===o||1===o&&t===r-1&&t===n+1?"":e.slice(t,r)};var i="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:181}],180:[function(e,t,n){(function(e){"use strict";void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,n,r,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,i)});default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick(function(){t.apply(null,o)})}}}:t.exports=e}).call(this,e("_process"))},{_process:181}],181:[function(e,t,n){var r,i,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var u,l=[],f=!1,h=-1;function p(){f&&u&&(f=!1,u.length?l=u.concat(l):h=-1,l.length&&d())}function d(){if(!f){var e=c(p);f=!0;for(var t=l.length;t;){for(u=l,l=[];++h<t;)u&&u[h].run();h=-1,t=l.length}u=null,f=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function _(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new _(e,t)),1!==l.length||f||c(d)},_.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],182:[function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty;function i(e,t){return Array.isArray(e)?function(e,t){for(var n,r="",o="",s=Array.isArray(t),a=0;a<e.length;a++)(n=i(e[a]))&&(s&&t[a]&&(n=c(n)),r=r+o+n,o=" ");return r}(e,t):e&&"object"==typeof e?function(e){var t="",n="";for(var i in e)i&&e[i]&&r.call(e,i)&&(t=t+n+i,n=" ");return t}(e):e||""}function o(e){if(!e)return"";if("object"==typeof e){var t="";for(var n in e)r.call(e,n)&&(t=t+n+":"+e[n]+";");return t}return e+""}function s(e,t,n,r){if(!1===t||null==t||!t&&("class"===e||"style"===e))return"";if(!0===t)return" "+(r?e:e+'="'+e+'"');var i=typeof t;return"object"!==i&&"function"!==i||"function"!=typeof t.toJSON||(t=t.toJSON()),"string"==typeof t||(t=JSON.stringify(t),n||-1===t.indexOf('"'))?(n&&(t=c(t))," "+e+'="'+t+'"'):" "+e+"='"+t.replace(/'/g,"&#39;")+"'"}n.merge=function e(t,n){if(1===arguments.length){for(var r=t[0],i=1;i<t.length;i++)r=e(r,t[i]);return r}for(var s in n)if("class"===s){var a=t[s]||[];t[s]=(Array.isArray(a)?a:[a]).concat(n[s]||[])}else if("style"===s){var a=o(t[s]);a=a&&";"!==a[a.length-1]?a+";":a;var c=o(n[s]);c=c&&";"!==c[c.length-1]?c+";":c,t[s]=a+c}else t[s]=n[s];return t},n.classes=i,n.style=o,n.attr=s,n.attrs=function(e,t){var n="";for(var a in e)if(r.call(e,a)){var c=e[a];if("class"===a){c=i(c),n=s(a,c,!1,t)+n;continue}"style"===a&&(c=o(c)),n+=s(a,c,!1,t)}return n};var a=/["&<>]/;function c(e){var t=""+e,n=a.exec(t);if(!n)return e;var r,i,o,s="";for(r=n.index,i=0;r<t.length;r++){switch(t.charCodeAt(r)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;case 62:o="&gt;";break;default:continue}i!==r&&(s+=t.substring(i,r)),i=r+1,s+=o}return i!==r?s+t.substring(i,r):s}n.escape=c,n.rethrow=function t(n,r,i,o){if(!(n instanceof Error))throw n;if(!("undefined"==typeof window&&r||o))throw n.message+=" on line "+i,n;try{o=o||e("fs").readFileSync(r,"utf8")}catch(e){t(n,null,i)}var s=3,a=o.split("\n"),c=Math.max(i-s,0),u=Math.min(a.length,i+s);var s=a.slice(c,u).map(function(e,t){var n=t+c+1;return(n==i?"  > ":"    ")+n+"| "+e}).join("\n");n.path=r;n.message=(r||"Pug")+":"+i+"\n"+s+"\n\n"+n.message;throw n}},{fs:46}],183:[function(e,t,n){(function(e){!function(r){var i="object"==typeof n&&n&&!n.nodeType&&n,o="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,u=2147483647,l=36,f=1,h=26,p=38,d=700,_=72,g=128,v="-",m=/^xn--/,y=/[^\x20-\x7E]/,E=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=l-f,w=Math.floor,T=String.fromCharCode;function R(e){throw RangeError(b[e])}function S(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function I(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+S((e=e.replace(E,".")).split("."),t).join(".")}function N(e){for(var t,n,r=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function O(e){return S(e,function(e){var t="";return e>65535&&(t+=T((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=T(e)}).join("")}function A(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function x(e,t,n){var r=0;for(e=n?w(e/d):e>>1,e+=w(e/t);e>C*h>>1;r+=l)e=w(e/C);return w(r+(C+1)*e/(e+p))}function B(e){var t,n,r,i,o,s,a,c,p,d,m,y=[],E=e.length,b=0,C=g,T=_;for((n=e.lastIndexOf(v))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&R("not-basic"),y.push(e.charCodeAt(r));for(i=n>0?n+1:0;i<E;){for(o=b,s=1,a=l;i>=E&&R("invalid-input"),((c=(m=e.charCodeAt(i++))-48<10?m-22:m-65<26?m-65:m-97<26?m-97:l)>=l||c>w((u-b)/s))&&R("overflow"),b+=c*s,!(c<(p=a<=T?f:a>=T+h?h:a-T));a+=l)s>w(u/(d=l-p))&&R("overflow"),s*=d;T=x(b-o,t=y.length+1,0==o),w(b/t)>u-C&&R("overflow"),C+=w(b/t),b%=t,y.splice(b++,0,C)}return O(y)}function k(e){var t,n,r,i,o,s,a,c,p,d,m,y,E,b,C,S=[];for(y=(e=N(e)).length,t=g,n=0,o=_,s=0;s<y;++s)(m=e[s])<128&&S.push(T(m));for(r=i=S.length,i&&S.push(v);r<y;){for(a=u,s=0;s<y;++s)(m=e[s])>=t&&m<a&&(a=m);for(a-t>w((u-n)/(E=r+1))&&R("overflow"),n+=(a-t)*E,t=a,s=0;s<y;++s)if((m=e[s])<t&&++n>u&&R("overflow"),m==t){for(c=n,p=l;!(c<(d=p<=o?f:p>=o+h?h:p-o));p+=l)C=c-d,b=l-d,S.push(T(A(d+C%b,0))),c=w(C/b);S.push(T(A(c,0))),o=x(n,E,r==i),n=0,++r}++n,++t}return S.join("")}if(a={version:"1.3.2",ucs2:{decode:N,encode:O},decode:B,encode:k,toASCII:function(e){return I(e,function(e){return y.test(e)?"xn--"+k(e):e})},toUnicode:function(e){return I(e,function(e){return m.test(e)?B(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return a});else if(i&&o)if(t.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else r.punycode=a}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],184:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"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 c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var u=e.length;c>0&&u>c&&(u=c);for(var l=0;l<u;++l){var f,h,p,d,_=e[l].replace(a,"%20"),g=_.indexOf(n);g>=0?(f=_.substr(0,g),h=_.substr(g+1)):(f=_,h=""),p=decodeURIComponent(f),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)}},{}],185:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(r(s))+n;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(r(e))}).join(t):a+encodeURIComponent(r(e[s]))}).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],186:[function(e,t,n){"use strict";n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":184,"./encode":185}],187:[function(e,t,n){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":188}],188:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";var r=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=f;var o=Object.create(e("core-util-is"));o.inherits=e("inherits");var s=e("./_stream_readable"),a=e("./_stream_writable");o.inherits(f,s);for(var c=i(a.prototype),u=0;u<c.length;u++){var l=c[u];f.prototype[l]||(f.prototype[l]=a.prototype[l])}function f(e){if(!(this instanceof f))return new f(e);s.call(this,e),a.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",h)}function h(){this.allowHalfOpen||this._writableState.ended||r.nextTick(p,this)}function p(e){e.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),f.prototype._destroy=function(e,t){this.push(null),this.end(),r.nextTick(t,e)}},{"./_stream_readable":190,"./_stream_writable":192,"core-util-is":74,inherits:153,"process-nextick-args":180}],189:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";t.exports=o;var r=e("./_stream_transform"),i=Object.create(e("core-util-is"));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=e("inherits"),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":191,"core-util-is":74,inherits:153}],190:[function(e,t,n){(function(n,r){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";var i=e("process-nextick-args");t.exports=y;var o,s=e("isarray");y.ReadableState=m;e("events").EventEmitter;var a=function(e,t){return e.listeners(t).length},c=e("./internal/streams/stream"),u=e("safe-buffer").Buffer,l=r.Uint8Array||function(){};var f=Object.create(e("core-util-is"));f.inherits=e("inherits");var h=e("util"),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var d,_=e("./internal/streams/BufferList"),g=e("./internal/streams/destroy");f.inherits(y,c);var v=["error","close","destroy","pause","resume"];function m(t,n){o=o||e("./_stream_duplex"),t=t||{};var r=n instanceof o;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,s=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new _,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=e("string_decoder/").StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function y(t){if(o=o||e("./_stream_duplex"),!(this instanceof y))return new y(t);this._readableState=new m(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),c.call(this)}function E(e,t,n,r,i){var o,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;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,T(e)}(e,s)):(i||(o=function(e,t){var n;r=t,u.isBuffer(r)||r instanceof l||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),r?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):b(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?b(e,s,t,!1):S(e,s)):b(e,s,t,!1))):r||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(s)}function b(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&T(e)),S(e,t)}Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),y.prototype.destroy=g.destroy,y.prototype._undestroy=g.undestroy,y.prototype._destroy=function(e,t){this.push(null),t(e)},y.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=u.from(e,t),t=""),n=!0),E(this,e,t,!1,n)},y.prototype.unshift=function(e){return E(this,e,null,!0,!1)},y.prototype.isPaused=function(){return!1===this._readableState.flowing},y.prototype.setEncoding=function(t){return d||(d=e("string_decoder/").StringDecoder),this._readableState.decoder=new d(t),this._readableState.encoding=t,this};var C=8388608;function w(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=C?e=C:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function T(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(R,e):R(e))}function R(e){p("emit readable"),e.emit("readable"),A(e)}function S(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(p("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function N(e){p("readable nexttick read 0"),e.read(0)}function O(e,t){t.reading||(p("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),A(e),t.flowing&&!t.reading&&e.read(0)}function A(e){var t=e._readableState;for(p("flow",t.flowing);t.flowing&&null!==e.read(););}function x(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,r=1,i=n.data;e-=i.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=u.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),0===(e-=s)){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(k,t,e))}function k(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function P(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}y.prototype.read=function(e){p("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(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?B(this):T(this),null;if(0===(e=w(e,t))&&t.ended)return 0===t.length&&B(this),null;var r,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&p("length less than watermark",i=!0),t.ended||t.reading?p("reading or ended",i=!1):i&&(p("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=w(n,t))),null===(r=e>0?x(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&B(this)),null!==r&&this.emit("data",r),r},y.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?l:y;function u(t,n){p("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),e.removeListener("close",v),e.removeListener("finish",m),e.removeListener("drain",f),e.removeListener("error",g),e.removeListener("unpipe",u),r.removeListener("end",l),r.removeListener("end",y),r.removeListener("data",_),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}function l(){p("onend"),e.end()}o.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",u);var f=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,A(e))}}(r);e.on("drain",f);var h=!1;var d=!1;function _(t){p("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==P(o.pipes,e))&&!h&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function g(t){p("onerror",t),y(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",m),y()}function m(){p("onfinish"),e.removeListener("close",v),y()}function y(){p("unpipe"),r.unpipe(e)}return r.on("data",_),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",g),e.once("close",v),e.once("finish",m),e.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),e},y.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};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,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,n);return this}var s=P(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},y.prototype.on=function(e,t){var n=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&T(this):i.nextTick(N,this))}return n},y.prototype.addListener=y.prototype.on,y.prototype.resume=function(){var e=this._readableState;return e.flowing||(p("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(O,e,t))}(this,e)),this},y.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},y.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(p("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(p("wrapped data"),n.decoder&&(i=n.decoder.write(i)),!n.objectMode||null!==i&&void 0!==i)&&((n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause())))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<v.length;o++)e.on(v[o],this.emit.bind(this,v[o]));return this._read=function(t){p("wrapped _read",t),r&&(r=!1,e.resume())},this},Object.defineProperty(y.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),y._fromList=x}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":188,"./internal/streams/BufferList":193,"./internal/streams/destroy":194,"./internal/streams/stream":195,_process:181,"core-util-is":74,events:148,inherits:153,isarray:157,"process-nextick-args":180,"safe-buffer":196,"string_decoder/":203,util:46}],191:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";t.exports=o;var r=e("./_stream_duplex"),i=Object.create(e("core-util-is"));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e),this._transformState={afterTransform:function(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",s)}function s(){var e=this;"function"==typeof this._flush?this._flush(function(t,n){a(e,t,n)}):a(this,null,null)}function a(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}i.inherits=e("inherits"),i.inherits(o,r),o.prototype.push=function(e,t){return this._transformState.needTransform=!1,r.prototype.push.call(this,e,t)},o.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},o.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},o.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},o.prototype._destroy=function(e,t){var n=this;r.prototype._destroy.call(this,e,function(e){t(e),n.emit("close")})}},{"./_stream_duplex":188,"core-util-is":74,inherits:153}],192:[function(e,t,n){(function(n,r,i){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";var o=e("process-nextick-args");function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}t.exports=m;var a,c=!n.browser&&["v0.10","v0.9."].indexOf(n.version.slice(0,5))>-1?i:o.nextTick;m.WritableState=v;var u=Object.create(e("core-util-is"));u.inherits=e("inherits");var l={deprecate:e("util-deprecate")},f=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,p=r.Uint8Array||function(){};var d,_=e("./internal/streams/destroy");function g(){}function v(t,n){a=a||e("./_stream_duplex"),t=t||{};var r=n instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,u=t.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(u||0===u)?u:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===t.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(T,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),T(e,t))}(e,n,r,t,i);else{var s=C(n);s||n.corked||n.bufferProcessing||!n.bufferedRequest||b(e,n),r?c(E,e,n,s,i):E(e,n,s,i)}}(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function m(t){if(a=a||e("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(t);this._writableState=new v(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),f.call(this)}function y(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function E(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),T(e,t)}function b(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,y(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;n;){var u=n.chunk,l=n.encoding,f=n.callback;if(y(e,t,!1,t.objectMode?1:u.length,u,l,f),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function w(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),T(e,t)})}function T(e,t){var n=C(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(w,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}u.inherits(m,f),v.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(v.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof v)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,n){var r,i=this._writableState,s=!1,a=!i.objectMode&&(r=e,h.isBuffer(r)||r instanceof p);return a&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=g),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(a||function(e,t,n,r){var i=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(r,s),i=!1),i}(this,i,e,n))&&(i.pendingcb++,s=function(e,t,n,r,i,o){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n));return t}(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else y(e,t,!1,a,r,i,o);return c}(this,i,a,e,t,n)),s},m.prototype.cork=function(){this._writableState.corked++},m.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||b(this,e))},m.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);return this._writableState.defaultEncoding=e,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},m.prototype._writev=null,m.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||function(e,t,n){t.ending=!0,T(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=_.destroy,m.prototype._undestroy=_.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":188,"./internal/streams/destroy":194,"./internal/streams/stream":195,_process:181,"core-util-is":74,inherits:153,"process-nextick-args":180,"safe-buffer":196,timers:205,"util-deprecate":220}],193:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,i=a,t.copy(n,i),a+=s.data.length,s=s.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":196,util:46}],194:[function(e,t,n){"use strict";var r=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var n=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(r.nextTick(i,n,e),n._writableState&&(n._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":180}],195:[function(e,t,n){t.exports=e("events").EventEmitter},{events:148}],196:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,n),n.Buffer=s),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:48}],197:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=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":188,"./lib/_stream_passthrough.js":189,"./lib/_stream_readable.js":190,"./lib/_stream_transform.js":191,"./lib/_stream_writable.js":192}],198:[function(e,t,n){"use strict";t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new function(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}(arguments[0],arguments[1],e)}},{}],199:[function(e,t,n){"use strict";t.exports=function(e,t,n){var r,i=e.length;if(!(t>=i||0===n)){var o=i-(n=t+n>i?i-t:n);for(r=t;r<o;++r)e[r]=e[r+n];e.length=o}}},{}],200:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,n),n.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:48}],201:[function(e,t,n){"use strict";var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.numChannels=3===t.length?parseInt(t[2],10):1,n},r.writeRtpMap=function(e){var t=e.payloadType;return void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType),"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==e.numChannels?"/"+e.numChannels:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){r.push(t+"="+e.parameters[t])}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var o=n[i],s=r.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var a=r.parseRtpMap(s),c=r.matchPrefix(e,"a=fmtp:"+o+" ");switch(a.parameters=c.length?r.parseFmtp(c[0]):{},a.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(r.parseRtcpFb),t.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(a.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),s=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=a.length>0&&a[0].ssrc,u=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(t=u[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),o&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:s?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var l=r.matchPrefix(e,"b=");return l.length&&(0===l[0].indexOf("b=TIAS:")?l=parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")&&(l=parseInt(l[0].substr(5),10)),n.forEach(function(e){e.maxBitrate=l})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=r.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.writeSessionBoilerplate=function(){return"v=0\r\no=thisisadapterortc 8169639915646943137 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var o=r.writeRtpDescription(e.kind,t);if(o+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var s="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),o},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.exports=r},{}],202:[function(e,t,n){t.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read((n=t,n.buffer.length?n.buffer.head?n.buffer.head.data.length:n.buffer[0].length:n.length)):null;var n}},{}],203:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";var r=e("safe-buffer").Buffer,i=r.isEncoding||function(e){switch((e=""+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}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function l(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}n.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=s(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if((i=s(t[r]))>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if((i=s(t[r]))>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":204}],204:[function(e,t,n){arguments[4][196][0].apply(n,arguments)},{buffer:48,dup:196}],205:[function(e,t,n){(function(t,r){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new u(o.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new u(o.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=c++,r=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof r?r:function(e){delete a[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":181,timers:205}],206:[function(e,t,n){"use strict";var r=e("../prototype/is");t.exports=function(e){if("function"!=typeof e)return!1;if(!hasOwnProperty.call(e,"length"))return!1;try{if("number"!=typeof e.length)return!1;if("function"!=typeof e.call)return!1;if("function"!=typeof e.apply)return!1}catch(e){return!1}return!r(e)}},{"../prototype/is":213}],207:[function(e,t,n){"use strict";var r=e("../value/is"),i=e("../object/is"),o=e("../string/coerce"),s=e("./to-short-string"),a=function(e,t){return e.replace("%v",s(t))};t.exports=function(e,t,n){if(!i(n))throw new TypeError(a(t,e));if(!r(e)){if("default"in n)return n.default;if(n.isOptional)return null}var s=o(n.errorMessage);throw r(s)||(s=t),new TypeError(a(s,e))}},{"../object/is":210,"../string/coerce":214,"../value/is":216,"./to-short-string":209}],208:[function(e,t,n){"use strict";t.exports=function(e){try{return e.toString()}catch(t){try{return String(e)}catch(e){return null}}}},{}],209:[function(e,t,n){"use strict";var r=e("./safe-to-string"),i=/[\n\r\u2028\u2029]/g;t.exports=function(e){var t=r(e);return null===t?"<Non-coercible to string value>":(t.length>100&&(t=t.slice(0,99)+"…"),t=t.replace(i,function(e){switch(e){case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw new Error("Unexpected character")}}))}},{"./safe-to-string":208}],210:[function(e,t,n){"use strict";var r=e("../value/is"),i={object:!0,function:!0,undefined:!0};t.exports=function(e){return!!r(e)&&hasOwnProperty.call(i,typeof e)}},{"../value/is":216}],211:[function(e,t,n){"use strict";var r=e("../lib/resolve-exception"),i=e("./is");t.exports=function(e){return i(e)?e:r(e,"%v is not a plain function",arguments[1])}},{"../lib/resolve-exception":207,"./is":212}],212:[function(e,t,n){"use strict";var r=e("../function/is"),i=/^\s*class[\s{/}]/,o=Function.prototype.toString;t.exports=function(e){return!!r(e)&&!i.test(o.call(e))}},{"../function/is":206}],213:[function(e,t,n){"use strict";var r=e("../object/is");t.exports=function(e){if(!r(e))return!1;try{return!!e.constructor&&e.constructor.prototype===e}catch(e){return!1}}},{"../object/is":210}],214:[function(e,t,n){"use strict";var r=e("../value/is"),i=e("../object/is"),o=Object.prototype.toString;t.exports=function(e){if(!r(e))return null;if(i(e)){var t=e.toString;if("function"!=typeof t)return null;if(t===o)return null}try{return""+e}catch(e){return null}}},{"../object/is":210,"../value/is":216}],215:[function(e,t,n){"use strict";var r=e("../lib/resolve-exception"),i=e("./is");t.exports=function(e){return i(e)?e:r(e,"Cannot use %v",arguments[1])}},{"../lib/resolve-exception":207,"./is":216}],216:[function(e,t,n){"use strict";t.exports=function(e){return void 0!==e&&null!==e}},{}],217:[function(e,t,n){var r,i;r=this,i=function(){function e(){}return e.prototype.encodeReserved=function(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){return/%[0-9A-Fa-f]/.test(e)||(e=encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]")),e}).join("")},e.prototype.encodeUnreserved=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})},e.prototype.encodeValue=function(e,t,n){return t="+"===e||"#"===e?this.encodeReserved(t):this.encodeUnreserved(t),n?this.encodeUnreserved(n)+"="+t:t},e.prototype.isDefined=function(e){return void 0!==e&&null!==e},e.prototype.isKeyOperator=function(e){return";"===e||"&"===e||"?"===e},e.prototype.getValues=function(e,t,n,r){var i=e[n],o=[];if(this.isDefined(i)&&""!==i)if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)i=i.toString(),r&&"*"!==r&&(i=i.substring(0,parseInt(r,10))),o.push(this.encodeValue(t,i,this.isKeyOperator(t)?n:null));else if("*"===r)Array.isArray(i)?i.filter(this.isDefined).forEach(function(e){o.push(this.encodeValue(t,e,this.isKeyOperator(t)?n:null))},this):Object.keys(i).forEach(function(e){this.isDefined(i[e])&&o.push(this.encodeValue(t,i[e],e))},this);else{var s=[];Array.isArray(i)?i.filter(this.isDefined).forEach(function(e){s.push(this.encodeValue(t,e))},this):Object.keys(i).forEach(function(e){this.isDefined(i[e])&&(s.push(this.encodeUnreserved(e)),s.push(this.encodeValue(t,i[e].toString())))},this),this.isKeyOperator(t)?o.push(this.encodeUnreserved(n)+"="+s.join(",")):0!==s.length&&o.push(s.join(","))}else";"===t?this.isDefined(i)&&o.push(this.encodeUnreserved(n)):""!==i||"&"!==t&&"?"!==t?""===i&&o.push(""):o.push(this.encodeUnreserved(n)+"=");return o},e.prototype.parse=function(e){var t=this,n=["+","#",".","/",";","?","&"];return{expand:function(r){return e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(e,i,o){if(i){var s=null,a=[];if(-1!==n.indexOf(i.charAt(0))&&(s=i.charAt(0),i=i.substr(1)),i.split(/,/g).forEach(function(e){var n=/([^:\*]*)(?::(\d+)|(\*))?/.exec(e);a.push.apply(a,t.getValues(r,s,n[1],n[2]||n[3]))}),s&&"+"!==s){var c=",";return"?"===s?c="&":"#"!==s&&(c=s),(0!==a.length?s:"")+a.join(c)}return a.join(",")}return t.encodeReserved(o)})}}},new e},"object"==typeof n?t.exports=i():"function"==typeof define&&define.amd?define([],i):r.urltemplate=i()},{}],218:[function(e,t,n){
// distribute, sublicense, and/or sell copies of the Software, and to permit
"use strict";var r=e("punycode"),i=e("./util");function o(){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}n.parse=y,n.resolve=function(e,t){return y(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?y(e,!1,!0).resolveObject(t):t},n.format=function(e){i.isString(e)&&(e=y(e));return e instanceof o?e.format():o.prototype.format.call(e)},n.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(u),f=["%","/","?",";","#"].concat(l),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,_={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=e("querystring");function y(e,t,n){if(e&&i.isObject(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}o.prototype.parse=function(e,t,n){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o<e.indexOf("#")?"?":"#",u=e.split(a);u[0]=u[0].replace(/\\/g,"/");var y=e=u.join(a);if(y=y.trim(),!n&&1===e.split("#").length){var E=c.exec(y);if(E)return this.path=y,this.href=y,this.pathname=E[1],E[2]?(this.search=E[2],this.query=t?m.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var b=s.exec(y);if(b){var C=(b=b[0]).toLowerCase();this.protocol=C,y=y.substr(b.length)}if(n||b||y.match(/^\/\/[^@\/]+@[^@\/]+/)){var w="//"===y.substr(0,2);!w||b&&g[b]||(y=y.substr(2),this.slashes=!0)}if(!g[b]&&(w||b&&!v[b])){for(var T,R,S=-1,I=0;I<h.length;I++){-1!==(N=y.indexOf(h[I]))&&(-1===S||N<S)&&(S=N)}-1!==(R=-1===S?y.lastIndexOf("@"):y.lastIndexOf("@",S))&&(T=y.slice(0,R),y=y.slice(R+1),this.auth=decodeURIComponent(T)),S=-1;for(I=0;I<f.length;I++){var N;-1!==(N=y.indexOf(f[I]))&&(-1===S||N<S)&&(S=N)}-1===S&&(S=y.length),this.host=y.slice(0,S),y=y.slice(S),this.parseHost(),this.hostname=this.hostname||"";var O="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!O)for(var A=this.hostname.split(/\./),x=(I=0,A.length);I<x;I++){var B=A[I];if(B&&!B.match(p)){for(var k="",P=0,D=B.length;P<D;P++)B.charCodeAt(P)>127?k+="x":k+=B[P];if(!k.match(p)){var L=A.slice(0,I),W=A.slice(I+1),j=B.match(d);j&&(L.push(j[1]),W.unshift(j[2])),W.length&&(y="/"+W.join(".")+y),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),O||(this.hostname=r.toASCII(this.hostname));var M=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+M,this.href+=this.host,O&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!_[C])for(I=0,x=l.length;I<x;I++){var F=l[I];if(-1!==y.indexOf(F)){var G=encodeURIComponent(F);G===F&&(G=escape(F)),y=y.split(F).join(G)}}var q=y.indexOf("#");-1!==q&&(this.hash=y.substr(q),y=y.slice(0,q));var H=y.indexOf("?");if(-1!==H?(this.search=y.substr(H),this.query=y.substr(H+1),t&&(this.query=m.parse(this.query)),y=y.slice(0,H)):t&&(this.search="",this.query={}),y&&(this.pathname=y),v[C]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){M=this.pathname||"";var V=this.search||"";this.path=M+V}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,s="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(s=m.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):o||(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+o+(n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}))+(a=a.replace("#","%23"))+r},o.prototype.resolve=function(e){return this.resolveObject(y(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if(i.isString(e)){var t=new o;t.parse(e,!1,!0),e=t}for(var n=new o,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0;u<c.length;u++){var l=c[u];"protocol"!==l&&(n[l]=e[l])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var f=Object.keys(e),h=0;h<f.length;h++){var p=f[h];n[p]=e[p]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||g[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var _=n.pathname||"",m=n.search||"";n.path=_+m}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var y=n.pathname&&"/"===n.pathname.charAt(0),E=e.host||e.pathname&&"/"===e.pathname.charAt(0),b=E||y||n.host&&e.pathname,C=b,w=n.pathname&&n.pathname.split("/")||[],T=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(T&&(n.hostname="",n.port=null,n.host&&(""===w[0]?w[0]=n.host:w.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),b=b&&(""===d[0]||""===w[0])),E)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,w=d;else if(d.length)w||(w=[]),w.pop(),w=w.concat(d),n.search=e.search,n.query=e.query;else if(!i.isNullOrUndefined(e.search)){if(T)n.hostname=n.host=w.shift(),(O=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=O.shift(),n.host=n.hostname=O.shift());return n.search=e.search,n.query=e.query,i.isNull(n.pathname)&&i.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 R=w.slice(-1)[0],S=(n.host||e.host||w.length>1)&&("."===R||".."===R)||""===R,I=0,N=w.length;N>=0;N--)"."===(R=w[N])?w.splice(N,1):".."===R?(w.splice(N,1),I++):I&&(w.splice(N,1),I--);if(!b&&!C)for(;I--;I)w.unshift("..");!b||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),S&&"/"!==w.join("/").substr(-1)&&w.push("");var O,A=""===w[0]||w[0]&&"/"===w[0].charAt(0);T&&(n.hostname=n.host=A?"":w.length?w.shift():"",(O=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=O.shift(),n.host=n.hostname=O.shift()));return(b=b||n.host&&w.length)&&!A&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.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},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":219,punycode:183,querystring:186}],219:[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}}},{}],220:[function(e,t,n){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],221:[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}},{}],222:[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}},{}],223:[function(e,t,n){(function(t,r){
// distribute, sublicense, and/or sell copies of the Software, and to permit
var i=/%[sdj%]/g;n.format=function(e){if(!v(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(a(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,s=String(e).replace(i,function(e){if("%%"===e)return"%";if(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(e){return"[Circular]"}default:return e}}),c=r[n];n<o;c=r[++n])_(c)||!E(c)?s+=" "+c:s+=" "+a(c);return s},n.deprecate=function(e,i){if(m(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(!0===t.noDeprecation)return e;var o=!1;return function(){if(!o){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}};var o,s={};function a(e,t){var r={seen:[],stylize:u};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(t)?r.showHidden=t:t&&n._extend(r,t),m(r.showHidden)&&(r.showHidden=!1),m(r.depth)&&(r.depth=2),m(r.colors)&&(r.colors=!1),m(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),l(r,e,r.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function u(e,t){return e}function l(e,t,r){if(e.customInspect&&t&&w(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return v(i)||(i=l(e,i,r)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(g(t))return e.stylize(""+t,"number");if(d(t))return e.stylize(""+t,"boolean");if(_(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),C(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(t);if(0===s.length){if(w(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(y(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(b(t))return e.stylize(Date.prototype.toString.call(t),"date");if(C(t))return f(t)}var u,E="",T=!1,R=["{","}"];(p(t)&&(T=!0,R=["[","]"]),w(t))&&(E=" [Function"+(t.name?": "+t.name:"")+"]");return y(t)&&(E=" "+RegExp.prototype.toString.call(t)),b(t)&&(E=" "+Date.prototype.toUTCString.call(t)),C(t)&&(E=" "+f(t)),0!==s.length||T&&0!=t.length?r<0?y(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=T?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)I(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}(e,t,r,a,s):s.map(function(n){return h(e,t,r,a,n,T)}),e.seen.pop(),function(e,t,n){if(e.reduce(function(e,t){return 0,t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(u,E,R)):R[0]+E+R[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),I(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=_(n)?l(e,c.value,null):l(e,c.value,n-1)).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")),m(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).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){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function _(e){return null===e}function g(e){return"number"==typeof e}function v(e){return"string"==typeof e}function m(e){return void 0===e}function y(e){return E(e)&&"[object RegExp]"===T(e)}function E(e){return"object"==typeof e&&null!==e}function b(e){return E(e)&&"[object Date]"===T(e)}function C(e){return E(e)&&("[object Error]"===T(e)||e instanceof Error)}function w(e){return"function"==typeof e}function T(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(m(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=t.pid;s[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else s[e]=function(){};return s[e]},n.inspect=a,a.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]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=d,n.isNull=_,n.isNullOrUndefined=function(e){return null==e},n.isNumber=g,n.isString=v,n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=m,n.isRegExp=y,n.isObject=E,n.isDate=b,n.isError=C,n.isFunction=w,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e("./support/isBuffer");var S=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":"),[e.getDate(),S[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!E(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":222,_process:181,inherits:221}],224:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";!function(){var n=e("./utils").log,r=e("./utils").browserDetails;t.exports.browserDetails=r,t.exports.extractVersion=e("./utils").extractVersion,t.exports.disableLog=e("./utils").disableLog;var i=e("./chrome/chrome_shim")||null,o=e("./edge/edge_shim")||null,s=e("./firefox/firefox_shim")||null,a=e("./safari/safari_shim")||null;switch(r.browser){case"opera":case"chrome":if(!i||!i.shimPeerConnection)return void n("Chrome shim is not included in this adapter release.");n("adapter.js shimming chrome."),t.exports.browserShim=i,i.shimGetUserMedia(),i.shimMediaStream(),i.shimSourceObject(),i.shimPeerConnection(),i.shimOnTrack();break;case"firefox":if(!s||!s.shimPeerConnection)return void n("Firefox shim is not included in this adapter release.");n("adapter.js shimming firefox."),t.exports.browserShim=s,s.shimGetUserMedia(),s.shimSourceObject(),s.shimPeerConnection(),s.shimOnTrack();break;case"edge":if(!o||!o.shimPeerConnection)return void n("MS edge shim is not included in this adapter release.");n("adapter.js shimming edge."),t.exports.browserShim=o,o.shimGetUserMedia(),o.shimPeerConnection();break;case"safari":if(!a)return void n("Safari shim is not included in this adapter release.");n("adapter.js shimming safari."),t.exports.browserShim=a,a.shimGetUserMedia();break;default:n("Unsupported browser!")}}()},{"./chrome/chrome_shim":225,"./edge/edge_shim":227,"./firefox/firefox_shim":229,"./safari/safari_shim":231,"./utils":232}],225:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r=e("../utils.js").log,i=e("../utils.js").browserDetails,o={shimMediaStream:function(){window.MediaStream=window.MediaStream||window.webkitMediaStream},shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){var t=this;this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.addEventListener("addtrack",function(n){var r=new Event("track");r.track=n.track,r.receiver={track:n.track},r.streams=[e.stream],t.dispatchEvent(r)}),e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var t=this;this._srcObject=e,this.src&&URL.revokeObjectURL(this.src),e?(this.src=URL.createObjectURL(e),e.addEventListener("addtrack",function(){t.src&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)}),e.addEventListener("removetrack",function(){t.src&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)})):this.src=""}}))},shimPeerConnection:function(){window.RTCPeerConnection=function(e,t){r("PeerConnection"),e&&e.iceTransportPolicy&&(e.iceTransports=e.iceTransportPolicy);var n=new webkitRTCPeerConnection(e,t),i=n.getStats.bind(n);return n.getStats=function(e,t,n){var r=this,o=arguments;if(arguments.length>0&&"function"==typeof e)return i(e,t);var s=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},a=function(e,t){var n=new Map(Object.keys(e).map(function(t){return[t,e[t]]}));return t=t||e,Object.keys(t).forEach(function(e){n[e]=t[e]}),n};if(arguments.length>=2){return i.apply(this,[function(e){o[1](a(s(e)))},arguments[0]])}return new Promise(function(t,n){1===o.length&&"object"==typeof e?i.apply(r,[function(e){t(a(s(e)))},n]):i.apply(r,[function(e){t(a(s(e),e.result()))},n])}).then(t,n)},n},window.RTCPeerConnection.prototype=webkitRTCPeerConnection.prototype,webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return webkitRTCPeerConnection.generateCertificate}}),["createOffer","createAnswer"].forEach(function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var n=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){t.apply(e,[r,i,n])})}return t.apply(this,arguments)}}),i.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){var e=arguments,n=this,r=new Promise(function(r,i){t.apply(n,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}});var e=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return null===arguments[0]?Promise.resolve():e.apply(this,arguments)},["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}})},attachMediaStream:function(e,t){r("DEPRECATED, attachMediaStream will soon be removed."),i.version>=43?e.srcObject=t:void 0!==e.src?e.src=URL.createObjectURL(t):r("Error attaching stream to element.")},reattachMediaStream:function(e,t){r("DEPRECATED, reattachMediaStream will soon be removed."),i.version>=43?e.srcObject=t.srcObject:e.src=t.src}};t.exports={shimMediaStream:o.shimMediaStream,shimOnTrack:o.shimOnTrack,shimSourceObject:o.shimSourceObject,shimPeerConnection:o.shimPeerConnection,shimGetUserMedia:e("./getusermedia"),attachMediaStream:o.attachMediaStream,reattachMediaStream:o.reattachMediaStream}},{"../utils.js":232,"./getusermedia":226}],226:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r=e("../utils.js").log;t.exports=function(){var e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var o={};"number"==typeof r.ideal?(o[i("min",n)]=r.ideal,t.optional.push(o),(o={})[i("max",n)]=r.ideal,t.optional.push(o)):(o[i("",n)]=r.ideal,t.optional.push(o))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(t,n){if((t=JSON.parse(JSON.stringify(t)))&&t.audio&&(t.audio=e(t.audio)),t&&"object"==typeof t.video){var i=t.video.facingMode;if((i=i&&("object"==typeof i?i:{ideal:i}))&&("user"===i.exact||"environment"===i.exact||"user"===i.ideal||"environment"===i.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode)&&(delete t.video.facingMode,"environment"===i.exact||"environment"===i.ideal))return navigator.mediaDevices.enumerateDevices().then(function(o){var s=(o=o.filter(function(e){return"videoinput"===e.kind})).find(function(e){return-1!==e.label.toLowerCase().indexOf("back")})||o.length&&o[o.length-1];return s&&(t.video.deviceId=i.exact?{exact:s.deviceId}:{ideal:s.deviceId}),t.video=e(t.video),r("chrome: "+JSON.stringify(t)),n(t)});t.video=e(t.video)}return r("chrome: "+JSON.stringify(t)),n(t)},n=function(e){return{name:{PermissionDeniedError:"NotAllowedError",ConstraintNotSatisfiedError:"OverconstrainedError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};navigator.getUserMedia=function(e,r,i){t(e,function(e){navigator.webkitGetUserMedia(e,r,function(e){i(n(e))})})};var i=function(e){return new Promise(function(t,n){navigator.getUserMedia(e,t,n)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:i,enumerateDevices:function(){return new Promise(function(e){var t={audio:"audioinput",video:"videoinput"};return MediaStreamTrack.getSources(function(n){e(n.map(function(e){return{label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""}}))})})}}),navigator.mediaDevices.getUserMedia){var o=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(e){return t(e,function(e){return o(e).catch(function(e){return Promise.reject(n(e))})})}}else navigator.mediaDevices.getUserMedia=function(e){return i(e)};void 0===navigator.mediaDevices.addEventListener&&(navigator.mediaDevices.addEventListener=function(){r("Dummy mediaDevices.addEventListener called.")}),void 0===navigator.mediaDevices.removeEventListener&&(navigator.mediaDevices.removeEventListener=function(){r("Dummy mediaDevices.removeEventListener called.")})}},{"../utils.js":232}],227:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r=e("sdp"),i=e("../utils").log,o={shimPeerConnection:function(){window.RTCIceGatherer&&(window.RTCIceCandidate||(window.RTCIceCandidate=function(e){return e}),window.RTCSessionDescription||(window.RTCSessionDescription=function(e){return e})),window.RTCPeerConnection=function(e){var t=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){t[e]=n[e].bind(n)}),this.onicecandidate=null,this.onaddstream=null,this.ontrack=null,this.onremovestream=null,this.onsignalingstatechange=null,this.oniceconnectionstatechange=null,this.onnegotiationneeded=null,this.ondatachannel=null,this.localStreams=[],this.remoteStreams=[],this.getLocalStreams=function(){return t.localStreams},this.getRemoteStreams=function(){return t.remoteStreams},this.localDescription=new RTCSessionDescription({type:"",sdp:""}),this.remoteDescription=new RTCSessionDescription({type:"",sdp:""}),this.signalingState="stable",this.iceConnectionState="new",this.iceGatheringState="new",this.iceOptions={gatherPolicy:"all",iceServers:[]},e&&e.iceTransportPolicy)switch(e.iceTransportPolicy){case"all":case"relay":this.iceOptions.gatherPolicy=e.iceTransportPolicy;break;case"none":throw new TypeError('iceTransportPolicy "none" not supported')}if(this.usingBundle=e&&"max-bundle"===e.bundlePolicy,e&&e.iceServers){var r=JSON.parse(JSON.stringify(e.iceServers));this.iceOptions.iceServers=r.filter(function(e){if(e&&e.urls){var t=e.urls;return"string"==typeof t&&(t=[t]),!!(t=t.filter(function(e){return 0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")})[0])}return!1})}this.transceivers=[],this._localIceCandidatesBuffer=[]},window.RTCPeerConnection.prototype._emitBufferedCandidates=function(){var e=this,t=r.splitSections(e.localDescription.sdp);this._localIceCandidatesBuffer.forEach(function(n){if(!n.candidate||0===Object.keys(n.candidate).length)for(var r=1;r<t.length;r++)-1===t[r].indexOf("\r\na=end-of-candidates\r\n")&&(t[r]+="a=end-of-candidates\r\n");else-1===n.candidate.candidate.indexOf("typ endOfCandidates")&&(t[n.candidate.sdpMLineIndex+1]+="a="+n.candidate.candidate+"\r\n");(e.localDescription.sdp=t.join(""),e.dispatchEvent(n),null!==e.onicecandidate&&e.onicecandidate(n),n.candidate||"complete"===e.iceGatheringState)||e.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state})&&(e.iceGatheringState="complete")}),this._localIceCandidatesBuffer=[]},window.RTCPeerConnection.prototype.addStream=function(e){this.localStreams.push(e.clone()),this._maybeFireNegotiationNeeded()},window.RTCPeerConnection.prototype.removeStream=function(e){var t=this.localStreams.indexOf(e);t>-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},window.RTCPeerConnection.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},window.RTCPeerConnection.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},window.RTCPeerConnection.prototype._getCommonCapabilities=function(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]};return e.codecs.forEach(function(e){for(var r=0;r<t.codecs.length;r++){var i=t.codecs[r];if(e.name.toLowerCase()===i.name.toLowerCase()&&e.clockRate===i.clockRate&&e.numChannels===i.numChannels){n.codecs.push(i);break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n},window.RTCPeerConnection.prototype._createIceAndDtlsTransports=function(e,t){var n=this,i=new RTCIceGatherer(n.iceOptions),o=new RTCIceTransport(i);i.onlocalcandidate=function(s){var a=new Event("icecandidate");a.candidate={sdpMid:e,sdpMLineIndex:t};var c=s.candidate,u=!c||0===Object.keys(c).length;u?(void 0===i.state&&(i.state="completed"),a.candidate.candidate="candidate:1 1 udp 1 0.0.0.0 9 typ endOfCandidates"):(c.component="RTCP"===o.component?2:1,a.candidate.candidate=r.writeCandidate(c));var l=r.splitSections(n.localDescription.sdp);-1===a.candidate.candidate.indexOf("typ endOfCandidates")?l[a.candidate.sdpMLineIndex+1]+="a="+a.candidate.candidate+"\r\n":l[a.candidate.sdpMLineIndex+1]+="a=end-of-candidates\r\n",n.localDescription.sdp=l.join("");var f=n.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});switch(n.iceGatheringState){case"new":n._localIceCandidatesBuffer.push(a),u&&f&&n._localIceCandidatesBuffer.push(new Event("icecandidate"));break;case"gathering":n._emitBufferedCandidates(),n.dispatchEvent(a),null!==n.onicecandidate&&n.onicecandidate(a),f&&(n.dispatchEvent(new Event("icecandidate")),null!==n.onicecandidate&&n.onicecandidate(new Event("icecandidate")),n.iceGatheringState="complete")}},o.onicestatechange=function(){n._updateConnectionState()};var s=new RTCDtlsTransport(o);return s.ondtlsstatechange=function(){n._updateConnectionState()},s.onerror=function(){s.state="failed",n._updateConnectionState()},{iceGatherer:i,iceTransport:o,dtlsTransport:s}},window.RTCPeerConnection.prototype._transceive=function(e,t,n){var i=this._getCommonCapabilities(e.localCapabilities,e.remoteCapabilities);t&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:r.localCName},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),n&&e.rtpReceiver&&(i.encodings=e.recvEncodingParameters,i.rtcp={cname:e.cname},e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},window.RTCPeerConnection.prototype.setLocalDescription=function(e){var t,n,i=this;if("offer"===e.type)this._pendingOffer&&(t=r.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=r.parseRtpParameters(e);i._pendingOffer[t].localCapabilities=n}),this.transceivers=this._pendingOffer,delete this._pendingOffer);else if("answer"===e.type){t=r.splitSections(i.remoteDescription.sdp),n=t.shift();var o=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var s=i.transceivers[t],a=s.iceGatherer,c=s.iceTransport,u=s.dtlsTransport,l=s.localCapabilities,f=s.remoteCapabilities;if(!("0"===e.split("\n",1)[0].split(" ",2)[1])){var h=r.getIceParameters(e,n);if(o){var p=r.matchPrefix(e,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return"1"===e.component});p.length&&c.setRemoteCandidates(p)}var d=r.getDtlsParameters(e,n);o&&(d.role="server"),i.usingBundle&&0!==t||(c.start(a,h,o?"controlling":"controlled"),u.start(d));var _=i._getCommonCapabilities(l,f);i._transceive(s,_.codecs.length>0,!1)}})}switch(this.localDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}var s=arguments.length>1&&"function"==typeof arguments[1];if(s){var a=arguments[1];window.setTimeout(function(){a(),"new"===i.iceGatheringState&&(i.iceGatheringState="gathering"),i._emitBufferedCandidates()},0)}var c=Promise.resolve();return c.then(function(){s||("new"===i.iceGatheringState&&(i.iceGatheringState="gathering"),window.setTimeout(i._emitBufferedCandidates.bind(i),500))}),c},window.RTCPeerConnection.prototype.setRemoteDescription=function(e){var t=this,n=new MediaStream,i=[],o=r.splitSections(e.sdp),s=o.shift(),a=r.matchPrefix(s,"a=ice-lite").length>0;switch(this.usingBundle=r.matchPrefix(s,"a=group:BUNDLE ").length>0,o.forEach(function(o,c){var u,l,f,h,p,d,_,g,v,m,y,E,b=r.splitLines(o)[0].substr(2).split(" "),C=b[0],w="0"===b[1],T=r.getDirection(o,s),R=r.parseRtpParameters(o);w||(y=r.getIceParameters(o,s),(E=r.getDtlsParameters(o,s)).role="client"),g=r.parseRtpEncodingParameters(o);var S,I=r.matchPrefix(o,"a=mid:");I=I.length?I[0].substr(6):r.generateIdentifier();var N=r.matchPrefix(o,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];N&&(S=N.value);var O=r.matchPrefix(o,"a=end-of-candidates").length>0,A=r.matchPrefix(o,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return"1"===e.component});if("offer"!==e.type||w)"answer"!==e.type||w||(l=(u=t.transceivers[c]).iceGatherer,f=u.iceTransport,h=u.dtlsTransport,p=u.rtpSender,d=u.rtpReceiver,_=u.sendEncodingParameters,v=u.localCapabilities,t.transceivers[c].recvEncodingParameters=g,t.transceivers[c].remoteCapabilities=R,t.transceivers[c].cname=S,(a||O)&&A.length&&f.setRemoteCandidates(A),t.usingBundle&&0!==c||(f.start(l,y,"controlling"),h.start(E)),t._transceive(u,"sendrecv"===T||"recvonly"===T,"sendrecv"===T||"sendonly"===T),!d||"sendrecv"!==T&&"sendonly"!==T?delete u.rtpReceiver:(m=d.track,i.push([m,d]),n.addTrack(m)));else{var x=t.usingBundle&&c>0?{iceGatherer:t.transceivers[0].iceGatherer,iceTransport:t.transceivers[0].iceTransport,dtlsTransport:t.transceivers[0].dtlsTransport}:t._createIceAndDtlsTransports(I,c);if(O&&x.iceTransport.setRemoteCandidates(A),v=RTCRtpReceiver.getCapabilities(C),_=[{ssrc:1001*(2*c+2)}],m=(d=new RTCRtpReceiver(x.dtlsTransport,C)).track,i.push([m,d]),n.addTrack(m),t.localStreams.length>0&&t.localStreams[0].getTracks().length>=c){var B=t.localStreams[0].getTracks()[c];p=new RTCRtpSender(B,x.dtlsTransport)}t.transceivers[c]={iceGatherer:x.iceGatherer,iceTransport:x.iceTransport,dtlsTransport:x.dtlsTransport,localCapabilities:v,remoteCapabilities:R,rtpSender:p,rtpReceiver:d,kind:C,mid:I,cname:S,sendEncodingParameters:_,recvEncodingParameters:g},t._transceive(t.transceivers[c],!1,"sendrecv"===T||"sendonly"===T)}}),this.remoteDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}return n.getTracks().length&&(t.remoteStreams.push(n),window.setTimeout(function(){var e=new Event("addstream");e.stream=n,t.dispatchEvent(e),null!==t.onaddstream&&window.setTimeout(function(){t.onaddstream(e)},0),i.forEach(function(r){var i=r[0],o=r[1],s=new Event("track");s.track=i,s.receiver=o,s.streams=[n],t.dispatchEvent(e),null!==t.ontrack&&window.setTimeout(function(){t.ontrack(s)},0)})},0)),arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},window.RTCPeerConnection.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._updateSignalingState("closed")},window.RTCPeerConnection.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),null!==this.onsignalingstatechange&&this.onsignalingstatechange(t)},window.RTCPeerConnection.prototype._maybeFireNegotiationNeeded=function(){var e=new Event("negotiationneeded");this.dispatchEvent(e),null!==this.onnegotiationneeded&&this.onnegotiationneeded(e)},window.RTCPeerConnection.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0||t.checking>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":(t.connected>0||t.completed>0)&&(e="connected"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this.dispatchEvent(n),null!==this.oniceconnectionstatechange&&this.oniceconnectionstatechange(n)}},window.RTCPeerConnection.prototype.createOffer=function(){var e,t=this;if(this._pendingOffer)throw new Error("createOffer called while there is a pending offer.");1===arguments.length&&"function"!=typeof arguments[0]?e=arguments[0]:3===arguments.length&&(e=arguments[2]);var n=[],i=0,o=0;if(this.localStreams.length&&(i=this.localStreams[0].getAudioTracks().length,o=this.localStreams[0].getVideoTracks().length),e){if(e.mandatory||e.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==e.offerToReceiveAudio&&(i=e.offerToReceiveAudio),void 0!==e.offerToReceiveVideo&&(o=e.offerToReceiveVideo)}for(this.localStreams.length&&this.localStreams[0].getTracks().forEach(function(e){n.push({kind:e.kind,track:e,wantReceive:"audio"===e.kind?i>0:o>0}),"audio"===e.kind?i--:"video"===e.kind&&o--});i>0||o>0;)i>0&&(n.push({kind:"audio",wantReceive:!0}),i--),o>0&&(n.push({kind:"video",wantReceive:!0}),o--);var s=r.writeSessionBoilerplate(),a=[];n.forEach(function(e,n){var i,o,s=e.track,c=e.kind,u=r.generateIdentifier(),l=t.usingBundle&&n>0?{iceGatherer:a[0].iceGatherer,iceTransport:a[0].iceTransport,dtlsTransport:a[0].dtlsTransport}:t._createIceAndDtlsTransports(u,n),f=RTCRtpSender.getCapabilities(c),h=[{ssrc:1001*(2*n+1)}];s&&(i=new RTCRtpSender(s,l.dtlsTransport)),e.wantReceive&&(o=new RTCRtpReceiver(l.dtlsTransport,c)),a[n]={iceGatherer:l.iceGatherer,iceTransport:l.iceTransport,dtlsTransport:l.dtlsTransport,localCapabilities:f,remoteCapabilities:null,rtpSender:i,rtpReceiver:o,kind:c,mid:u,sendEncodingParameters:h,recvEncodingParameters:null}}),this.usingBundle&&(s+="a=group:BUNDLE "+a.map(function(e){return e.mid}).join(" ")+"\r\n"),n.forEach(function(e,n){var i=a[n];s+=r.writeMediaSection(i,i.localCapabilities,"offer",t.localStreams[0])}),this._pendingOffer=a;var c=new RTCSessionDescription({type:"offer",sdp:s});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,c),Promise.resolve(c)},window.RTCPeerConnection.prototype.createAnswer=function(){var e=this,t=r.writeSessionBoilerplate();this.usingBundle&&(t+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),this.transceivers.forEach(function(n){var i=e._getCommonCapabilities(n.localCapabilities,n.remoteCapabilities);t+=r.writeMediaSection(n,i,"answer",e.localStreams[0])});var n=new RTCSessionDescription({type:"answer",sdp:t});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,n),Promise.resolve(n)},window.RTCPeerConnection.prototype.addIceCandidate=function(e){if(null===e)this.transceivers.forEach(function(e){e.iceTransport.addRemoteCandidate({})});else{var t=e.sdpMLineIndex;if(e.sdpMid)for(var n=0;n<this.transceivers.length;n++)if(this.transceivers[n].mid===e.sdpMid){t=n;break}var i=this.transceivers[t];if(i){var o=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===o.protocol&&0===o.port)return;if("1"!==o.component)return;"endOfCandidates"===o.type&&(o={}),i.iceTransport.addRemoteCandidate(o);var s=r.splitSections(this.remoteDescription.sdp);s[t+1]+=(o.type?e.candidate.trim():"a=end-of-candidates")+"\r\n",this.remoteDescription.sdp=s.join("")}}return arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},window.RTCPeerConnection.prototype.getStats=function(){var e=[];this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})});var t=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1];return new Promise(function(n){var r=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){r.set(t,e[t]),r[t]=e[t]})}),t&&window.setTimeout(t,0,r),n(r)})})}},attachMediaStream:function(e,t){i("DEPRECATED, attachMediaStream will soon be removed."),e.srcObject=t},reattachMediaStream:function(e,t){i("DEPRECATED, reattachMediaStream will soon be removed."),e.srcObject=t.srcObject}};t.exports={shimPeerConnection:o.shimPeerConnection,shimGetUserMedia:e("./getusermedia"),attachMediaStream:o.attachMediaStream,reattachMediaStream:o.reattachMediaStream}},{"../utils":232,"./getusermedia":228,sdp:201}],228:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";t.exports=function(){var e=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(t){return e(t).catch(function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))})}}},{}],229:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r=e("../utils").log,i=e("../utils").browserDetails,o={shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(){if("object"==typeof window&&(window.RTCPeerConnection||window.mozRTCPeerConnection)){window.RTCPeerConnection||(window.RTCPeerConnection=function(e,t){if(i.version<38&&e&&e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++){var o=e.iceServers[r];if(o.hasOwnProperty("urls"))for(var s=0;s<o.urls.length;s++){var a={url:o.urls[s]};0===o.urls[s].indexOf("turn")&&(a.username=o.username,a.credential=o.credential),n.push(a)}else n.push(e.iceServers[r])}e.iceServers=n}return new mozRTCPeerConnection(e,t)},window.RTCPeerConnection.prototype=mozRTCPeerConnection.prototype,mozRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return mozRTCPeerConnection.generateCertificate}}),window.RTCSessionDescription=mozRTCSessionDescription,window.RTCIceCandidate=mozRTCIceCandidate),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var e=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return null===arguments[0]?Promise.resolve():e.apply(this,arguments)};var t=RTCPeerConnection.prototype.getStats;RTCPeerConnection.prototype.getStats=function(e,n,r){return t.apply(this,[e||null]).then(function(e){return function(e){var t=new Map;return Object.keys(e).forEach(function(n){t.set(n,e[n]),t[n]=e[n]}),t}(e)}).then(n,r)}}},attachMediaStream:function(e,t){r("DEPRECATED, attachMediaStream will soon be removed."),e.srcObject=t},reattachMediaStream:function(e,t){r("DEPRECATED, reattachMediaStream will soon be removed."),e.srcObject=t.srcObject}};t.exports={shimOnTrack:o.shimOnTrack,shimSourceObject:o.shimSourceObject,shimPeerConnection:o.shimPeerConnection,shimGetUserMedia:e("./getusermedia"),attachMediaStream:o.attachMediaStream,reattachMediaStream:o.reattachMediaStream}},{"../utils":232,"./getusermedia":230}],230:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r=e("../utils").log,i=e("../utils").browserDetails;t.exports=function(){var e=function(e){return{name:{SecurityError:"NotAllowedError",PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[e.message]||e.message,constraint:e.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},t=function(t,n,o){var s=function(e){if("object"!=typeof e||e.require)return e;var t=[];return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r=e[n]="object"==typeof e[n]?e[n]:{ideal:e[n]};if(void 0===r.min&&void 0===r.max&&void 0===r.exact||t.push(n),void 0!==r.exact&&("number"==typeof r.exact?r.min=r.max=r.exact:e[n]=r.exact,delete r.exact),void 0!==r.ideal){e.advanced=e.advanced||[];var i={};"number"==typeof r.ideal?i[n]={min:r.ideal,max:r.ideal}:i[n]=r.ideal,e.advanced.push(i),delete r.ideal,Object.keys(r).length||delete e[n]}}}),t.length&&(e.require=t),e};return t=JSON.parse(JSON.stringify(t)),i.version<38&&(r("spec: "+JSON.stringify(t)),t.audio&&(t.audio=s(t.audio)),t.video&&(t.video=s(t.video)),r("ff37: "+JSON.stringify(t))),navigator.mozGetUserMedia(t,n,function(t){o(e(t))})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:function(e){return new Promise(function(n,r){t(e,n,r)})},addEventListener:function(){},removeEventListener:function(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})},i.version<41){var n=navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);navigator.mediaDevices.enumerateDevices=function(){return n().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(i.version<49){var o=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(t){return o(t).catch(function(t){return Promise.reject(e(t))})}}navigator.getUserMedia=function(e,n,r){if(i.version<44)return t(e,n,r);console.warn("navigator.getUserMedia has been replaced by navigator.mediaDevices.getUserMedia"),navigator.mediaDevices.getUserMedia(e).then(n,r)}}},{"../utils":232}],231:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r={shimGetUserMedia:function(){navigator.getUserMedia=navigator.webkitGetUserMedia}};t.exports={shimGetUserMedia:r.shimGetUserMedia}},{}],232:[function(e,t,n){
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */
"use strict";var r=!0,i={disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},extractVersion:function(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)},detectBrowser:function(){var e={browser:null,version:null,minVersion:null};if("undefined"==typeof window||!window.navigator)return e.browser="Not a browser.",e;if(navigator.mozGetUserMedia)e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/([0-9]+)\./,1),e.minVersion=31;else if(navigator.webkitGetUserMedia)if(window.webkitRTCPeerConnection)e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/([0-9]+)\./,2),e.minVersion=38;else{if(!navigator.userAgent.match(/Version\/(\d+).(\d+)/))return e.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/([0-9]+)\./,1),e.minVersion=602}else{if(!navigator.mediaDevices||!navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))return e.browser="Not a supported browser.",e;e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),e.minVersion=10547}return e.version<e.minVersion&&i.log("Browser: "+e.browser+" Version: "+e.version+" < minimum supported version: "+e.minVersion+"\n some things might not work!"),e}};t.exports={log:i.log,disableLog:i.disableLog,browserDetails:i.detectBrowser(),extractVersion:i.extractVersion}},{}],233:[function(e,t,n){(function(n,r){"use strict";var i=e("readable-stream").Transform,o=e("duplexify"),s=e("ws"),a=e("safe-buffer").Buffer;t.exports=function(e,t,c){var u,l,f="browser"===n.title,h=!!r.WebSocket,p=f?function e(t,n,r){if(l.bufferedAmount>_)return void setTimeout(e,g,t,n,r);v&&"string"==typeof t&&(t=a.from(t,"utf8"));try{l.send(t)}catch(e){return r(e)}r()}:function(e,t,n){if(l.readyState!==l.OPEN)return void n();v&&"string"==typeof e&&(e=a.from(e,"utf8"));l.send(e,n)};t&&!Array.isArray(t)&&"object"==typeof t&&(c=t,t=null,("string"==typeof c.protocol||Array.isArray(c.protocol))&&(t=c.protocol));c||(c={});void 0===c.objectMode&&(c.objectMode=!(!0===c.binary||void 0===c.binary));var d=function(e,t,n){var r=new i({objectMode:e.objectMode});return r._write=t,r._flush=n,r}(c,p,function(e){l.close(),e()});c.objectMode||(d._writev=m);var _=c.browserBufferSize||524288,g=c.browserBufferTimeout||1e3;"object"==typeof e?l=e:(l=h&&f?new s(e,t):new s(e,t,c)).binaryType="arraybuffer";l.readyState===l.OPEN?u=d:(u=u=o(void 0,void 0,c),c.objectMode||(u._writev=m),l.onopen=function(){u.setReadable(d),u.setWritable(d),u.emit("connect")});u.socket=l,l.onclose=function(){u.end(),u.destroy()},l.onerror=function(e){u.destroy(e)},l.onmessage=function(e){var t=e.data;t=t instanceof ArrayBuffer?a.from(t):a.from(t,"utf8");d.push(t)},d.on("close",function(){l.close()});var v=!c.objectMode;function m(e,t){for(var n=new Array(e.length),r=0;r<e.length;r++)"string"==typeof e[r].chunk?n[r]=a.from(e[r],"utf8"):n[r]=e[r].chunk;this._write(a.concat(n),"binary",t)}return u}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:181,duplexify:82,"readable-stream":197,"safe-buffer":200,ws:234}],234:[function(e,t,n){var r=null;"undefined"!=typeof WebSocket?r=WebSocket:"undefined"!=typeof MozWebSocket?r=MozWebSocket:"undefined"!=typeof window&&(r=window.WebSocket||window.MozWebSocket),t.exports=r},{}],235:[function(e,t,n){t.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");Object.keys(t).forEach(function(e){r[e]=t[e]});return r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}}},{}],236:[function(e,t,n){t.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var i in n)r.call(n,i)&&(e[i]=n[i])}return e};var r=Object.prototype.hasOwnProperty},{}],237:[function(e,t,n){"use strict";var r=e("./initial/services/commonWebRtc"),i=e("./initial/main"),o=e("common-webrtc").WEBRTC_EVENTS,s=i.analytics,a=i.logger,c=i.preferencesRawReader,u=i.unifiWebRtcConnector,l=i.webRtcConnectionStatus,f=i.webRtcEventBus,h=i.webRtcConnectorCloud,p=i.webRtcDevice,d=i.UNIFI_WEBRTC_APP_EVENTS,_=i.UNIFI_WEBRTC_ERROR,g=i.UNIFI_WEBRTC_EVENTS,v=i.WEBRTC_EVENTS_PROGRESS,m=i.WEBRTC_EVENTS_TRANSLATION_KEYS;window.analytics=s,window.logger=a,window.preferencesRawReader=c,window.webrtc={commonWebRtc:r,unifiWebRtcConnector:u,webRtcConnectionStatus:l,webRtcConnectorCloud:h,webRtcDevice:p,webRtcEventBus:f,UNIFI_WEBRTC_APP_EVENTS:d,UNIFI_WEBRTC_ERROR:_,UNIFI_WEBRTC_EVENTS:g,WEBRTC_EVENTS:o,WEBRTC_EVENTS_PROGRESS:v,WEBRTC_EVENTS_TRANSLATION_KEYS:m}},{"./initial/main":249,"./initial/services/commonWebRtc":252,"common-webrtc":69}],238:[function(e,t,n){"use strict";var r=e("./webRtcConnectionStatus");t.exports={webRtcConnectionStatus:r}},{"./webRtcConnectionStatus":239}],239:[function(e,t,n){"use strict";t.exports=e("./webRtcConnectionStatus")},{"./webRtcConnectionStatus":240}],240:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=e("../../services/webRtcEventBus"),o=e("../../constants/UNIFI_WEBRTC_EVENTS"),s=e("common-webrtc").WEBRTC_EVENTS,a=e("../../locales/webrtc.json"),c=e("../../constants/WEBRTC_EVENTS_PROGRESS"),u=e("../../constants/WEBRTC_EVENTS_TRANSLATION_KEYS"),l=function(){function t(n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.document=n,this.element=null,this.template=e("./webRtcConnectionStatus.pug")(),this.listeners=[],this.progress=0,this.status="Starting up...",this.addEventListeners(o),this.addEventListeners(s)}var n,l,f;return n=t,(l=[{key:"render",value:function(){this.element=document.createElement("div"),this.element.innerHTML=this.template,this.document.body.appendChild(this.element),this.updateProgress(this.progress),this.updateStatus(this.status)}},{key:"addEventListeners",value:function(e){var t=this;Object.keys(e).forEach(function(n){var r=e[n],o=function(){var e=u[r];void 0!==e&&t.updateStatus(a[e]);var n=c[r];void 0!==n&&t.updateProgress(n)};i.on(r,o),t.listeners.push({event:r,listener:o})})}},{key:"unregisterAllEventListeners",value:function(){this.listeners.forEach(function(e){i.removeListener(e.event,e.listener)}),this.listeners=[]}},{key:"updateProgress",value:function(e){(this.progress=e,this.element)&&(this.element.querySelector(".ubntStatusBar__status").style.width=e+"%")}},{key:"updateStatus",value:function(e){(this.status=e,this.element)&&(this.element.querySelector(".unifiConnectionStatus__text").innerText=e)}},{key:"destroy",value:function(){this.unregisterAllEventListeners(),this.element&&this.element.remove()}}])&&r(n.prototype,l),f&&r(n,f),t}();t.exports=new l(document)},{"../../constants/UNIFI_WEBRTC_EVENTS":244,"../../constants/WEBRTC_EVENTS_PROGRESS":245,"../../constants/WEBRTC_EVENTS_TRANSLATION_KEYS":246,"../../locales/webrtc.json":248,"../../services/webRtcEventBus":258,"./webRtcConnectionStatus.pug":241,"common-webrtc":69}],241:[function(e,t,n){e("pug-runtime");t.exports=function(e){var t="";return t+='<div class="whiteout"><div class="appSpinner appSpinner--medium appSpinner--dark"></div><div class="unifiConnectionStatus appContainer appContainer--smash mt-3"><div class="stackCenter"><div class="unifiConnectionStatus__text mb-3"></div><div class="ubntStatusBar ubntStatusBar--success" style="width: 100px"><div class="ubntStatusBar__status" style="width: 0%"></div></div></div></div></div>'}},{"pug-runtime":182}],242:[function(e,t,n){"use strict";t.exports={UNIFI_WEBRTC_APP_CONTEXT_CHANGE:"UNIFI_WEBRTC_APP_CONTEXT_CHANGE"}},{}],243:[function(e,t,n){"use strict";t.exports={DEVICE_OFFLINE:"DEVICE_OFFLINE",DEVICE_VERSION_INCOMPATIBLE:"DEVICE_VERSION_INCOMPATIBLE",ERROR_CONTROLLER_NOT_FOUND:"ERROR_CONTROLLER_NOT_FOUND",ERROR_ESTABLISH_CONNECTION:"ERROR_ESTABLISH_CONNECTION",ERROR_NOT_LOGGED_INTO_SSO:"ERROR_NOT_LOGGED_INTO_SSO"}},{}],244:[function(e,t,n){"use strict";t.exports={UNIFI_WEBRTC_VALIDATING_SSO:"UNIFI_WEBRTC_VALIDATING_SSO",UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO:"UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO",UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION:"UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION",UNIFI_WEBRTC_INITIALIZING_APPLICATION:"UNIFI_WEBRTC_INITIALIZING_APPLICATION"}},{}],245:[function(e,t,n){"use strict";t.exports={UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO:5,UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION:10,WEBRTC_WS_OPENING:40,WEBRTC_WS_CONNECTED:45,WEBRTC_CREATING_API_GATEWAY_CLIENT:20,WEBRTC_AWS_IOT_CONNECTING:30,WEBRTC_AWS_OPENING:40,WEBRTC_AWS_CONNECTED:45,WEBRTC_CREATE_OFFER:50,WEBRTC_SDP_REQUESTING:50,WEBRTC_SDP_RECEIVED:55,WEBRTC_CREATE_ANSWER:70,WEBRTC_SDP_SENDING:70,WEBRTC_INITIALIZED:80,WEBRTC_CONNECTED:90,UNIFI_WEBRTC_INITIALIZING_APPLICATION:95}},{}],246:[function(e,t,n){"use strict";t.exports={UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO:"CONNECTION_UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO",UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION:"CONNECTION_UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION",WEBRTC_CREATING_API_GATEWAY_CLIENT:"CONNECTION_WEBRTC_CREATING_API_GATEWAY_CLIENT",WEBRTC_AWS_IOT_CONNECTING:"CONNECTION_WEBRTC_AWS_IOT_CONNECTING",WEBRTC_WS_OPENING:"CONNECTION_WEBRTC_WS_OPENING",WEBRTC_WS_OPENING_ERROR:"CONNECTION_WEBRTC_WS_OPENING_ERROR",WEBRTC_WS_CONNECTED:"CONNECTION_WEBRTC_WS_CONNECTED",WEBRTC_AWS_OPENING:"CONNECTION_WEBRTC_AWS_OPENING",WEBRTC_AWS_OPENING_ERROR:"CONNECTION_WEBRTC_AWS_OPENING_ERROR",WEBRTC_AWS_CONNECTED:"CONNECTION_WEBRTC_AWS_CONNECTED",WEBRTC_CREATE_ANSWER:"CONNECTION_WEBRTC_CREATE_ANSWER",WEBRTC_CREATE_ANSWER_ERROR:"CONNECTION_WEBRTC_CREATE_ANSWER_ERROR",WEBRTC_CREATE_OFFER:"CONNECTION_WEBRTC_CREATE_OFFER",WEBRTC_CREATE_OFFER_ERROR:"CONNECTION_WEBRTC_CREATE_OFFER_ERROR",WEBRTC_SDP_REQUESTING:"CONNECTION_WEBRTC_SDP_REQUESTING",WEBRTC_SDP_RECEIVED:"CONNECTION_WEBRTC_SDP_RECEIVED",WEBRTC_SDP_SENDING:"CONNECTION_WEBRTC_SDP_SENDING",WEBRTC_INITIALIZED:"CONNECTION_WEBRTC_INITIALIZED",WEBRTC_CONNECTED:"CONNECTION_WEBRTC_CONNECTED",WEBRTC_CONNECTION_ERROR:"CONNECTION_WEBRTC_CONNECTION_ERROR",UNIFI_WEBRTC_INITIALIZING_APPLICATION:"CONNECTION_UNIFI_WEBRTC_INITIALIZING_APPLICATION"}},{}],247:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=window.unifiConstant.GoogleAnalyticsDemoKey,o=window.unifiConstant.GoogleAnalyticsCloudKey,s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.document=t,this.UseWebrtc=n.webrtcConfig.UseWebrtc,this.loaded=!1}var t,n,s;return t=e,(n=[{key:"loadOnce",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.loaded&&(this.UseWebrtc||e)){var t=e?i:o,n=this.document.createElement("script");n.setAttribute("type","text/javascript"),n.text='(function (i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function (){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");ga("create", "'+t+'", "auto");ga("set", "anonymizeIp", true);',this.document.head.appendChild(n),this.loaded=!0}}}])&&r(t.prototype,n),s&&r(t,s),e}();t.exports=s},{}],248:[function(e,t,n){t.exports={CONNECTION_UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO:"Verifying Your Account",CONNECTION_UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION:"Establishing Remote Connection",CONNECTION_WEBRTC_CREATING_API_GATEWAY_CLIENT:"Establishing Remote Connection",CONNECTION_WEBRTC_AWS_IOT_CONNECTING:"Establishing Remote Connection",CONNECTION_WEBRTC_WS_OPENING:"Establishing Remote Connection",CONNECTION_WEBRTC_WS_OPENING_ERROR:"Establishing Remote Connection failed",CONNECTION_WEBRTC_WS_CONNECTED:"Establishing Remote Connection",CONNECTION_WEBRTC_AWS_OPENING:"Establishing Remote Connection",CONNECTION_WEBRTC_AWS_OPENING_ERROR:"Establishing Remote Connection failed",CONNECTION_WEBRTC_AWS_CONNECTED:"Establishing Remote Connection",CONNECTION_WEBRTC_CREATE_ANSWER:"Checking Network",CONNECTION_WEBRTC_CREATE_ANSWER_ERROR:"Checking Network failed",CONNECTION_WEBRTC_CREATE_OFFER:"Checking Network",CONNECTION_WEBRTC_CREATE_OFFER_ERROR:"Checking Network failed",CONNECTION_WEBRTC_SDP_REQUESTING:"Checking Network",CONNECTION_WEBRTC_SDP_SENDING_ERROR:"Checking Network failed",CONNECTION_WEBRTC_SDP_RECEIVED:"Checking Network",CONNECTION_WEBRTC_SDP_SENDING:"Checking Network",CONNECTION_WEBRTC_INITIALIZED:"Remote Connection Initialized",CONNECTION_WEBRTC_CONNECTED:"Remote Connection Initialized",CONNECTION_WEBRTC_CONNECTION_ERROR:"Remote Connection Initialized",CONNECTION_UNIFI_WEBRTC_INITIALIZING_APPLICATION:"Connected"}},{}],249:[function(e,t,n){"use strict";var r=e("./services/analytics"),i=e("../unifi-logger"),o=e("./utils/preferencesRawReader"),s=e("./services/unifiWebRtcConnector"),a=e("./services/webRtcConnectorCloud"),c=e("./services/webRtcDevice"),u=e("./services/webRtcEventBus"),l=e("./constants/UNIFI_WEBRTC_APP_EVENTS"),f=e("./constants/UNIFI_WEBRTC_ERROR"),h=e("./constants/UNIFI_WEBRTC_EVENTS"),p=e("./constants/WEBRTC_EVENTS_PROGRESS"),d=e("./constants/WEBRTC_EVENTS_TRANSLATION_KEYS"),_=e("./components").webRtcConnectionStatus;e("./run/logger"),t.exports={analytics:r,logger:i,preferencesRawReader:o,unifiWebRtcConnector:s,webRtcConnectionStatus:_,webRtcConnectorCloud:a,webRtcDevice:c,webRtcEventBus:u,UNIFI_WEBRTC_APP_EVENTS:l,UNIFI_WEBRTC_ERROR:f,UNIFI_WEBRTC_EVENTS:h,WEBRTC_EVENTS_PROGRESS:p,WEBRTC_EVENTS_TRANSLATION_KEYS:d}},{"../unifi-logger":261,"./components":238,"./constants/UNIFI_WEBRTC_APP_EVENTS":242,"./constants/UNIFI_WEBRTC_ERROR":243,"./constants/UNIFI_WEBRTC_EVENTS":244,"./constants/WEBRTC_EVENTS_PROGRESS":245,"./constants/WEBRTC_EVENTS_TRANSLATION_KEYS":246,"./run/logger":250,"./services/analytics":251,"./services/unifiWebRtcConnector":255,"./services/webRtcConnectorCloud":256,"./services/webRtcDevice":257,"./services/webRtcEventBus":258,"./utils/preferencesRawReader":259}],250:[function(e,t,n){"use strict";var r=e("../../initial/utils/preferencesRawReader"),i=e("../../unifi-logger"),o=r.readKey("browserLogLevel");i.setLevel(i[o]||i.INFO)},{"../../initial/utils/preferencesRawReader":259,"../../unifi-logger":261}],251:[function(e,t,n){"use strict";var r=e("../factories/Analytics");t.exports=new r(document,window)},{"../factories/Analytics":247}],252:[function(e,t,n){"use strict";var r=e("common-webrtc"),i=e("../../unifi-logger"),o=e("./webRtcEventBus");t.exports=r.builder().withLoggerService(i).withEventBusService({emit:function(e,t){o.emit(e,t)}}).build()},{"../../unifi-logger":261,"./webRtcEventBus":258,"common-webrtc":69}],253:[function(e,t,n){"use strict";var r=e("axios");t.exports=r.create()},{axios:20}],254:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=t.split("/"),r=n.indexOf("site");this.site=r>=0&&n[r+1]?n[r+1]:null}var t,n,i;return t=e,(n=[{key:"getActiveSite",value:function(){return this.site}}])&&r(t.prototype,n),i&&r(t,i),e}();t.exports=new i(window.location.pathname)},{}],255:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=e("../../initial/services/analytics"),o=e("../../unifi-logger/services/loggerHandlerAggregator"),s=e("./site"),a=e("./webRtcConnectorCloud"),c=e("./webRtcEventBus"),u=e("./httpClient"),l=e("es6-deferred"),f=e("../constants/UNIFI_WEBRTC_EVENTS"),h=e("../constants/UNIFI_WEBRTC_APP_EVENTS"),p=e("../constants/UNIFI_WEBRTC_ERROR"),d=e("common-webrtc").WEBRTC_EVENTS,_=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.connectionDefered=null,this.connecting=!1,this.eventHandlers={},this.logsEventHandlers={},this.connectivityDetails={}}var t,n,_;return t=e,(n=[{key:"connect",value:function(e){return i.loadOnce(),this.init().then(this.getConnectivityDetails.bind(this)).then(this.establishConnection.bind(this,e)).then(this.finalize.bind(this,e)).catch(function(){})}},{key:"waitForCurrentConnection",value:function(){return this.connectionDefered?this.connectionDefered.promise:void 0}},{key:"isConnecting",value:function(){return!!this.connecting}},{key:"init",value:function(){return this.connectionDefered=new l,this.connecting=!0,Promise.resolve()}},{key:"getConnectivityDetails",value:function(){return this.connectivityDetails=window.ubntConfig,Promise.resolve(this.connectivityDetails)}},{key:"establishConnection",value:function(e){var t=this;return c.emit(f.UNIFI_WEBRTC_OBTAINING_CONTROLLER_INFO),this.createCredentials(e).then(function(n){return t.tryOpenConnection(e,n)}).catch(function(){var n=p.ERROR_ESTABLISH_CONNECTION;return t.connectionDefered.reject({message:n,deviceId:e}),Promise.reject(n)})}},{key:"createCredentials",value:function(e){var t=this;return u.post(this.connectivityDetails.unifiCloudAccess.apiGatewayUI.url+"/create-credentials",{withTurn:!0},{withCredentials:!0}).then(function(e){return e.data}).catch(function(){var n=p.ERROR_NOT_LOGGED_INTO_SSO;return t.connectionDefered.reject({message:n,deviceId:e}),Promise.reject(n)})}},{key:"tryOpenConnection",value:function(e,t){var n=this;return this.openConnection(e,t).catch(function(r){return r===d.WEBRTC_DEVICE_OFFLINE?(n.connectionDefered.reject({message:p.DEVICE_OFFLINE,deviceId:e}),Promise.reject(p.DEVICE_OFFLINE)):(n.connectionDefered.reject({message:p.ERROR_ESTABLISH_CONNECTION,deviceId:e,credentials:t}),Promise.reject(p.ERROR_ESTABLISH_CONNECTION))})}},{key:"openConnection",value:function(e,t){var n=this;c.emit(f.UNIFI_WEBRTC_ESTABLISHING_COMMUNICATION);var r=null;return s.getActiveSite()&&(r="update_"+s.getActiveSite()),o.clear(),o.enable(),a.establishConnection({deviceId:e,turnCredentials:t.turnCredentials,credentials:t,connectivityDetails:this.connectivityDetails,channelNames:r?[r]:[]}).then(function(){o.clear(),o.disable(),r&&a.on(r,n.onmessage.bind(n)),c.on(h.UNIFI_WEBRTC_APP_CONTEXT_CHANGE,function(e,t){var i=r?r.substring(r.indexOf("_")+1):null;t&&t!==i&&a.closeChannel(r).catch(function(){}).then(function(){return r="update_"+t,n.openChannel(r)}).then(function(){a.on(r,n.onmessage.bind(n))})})})}},{key:"finalize",value:function(e){c.emit(f.UNIFI_WEBRTC_INITIALIZING_APPLICATION),this.connectionDefered.resolve(e),this.connecting=!1}},{key:"onmessage",value:function(e){var t=e.data.meta.message;if(this.eventHandlers[t]){var n=Object.assign({},e.data.meta,e.data);this.eventHandlers[t].forEach(function(e){e(n)})}}},{key:"onLogsMessage",value:function(e){var t=e.data.meta.message;if(this.logsEventHandlers[t]){var n=Object.assign({},e.data.meta,e.data);this.logsEventHandlers[t](n)}}},{key:"getBrowserLog",value:function(){return o.dumpToJsonFile()}},{key:"getControllerLog",value:function(e){return a.sendSignallingAction("get_webrtc_logs",{device_id:e}).then(function(e){return e.debug_log})}},{key:"send",value:function(e,t){return a.sendApiRequest(e,{method:"POST",contentType:"application/json",data:t})}},{key:"registerHandler",value:function(e,t){this.eventHandlers[e]=this.eventHandlers[e]||[],this.eventHandlers[e].push(t)}},{key:"unregisterHandler",value:function(e){this.eventHandlers[e]&&delete this.eventHandlers[e]}},{key:"registerLogsHandler",value:function(e,t){this.logsEventHandlers[e]=t}},{key:"openChannel",value:function(e){var t=this;a.openChannel(e).then(function(){a.on(e,t.onmessage.bind(t))})}}])&&r(t.prototype,n),_&&r(t,_),e}();t.exports=new _},{"../../initial/services/analytics":251,"../../unifi-logger/services/loggerHandlerAggregator":264,"../constants/UNIFI_WEBRTC_APP_EVENTS":242,"../constants/UNIFI_WEBRTC_ERROR":243,"../constants/UNIFI_WEBRTC_EVENTS":244,"./httpClient":253,"./site":254,"./webRtcConnectorCloud":256,"./webRtcEventBus":258,"common-webrtc":69,"es6-deferred":124}],256:[function(e,t,n){"use strict";var r=e("./commonWebRtc"),i=window.webrtcConfig,o=i.SignallingChannelType,s=i.WebRtcStartAsCaller;t.exports=new r.WebRtcConnector({signallingChannel:new r.SignallingChannel({type:o}),startAsCaller:s,autoReconnect:!0})},{"./commonWebRtc":252}],257:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n={};t.search.substring(1).split("&").forEach(function(e){var t=e.split("=");n[decodeURIComponent(t[0])]=decodeURIComponent(t[1])}),n.d&&(this.activeDevice=n.d)}var t,n,i;return t=e,(n=[{key:"getActiveDevice",value:function(){return this.activeDevice}}])&&r(t.prototype,n),i&&r(t,i),e}();t.exports=new i(document.location)},{}],258:[function(e,t,n){"use strict";var r=e("nanobus");t.exports=r("webrtc")},{nanobus:175}],259:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"readKey",value:function(e){if(window.localStorage){var t=localStorage.getItem("unifi-preferences"),n=localStorage.getItem("unifi-preferences-"+t);try{return n&&JSON.parse(n)[e]}catch(e){}}}}])&&r(t.prototype,n),i&&r(t,i),e}();t.exports=new i},{}],260:[function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._storage=[],this._enabled=!0}var t,n,i;return t=e,(n=[{key:"clear",value:function(){this._storage=[]}},{key:"get",value:function(){return this._storage}},{key:"dumpToJsonFile",value:function(){var e=JSON.stringify(this.get(),null,4);return new Blob([e],{type:"application/json"})}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1}},{key:"handle",value:function(e){this._enabled&&this._storage.push(e)}}])&&r(t.prototype,n),i&&r(t,i),e}();t.exports=i},{}],261:[function(e,t,n){"use strict";t.exports=e("./services/logger")},{"./services/logger":262}],262:[function(e,t,n){"use strict";var r=e("js-logger"),i=e("./loggerHandlerAggregator"),o=e("./loggerHandlerConsole");r.setHandler(function(e,t){i.handle(e,t),o.handle(e,t)}),r.aggregator=i,t.exports=r},{"./loggerHandlerAggregator":264,"./loggerHandlerConsole":265,"js-logger":158}],263:[function(e,t,n){"use strict";function r(e){"@babel/helpers - typeof";return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e){if(e&&("object"!==r(e)||e instanceof Event))return e;if(void 0!==e)try{return JSON.parse(JSON.stringify(e))}catch(e){return}}t.exports=function(e){for(var t=0;t<e.length;++t)e[t]=i(e[t]);e.unshift((new Date).toUTCString()),e.unshift(window.performance.now().toFixed(4)+"ms")}},{}],264:[function(e,t,n){"use strict";var r=e("../factories/LoggerHandlerAggregator");t.exports=new r},{"../factories/LoggerHandlerAggregator":260}],265:[function(e,t,n){"use strict";var r=e("js-logger"),i=e("./loggerFormatter");t.exports=new function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.handle=r.createDefaultHandler({formatter:i})}},{"./loggerFormatter":263,"js-logger":158}]},{},[237]);