From e7dcccfb4d86a4c8fd34649eb7673001584c888e Mon Sep 17 00:00:00 2001 From: Mikhail Kiurshin Date: Thu, 1 Aug 2019 15:37:56 -0500 Subject: [PATCH] fixed session distr --- sdks/js/dist/zcc.session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/js/dist/zcc.session.js b/sdks/js/dist/zcc.session.js index 435f2e5..395dcba 100644 --- a/sdks/js/dist/zcc.session.js +++ b/sdks/js/dist/zcc.session.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Session=t():(e.ZCC=e.ZCC||{},e.ZCC.Session=t())}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=42)}([function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],l=!1,f=-1;function p(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&h())}function h(){if(!l){var e=a(p);l=!0;for(var t=u.length;t;){for(c=u,u=[];++f1)for(var n=1;n3)for(t=new Array(s),i=0;i3)for(t=new Array(s-1),i=1;i3)for(t=new Array(a),i=1;i3)for(t=new Array(a-1),i=1;i0&&i._listeners.length>this._maxListeners&&(i._listeners.warned=!0,l.call(this,i._listeners.length,s))):i._listeners=t,!0;s=e.shift()}return!0}.call(this,e,t),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,l.call(this,this._events[e].length,e))):this._events[e]=t,this)},f.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();r=p.call(this,null,i,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var a=0;a0&&e(t[i]),0===Object.keys(s).length&&delete t[i])}}}(this.listenerTree),this},f.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n1||"string"==typeof e&&-1!==e.indexOf(".")||(arguments[0]=(arguments[0]instanceof Array?arguments[0][0]:arguments[0])+".*",i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"emit",this).apply(this,arguments))}}]),t}();e.exports=s},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,n){(function(e,r){var i=/%[sdj%]/g;t.format=function(e){if(!m(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),c=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(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,n,r){if(e.customInspect&&n&&w(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return m(i)||(i=l(e,i,r)),i}var o=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(m(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}(e,n);if(o)return o;var s=Object.keys(n),a=function(e){var t={};return s.forEach(function(e,n){t[e]=!0}),t}();if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),O(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(n);if(0===s.length){if(w(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special")}if(g(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(T(n))return e.stylize(Date.prototype.toString.call(n),"date");if(O(n))return f(n)}var u,E="",b=!1,N=["{","}"];return h(n)&&(b=!0,N=["[","]"]),w(n)&&(E=" [Function"+(n.name?": "+n.name:"")+"]"),g(n)&&(E=" "+RegExp.prototype.toString.call(n)),T(n)&&(E=" "+Date.prototype.toUTCString.call(n)),O(n)&&(E=" "+f(n)),0!==s.length||b&&0!=n.length?r<0?g(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),u=b?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,E,N)):N[0]+E+N[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function p(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")),k(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=y(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")),_(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 h(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return"number"==typeof e}function m(e){return"string"==typeof e}function _(e){return void 0===e}function g(e){return E(e)&&"[object RegExp]"===b(e)}function E(e){return"object"==typeof e&&null!==e}function T(e){return E(e)&&"[object Date]"===b(e)}function O(e){return E(e)&&("[object Error]"===b(e)||e instanceof Error)}function w(e){return"function"==typeof e}function b(e){return Object.prototype.toString.call(e)}function N(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(_(o)&&(o=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.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"},t.isArray=h,t.isBoolean=d,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=v,t.isString=m,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=_,t.isRegExp=g,t.isObject=E,t.isDate=T,t.isError=O,t.isFunction=w,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(6);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(n=[N((e=new Date).getHours()),N(e.getMinutes()),N(e.getSeconds())].join(":"),[e.getDate(),A[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(5),t._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,n(1),n(0))},function(e,t,n){"use strict";(function(t){function r(e,t){if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i=0;u--)if(l[u]!==f[u])return!1;for(u=l.length-1;u>=0;u--)if(!_(e[c=l[u]],t[c],n,r))return!1;return!0}(e,t,n,s))}return n?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function E(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function T(e,t,n,r){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&v(i,n,"Missing expected exception"+r);var s="string"==typeof r,a=!e&&o.isError(i),c=!e&&i&&!n;if((a&&s&&E(i,n)||c)&&v(i,n,"Got unwanted exception"+r),e&&i&&n&&!E(i,n)||!e&&i)throw i}f.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=d(y((t=this).actual),128)+" "+t.operator+" "+d(y(t.expected),128),this.generatedMessage=!0);var n=e.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,o=h(n),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},o.inherits(f.AssertionError,Error),f.fail=v,f.ok=m,f.equal=function(e,t,n){e!=t&&v(e,t,n,"==",f.equal)},f.notEqual=function(e,t,n){e==t&&v(e,t,n,"!=",f.notEqual)},f.deepEqual=function(e,t,n){_(e,t,!1)||v(e,t,n,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(e,t,n){_(e,t,!0)||v(e,t,n,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(e,t,n){_(e,t,!1)&&v(e,t,n,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function e(t,n,r){_(t,n,!0)&&v(t,n,r,"notDeepStrictEqual",e)},f.strictEqual=function(e,t,n){e!==t&&v(e,t,n,"===",f.strictEqual)},f.notStrictEqual=function(e,t,n){e===t&&v(e,t,n,"!==",f.notStrictEqual)},f.throws=function(e,t,n){T(!0,e,t,n)},f.doesNotThrow=function(e,t,n){T(!1,e,t,n)},f.ifError=function(e){if(e)throw e};var O=Object.keys||function(e){var t=[];for(var n in e)s.call(e,n)&&t.push(n);return t}}).call(this,n(1))},function(e,t,n){!function(n){"use strict";function r(e,t){t instanceof Object||(t={});var n=/^(data:\w+\/[a-zA-Z\+\-\.]+;base64,)?(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/gi;return!1===t.paddingRequired&&(n=/^(data:\w+\/[a-zA-Z\+\-\.]+;base64,)?(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/gi),n.test(e)}void 0!==e&&e.exports&&(t=e.exports=r),t.isBase64=r}()},function(e,t){e.exports=function(e){return atob(e)}},function(e,t,n){"use strict";var r=n(10),i=n(9),o=n(8);function s(e){for(var t=new Uint8Array(e.length),n=0;n=10&&(i=9),t>0&&t<10&&(t="0"+t),n>0&&n<10&&(n="0"+n),r>0&&r<10&&(r="0"+r),t?t+":"+n+":"+r+"."+i:n?n+":"+r+"."+i:r?"00:"+r+"."+i:"00:00."+i}},{key:"buildBinaryPacket",value:function(t,n,r,i){var o=new ArrayBuffer(9),s=new DataView(o);return s.setInt8(0,t),s.setInt32(1,n,!1),s.setInt32(5,r,!1),new Uint8Array(e.arrayBufferConcat(o,i))}},{key:"buildCodecHeader",value:function(e,t,n){var r=new ArrayBuffer(4),i=new DataView(r);return i.setUint16(0,e,!0),i.setUint8(2,t),i.setUint8(3,n),btoa(String.fromCharCode.apply(null,new Uint8Array(r)))}},{key:"arrayBufferConcat",value:function(){var e=0,t=null;for(var n in arguments)e+=(t=arguments[n]).byteLength;var r=new Uint8Array(e),i=0;for(var o in arguments)t=arguments[o],r.set(new Uint8Array(t),i),i+=t.byteLength;return r.buffer}},{key:"parseCodedHeader",value:function(e){var t=new DataView(o("data:text/plain;base64,"+e));return{rate:t.getUint16(0,!0),framesPerPacket:t.getUint8(2),frameSize:t.getUint8(3)}}},{key:"isFunction",value:function(t){return e.instanceOf(t,Function)}},{key:"isArray",value:function(t){return e.instanceOf(t,Array)}},{key:"instanceOf",value:function(e,t){return e instanceof t}},{key:"parseIncomingBinaryMessage",value:function(e){var t=new DataView(e.slice(0,9));return{messageType:t.getUint8(0),messageData:new Uint8Array(e.slice(9)),messageId:t.getUint32(1,!1),packetId:t.getUint32(5,!1)}}}]),e}();e.exports=s},,function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,a,c=1,u={},l=!1,f=e.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(e);p=p&&p.setTimeout?p:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){d(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&d(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),r=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){d(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(d,0,e)},p.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(15),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(t,n){!function(t){"use strict";"function"==typeof bootstrap?bootstrap("promise",t):e.exports=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=w(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1,c=[];function u(){for(var t,n;e.next;)t=(e=e.next).task,e.task=void 0,(n=e.domain)&&(e.domain=void 0,n.enter()),l(t,n);for(;c.length;)l(t=c.pop());i=!1}function l(e,t){try{e()}catch(e){if(a)throw t&&t.exit(),setTimeout(u,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},"object"==typeof t&&"[object process]"===t.toString()&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var f=new MessageChannel;f.port1.onmessage=function(){o=p,f.port1.onmessage=u,u()};var p=function(){f.port2.postMessage(0)};o=function(){setTimeout(u,0),p()}}else o=function(){setTimeout(u,0)};return s.runAfter=function(e){c.push(e),i||(i=!0,o())},s}(),a=Function.call;function c(e){return function(){return a.apply(e,arguments)}}var u,l=c(Array.prototype.slice),f=c(Array.prototype.reduce||function(e,t){var n=0,r=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=r)throw new TypeError}for(;ni.stackCounter)&&(y(t,"__minimumStackCounter__",{value:i.stackCounter,configurable:!0}),r.unshift(i.stack));r.unshift(t.stack);var o=function(e){for(var t=e.split("\n"),n=[],r=0;r=i&&o<=$}function w(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=T(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function b(e){return e instanceof S?e:x(e)?(t=e,n=A(),b.nextTick(function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}}),n.promise):q(e);var t,n}b.resolve=b,b.nextTick=s,b.longStackSupport=!1;var N=1;function A(){var t,n=[],r=[],i=d(A.prototype),o=d(S.prototype);if(o.promiseDispatch=function(e,i,o){var s=l(arguments);n?(n.push(s),"when"===i&&o[1]&&r.push(o[1])):b.nextTick(function(){t.promiseDispatch.apply(t,s)})},o.valueOf=function(){if(n)return o;var e=R(t);return j(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},b.longStackSupport&&e)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=N++}function s(i){t=i,b.longStackSupport&&e&&(o.source=i),f(n,function(e,t){b.nextTick(function(){i.promiseDispatch.apply(i,t)})},void 0),n=void 0,r=void 0}return i.promise=o,i.resolve=function(e){t||s(b(e))},i.fulfill=function(e){t||s(q(e))},i.reject=function(e){t||s(B(e))},i.notify=function(e){t||f(r,function(t,n){b.nextTick(function(){n(e)})},void 0)},i}function k(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=A();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function I(e){return k(function(t,n){for(var r=0,i=e.length;r2?e.resolve(l(arguments,1)):e.resolve(n)}},b.Promise=k,b.promise=k,k.race=I,k.all=W,k.reject=B,k.resolve=b,b.passByCopy=function(e){return e},S.prototype.passByCopy=function(){return this},b.join=function(e,t){return b(e).join(t)},S.prototype.join=function(e){return b([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Q can't join: not the same: "+e+" "+t)})},b.race=I,S.prototype.race=function(){return this.then(b.race)},b.makePromise=S,S.prototype.toString=function(){return"[object Promise]"},S.prototype.then=function(e,t,n){var r=this,i=A(),o=!1;return b.nextTick(function(){r.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return B(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){E(e,r);try{return t(e)}catch(e){return B(e)}}return B(e)}(e)))}])}),r.promiseDispatch(void 0,"when",[void 0,function(e){var t,r=!1;try{t=function(e){return"function"==typeof n?n(e):e}(e)}catch(e){if(r=!0,!b.onerror)throw e;b.onerror(e)}r||i.notify(t)}]),i.promise},b.tap=function(e,t){return b(e).tap(t)},S.prototype.tap=function(e){return e=b(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},b.when=C,S.prototype.thenResolve=function(e){return this.then(function(){return e})},b.thenResolve=function(e,t){return b(e).thenResolve(t)},S.prototype.thenReject=function(e){return this.then(function(){throw e})},b.thenReject=function(e,t){return b(e).thenReject(t)},b.nearer=R,b.isPromise=j,b.isPromiseAlike=x,b.isPending=function(e){return j(e)&&"pending"===e.inspect().state},S.prototype.isPending=function(){return"pending"===this.inspect().state},b.isFulfilled=function(e){return!j(e)||"fulfilled"===e.inspect().state},S.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},b.isRejected=function(e){return j(e)&&"rejected"===e.inspect().state},S.prototype.isRejected=function(){return"rejected"===this.inspect().state};var L,D,M,V=[],P=[],U=[],G=!0;function F(){V.length=0,P.length=0,G||(G=!0)}function B(e){var n=S({when:function(n){return n&&function(e){if(G){var n=p(P,e);-1!==n&&("object"==typeof t&&"function"==typeof t.emit&&b.nextTick.runAfter(function(){var r=p(U,e);-1!==r&&(t.emit("rejectionHandled",V[n],e),U.splice(r,1))}),P.splice(n,1),V.splice(n,1))}}(this),n?n(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,n){G&&("object"==typeof t&&"function"==typeof t.emit&&b.nextTick.runAfter(function(){-1!==p(P,e)&&(t.emit("unhandledRejection",n,e),U.push(e))}),P.push(e),n&&void 0!==n.stack?V.push(n.stack):V.push("(no stack) "+n))}(n,e),n}function q(e){return S({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},delete:function(t){delete e[t]},post:function(t,n){return null===t||void 0===t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return m(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function z(e,t,n){return b(e).spread(t,n)}function H(e,t,n){return b(e).dispatch(t,n)}function W(e){return C(e,function(e){var t=0,n=A();return f(e,function(r,i,o){var s;j(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,C(i,function(r){e[o]=r,0==--t&&n.resolve(e)},n.reject,function(e){n.notify({index:o,value:e})}))},void 0),0===t&&n.resolve(e),n.promise})}function Z(e){if(0===e.length)return b.resolve();var t=b.defer(),n=0;return f(e,function(r,i,o){var s=e[o];n++,C(s,function(e){t.resolve(e)},function(e){if(0==--n){var r=e||new Error(""+e);r.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+r.message,t.reject(r)}},function(e){t.notify({index:o,value:e})})},void 0),t.promise}function Y(e){return C(e,function(e){return e=h(e,b),C(W(h(e,function(e){return C(e,o,o)})),function(){return e})})}b.resetUnhandledRejections=F,b.getUnhandledReasons=function(){return V.slice()},b.stopUnhandledRejectionTracking=function(){F(),G=!1},F(),b.reject=B,b.fulfill=q,b.master=function(e){return S({isDef:function(){}},function(t,n){return H(e,t,n)},function(){return b(e).inspect()})},b.spread=z,S.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},b.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=n[e](t)}catch(e){return B(e)}return o.done?b(o.value):C(o.value,r,i)}try{o=n[e](t)}catch(e){return function(e){return"[object StopIteration]"===_(e)||e instanceof u}(e)?b(e.value):B(e)}return C(o,r,i)}var n=e.apply(this,arguments),r=t.bind(t,"next"),i=t.bind(t,"throw");return r()}},b.spawn=function(e){b.done(b.async(e)())},b.return=function(e){throw new u(e)},b.promised=function(e){return function(){return z([this,W(arguments)],function(t,n){return e.apply(t,n)})}},b.dispatch=H,S.prototype.dispatch=function(e,t){var n=this,r=A();return b.nextTick(function(){n.promiseDispatch(r.resolve,e,t)}),r.promise},b.get=function(e,t){return b(e).dispatch("get",[t])},S.prototype.get=function(e){return this.dispatch("get",[e])},b.set=function(e,t,n){return b(e).dispatch("set",[t,n])},S.prototype.set=function(e,t){return this.dispatch("set",[e,t])},b.del=b.delete=function(e,t){return b(e).dispatch("delete",[t])},S.prototype.del=S.prototype.delete=function(e){return this.dispatch("delete",[e])},b.mapply=b.post=function(e,t,n){return b(e).dispatch("post",[t,n])},S.prototype.mapply=S.prototype.post=function(e,t){return this.dispatch("post",[e,t])},b.send=b.mcall=b.invoke=function(e,t){return b(e).dispatch("post",[t,l(arguments,2)])},S.prototype.send=S.prototype.mcall=S.prototype.invoke=function(e){return this.dispatch("post",[e,l(arguments,1)])},b.fapply=function(e,t){return b(e).dispatch("apply",[void 0,t])},S.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},b.try=b.fcall=function(e){return b(e).dispatch("apply",[void 0,l(arguments,1)])},S.prototype.fcall=function(){return this.dispatch("apply",[void 0,l(arguments)])},b.fbind=function(e){var t=b(e),n=l(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(l(arguments))])}},S.prototype.fbind=function(){var e=this,t=l(arguments);return function(){return e.dispatch("apply",[this,t.concat(l(arguments))])}},b.keys=function(e){return b(e).dispatch("keys",[])},S.prototype.keys=function(){return this.dispatch("keys",[])},b.all=W,S.prototype.all=function(){return W(this)},b.any=Z,S.prototype.any=function(){return Z(this)},b.allResolved=(L=Y,D="allResolved",M="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(D+" is deprecated, use "+M+" instead.",new Error("").stack),L.apply(L,arguments)}),S.prototype.allResolved=function(){return Y(this)},b.allSettled=function(e){return b(e).allSettled()},S.prototype.allSettled=function(){return this.then(function(e){return W(h(e,function(e){function t(){return e.inspect()}return(e=b(e)).then(t,t)}))})},b.fail=b.catch=function(e,t){return b(e).then(void 0,t)},S.prototype.fail=S.prototype.catch=function(e){return this.then(void 0,e)},b.progress=function(e,t){return b(e).then(void 0,void 0,t)},S.prototype.progress=function(e){return this.then(void 0,void 0,e)},b.fin=b.finally=function(e,t){return b(e).finally(t)},S.prototype.fin=S.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw new Error("Q can't apply finally callback");return e=b(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},b.done=function(e,t,n,r){return b(e).done(t,n,r)},S.prototype.done=function(e,n,r){var i=function(e){b.nextTick(function(){if(E(e,o),!b.onerror)throw e;b.onerror(e)})},o=e||n||r?this.then(e,n,r):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},b.timeout=function(e,t,n){return b(e).timeout(t,n)},S.prototype.timeout=function(e,t){var n=A(),r=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),n.reject(t)},e);return this.then(function(e){clearTimeout(r),n.resolve(e)},function(e){clearTimeout(r),n.reject(e)},n.notify),n.promise},b.delay=function(e,t){return void 0===t&&(t=e,e=void 0),b(e).delay(t)},S.prototype.delay=function(e){return this.then(function(t){var n=A();return setTimeout(function(){n.resolve(t)},e),n.promise})},b.nfapply=function(e,t){return b(e).nfapply(t)},S.prototype.nfapply=function(e){var t=A(),n=l(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},b.nfcall=function(e){var t=l(arguments,1);return b(e).nfapply(t)},S.prototype.nfcall=function(){var e=l(arguments),t=A();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},b.nfbind=b.denodeify=function(e){if(void 0===e)throw new Error("Q can't wrap an undefined function");var t=l(arguments,1);return function(){var n=t.concat(l(arguments)),r=A();return n.push(r.makeNodeResolver()),b(e).fapply(n).fail(r.reject),r.promise}},S.prototype.nfbind=S.prototype.denodeify=function(){var e=l(arguments);return e.unshift(this),b.denodeify.apply(void 0,e)},b.nbind=function(e,t){var n=l(arguments,2);return function(){var r=n.concat(l(arguments)),i=A();return r.push(i.makeNodeResolver()),b(function(){return e.apply(t,arguments)}).fapply(r).fail(i.reject),i.promise}},S.prototype.nbind=function(){var e=l(arguments,0);return e.unshift(this),b.nbind.apply(void 0,e)},b.nmapply=b.npost=function(e,t,n){return b(e).npost(t,n)},S.prototype.nmapply=S.prototype.npost=function(e,t){var n=l(t||[]),r=A();return n.push(r.makeNodeResolver()),this.dispatch("post",[e,n]).fail(r.reject),r.promise},b.nsend=b.nmcall=b.ninvoke=function(e,t){var n=l(arguments,2),r=A();return n.push(r.makeNodeResolver()),b(e).dispatch("post",[t,n]).fail(r.reject),r.promise},S.prototype.nsend=S.prototype.nmcall=S.prototype.ninvoke=function(e){var t=l(arguments,1),n=A();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},b.nodeify=function(e,t){return b(e).nodeify(t)},S.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){b.nextTick(function(){e(null,t)})},function(t){b.nextTick(function(){e(t)})})},b.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var $=w();return b})}).call(this,n(0),n(16).setImmediate)},,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;return this.connectOrReconnect(e)}},{key:"clearExistingReconnectTimeout",value:function(){this.reconnectTimeout&&clearTimeout(this.reconnectTimeout)}},{key:"connectOrReconnect",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=o.defer();return this.connectAttempts?(this.connectAttempts===this.maxConnectAttempts&&this.emit(s.EVENT_SESSION_START_CONNECT),this.connectAttempts--,this.doConnect().then(function(){return e.doLogon()}).then(function(n){"function"==typeof t&&t.apply(e,[null,n]),e.emit(s.EVENT_SESSION_CONNECT),r.resolve(n)}).catch(function(r){if(e.connectAttempts)return e.clearExistingReconnectTimeout(),void(e.reconnectTimeout=setTimeout(function(){e.connectOrReconnect(t,n)},e.connectRetryTimeoutMs));"function"==typeof t&&t.apply(e,[r]),e.emit(n?s.EVENT_SESSION_DISCONNECT:s.EVENT_SESSION_FAIL_CONNECT,r)}),r.promise):(this.emit(this.channelConfigurationError?s.EVENT_SESSION_DISCONNECT:s.EVENT_SESSION_FAIL_CONNECT),r.reject("Failed to connect"))}},{key:"doConnect",value:function(){var e=this,t=o.defer();return this.wsConnection=new WebSocket(this.options.serverUrl),this.wsConnection.binaryType="arraybuffer",this.wsConnection.addEventListener("open",function(){return t.resolve()}),this.wsConnection.addEventListener("message",function(t){e.wsMessageHandler(t.data)}),this.wsConnection.addEventListener("error",function(e){return t.reject(e)}),this.wsConnection.addEventListener("close",function(n){e.selfDisconnect?e.selfDisconnect=!1:"fulfilled"===t.promise.inspect().state&&(e.emit(s.EVENT_SESSION_CONNECTION_LOST,n.reason),e.clearExistingReconnectTimeout(),e.reconnectTimeout=setTimeout(function(){e.connectOrReconnect(null,!0)},e.connectRetryTimeoutMs))}),t.promise}},{key:"doLogon",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=o.defer(),n={command:"logon",seq:this.getSeq(),channel:this.options.channel};return e?n.refresh_token=e:n.auth_token=this.options.authToken,this.options.listenOnly&&(n.listen_only=!0),this.options.username&&(n.username=this.options.username,n.password=this.options.password),this.sendCommand(n,function(e,n){e?t.reject(e):t.resolve(n)}),t.promise}},{key:"disconnect",value:function(){this.selfDisconnect=!0,this.wsConnection.close()}},{key:"wsBinaryDataHandler",value:function(e){var t=a.parseIncomingBinaryMessage(e);switch(t.messageType){case s.MESSAGE_TYPE_AUDIO:this.emit(s.EVENT_INCOMING_VOICE_DATA,t);break;case s.MESSAGE_TYPE_IMAGE:this.emit(s.EVENT_INCOMING_IMAGE_DATA,t)}}},{key:"jsonDataHandler",value:function(e){e&&e.seq&&this.handleCallbacks(e),e.refresh_token&&(this.refreshToken=e.refresh_token);var t=a.getLoadedLibrary();switch(e.command){case"on_error":var n=s.ERROR_TYPE_UNKNOWN_SERVER_ERROR;e.error&&(n=e.error),this.emit(s.EVENT_ERROR,n);break;case"on_channel_status":if(!this.wasOnline)switch(e.status){case s.SN_STATUS_ONLINE:this.wasOnline=!0,this.connectAttempts=this.maxConnectAttempts;break;case s.SN_STATUS_OFFLINE:e.error&&e.error_type===s.ERROR_TYPE_CONFIGURATION&&(this.channelConfigurationError=!0)}this.emit(s.EVENT_STATUS,e);break;case"on_stream_start":var r=new t.IncomingMessage(e,this);this.incomingMessages[e.stream_id]=r,this.emit(s.EVENT_INCOMING_VOICE_WILL_START,r);break;case"on_stream_stop":this.emit(s.EVENT_INCOMING_VOICE_DID_STOP,this.incomingMessages[e.stream_id]);break;case"on_text_message":this.emit(s.EVENT_INCOMING_TEXT_MESSAGE,e);break;case"on_location":this.emit(s.EVENT_INCOMING_LOCATION,e);break;case"on_image":var i=new t.IncomingImage(e,this);this.emit(s.EVENT_INCOMING_IMAGE,i)}}},{key:"wsMessageHandler",value:function(e){var t=null;try{t=JSON.parse(e)}catch(e){}return t?this.jsonDataHandler(t):this.wsBinaryDataHandler(e)}},{key:"handleCallbacks",value:function(e){var t=e.error?e.error:null,n=this.callbacks[e.seq];"function"==typeof n&&(n.apply(this,[t,e]),delete this.callbacks[e.seq])}},{key:"sendCommand",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e.seq&&t&&(this.callbacks[e.seq]=t),this.wsConnection.send(JSON.stringify(e))}},{key:"sendBinary",value:function(e){this.wsConnection.send(e)}},{key:"startStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("start_stream",e,t)}},{key:"stopStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("stop_stream",e,t)}},{key:"startVoiceMessage",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=a.getLoadedLibrary();return this.activeOutgoingMessage=new n.OutgoingMessage(this,t),this.activeOutgoingMessage.on(s.EVENT_DATA_ENCODED,function(t){e.activeOutgoingMessage.options.autoSendAudio&&e.sendBinary(t)}),this.activeOutgoingMessage}},{key:"onIncomingVoiceDidStart",value:function(e){this.emit(s.EVENT_INCOMING_VOICE_DID_START,e)}},{key:"onIncomingVoiceDecoded",value:function(e,t){this.emit(s.EVENT_INCOMING_VOICE_DATA_DECODED,e,t)}},{key:"sendImage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=a.getLoadedLibrary();return this.activeOutgoingImage=new t.OutgoingImage(this,e),this.activeOutgoingImage}},{key:"sendTextMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("send_text_message",e,t)}},{key:"sendLocation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("send_location",e,t)}},{key:"sendCommandWithCallback",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.seq=this.getSeq(),t.command=e;var i=o.defer();return this.sendCommand(t,function(e,t){if(e)return"function"==typeof r&&r.apply(n,[e]),void i.reject(e);"function"==typeof r&&r.apply(n,[null,t]),i.resolve(t)}),i.promise}}],[{key:"validateInitialOptions",value:function(e){if(!e||!e.serverUrl||!e.authToken||!e.channel||e.username&&!e.password)throw new Error(s.ERROR_NOT_ENOUGH_PARAMS);if(!e.serverUrl.match(/^wss?:\/\//i))throw new Error(s.ERROR_INVALID_SERVER_PROTOCOL)}}]),t}();e.exports=c}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Session=t():(e.ZCC=e.ZCC||{},e.ZCC.Session=t())}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=42)}([function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],l=!1,f=-1;function p(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&h())}function h(){if(!l){var e=a(p);l=!0;for(var t=u.length;t;){for(c=u,u=[];++f1)for(var n=1;n3)for(t=new Array(s),i=0;i3)for(t=new Array(s-1),i=1;i3)for(t=new Array(a),i=1;i3)for(t=new Array(a-1),i=1;i0&&i._listeners.length>this._maxListeners&&(i._listeners.warned=!0,l.call(this,i._listeners.length,s))):i._listeners=t,!0;s=e.shift()}return!0}.call(this,e,t),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,l.call(this,this._events[e].length,e))):this._events[e]=t,this)},f.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();r=p.call(this,null,i,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var a=0;a0&&e(t[i]),0===Object.keys(s).length&&delete t[i])}}}(this.listenerTree),this},f.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n1||"string"==typeof e&&-1!==e.indexOf(".")||(arguments[0]=(arguments[0]instanceof Array?arguments[0][0]:arguments[0])+".*",i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"emit",this).apply(this,arguments))}}]),t}();e.exports=s},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,n){(function(e,r){var i=/%[sdj%]/g;t.format=function(e){if(!m(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),c=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(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,n,r){if(e.customInspect&&n&&w(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return m(i)||(i=l(e,i,r)),i}var o=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(m(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}(e,n);if(o)return o;var s=Object.keys(n),a=function(e){var t={};return s.forEach(function(e,n){t[e]=!0}),t}();if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),O(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(n);if(0===s.length){if(w(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special")}if(g(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(T(n))return e.stylize(Date.prototype.toString.call(n),"date");if(O(n))return f(n)}var u,E="",b=!1,N=["{","}"];return h(n)&&(b=!0,N=["[","]"]),w(n)&&(E=" [Function"+(n.name?": "+n.name:"")+"]"),g(n)&&(E=" "+RegExp.prototype.toString.call(n)),T(n)&&(E=" "+Date.prototype.toUTCString.call(n)),O(n)&&(E=" "+f(n)),0!==s.length||b&&0!=n.length?r<0?g(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),u=b?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(u,E,N)):N[0]+E+N[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function p(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")),k(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=y(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")),_(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 h(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return"number"==typeof e}function m(e){return"string"==typeof e}function _(e){return void 0===e}function g(e){return E(e)&&"[object RegExp]"===b(e)}function E(e){return"object"==typeof e&&null!==e}function T(e){return E(e)&&"[object Date]"===b(e)}function O(e){return E(e)&&("[object Error]"===b(e)||e instanceof Error)}function w(e){return"function"==typeof e}function b(e){return Object.prototype.toString.call(e)}function N(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(_(o)&&(o=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.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"},t.isArray=h,t.isBoolean=d,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=v,t.isString=m,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=_,t.isRegExp=g,t.isObject=E,t.isDate=T,t.isError=O,t.isFunction=w,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(6);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(n=[N((e=new Date).getHours()),N(e.getMinutes()),N(e.getSeconds())].join(":"),[e.getDate(),A[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(5),t._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,n(1),n(0))},function(e,t,n){"use strict";(function(t){function r(e,t){if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i=0;u--)if(l[u]!==f[u])return!1;for(u=l.length-1;u>=0;u--)if(!_(e[c=l[u]],t[c],n,r))return!1;return!0}(e,t,n,s))}return n?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function E(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function T(e,t,n,r){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&v(i,n,"Missing expected exception"+r);var s="string"==typeof r,a=!e&&o.isError(i),c=!e&&i&&!n;if((a&&s&&E(i,n)||c)&&v(i,n,"Got unwanted exception"+r),e&&i&&n&&!E(i,n)||!e&&i)throw i}f.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=d(y((t=this).actual),128)+" "+t.operator+" "+d(y(t.expected),128),this.generatedMessage=!0);var n=e.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,o=h(n),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},o.inherits(f.AssertionError,Error),f.fail=v,f.ok=m,f.equal=function(e,t,n){e!=t&&v(e,t,n,"==",f.equal)},f.notEqual=function(e,t,n){e==t&&v(e,t,n,"!=",f.notEqual)},f.deepEqual=function(e,t,n){_(e,t,!1)||v(e,t,n,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(e,t,n){_(e,t,!0)||v(e,t,n,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(e,t,n){_(e,t,!1)&&v(e,t,n,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function e(t,n,r){_(t,n,!0)&&v(t,n,r,"notDeepStrictEqual",e)},f.strictEqual=function(e,t,n){e!==t&&v(e,t,n,"===",f.strictEqual)},f.notStrictEqual=function(e,t,n){e===t&&v(e,t,n,"!==",f.notStrictEqual)},f.throws=function(e,t,n){T(!0,e,t,n)},f.doesNotThrow=function(e,t,n){T(!1,e,t,n)},f.ifError=function(e){if(e)throw e};var O=Object.keys||function(e){var t=[];for(var n in e)s.call(e,n)&&t.push(n);return t}}).call(this,n(1))},function(e,t,n){!function(n){"use strict";function r(e,t){t instanceof Object||(t={});var n=/^(data:\w+\/[a-zA-Z\+\-\.]+;base64,)?(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/gi;return!1===t.paddingRequired&&(n=/^(data:\w+\/[a-zA-Z\+\-\.]+;base64,)?(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/gi),n.test(e)}void 0!==e&&e.exports&&(t=e.exports=r),t.isBase64=r}()},function(e,t){e.exports=function(e){return atob(e)}},function(e,t,n){"use strict";var r=n(10),i=n(9),o=n(8);function s(e){for(var t=new Uint8Array(e.length),n=0;n=10&&(i=9),t>0&&t<10&&(t="0"+t),n>0&&n<10&&(n="0"+n),r>0&&r<10&&(r="0"+r),t?t+":"+n+":"+r+"."+i:n?n+":"+r+"."+i:r?"00:"+r+"."+i:"00:00."+i}},{key:"buildBinaryPacket",value:function(t,n,r,i){var o=new ArrayBuffer(9),s=new DataView(o);return s.setInt8(0,t),s.setInt32(1,n,!1),s.setInt32(5,r,!1),new Uint8Array(e.arrayBufferConcat(o,i))}},{key:"buildCodecHeader",value:function(e,t,n){var r=new ArrayBuffer(4),i=new DataView(r);return i.setUint16(0,e,!0),i.setUint8(2,t),i.setUint8(3,n),btoa(String.fromCharCode.apply(null,new Uint8Array(r)))}},{key:"arrayBufferConcat",value:function(){var e=0,t=null;for(var n in arguments)e+=(t=arguments[n]).byteLength;var r=new Uint8Array(e),i=0;for(var o in arguments)t=arguments[o],r.set(new Uint8Array(t),i),i+=t.byteLength;return r.buffer}},{key:"parseCodedHeader",value:function(e){var t=new DataView(o("data:text/plain;base64,"+e));return{rate:t.getUint16(0,!0),framesPerPacket:t.getUint8(2),frameSize:t.getUint8(3)}}},{key:"isFunction",value:function(t){return e.instanceOf(t,Function)}},{key:"isArray",value:function(t){return e.instanceOf(t,Array)}},{key:"instanceOf",value:function(e,t){return e instanceof t}},{key:"parseIncomingBinaryMessage",value:function(e){var t=new DataView(e.slice(0,9));return{messageType:t.getUint8(0),messageData:new Uint8Array(e.slice(9)),messageId:t.getUint32(1,!1),packetId:t.getUint32(5,!1)}}}]),e}();e.exports=s},,function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,a,c=1,u={},l=!1,f=e.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(e);p=p&&p.setTimeout?p:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){d(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&d(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),r=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){d(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(d,0,e)},p.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(15),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(t,n){!function(t){"use strict";"function"==typeof bootstrap?bootstrap("promise",t):e.exports=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=w(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1,c=[];function u(){for(var t,n;e.next;)t=(e=e.next).task,e.task=void 0,(n=e.domain)&&(e.domain=void 0,n.enter()),l(t,n);for(;c.length;)l(t=c.pop());i=!1}function l(e,t){try{e()}catch(e){if(a)throw t&&t.exit(),setTimeout(u,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},"object"==typeof t&&"[object process]"===t.toString()&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var f=new MessageChannel;f.port1.onmessage=function(){o=p,f.port1.onmessage=u,u()};var p=function(){f.port2.postMessage(0)};o=function(){setTimeout(u,0),p()}}else o=function(){setTimeout(u,0)};return s.runAfter=function(e){c.push(e),i||(i=!0,o())},s}(),a=Function.call;function c(e){return function(){return a.apply(e,arguments)}}var u,l=c(Array.prototype.slice),f=c(Array.prototype.reduce||function(e,t){var n=0,r=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=r)throw new TypeError}for(;ni.stackCounter)&&(y(t,"__minimumStackCounter__",{value:i.stackCounter,configurable:!0}),r.unshift(i.stack));r.unshift(t.stack);var o=function(e){for(var t=e.split("\n"),n=[],r=0;r=i&&o<=$}function w(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=T(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function b(e){return e instanceof S?e:x(e)?(t=e,n=A(),b.nextTick(function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}}),n.promise):q(e);var t,n}b.resolve=b,b.nextTick=s,b.longStackSupport=!1;var N=1;function A(){var t,n=[],r=[],i=d(A.prototype),o=d(S.prototype);if(o.promiseDispatch=function(e,i,o){var s=l(arguments);n?(n.push(s),"when"===i&&o[1]&&r.push(o[1])):b.nextTick(function(){t.promiseDispatch.apply(t,s)})},o.valueOf=function(){if(n)return o;var e=R(t);return j(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},b.longStackSupport&&e)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=N++}function s(i){t=i,b.longStackSupport&&e&&(o.source=i),f(n,function(e,t){b.nextTick(function(){i.promiseDispatch.apply(i,t)})},void 0),n=void 0,r=void 0}return i.promise=o,i.resolve=function(e){t||s(b(e))},i.fulfill=function(e){t||s(q(e))},i.reject=function(e){t||s(B(e))},i.notify=function(e){t||f(r,function(t,n){b.nextTick(function(){n(e)})},void 0)},i}function k(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=A();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function I(e){return k(function(t,n){for(var r=0,i=e.length;r2?e.resolve(l(arguments,1)):e.resolve(n)}},b.Promise=k,b.promise=k,k.race=I,k.all=W,k.reject=B,k.resolve=b,b.passByCopy=function(e){return e},S.prototype.passByCopy=function(){return this},b.join=function(e,t){return b(e).join(t)},S.prototype.join=function(e){return b([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Q can't join: not the same: "+e+" "+t)})},b.race=I,S.prototype.race=function(){return this.then(b.race)},b.makePromise=S,S.prototype.toString=function(){return"[object Promise]"},S.prototype.then=function(e,t,n){var r=this,i=A(),o=!1;return b.nextTick(function(){r.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return B(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){E(e,r);try{return t(e)}catch(e){return B(e)}}return B(e)}(e)))}])}),r.promiseDispatch(void 0,"when",[void 0,function(e){var t,r=!1;try{t=function(e){return"function"==typeof n?n(e):e}(e)}catch(e){if(r=!0,!b.onerror)throw e;b.onerror(e)}r||i.notify(t)}]),i.promise},b.tap=function(e,t){return b(e).tap(t)},S.prototype.tap=function(e){return e=b(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},b.when=C,S.prototype.thenResolve=function(e){return this.then(function(){return e})},b.thenResolve=function(e,t){return b(e).thenResolve(t)},S.prototype.thenReject=function(e){return this.then(function(){throw e})},b.thenReject=function(e,t){return b(e).thenReject(t)},b.nearer=R,b.isPromise=j,b.isPromiseAlike=x,b.isPending=function(e){return j(e)&&"pending"===e.inspect().state},S.prototype.isPending=function(){return"pending"===this.inspect().state},b.isFulfilled=function(e){return!j(e)||"fulfilled"===e.inspect().state},S.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},b.isRejected=function(e){return j(e)&&"rejected"===e.inspect().state},S.prototype.isRejected=function(){return"rejected"===this.inspect().state};var L,D,M,V=[],P=[],U=[],G=!0;function F(){V.length=0,P.length=0,G||(G=!0)}function B(e){var n=S({when:function(n){return n&&function(e){if(G){var n=p(P,e);-1!==n&&("object"==typeof t&&"function"==typeof t.emit&&b.nextTick.runAfter(function(){var r=p(U,e);-1!==r&&(t.emit("rejectionHandled",V[n],e),U.splice(r,1))}),P.splice(n,1),V.splice(n,1))}}(this),n?n(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,n){G&&("object"==typeof t&&"function"==typeof t.emit&&b.nextTick.runAfter(function(){-1!==p(P,e)&&(t.emit("unhandledRejection",n,e),U.push(e))}),P.push(e),n&&void 0!==n.stack?V.push(n.stack):V.push("(no stack) "+n))}(n,e),n}function q(e){return S({when:function(){return e},get:function(t){return e[t]},set:function(t,n){e[t]=n},delete:function(t){delete e[t]},post:function(t,n){return null===t||void 0===t?e.apply(void 0,n):e[t].apply(e,n)},apply:function(t,n){return e.apply(t,n)},keys:function(){return m(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function z(e,t,n){return b(e).spread(t,n)}function H(e,t,n){return b(e).dispatch(t,n)}function W(e){return C(e,function(e){var t=0,n=A();return f(e,function(r,i,o){var s;j(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,C(i,function(r){e[o]=r,0==--t&&n.resolve(e)},n.reject,function(e){n.notify({index:o,value:e})}))},void 0),0===t&&n.resolve(e),n.promise})}function Z(e){if(0===e.length)return b.resolve();var t=b.defer(),n=0;return f(e,function(r,i,o){var s=e[o];n++,C(s,function(e){t.resolve(e)},function(e){if(0==--n){var r=e||new Error(""+e);r.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+r.message,t.reject(r)}},function(e){t.notify({index:o,value:e})})},void 0),t.promise}function Y(e){return C(e,function(e){return e=h(e,b),C(W(h(e,function(e){return C(e,o,o)})),function(){return e})})}b.resetUnhandledRejections=F,b.getUnhandledReasons=function(){return V.slice()},b.stopUnhandledRejectionTracking=function(){F(),G=!1},F(),b.reject=B,b.fulfill=q,b.master=function(e){return S({isDef:function(){}},function(t,n){return H(e,t,n)},function(){return b(e).inspect()})},b.spread=z,S.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},b.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=n[e](t)}catch(e){return B(e)}return o.done?b(o.value):C(o.value,r,i)}try{o=n[e](t)}catch(e){return function(e){return"[object StopIteration]"===_(e)||e instanceof u}(e)?b(e.value):B(e)}return C(o,r,i)}var n=e.apply(this,arguments),r=t.bind(t,"next"),i=t.bind(t,"throw");return r()}},b.spawn=function(e){b.done(b.async(e)())},b.return=function(e){throw new u(e)},b.promised=function(e){return function(){return z([this,W(arguments)],function(t,n){return e.apply(t,n)})}},b.dispatch=H,S.prototype.dispatch=function(e,t){var n=this,r=A();return b.nextTick(function(){n.promiseDispatch(r.resolve,e,t)}),r.promise},b.get=function(e,t){return b(e).dispatch("get",[t])},S.prototype.get=function(e){return this.dispatch("get",[e])},b.set=function(e,t,n){return b(e).dispatch("set",[t,n])},S.prototype.set=function(e,t){return this.dispatch("set",[e,t])},b.del=b.delete=function(e,t){return b(e).dispatch("delete",[t])},S.prototype.del=S.prototype.delete=function(e){return this.dispatch("delete",[e])},b.mapply=b.post=function(e,t,n){return b(e).dispatch("post",[t,n])},S.prototype.mapply=S.prototype.post=function(e,t){return this.dispatch("post",[e,t])},b.send=b.mcall=b.invoke=function(e,t){return b(e).dispatch("post",[t,l(arguments,2)])},S.prototype.send=S.prototype.mcall=S.prototype.invoke=function(e){return this.dispatch("post",[e,l(arguments,1)])},b.fapply=function(e,t){return b(e).dispatch("apply",[void 0,t])},S.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},b.try=b.fcall=function(e){return b(e).dispatch("apply",[void 0,l(arguments,1)])},S.prototype.fcall=function(){return this.dispatch("apply",[void 0,l(arguments)])},b.fbind=function(e){var t=b(e),n=l(arguments,1);return function(){return t.dispatch("apply",[this,n.concat(l(arguments))])}},S.prototype.fbind=function(){var e=this,t=l(arguments);return function(){return e.dispatch("apply",[this,t.concat(l(arguments))])}},b.keys=function(e){return b(e).dispatch("keys",[])},S.prototype.keys=function(){return this.dispatch("keys",[])},b.all=W,S.prototype.all=function(){return W(this)},b.any=Z,S.prototype.any=function(){return Z(this)},b.allResolved=(L=Y,D="allResolved",M="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(D+" is deprecated, use "+M+" instead.",new Error("").stack),L.apply(L,arguments)}),S.prototype.allResolved=function(){return Y(this)},b.allSettled=function(e){return b(e).allSettled()},S.prototype.allSettled=function(){return this.then(function(e){return W(h(e,function(e){function t(){return e.inspect()}return(e=b(e)).then(t,t)}))})},b.fail=b.catch=function(e,t){return b(e).then(void 0,t)},S.prototype.fail=S.prototype.catch=function(e){return this.then(void 0,e)},b.progress=function(e,t){return b(e).then(void 0,void 0,t)},S.prototype.progress=function(e){return this.then(void 0,void 0,e)},b.fin=b.finally=function(e,t){return b(e).finally(t)},S.prototype.fin=S.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw new Error("Q can't apply finally callback");return e=b(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},b.done=function(e,t,n,r){return b(e).done(t,n,r)},S.prototype.done=function(e,n,r){var i=function(e){b.nextTick(function(){if(E(e,o),!b.onerror)throw e;b.onerror(e)})},o=e||n||r?this.then(e,n,r):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},b.timeout=function(e,t,n){return b(e).timeout(t,n)},S.prototype.timeout=function(e,t){var n=A(),r=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),n.reject(t)},e);return this.then(function(e){clearTimeout(r),n.resolve(e)},function(e){clearTimeout(r),n.reject(e)},n.notify),n.promise},b.delay=function(e,t){return void 0===t&&(t=e,e=void 0),b(e).delay(t)},S.prototype.delay=function(e){return this.then(function(t){var n=A();return setTimeout(function(){n.resolve(t)},e),n.promise})},b.nfapply=function(e,t){return b(e).nfapply(t)},S.prototype.nfapply=function(e){var t=A(),n=l(e);return n.push(t.makeNodeResolver()),this.fapply(n).fail(t.reject),t.promise},b.nfcall=function(e){var t=l(arguments,1);return b(e).nfapply(t)},S.prototype.nfcall=function(){var e=l(arguments),t=A();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},b.nfbind=b.denodeify=function(e){if(void 0===e)throw new Error("Q can't wrap an undefined function");var t=l(arguments,1);return function(){var n=t.concat(l(arguments)),r=A();return n.push(r.makeNodeResolver()),b(e).fapply(n).fail(r.reject),r.promise}},S.prototype.nfbind=S.prototype.denodeify=function(){var e=l(arguments);return e.unshift(this),b.denodeify.apply(void 0,e)},b.nbind=function(e,t){var n=l(arguments,2);return function(){var r=n.concat(l(arguments)),i=A();return r.push(i.makeNodeResolver()),b(function(){return e.apply(t,arguments)}).fapply(r).fail(i.reject),i.promise}},S.prototype.nbind=function(){var e=l(arguments,0);return e.unshift(this),b.nbind.apply(void 0,e)},b.nmapply=b.npost=function(e,t,n){return b(e).npost(t,n)},S.prototype.nmapply=S.prototype.npost=function(e,t){var n=l(t||[]),r=A();return n.push(r.makeNodeResolver()),this.dispatch("post",[e,n]).fail(r.reject),r.promise},b.nsend=b.nmcall=b.ninvoke=function(e,t){var n=l(arguments,2),r=A();return n.push(r.makeNodeResolver()),b(e).dispatch("post",[t,n]).fail(r.reject),r.promise},S.prototype.nsend=S.prototype.nmcall=S.prototype.ninvoke=function(e){var t=l(arguments,1),n=A();return t.push(n.makeNodeResolver()),this.dispatch("post",[e,t]).fail(n.reject),n.promise},b.nodeify=function(e,t){return b(e).nodeify(t)},S.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){b.nextTick(function(){e(null,t)})},function(t){b.nextTick(function(){e(t)})})},b.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var $=w();return b})}).call(this,n(0),n(16).setImmediate)},,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;return this.connectOrReconnect(e)}},{key:"clearExistingReconnectTimeout",value:function(){this.reconnectTimeout&&clearTimeout(this.reconnectTimeout)}},{key:"connectOrReconnect",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=o.defer();return this.connectAttempts?(this.connectAttempts===this.maxConnectAttempts&&this.emit(s.EVENT_SESSION_START_CONNECT),this.connectAttempts--,this.doConnect().then(function(){return e.doLogon()}).then(function(n){"function"==typeof t&&t.apply(e,[null,n]),e.emit(s.EVENT_SESSION_CONNECT),r.resolve(n)}).catch(function(r){if(e.connectAttempts)return e.clearExistingReconnectTimeout(),void(e.reconnectTimeout=setTimeout(function(){e.connectOrReconnect(t,n)},e.connectRetryTimeoutMs));"function"==typeof t&&t.apply(e,[r]),e.emit(n?s.EVENT_SESSION_DISCONNECT:s.EVENT_SESSION_FAIL_CONNECT,r)}),r.promise):(this.emit(this.channelConfigurationError?s.EVENT_SESSION_DISCONNECT:s.EVENT_SESSION_FAIL_CONNECT),r.reject("Failed to connect"))}},{key:"doConnect",value:function(){var e=this,t=o.defer();return this.wsConnection=new WebSocket(this.options.serverUrl),this.wsConnection.binaryType="arraybuffer",this.wsConnection.addEventListener("open",function(){return t.resolve()}),this.wsConnection.addEventListener("message",function(t){e.wsMessageHandler(t.data)}),this.wsConnection.addEventListener("error",function(e){return t.reject(e)}),this.wsConnection.addEventListener("close",function(n){e.selfDisconnect?e.selfDisconnect=!1:"fulfilled"===t.promise.inspect().state&&(e.emit(s.EVENT_SESSION_CONNECTION_LOST,n.reason),e.clearExistingReconnectTimeout(),e.reconnectTimeout=setTimeout(function(){e.connectOrReconnect(null,!0)},e.connectRetryTimeoutMs))}),t.promise}},{key:"doLogon",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=o.defer(),n={command:"logon",seq:this.getSeq(),channel:this.options.channel};return e?n.refresh_token=e:n.auth_token=this.options.authToken,this.options.listenOnly&&(n.listen_only=!0),this.options.username&&(n.username=this.options.username,n.password=this.options.password),this.sendCommand(n,function(e,n){e?t.reject(e):t.resolve(n)}),t.promise}},{key:"disconnect",value:function(){this.selfDisconnect=!0,this.wsConnection.close()}},{key:"wsBinaryDataHandler",value:function(e){var t=a.parseIncomingBinaryMessage(e);switch(t.messageType){case s.MESSAGE_TYPE_AUDIO:this.emit(s.EVENT_INCOMING_VOICE_DATA,t);break;case s.MESSAGE_TYPE_IMAGE:this.emit(s.EVENT_INCOMING_IMAGE_DATA,t)}}},{key:"jsonDataHandler",value:function(e){e&&e.seq&&this.handleCallbacks(e),e.refresh_token&&(this.refreshToken=e.refresh_token);var t=a.getLoadedLibrary();switch(e.command){case"on_error":var n=s.ERROR_TYPE_UNKNOWN_SERVER_ERROR;e.error&&(n=e.error),this.emit(s.EVENT_ERROR,n);break;case"on_channel_status":if(!this.wasOnline)switch(e.status){case s.SN_STATUS_ONLINE:this.wasOnline=!0,this.connectAttempts=this.maxConnectAttempts;break;case s.SN_STATUS_OFFLINE:e.error&&e.error_type===s.ERROR_TYPE_CONFIGURATION&&(this.channelConfigurationError=!0)}this.emit(s.EVENT_STATUS,e);break;case"on_stream_start":var r=new t.IncomingMessage(e,this);this.incomingMessages[e.stream_id]=r,this.emit(s.EVENT_INCOMING_VOICE_WILL_START,r);break;case"on_stream_stop":this.emit(s.EVENT_INCOMING_VOICE_DID_STOP,this.incomingMessages[e.stream_id]);break;case"on_text_message":this.emit(s.EVENT_INCOMING_TEXT_MESSAGE,e);break;case"on_location":this.emit(s.EVENT_INCOMING_LOCATION,e);break;case"on_image":var i=new t.IncomingImage(e,this);this.emit(s.EVENT_INCOMING_IMAGE,i)}}},{key:"wsMessageHandler",value:function(e){var t=null;try{t=JSON.parse(e)}catch(e){}return t?this.jsonDataHandler(t):this.wsBinaryDataHandler(e)}},{key:"handleCallbacks",value:function(e){var t=e.error?e.error:null,n=this.callbacks[e.seq];"function"==typeof n&&(n.apply(this,[t,e]),delete this.callbacks[e.seq])}},{key:"sendCommand",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e.seq&&t&&(this.callbacks[e.seq]=t),this.wsConnection.send(JSON.stringify(e))}},{key:"sendBinary",value:function(e){this.wsConnection.send(e)}},{key:"startStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("start_stream",e,t)}},{key:"stopStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("stop_stream",e,t)}},{key:"startVoiceMessage",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=a.getLoadedLibrary();return this.activeOutgoingMessage=new n.OutgoingMessage(this,t),this.activeOutgoingMessage.on(s.EVENT_DATA_ENCODED,function(t){e.activeOutgoingMessage.options.autoSendAudio&&e.sendBinary(t)}),this.activeOutgoingMessage}},{key:"onIncomingVoiceDidStart",value:function(e){this.emit(s.EVENT_INCOMING_VOICE_DID_START,e)}},{key:"onIncomingVoiceDecoded",value:function(e,t){this.emit(s.EVENT_INCOMING_VOICE_DATA_DECODED,e,t)}},{key:"sendImage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=a.getLoadedLibrary();return this.activeOutgoingImage=new t.OutgoingImage(this,e),this.activeOutgoingImage}},{key:"sendTextMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("send_text_message",e,t)}},{key:"sendLocation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.sendCommandWithCallback("send_location",e,t)}},{key:"sendCommandWithCallback",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.seq=this.getSeq(),t.command=e;var i=o.defer();return this.sendCommand(t,function(e,t){if(e)return"function"==typeof r&&r.apply(n,[e]),void i.reject(e);"function"==typeof r&&r.apply(n,[null,t]),i.resolve(t)}),i.promise}}],[{key:"validateInitialOptions",value:function(e){if(!e||!e.serverUrl||!e.authToken||!e.channel||e.username&&!e.password)throw new Error(s.ERROR_NOT_ENOUGH_PARAMS);if(!e.serverUrl.match(/^wss?:\/\//i))throw new Error(s.ERROR_INVALID_SERVER_PROTOCOL)}}]),t}();e.exports=c}])}); \ No newline at end of file