chat4app-client-angular 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -24
- package/bundles/chat4app-client-angular.umd.js +2533 -2488
- package/bundles/chat4app-client-angular.umd.js.map +1 -1
- package/bundles/chat4app-client-angular.umd.min.js +2 -2
- package/bundles/chat4app-client-angular.umd.min.js.map +1 -1
- package/chat4app-client-angular.d.ts +4 -4
- package/chat4app-client-angular.metadata.json +1 -1
- package/esm2015/chat4app-client-angular.js +4 -4
- package/esm2015/lib/chat4app-client-angular.component.js +18 -18
- package/esm2015/lib/chat4app-client-angular.module.js +12 -12
- package/esm2015/lib/chat4app-client-angular.service.js +704 -659
- package/esm2015/lib/nats.min.js +695 -695
- package/esm2015/public-api.js +7 -7
- package/fesm2015/chat4app-client-angular.js +1416 -1371
- package/fesm2015/chat4app-client-angular.js.map +1 -1
- package/lib/chat4app-client-angular.component.d.ts +5 -5
- package/lib/chat4app-client-angular.module.d.ts +2 -2
- package/lib/chat4app-client-angular.service.d.ts +192 -196
- package/lib/chat4app-client-angular.service.d.ts.map +1 -1
- package/lib/nats.min.d.ts +3 -3
- package/package.json +1 -1
- package/public-api.d.ts +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("chat4app-client-angular",["exports","@angular/core","@angular/common/http"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["chat4app-client-angular"]={},t.ng.core,t.ng.common.http)}(this,function(t,e,r){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var o=n(e),i=n(r),s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},s(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function u(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})}function h(t,e){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}Object.create;function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function f(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(c(arguments[e]));return t}Object.create;"function"==typeof SuppressedError&&SuppressedError;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var p=function(t){var e={exports:{}};return t(e,e.exports),e.exports}(function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){var n;r.d(e,"a",function(){return n}),r.d(e,"b",function(){return o}),r.d(e,"c",function(){return i}),function(t){t.BAD_AUTHENTICATION="BAD_AUTHENTICATION",t.BAD_SUBJECT="BAD_SUBJECT",t.CONNECTION_CLOSED="CONNECTION_CLOSED",t.CONNECTION_DRAINING="CONNECTION_DRAINING",t.CONNECTION_REFUSED="CONNECTION_REFUSED",t.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",t.INVALID_PAYLOAD_TYPE="INVALID_PAYLOAD",t.UNKNOWN="UNKNOWN_ERROR",t.WSS_REQUIRED="WSS_REQUIRED",t.SUB_CLOSED="SUB_CLOSED",t.SUB_DRAINING="SUB_DRAINING",t.PERMISSIONS_VIOLATION="PERMISSIONS_VIOLATION",t.AUTHORIZATION_VIOLATION="AUTHORIZATION_VIOLATION",t.NATS_PROTOCOL_ERR="NATS_PROTOCOL_ERR"}(n||(n={}));var o=function(){function t(){this.messages={},this.messages[n.BAD_AUTHENTICATION]="User and Token can not both be provided",this.messages[n.BAD_SUBJECT]="Subject must be supplied",this.messages[n.CONNECTION_CLOSED]="Connection closed",this.messages[n.CONNECTION_CLOSED]="Connection closed",this.messages[n.CONNECTION_REFUSED]="Connection refused",this.messages[n.CONNECTION_TIMEOUT]="Connection timeout",this.messages[n.CONNECTION_DRAINING]="Connection draining",this.messages[n.INVALID_PAYLOAD_TYPE]="Invalid payload type - payloads can be 'binary', 'string', or 'json'",this.messages[n.SUB_CLOSED]="Subscription closed",this.messages[n.SUB_DRAINING]="Subscription draining",this.messages[n.WSS_REQUIRED]="TLS is required, therefore a secure websocket connection is also required"}return t.getMessage=function(e){return t.messages.getMessage(e)},t.prototype.getMessage=function(t){var e=this.messages[t];return e||(e=t),e},t}();o.messages=new o;var i=function(t){function e(e,r,n){var o=this;return(o=t.call(this,e)||this).name="NatsError",o.message=e,o.code=r,o.chainedError=n,o}return a(e,t),e.errorForCode=function(t,r){return new e(o.getMessage(t),t,r)},e}(Error)},function(t,e,r){r.d(e,"d",function(){return a}),r.d(e,"b",function(){return u}),r.d(e,"c",function(){return h}),r.d(e,"a",function(){return c}),r.d(e,"e",function(){return f}),r.d(e,"f",function(){return p});var n=r(2),o=n.a.fromAscii("\r\n"),i=new Uint8Array(o)[0],s=new Uint8Array(o)[1];function a(t){return t instanceof ArrayBuffer}function u(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=function(r){var n=e[r];Object.keys(n).forEach(function(e){t[e]=n[e]})},o=0;o<e.length;o++)n(o);return t}function h(t){var e=function(t){for(var e=new Uint8Array(t),r=0;r<e.byteLength;r++){var n=r+1;if(e.byteLength>n&&e[r]===i&&e[n]===s)return n+1}return-1}(t);if(e){var r=new Uint8Array(t).slice(0,e);return String.fromCharCode.apply(null,r)}return""}function c(t,e){var r=n.a.fromAscii(t);return e&&(r=n.a.concat(r,e,o)),r}function f(t){return Array.isArray(t)?Promise.resolve(t).then(l):Promise.reject(new TypeError("argument requires an array of promises"))}function p(t){for(var e=t.split(""),r=[],n=0;n<e.length;n++)r.push(e[n].charCodeAt(0));return new Uint8Array(r)}function l(t){return Promise.all(t.map(function(t){return Promise.resolve(t).then(d,d)}))}function d(t){return t}},function(t,e,r){r.d(e,"a",function(){return n});var n=function(){function t(){this.buffers=[],this.byteLength=0}return t.concat=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,n=0;n<t.length;n++)r+=t[n].byteLength;for(var o=new Uint8Array(r),i=0,s=0;s<t.length;s++)o.set(new Uint8Array(t[s]),i),i+=t[s].byteLength;return o.buffer},t.fromAscii=function(t){t||(t="");for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return e},t.toAscii=function(t){return String.fromCharCode.apply(null,new Uint8Array(t))},t.prototype.pack=function(){if(this.buffers.length>1){var e=this.buffers.splice(0,this.buffers.length);this.buffers.push(t.concat.apply(t,f(e)))}},t.prototype.drain=function(t){if(this.buffers.length){this.pack();var e=this.buffers.pop();if(e){var r=this.byteLength;(void 0===t||t>r)&&(t=r);var n=e.slice(0,t);return r>t&&this.buffers.push(e.slice(t)),this.byteLength=r-t,n}}return new Uint8Array(0).buffer},t.prototype.fill=function(t){t&&(this.buffers.push(t),this.byteLength+=t.byteLength)},t.prototype.peek=function(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0).buffer},t.prototype.size=function(){return this.byteLength},t.prototype.length=function(){return this.buffers.length},t}()},function(t,e,r){var n;r.d(e,"a",function(){return n}),function(t){t.STRING="string",t.JSON="json",t.BINARY="binary"}(n||(n={}))},function(t,e,r){(function(t){r.d(e,"d",function(){return o}),r.d(e,"i",function(){return b}),r.d(e,"a",function(){return v}),r.d(e,"k",function(){return m}),r.d(e,"j",function(){return I}),r.d(e,"f",function(){return w}),r.d(e,"g",function(){return A}),r.d(e,"c",function(){return T}),r.d(e,"h",function(){return C}),r.d(e,"b",function(){return E}),r.d(e,"e",function(){return O});var n,o,i=r(3),s=r(5),a=r(0),u=r(1),h=r(6),c=r(2);!function(t){t[t.CLOSED=-1]="CLOSED",t[t.AWAITING_CONTROL=0]="AWAITING_CONTROL",t[t.AWAITING_MSG_PAYLOAD=1]="AWAITING_MSG_PAYLOAD"}(o||(o={}));var f=/^MSG\s+([^\s\r\n]+)\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?(\d+)\r\n/i,p=/^\+OK\s*\r\n/i,l=/^-ERR\s+('.+')?\r\n/i,d=/^PING\r\n/i,g=/^PONG\r\n/i,y=/^INFO\s+([^\r\n]+)\r\n/i;function b(){return n||(n=new h.a),"_INBOX."+n.next()}var v=function(t){this.lang="javascript",this.pedantic=!1,this.protocol=1,this.verbose=!1,(t=t||{}).token&&(this.auth_token=t.token),t.noEcho&&(this.echo=!1),t.userJWT&&("function"==typeof t.userJWT?this.jwt=t.userJWT():this.jwt=t.userJWT),Object(u.b)(this,t)};function m(){return{sid:0,subject:"",received:0}}function I(){return{token:"",subject:"",received:0,max:1}}var w=function(){function t(t,e){this.token=t.token,this.protocol=e}return t.prototype.cancel=function(){this.protocol.cancelRequest(this.token,0)},t}(),A=function(){function t(t,e){this.sid=t.sid,this.protocol=e}return t.prototype.unsubscribe=function(t){this.protocol.unsubscribe(this.sid,t)},t.prototype.hasTimeout=function(){var t=this.protocol.subscriptions.get(this.sid);return null!==t&&null!==t.timeout},t.prototype.cancelTimeout=function(){var t=this.protocol.subscriptions.get(this.sid);null!==t&&null!==t.timeout&&(clearTimeout(t.timeout),t.timeout=null)},t.prototype.setTimeout=function(t,e){var r=this.protocol.subscriptions.get(this.sid);return null!==r&&(r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.timeout=setTimeout(e,t),!0)},t.prototype.getReceived=function(){var t=this.protocol.subscriptions.get(this.sid);return t?t.received:0},t.prototype.drain=function(){return this.protocol.drainSubscription(this.sid)},t.prototype.isDraining=function(){var t=this.protocol.subscriptions.get(this.sid);return!!t&&t.draining},t.prototype.isCancelled=function(){return null===this.protocol.subscriptions.get(this.sid)},t}(),T=function(){function t(){this.reqs={},this.length=0}return t.prototype.init=function(){return this.baseInbox=b()+".",this.baseInbox},t.prototype.add=function(t){isNaN(t.received)||(t.received=0),this.length++,this.reqs[t.token]=t},t.prototype.get=function(t){return t in this.reqs?this.reqs[t]:null},t.prototype.cancel=function(t){t&&t.timeout&&(clearTimeout(t.timeout),t.timeout=null),t.token in this.reqs&&(delete this.reqs[t.token],this.length--)},t.prototype.getToken=function(t){var e=t.subject||"";return 0===e.indexOf(this.baseInbox)?e.substring(this.baseInbox.length):null},t.prototype.dispatcher=function(){var t=this;return function(e){var r=t.getToken(e);if(r){var n=t.get(r);n&&(n.received++,n.callback(e),n.max&&n.received>=n.max&&t.cancel(n))}}},t}(),C=function(){function t(){this.subs={},this.sidCounter=0,this.length=0}return t.prototype.add=function(t){return this.sidCounter++,this.length++,t.sid=this.sidCounter,this.subs[t.sid]=t,t},t.prototype.setMux=function(t){return this.mux=t,t},t.prototype.getMux=function(){return this.mux},t.prototype.get=function(t){return t in this.subs?this.subs[t]:null},t.prototype.all=function(){var t=[];for(var e in this.subs){var r=this.subs[e];t.push(r)}return t},t.prototype.cancel=function(t){t&&t.timeout&&(clearTimeout(t.timeout),t.timeout=null),t.sid in this.subs&&(delete this.subs[t.sid],this.length--)},t}(),E=function(){function e(t,e){void 0===e&&(e="string"),this.msg={},this.msg.subject=t[1],this.msg.sid=parseInt(t[2],10),this.msg.reply=t[4],this.msg.size=parseInt(t[5],10),this.length=this.msg.size+2,this.payload=e}return e.prototype.fill=function(e){if(this.buf?this.buf=c.a.concat(this.buf,e):this.buf=e,this.length-=e.byteLength,0===this.length){switch(this.msg.data=this.buf.slice(0,this.buf.byteLength-2),this.payload){case i.a.JSON:this.msg.data=t.from(this.msg.data).toString("utf8"),this.msg.data=JSON.parse(this.msg.data);break;case i.a.STRING:this.msg.data=t.from(this.msg.data).toString("utf8");case i.a.BINARY:}this.buf=null}},e}(),O=function(){function e(t,e){this.infoReceived=!1,this.payload=null,this.pongs=[],this.pout=0,this.state=o.AWAITING_CONTROL,this.noMorePublishing=!1,this.options=t,this.clientHandlers=e,this.subscriptions=new C,this.muxSubscriptions=new T,this.inbound=new c.a,this.outbound=new c.a}return e.connect=function(t,r){return new Promise(function(n,o){var i=new e(t,r);i.connectError=o;var u=t.connectTimeout||1e4,h=new Promise(function(t,e){var r=setTimeout(function(){e(a.c.errorForCode(a.a.CONNECTION_TIMEOUT))},u);i.pongs.push(function(){clearTimeout(r),t(!0)})});s.a.connect(t,i,t.debug).then(function(t){i.transport=t}).catch(function(t){i.connectError=null,o(t)}),h.then(function(){i.connectError=null,n(i)}).catch(function(t){i.connectError=null,o(t)})})},e.toError=function(t){var e=t?t.toLowerCase():"";return-1!==e.indexOf("permissions violation")?new a.c(t,a.a.PERMISSIONS_VIOLATION):-1!==e.indexOf("authorization violation")?new a.c(t,a.a.AUTHORIZATION_VIOLATION):new a.c(t,a.a.NATS_PROTOCOL_ERR)},e.prototype.processInbound=function(){for(var t=null;this.inbound.size();){switch(this.state){case o.CLOSED:return;case o.AWAITING_CONTROL:var e=this.inbound.peek(),r=Object(u.c)(e);if(t=f.exec(r))this.payload=new E(t,this.options.payload),this.state=o.AWAITING_MSG_PAYLOAD;else if(t=p.exec(r));else{if(t=l.exec(r))return void this.processError(t[1]);if(t=g.exec(r)){this.pout=0;var n=this.pongs.shift();n&&n()}else if(t=d.exec(r))this.transport.write(Object(u.a)("PONG \r\n"));else{if(!(t=y.exec(r)))return;if(!this.infoReceived){if(JSON.parse(t[1]).tls_required&&!this.transport.isSecure())return void this.handleError(a.c.errorForCode(a.a.WSS_REQUIRED));var i=JSON.stringify(new v(this.options));this.transport.write(Object(u.a)("CONNECT "+i+"\r\n")),this.sendSubscriptions(),this.transport.write(Object(u.a)("PING \r\n")),this.infoReceived=!0,this.flushPending()}}}break;case o.AWAITING_MSG_PAYLOAD:if(!this.payload)break;if(this.inbound.size()<this.payload.length){var s=this.inbound.drain();return void this.payload.fill(s)}var h=this.inbound.drain(this.payload.length);this.payload.fill(h);try{this.processMsg()}catch(t){}this.state=o.AWAITING_CONTROL,this.payload=null}if(t){var c=t[0].length;c>=this.inbound.size()?this.inbound.drain():this.inbound.drain(c),t=null}}},e.prototype.processMsg=function(){if(this.payload&&this.subscriptions.sidCounter){var t=this.payload,e=this.subscriptions.get(t.msg.sid);e&&(e.received+=1,e.timeout&&void 0===e.max&&(clearTimeout(e.timeout),e.timeout=null),e.callback&&e.callback(t.msg),void 0!==e.max&&e.received>=e.max&&this.unsubscribe(e.sid))}},e.prototype.sendCommand=function(t){var e,r=this;e="string"==typeof t?Object(u.f)(t):t,t&&this.outbound.fill(e),1===this.outbound.length()?setTimeout(function(){r.flushPending()}):this.outbound.size()>8192&&this.flushPending()},e.prototype.publish=function(e,r,n){if(this.isClosed())throw a.c.errorForCode(a.a.CONNECTION_CLOSED);if(this.noMorePublishing)throw a.c.errorForCode(a.a.CONNECTION_DRAINING);var o,i=t.byteLength(r);o=(n=n||"")?"PUB "+e+" "+n+" "+i+"\r\n":"PUB "+e+" "+i+"\r\n",this.sendCommand(Object(u.a)(o,r))},e.prototype.request=function(t){return this.initMux(),this.muxSubscriptions.add(t),new w(t,this)},e.prototype.subscribe=function(t){var e=this.subscriptions.add(t);return e.queue?this.sendCommand("SUB "+e.subject+" "+e.queue+" "+e.sid+"\r\n"):this.sendCommand("SUB "+e.subject+" "+e.sid+"\r\n"),new A(e,this)},e.prototype.unsubscribe=function(t,e){if(t&&!this.isClosed()){var r=this.subscriptions.get(t);r&&(e?this.sendCommand("UNSUB "+t+" "+e+"\r\n"):this.sendCommand("UNSUB "+t+"\r\n"),r.max=e,(void 0===r.max||r.received>=r.max)&&this.subscriptions.cancel(r))}},e.prototype.cancelRequest=function(t,e){if(t&&!this.isClosed()){var r=this.muxSubscriptions.get(t);r&&(r.max=e,(void 0===r.max||r.received>=r.max)&&this.muxSubscriptions.cancel(r))}},e.prototype.flush=function(t){this.pongs.push(t),this.sendCommand("PING \r\n")},e.prototype.processError=function(t){var r={error:e.toError(t)};this.errorHandler(r)},e.prototype.sendSubscriptions=function(){var t=[];this.subscriptions.all().forEach(function(e){e.queue?t.push("SUB "+e.subject+" "+e.queue+" "+e.sid+" \r\n"):t.push("SUB "+e.subject+" "+e.sid+" \r\n")}),t.length&&this.transport.write(Object(u.a)(t.join("")))},e.prototype.openHandler=function(t){},e.prototype.closeHandler=function(t){this.close(),this.clientHandlers.closeHandler()},e.prototype.errorHandler=function(t){var e;t&&(e=t.error),this.handleError(e)},e.prototype.messageHandler=function(t){this.inbound.fill(t.data),this.processInbound()},e.prototype.close=function(){this.transport.close(),this.state=o.CLOSED},e.prototype.isClosed=function(){return this.transport.isClosed()},e.prototype.drain=function(){var t=this,e=this.subscriptions.all(),r=[];return e.forEach(function(e){var n=t.drainSubscription(e.sid);r.push(n)}),new Promise(function(e){Object(u.e)(r).then(function(r){t.noMorePublishing=!0,setTimeout(function(){t.close(),e(r)})}).catch(function(){})})},e.prototype.drainSubscription=function(t){var e=this;if(this.isClosed())return Promise.reject(a.c.errorForCode(a.a.CONNECTION_CLOSED));if(!t)return Promise.reject(a.c.errorForCode(a.a.SUB_CLOSED));var r=this.subscriptions.get(t);if(!r)return Promise.reject(a.c.errorForCode(a.a.SUB_CLOSED));if(r.draining)return Promise.reject(a.c.errorForCode(a.a.SUB_DRAINING));var n=r;return new Promise(function(t){n.draining=!0,e.sendCommand("UNSUB "+n.sid+"\r\n"),e.flush(function(){e.subscriptions.cancel(n),t(n)})})},e.prototype.flushPending=function(){if(this.infoReceived&&this.outbound.size()){var t=this.outbound.drain();this.transport.write(t)}},e.prototype.initMux=function(){if(!this.subscriptions.getMux()){var t=this.muxSubscriptions.init(),e={sid:0,subject:"",received:0};e.subject=t+"*",e.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(e),this.subscribe(e)}},e.prototype.handleError=function(t){this.connectError&&(this.connectError(t),this.connectError=null),this.close(),this.clientHandlers.errorHandler(t)},e}()}).call(this,r(7).Buffer)},function(t,e,r){r.d(e,"a",function(){return o});var n=r(0),o=function(){function t(t){this.stream=null,this.closed=!1,this.debug=!1,this.listeners={},this.handlers=t}return t.connect=function(e,r,o){return void 0===o&&(o=!1),new Promise(function(i,s){var a,u=new t(r);u.debug=o,u.stream=new WebSocket(e.url),u.stream.binaryType="arraybuffer",u.listeners={},u.stream.onclose=function(t){u.trace("ws closed",t),u.closed||(a?(u.handlers.closeHandler(t),u.close()):(clearTimeout(void 0),s(n.c.errorForCode(n.a.CONNECTION_CLOSED))))},u.stream.onerror=function(t){var e;if(t&&!(e=t.error)){var r=t.message;e=r?new n.c(r,n.a.UNKNOWN):a?n.c.errorForCode(n.a.UNKNOWN):n.c.errorForCode(n.a.CONNECTION_REFUSED)}u.trace("ws error",e),u.closed||(u&&u.close(),a?u.handlers.errorHandler(t):s(e))},u.stream.onopen=function(){u.trace("ws open")},u.stream.onmessage=function(t){u.trace(">",[t.data]),a?u.handlers.messageHandler(t):(a=!0,i(u),setTimeout(function(){u.handlers.messageHandler(t)},100))}})},t.prototype.isClosed=function(){return this.closed},t.prototype.isConnected=function(){return null!==this.stream&&this.stream.readyState===WebSocket.OPEN},t.prototype.write=function(t){this.stream&&this.isConnected()&&(this.trace("<",[t]),this.stream.send(t))},t.prototype.destroy=function(){this.stream&&(this.closed&&(this.stream.onclose=null,this.stream.onerror=null,this.stream.onopen=null,this.stream.onmessage=null),this.stream.readyState!==WebSocket.CLOSED&&this.stream.readyState!==WebSocket.CLOSING&&this.stream.close(1e3),this.stream=null)},t.prototype.close=function(){this.closed=!0,this.stream&&this.stream.bufferedAmount>0?setTimeout(this.close.bind(this),100):this.destroy()},t.prototype.trace=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.debug&&console.log(t)},t.prototype.isSecure=function(){return!!this.stream&&"wss:"===new URL(this.stream.url).protocol.toLowerCase()},t}()},function(t,e,r){r.d(e,"a",function(){return i});var n,o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i=function(){function t(){this.buf=new Uint8Array(22),this.init()}return t.prototype.init=function(){"crypto"in Object({})&&Object({}).crypto.getRandomValues?n=Object({}).crypto:"msCrypto"in Object({})&&Object({}).msCrypto.getRandomValues&&(n=Object({}).msCrypto),n||(n={getRandomValues:function(t){for(var e=0;e<t.length;e++)t[e]=Math.floor(255*Math.random())}}),this.setPre(),this.initSeqAndInc(),this.fillSeq()},t.prototype.initSeqAndInc=function(){this.seq=Math.floor(0xcfd41b9100000*Math.random()),this.inc=Math.floor(300*Math.random()+33)},t.prototype.setPre=function(){var t=new Uint8Array(12);n.getRandomValues(t);for(var e=0;e<12;e++){var r=t[e]%36;this.buf[e]=o.charCodeAt(r)}},t.prototype.fillSeq=function(){for(var t=this.seq,e=21;e>=12;e--)this.buf[e]=o.charCodeAt(t%36),t=Math.floor(t/36)},t.prototype.next=function(){return this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)},t.prototype.reset=function(){this.init()},t}()},function(t,e,r){(function(t){
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("chat4app-client-angular",["exports","@angular/core","@angular/common/http"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["chat4app-client-angular"]={},t.ng.core,t.ng.common.http)}(this,function(t,e,r){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var o=n(e),i=n(r),s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},s(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function u(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})}function h(t,e){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}Object.create;function c(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function f(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(c(arguments[e]));return t}Object.create;"function"==typeof SuppressedError&&SuppressedError;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var p=function(t){var e={exports:{}};return t(e,e.exports),e.exports}(function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=12)}([function(t,e,r){var n;r.d(e,"a",function(){return n}),r.d(e,"b",function(){return o}),r.d(e,"c",function(){return i}),function(t){t.BAD_AUTHENTICATION="BAD_AUTHENTICATION",t.BAD_SUBJECT="BAD_SUBJECT",t.CONNECTION_CLOSED="CONNECTION_CLOSED",t.CONNECTION_DRAINING="CONNECTION_DRAINING",t.CONNECTION_REFUSED="CONNECTION_REFUSED",t.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",t.INVALID_PAYLOAD_TYPE="INVALID_PAYLOAD",t.UNKNOWN="UNKNOWN_ERROR",t.WSS_REQUIRED="WSS_REQUIRED",t.SUB_CLOSED="SUB_CLOSED",t.SUB_DRAINING="SUB_DRAINING",t.PERMISSIONS_VIOLATION="PERMISSIONS_VIOLATION",t.AUTHORIZATION_VIOLATION="AUTHORIZATION_VIOLATION",t.NATS_PROTOCOL_ERR="NATS_PROTOCOL_ERR"}(n||(n={}));var o=function(){function t(){this.messages={},this.messages[n.BAD_AUTHENTICATION]="User and Token can not both be provided",this.messages[n.BAD_SUBJECT]="Subject must be supplied",this.messages[n.CONNECTION_CLOSED]="Connection closed",this.messages[n.CONNECTION_CLOSED]="Connection closed",this.messages[n.CONNECTION_REFUSED]="Connection refused",this.messages[n.CONNECTION_TIMEOUT]="Connection timeout",this.messages[n.CONNECTION_DRAINING]="Connection draining",this.messages[n.INVALID_PAYLOAD_TYPE]="Invalid payload type - payloads can be 'binary', 'string', or 'json'",this.messages[n.SUB_CLOSED]="Subscription closed",this.messages[n.SUB_DRAINING]="Subscription draining",this.messages[n.WSS_REQUIRED]="TLS is required, therefore a secure websocket connection is also required"}return t.getMessage=function(e){return t.messages.getMessage(e)},t.prototype.getMessage=function(t){var e=this.messages[t];return e||(e=t),e},t}();o.messages=new o;var i=function(t){function e(e,r,n){var o=this;return(o=t.call(this,e)||this).name="NatsError",o.message=e,o.code=r,o.chainedError=n,o}return a(e,t),e.errorForCode=function(t,r){return new e(o.getMessage(t),t,r)},e}(Error)},function(t,e,r){r.d(e,"d",function(){return a}),r.d(e,"b",function(){return u}),r.d(e,"c",function(){return h}),r.d(e,"a",function(){return c}),r.d(e,"e",function(){return f}),r.d(e,"f",function(){return p});var n=r(2),o=n.a.fromAscii("\r\n"),i=new Uint8Array(o)[0],s=new Uint8Array(o)[1];function a(t){return t instanceof ArrayBuffer}function u(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=function(r){var n=e[r];Object.keys(n).forEach(function(e){t[e]=n[e]})},o=0;o<e.length;o++)n(o);return t}function h(t){var e=function(t){for(var e=new Uint8Array(t),r=0;r<e.byteLength;r++){var n=r+1;if(e.byteLength>n&&e[r]===i&&e[n]===s)return n+1}return-1}(t);if(e){var r=new Uint8Array(t).slice(0,e);return String.fromCharCode.apply(null,r)}return""}function c(t,e){var r=n.a.fromAscii(t);return e&&(r=n.a.concat(r,e,o)),r}function f(t){return Array.isArray(t)?Promise.resolve(t).then(l):Promise.reject(new TypeError("argument requires an array of promises"))}function p(t){for(var e=t.split(""),r=[],n=0;n<e.length;n++)r.push(e[n].charCodeAt(0));return new Uint8Array(r)}function l(t){return Promise.all(t.map(function(t){return Promise.resolve(t).then(d,d)}))}function d(t){return t}},function(t,e,r){r.d(e,"a",function(){return n});var n=function(){function t(){this.buffers=[],this.byteLength=0}return t.concat=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,n=0;n<t.length;n++)r+=t[n].byteLength;for(var o=new Uint8Array(r),i=0,s=0;s<t.length;s++)o.set(new Uint8Array(t[s]),i),i+=t[s].byteLength;return o.buffer},t.fromAscii=function(t){t||(t="");for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return e},t.toAscii=function(t){return String.fromCharCode.apply(null,new Uint8Array(t))},t.prototype.pack=function(){if(this.buffers.length>1){var e=this.buffers.splice(0,this.buffers.length);this.buffers.push(t.concat.apply(t,f(e)))}},t.prototype.drain=function(t){if(this.buffers.length){this.pack();var e=this.buffers.pop();if(e){var r=this.byteLength;(void 0===t||t>r)&&(t=r);var n=e.slice(0,t);return r>t&&this.buffers.push(e.slice(t)),this.byteLength=r-t,n}}return new Uint8Array(0).buffer},t.prototype.fill=function(t){t&&(this.buffers.push(t),this.byteLength+=t.byteLength)},t.prototype.peek=function(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0).buffer},t.prototype.size=function(){return this.byteLength},t.prototype.length=function(){return this.buffers.length},t}()},function(t,e,r){var n;r.d(e,"a",function(){return n}),function(t){t.STRING="string",t.JSON="json",t.BINARY="binary"}(n||(n={}))},function(t,e,r){(function(t){r.d(e,"d",function(){return o}),r.d(e,"i",function(){return b}),r.d(e,"a",function(){return v}),r.d(e,"k",function(){return m}),r.d(e,"j",function(){return I}),r.d(e,"f",function(){return w}),r.d(e,"g",function(){return A}),r.d(e,"c",function(){return C}),r.d(e,"h",function(){return T}),r.d(e,"b",function(){return E}),r.d(e,"e",function(){return O});var n,o,i=r(3),s=r(5),a=r(0),u=r(1),h=r(6),c=r(2);!function(t){t[t.CLOSED=-1]="CLOSED",t[t.AWAITING_CONTROL=0]="AWAITING_CONTROL",t[t.AWAITING_MSG_PAYLOAD=1]="AWAITING_MSG_PAYLOAD"}(o||(o={}));var f=/^MSG\s+([^\s\r\n]+)\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?(\d+)\r\n/i,p=/^\+OK\s*\r\n/i,l=/^-ERR\s+('.+')?\r\n/i,d=/^PING\r\n/i,g=/^PONG\r\n/i,y=/^INFO\s+([^\r\n]+)\r\n/i;function b(){return n||(n=new h.a),"_INBOX."+n.next()}var v=function(t){this.lang="javascript",this.pedantic=!1,this.protocol=1,this.verbose=!1,(t=t||{}).token&&(this.auth_token=t.token),t.noEcho&&(this.echo=!1),t.userJWT&&("function"==typeof t.userJWT?this.jwt=t.userJWT():this.jwt=t.userJWT),Object(u.b)(this,t)};function m(){return{sid:0,subject:"",received:0}}function I(){return{token:"",subject:"",received:0,max:1}}var w=function(){function t(t,e){this.token=t.token,this.protocol=e}return t.prototype.cancel=function(){this.protocol.cancelRequest(this.token,0)},t}(),A=function(){function t(t,e){this.sid=t.sid,this.protocol=e}return t.prototype.unsubscribe=function(t){this.protocol.unsubscribe(this.sid,t)},t.prototype.hasTimeout=function(){var t=this.protocol.subscriptions.get(this.sid);return null!==t&&null!==t.timeout},t.prototype.cancelTimeout=function(){var t=this.protocol.subscriptions.get(this.sid);null!==t&&null!==t.timeout&&(clearTimeout(t.timeout),t.timeout=null)},t.prototype.setTimeout=function(t,e){var r=this.protocol.subscriptions.get(this.sid);return null!==r&&(r.timeout&&(clearTimeout(r.timeout),r.timeout=null),r.timeout=setTimeout(e,t),!0)},t.prototype.getReceived=function(){var t=this.protocol.subscriptions.get(this.sid);return t?t.received:0},t.prototype.drain=function(){return this.protocol.drainSubscription(this.sid)},t.prototype.isDraining=function(){var t=this.protocol.subscriptions.get(this.sid);return!!t&&t.draining},t.prototype.isCancelled=function(){return null===this.protocol.subscriptions.get(this.sid)},t}(),C=function(){function t(){this.reqs={},this.length=0}return t.prototype.init=function(){return this.baseInbox=b()+".",this.baseInbox},t.prototype.add=function(t){isNaN(t.received)||(t.received=0),this.length++,this.reqs[t.token]=t},t.prototype.get=function(t){return t in this.reqs?this.reqs[t]:null},t.prototype.cancel=function(t){t&&t.timeout&&(clearTimeout(t.timeout),t.timeout=null),t.token in this.reqs&&(delete this.reqs[t.token],this.length--)},t.prototype.getToken=function(t){var e=t.subject||"";return 0===e.indexOf(this.baseInbox)?e.substring(this.baseInbox.length):null},t.prototype.dispatcher=function(){var t=this;return function(e){var r=t.getToken(e);if(r){var n=t.get(r);n&&(n.received++,n.callback(e),n.max&&n.received>=n.max&&t.cancel(n))}}},t}(),T=function(){function t(){this.subs={},this.sidCounter=0,this.length=0}return t.prototype.add=function(t){return this.sidCounter++,this.length++,t.sid=this.sidCounter,this.subs[t.sid]=t,t},t.prototype.setMux=function(t){return this.mux=t,t},t.prototype.getMux=function(){return this.mux},t.prototype.get=function(t){return t in this.subs?this.subs[t]:null},t.prototype.all=function(){var t=[];for(var e in this.subs){var r=this.subs[e];t.push(r)}return t},t.prototype.cancel=function(t){t&&t.timeout&&(clearTimeout(t.timeout),t.timeout=null),t.sid in this.subs&&(delete this.subs[t.sid],this.length--)},t}(),E=function(){function e(t,e){void 0===e&&(e="string"),this.msg={},this.msg.subject=t[1],this.msg.sid=parseInt(t[2],10),this.msg.reply=t[4],this.msg.size=parseInt(t[5],10),this.length=this.msg.size+2,this.payload=e}return e.prototype.fill=function(e){if(this.buf?this.buf=c.a.concat(this.buf,e):this.buf=e,this.length-=e.byteLength,0===this.length){switch(this.msg.data=this.buf.slice(0,this.buf.byteLength-2),this.payload){case i.a.JSON:this.msg.data=t.from(this.msg.data).toString("utf8"),this.msg.data=JSON.parse(this.msg.data);break;case i.a.STRING:this.msg.data=t.from(this.msg.data).toString("utf8");case i.a.BINARY:}this.buf=null}},e}(),O=function(){function e(t,e){this.infoReceived=!1,this.payload=null,this.pongs=[],this.pout=0,this.state=o.AWAITING_CONTROL,this.noMorePublishing=!1,this.options=t,this.clientHandlers=e,this.subscriptions=new T,this.muxSubscriptions=new C,this.inbound=new c.a,this.outbound=new c.a}return e.connect=function(t,r){return new Promise(function(n,o){var i=new e(t,r);i.connectError=o;var u=t.connectTimeout||1e4,h=new Promise(function(t,e){var r=setTimeout(function(){e(a.c.errorForCode(a.a.CONNECTION_TIMEOUT))},u);i.pongs.push(function(){clearTimeout(r),t(!0)})});s.a.connect(t,i,t.debug).then(function(t){i.transport=t}).catch(function(t){i.connectError=null,o(t)}),h.then(function(){i.connectError=null,n(i)}).catch(function(t){i.connectError=null,o(t)})})},e.toError=function(t){var e=t?t.toLowerCase():"";return-1!==e.indexOf("permissions violation")?new a.c(t,a.a.PERMISSIONS_VIOLATION):-1!==e.indexOf("authorization violation")?new a.c(t,a.a.AUTHORIZATION_VIOLATION):new a.c(t,a.a.NATS_PROTOCOL_ERR)},e.prototype.processInbound=function(){for(var t=null;this.inbound.size();){switch(this.state){case o.CLOSED:return;case o.AWAITING_CONTROL:var e=this.inbound.peek(),r=Object(u.c)(e);if(t=f.exec(r))this.payload=new E(t,this.options.payload),this.state=o.AWAITING_MSG_PAYLOAD;else if(t=p.exec(r));else{if(t=l.exec(r))return void this.processError(t[1]);if(t=g.exec(r)){this.pout=0;var n=this.pongs.shift();n&&n()}else if(t=d.exec(r))this.transport.write(Object(u.a)("PONG \r\n"));else{if(!(t=y.exec(r)))return;if(!this.infoReceived){if(JSON.parse(t[1]).tls_required&&!this.transport.isSecure())return void this.handleError(a.c.errorForCode(a.a.WSS_REQUIRED));var i=JSON.stringify(new v(this.options));this.transport.write(Object(u.a)("CONNECT "+i+"\r\n")),this.sendSubscriptions(),this.transport.write(Object(u.a)("PING \r\n")),this.infoReceived=!0,this.flushPending()}}}break;case o.AWAITING_MSG_PAYLOAD:if(!this.payload)break;if(this.inbound.size()<this.payload.length){var s=this.inbound.drain();return void this.payload.fill(s)}var h=this.inbound.drain(this.payload.length);this.payload.fill(h);try{this.processMsg()}catch(t){}this.state=o.AWAITING_CONTROL,this.payload=null}if(t){var c=t[0].length;c>=this.inbound.size()?this.inbound.drain():this.inbound.drain(c),t=null}}},e.prototype.processMsg=function(){if(this.payload&&this.subscriptions.sidCounter){var t=this.payload,e=this.subscriptions.get(t.msg.sid);e&&(e.received+=1,e.timeout&&void 0===e.max&&(clearTimeout(e.timeout),e.timeout=null),e.callback&&e.callback(t.msg),void 0!==e.max&&e.received>=e.max&&this.unsubscribe(e.sid))}},e.prototype.sendCommand=function(t){var e,r=this;e="string"==typeof t?Object(u.f)(t):t,t&&this.outbound.fill(e),1===this.outbound.length()?setTimeout(function(){r.flushPending()}):this.outbound.size()>8192&&this.flushPending()},e.prototype.publish=function(e,r,n){if(this.isClosed())throw a.c.errorForCode(a.a.CONNECTION_CLOSED);if(this.noMorePublishing)throw a.c.errorForCode(a.a.CONNECTION_DRAINING);var o,i=t.byteLength(r);o=(n=n||"")?"PUB "+e+" "+n+" "+i+"\r\n":"PUB "+e+" "+i+"\r\n",this.sendCommand(Object(u.a)(o,r))},e.prototype.request=function(t){return this.initMux(),this.muxSubscriptions.add(t),new w(t,this)},e.prototype.subscribe=function(t){var e=this.subscriptions.add(t);return e.queue?this.sendCommand("SUB "+e.subject+" "+e.queue+" "+e.sid+"\r\n"):this.sendCommand("SUB "+e.subject+" "+e.sid+"\r\n"),new A(e,this)},e.prototype.unsubscribe=function(t,e){if(t&&!this.isClosed()){var r=this.subscriptions.get(t);r&&(e?this.sendCommand("UNSUB "+t+" "+e+"\r\n"):this.sendCommand("UNSUB "+t+"\r\n"),r.max=e,(void 0===r.max||r.received>=r.max)&&this.subscriptions.cancel(r))}},e.prototype.cancelRequest=function(t,e){if(t&&!this.isClosed()){var r=this.muxSubscriptions.get(t);r&&(r.max=e,(void 0===r.max||r.received>=r.max)&&this.muxSubscriptions.cancel(r))}},e.prototype.flush=function(t){this.pongs.push(t),this.sendCommand("PING \r\n")},e.prototype.processError=function(t){var r={error:e.toError(t)};this.errorHandler(r)},e.prototype.sendSubscriptions=function(){var t=[];this.subscriptions.all().forEach(function(e){e.queue?t.push("SUB "+e.subject+" "+e.queue+" "+e.sid+" \r\n"):t.push("SUB "+e.subject+" "+e.sid+" \r\n")}),t.length&&this.transport.write(Object(u.a)(t.join("")))},e.prototype.openHandler=function(t){},e.prototype.closeHandler=function(t){this.close(),this.clientHandlers.closeHandler()},e.prototype.errorHandler=function(t){var e;t&&(e=t.error),this.handleError(e)},e.prototype.messageHandler=function(t){this.inbound.fill(t.data),this.processInbound()},e.prototype.close=function(){this.transport.close(),this.state=o.CLOSED},e.prototype.isClosed=function(){return this.transport.isClosed()},e.prototype.drain=function(){var t=this,e=this.subscriptions.all(),r=[];return e.forEach(function(e){var n=t.drainSubscription(e.sid);r.push(n)}),new Promise(function(e){Object(u.e)(r).then(function(r){t.noMorePublishing=!0,setTimeout(function(){t.close(),e(r)})}).catch(function(){})})},e.prototype.drainSubscription=function(t){var e=this;if(this.isClosed())return Promise.reject(a.c.errorForCode(a.a.CONNECTION_CLOSED));if(!t)return Promise.reject(a.c.errorForCode(a.a.SUB_CLOSED));var r=this.subscriptions.get(t);if(!r)return Promise.reject(a.c.errorForCode(a.a.SUB_CLOSED));if(r.draining)return Promise.reject(a.c.errorForCode(a.a.SUB_DRAINING));var n=r;return new Promise(function(t){n.draining=!0,e.sendCommand("UNSUB "+n.sid+"\r\n"),e.flush(function(){e.subscriptions.cancel(n),t(n)})})},e.prototype.flushPending=function(){if(this.infoReceived&&this.outbound.size()){var t=this.outbound.drain();this.transport.write(t)}},e.prototype.initMux=function(){if(!this.subscriptions.getMux()){var t=this.muxSubscriptions.init(),e={sid:0,subject:"",received:0};e.subject=t+"*",e.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(e),this.subscribe(e)}},e.prototype.handleError=function(t){this.connectError&&(this.connectError(t),this.connectError=null),this.close(),this.clientHandlers.errorHandler(t)},e}()}).call(this,r(7).Buffer)},function(t,e,r){r.d(e,"a",function(){return o});var n=r(0),o=function(){function t(t){this.stream=null,this.closed=!1,this.debug=!1,this.listeners={},this.handlers=t}return t.connect=function(e,r,o){return void 0===o&&(o=!1),new Promise(function(i,s){var a,u=new t(r);u.debug=o,u.stream=new WebSocket(e.url),u.stream.binaryType="arraybuffer",u.listeners={},u.stream.onclose=function(t){u.trace("ws closed",t),u.closed||(a?(u.handlers.closeHandler(t),u.close()):(clearTimeout(void 0),s(n.c.errorForCode(n.a.CONNECTION_CLOSED))))},u.stream.onerror=function(t){var e;if(t&&!(e=t.error)){var r=t.message;e=r?new n.c(r,n.a.UNKNOWN):a?n.c.errorForCode(n.a.UNKNOWN):n.c.errorForCode(n.a.CONNECTION_REFUSED)}u.trace("ws error",e),u.closed||(u&&u.close(),a?u.handlers.errorHandler(t):s(e))},u.stream.onopen=function(){u.trace("ws open")},u.stream.onmessage=function(t){u.trace(">",[t.data]),a?u.handlers.messageHandler(t):(a=!0,i(u),setTimeout(function(){u.handlers.messageHandler(t)},100))}})},t.prototype.isClosed=function(){return this.closed},t.prototype.isConnected=function(){return null!==this.stream&&this.stream.readyState===WebSocket.OPEN},t.prototype.write=function(t){this.stream&&this.isConnected()&&(this.trace("<",[t]),this.stream.send(t))},t.prototype.destroy=function(){this.stream&&(this.closed&&(this.stream.onclose=null,this.stream.onerror=null,this.stream.onopen=null,this.stream.onmessage=null),this.stream.readyState!==WebSocket.CLOSED&&this.stream.readyState!==WebSocket.CLOSING&&this.stream.close(1e3),this.stream=null)},t.prototype.close=function(){this.closed=!0,this.stream&&this.stream.bufferedAmount>0?setTimeout(this.close.bind(this),100):this.destroy()},t.prototype.trace=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.debug&&console.log(t)},t.prototype.isSecure=function(){return!!this.stream&&"wss:"===new URL(this.stream.url).protocol.toLowerCase()},t}()},function(t,e,r){r.d(e,"a",function(){return i});var n,o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i=function(){function t(){this.buf=new Uint8Array(22),this.init()}return t.prototype.init=function(){"crypto"in Object({})&&Object({}).crypto.getRandomValues?n=Object({}).crypto:"msCrypto"in Object({})&&Object({}).msCrypto.getRandomValues&&(n=Object({}).msCrypto),n||(n={getRandomValues:function(t){for(var e=0;e<t.length;e++)t[e]=Math.floor(255*Math.random())}}),this.setPre(),this.initSeqAndInc(),this.fillSeq()},t.prototype.initSeqAndInc=function(){this.seq=Math.floor(0xcfd41b9100000*Math.random()),this.inc=Math.floor(300*Math.random()+33)},t.prototype.setPre=function(){var t=new Uint8Array(12);n.getRandomValues(t);for(var e=0;e<12;e++){var r=t[e]%36;this.buf[e]=o.charCodeAt(r)}},t.prototype.fillSeq=function(){for(var t=this.seq,e=21;e>=12;e--)this.buf[e]=o.charCodeAt(t%36),t=Math.floor(t/36)},t.prototype.next=function(){return this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)},t.prototype.reset=function(){this.init()},t}()},function(t,e,r){(function(t){
|
|
2
2
|
/*!
|
|
3
3
|
* The buffer module from node.js, for the browser.
|
|
4
4
|
*
|
|
5
5
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
var n=r(9),o=r(10),i=r(11);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return h(this,t,e,r)}function h(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=p(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),o=(t=a(t,n)).write(e,r);return o!==n&&(t=t.slice(0,o)),t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|l(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):p(t,e);if("Buffer"===e.type&&i(e.data))return p(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(c(e),t=a(t,e<0?0:0|l(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function p(t,e){var r=e.length<0?0:0|l(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return j(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return N(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var c=-1;for(i=r;i<a;i++)if(h(t,i)===h(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*s}else-1!==c&&(i-=i-c),c=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,p=0;p<u;p++)if(h(t,i+p)!==h(e,p)){f=!1;break}if(f)return i}return-1}function m(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function I(t,e,r,n){return Y(j(e,t.length-r),t,r,n)}function w(t,e,r,n){return Y(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function A(t,e,r,n){return w(t,e,r,n)}function T(t,e,r,n){return Y(F(e),t,r,n)}function C(t,e,r,n){return Y(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,h=t[o],c=null,f=h>239?4:h>223?3:h>191?2:1;if(o+f<=r)switch(f){case 1:h<128&&(c=h);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&h)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&h)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function N(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function _(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=D(t[i]);return o}function U(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function P(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function M(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,n,i){return i||x(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,i){return i||x(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return h(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return c(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,n,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),h=this.slice(n,o),c=t.slice(e,r),f=0;f<a;++f)if(h[f]!==c[f]){i=h[f],s=c[f];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return I(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return A(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},u.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||B(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||B(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):M(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):M(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);B(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);B(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):M(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):M(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=u.isBuffer(t)?t:j(new u(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var k=/[^+\/0-9A-Za-z-_]/g;function D(t){return t<16?"0"+t.toString(16):t.toString(16)}function j(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(8))},function(t,e,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){n=Object({})}t.exports=n},function(t,e,r){e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=u(t),s=n[0],a=n[1],h=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),c=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],h[c++]=e>>16&255,h[c++]=e>>8&255,h[c++]=255&e;return 2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,h[c++]=255&e),1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e),h},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(h(t,s,s+16383>a?a:s+16383));return 1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,h=u>>1,c=-7,f=r?o-1:0,p=r?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-c)-1,l>>=-c,c+=a;c>0;i=256*i+t[e+f],f+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+f],f+=p,c-=8);if(0===i)i=1-h;else{if(i===u)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,n),i-=h}return(l?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,h=8*i-o-1,c=(1<<h)-1,f=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+l]=255&a,l+=d,a/=256,o-=8);for(s=s<<o|a,h+=o;h>0;t[r+l]=255&s,l+=d,s/=256,h-=8);t[r+l-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){r.r(e);var n=r(2),o=r(0),i=r(3),s=r(1),a=r(4),u=r(6);function h(t){return c.connect(t)}var c=function(){function t(t){if(this.closeListeners=[],this.errorListeners=[],this.draining=!1,this.nuid=new u.a,this.options={url:"ws://localhost:4222"},void 0===t.payload&&(t.payload=i.a.STRING),!["json","string","binary"].includes(t.payload))throw o.c.errorForCode(o.a.INVALID_PAYLOAD_TYPE);if(t.user&&t.token)throw o.c.errorForCode(o.a.BAD_AUTHENTICATION);Object(s.b)(this.options,t)}return t.connect=function(e){return new Promise(function(r,n){var o=new t(e);a.e.connect(e,o).then(function(t){o.protocol=t,r(o)}).catch(function(t){n(t)})})},t.prototype.close=function(){this.protocol.close()},t.prototype.publish=function(t,e,r){return void 0===r&&(r=""),0===(t=t||"").length?(this.errorHandler(o.c.errorForCode(o.a.BAD_SUBJECT)),this):(Object(s.d)(e)||(this.options.payload!==i.a.JSON?e=e||"":(e=void 0===e?null:e,e=JSON.stringify(e)),e=Object(s.f)(e)),this.protocol.publish(t,e,r),this)},t.prototype.subscribe=function(t,e,r){var n=this;return void 0===r&&(r={}),new Promise(function(i,u){n.isClosed()&&u(o.c.errorForCode(o.a.CONNECTION_CLOSED)),n.isDraining()&&u(o.c.errorForCode(o.a.CONNECTION_DRAINING));var h=Object(a.k)();Object(s.b)(h,r),h.subject=t,h.callback=e,i(n.protocol.subscribe(h))})},t.prototype.request=function(t,e,r){var n=this;return void 0===e&&(e=1e3),new Promise(function(i,u){n.isClosed()&&u(o.c.errorForCode(o.a.CONNECTION_CLOSED)),n.isDraining()&&u(o.c.errorForCode(o.a.CONNECTION_DRAINING));var h=Object(a.j)();Object(s.b)(h,{max:1}),h.token=n.nuid.next(),h.timeout=setTimeout(function(){c.cancel(),u("timeout")},e),h.callback=function(t){i(t)};var c=n.protocol.request(h);n.publish(t,r,""+n.protocol.muxSubscriptions.baseInbox+h.token)})},t.prototype.flush=function(t){var e=this;if(void 0===t)return new Promise(function(t){e.protocol.flush(function(){t()})});this.protocol.flush(t)},t.prototype.drain=function(){return this.isClosed()?Promise.reject(o.c.errorForCode(o.a.CONNECTION_CLOSED)):this.isDraining()?Promise.reject(o.c.errorForCode(o.a.CONNECTION_DRAINING)):(this.draining=!0,this.protocol.drain())},t.prototype.errorHandler=function(t){this.errorListeners.forEach(function(e){try{e(t)}catch(t){}})},t.prototype.closeHandler=function(){this.closeListeners.forEach(function(t){try{t()}catch(t){}})},t.prototype.addEventListener=function(t,e){"close"===t?this.closeListeners.push(e):"error"===t&&this.errorListeners.push(e)},t.prototype.isClosed=function(){return this.protocol.isClosed()},t.prototype.isDraining=function(){return this.draining},t}(),f=r(5);r.d(e,"DataBuffer",function(){return n.a}),r.d(e,"ErrorCode",function(){return o.a}),r.d(e,"Messages",function(){return o.b}),r.d(e,"NatsError",function(){return o.c}),r.d(e,"connect",function(){return h}),r.d(e,"Connection",function(){return c}),r.d(e,"ParserState",function(){return a.d}),r.d(e,"createInbox",function(){return a.i}),r.d(e,"Connect",function(){return a.a}),r.d(e,"defaultSub",function(){return a.k}),r.d(e,"defaultReq",function(){return a.j}),r.d(e,"Request",function(){return a.f}),r.d(e,"Subscription",function(){return a.g}),r.d(e,"MuxSubscription",function(){return a.c}),r.d(e,"Subscriptions",function(){return a.h}),r.d(e,"MsgBuffer",function(){return a.b}),r.d(e,"ProtocolHandler",function(){return a.e}),r.d(e,"WSTransport",function(){return f.a}),r.d(e,"isArrayBuffer",function(){return s.d}),r.d(e,"extend",function(){return s.b}),r.d(e,"extractProtocolMessage",function(){return s.c}),r.d(e,"buildWSMessage",function(){return s.a}),r.d(e,"settle",function(){return s.e}),r.d(e,"stringToUint8Array",function(){return s.f})}])},t.exports=r()}),l=function(){function t(t){this.http=t,this.chatServer="",this.chatUrl="",this.debug=!1,this.chatUserExternalId="",this.timeoutReconnect=500}return t.prototype.ngOnInit=function(){},t.prototype.config=function(t){this.chatServer=t.endpoint,this.chatUrl=t.endpoint+"/api/v1/",this.debug=t.debug},t.prototype.init=function(t,e,r,n){if(!this.chatServer||0==this.chatServer.trim().length)throw new Error("Endpoint is empty");if(!t||0==t.trim().length)throw new Error("SecurityChatToken is empty");this.setTokenChat4app(t),r&&n&&this.connectWebsocket(r,n),e(t)},t.prototype.getChatUrlDownload=function(t){return this.chatUrl+"chatmessage/getFile?messageFileId="+t+"&token="+this.getBearerToken()},t.prototype.getMessageChat=function(t,e,n){var o=this.chatUrl+"chatmessage/"+t+"/"+e+"/"+n;return this.http.get(o,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getMessageChatByGrop=function(t,e,n){var o=this.chatUrl+"chatmessage/byGroup/"+t+"/"+e+"/"+n;return this.http.get(o,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.addMessageChat=function(t){var e=this.chatUrl+"chatmessage/"+t.chatId;return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.props=function(t){var e=this.chatUrl+"chatmessage/props";return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.removeUsersChat=function(t,e,n){var o=new Array;e&&e.length>0?e.forEach(function(t){o.push("chatUserId="+t)}):n&&n.length>0&&n.forEach(function(t){o.push("chatUserExternalId="+t)});var i=this.chatUrl+"chatuser/"+t+"?"+o.join("&");return this.http.delete(i,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.removeUserChat=function(t,e,n){var o="";o=e?"chatUserId="+e:"chatUserExternalId="+n;var i=this.chatUrl+"chatuser/"+t+"?"+o;return this.http.delete(i,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.updateUserChat=function(t,e){var n=this.chatUrl+"chatuser/"+t;return this.http.put(n,e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createUserChat=function(t,e){var n=this.chatUrl+"chatuser/"+t;return this.http.post(n,e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createUsersChat=function(t,e){var n=this.chatUrl+"chatuser/users/"+t;return this.http.post(n,e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createChat=function(t){var e=this.chatUrl+"chat";return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createUpdateChat=function(t){var e=this.chatUrl+"chat";return this.http.put(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getLastMessageGroup=function(t,e){var n=this.chatUrl+"chatmessage/lastMessageGroup?chatExternalId="+t+"&groupId="+e;return this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getLastMessage=function(t,e){var n=this.chatUrl+"chatmessage/lastMessage?chatExternalId="+t+"&chatUserExternalId="+e;return this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.countNotReadMessages=function(t,e,n,o){var i=this.chatUrl+"chatmessage/countNotReadMessages?chatUserExternalId="+t;return e&&e.length>0&&(i+="&chatExternalId="+e),n&&n.length>0&&(i+="&groupId="+n),o&&o.length>0&&(i+="&fromId="+n),this.http.get(i,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getChatByExternalId=function(t){var e=this.chatUrl+"chat?externalId="+t;return this.http.get(e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getChatById=function(t){var e=this.chatUrl+"chat?chatId="+t;return this.http.get(e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.listChatByUser=function(t,e,n){var o=this.chatUrl+"chat/listChatByUser/?externalUserId="+t+"&userId="+e+"&chatStatus="+n;return this.http.get(o,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.closeChat=function(t,e){var n=this.chatUrl;return t&&t.length>0&&(n+="chat?chatId="+t),e&&e.length>0&&(n+="chat?externalId="+e),this.http.delete(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.readMessage=function(t,e){var n=this.chatUrl+"chatmessage/read/"+t;return e&&e.length>0&&(n+="/"+e),this.http.put(n,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.online=function(t){var e=this.chatUrl+"chatmessage/online/"+t;return this.http.get(e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.setOffLine=function(t){var e=this.chatUrl+"chatmessage/set-offline/"+t;return this.http.put(e,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.sendFile=function(t,e,n,o){var i=this.chatUrl+"chatmessage/sendFile/"+t+"/"+e+"/"+n,s=new FormData;return s.append("file",o),this.http.post(i,s,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.sendFileGroup=function(t,e,n,o){var i=this.chatUrl+"chatmessage/sendFileGroup/"+t+"/"+e+"/"+n,s=new FormData;return s.append("file",o),this.http.post(i,s,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.translateMessage=function(t,e){var n=this.chatUrl+"chatmessage/translate/"+t+"/"+e;return this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.startTyping=function(t,e,n){var o=this.chatUrl+"chatmessage/startTyping/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.startTypingGroup=function(t,e,n){var o=this.chatUrl+"chatmessage/startTypingGroup/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.stopTyping=function(t,e,n){var o=this.chatUrl+"chatmessage/stopTyping/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.stopTypingGroup=function(t,e,n){var o=this.chatUrl+"chatmessage/stopTypingGroup/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createGroup=function(t){var e=this.chatUrl+"/group";return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getGroup=function(t,e){var n=this.chatUrl+"/group/"+e+"/"+t;return this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.listGroups=function(t,e){var n=this.chatUrl+"/group/";return t&&t.length>0&&(n+="&chatId="+t),e&&e.length>0&&(n+="&externalId="+e),this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.listFilesGroup=function(t,e){var n=this.chatUrl+"/group/"+t;return e&&e.length>0&&(n+="&groupId="+t),this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getBearerToken=function(){return"Bearer "+window.sessionStorage.getItem("chat4AppSessionToken")},t.prototype.setTokenChat4app=function(t){window.sessionStorage.setItem("chat4AppSessionToken",t)},t.prototype.onMessageFirebaseReceived=function(t,e){if("msg"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type,o.notification.body=t.body,t.fileId&&t.fileId.length>0&&(o.data.fileId=t.fileId,o.data.fileName=t.fileName,o.data.fileSize=t.fileSize,o.data.fileType=t.fileType);var r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onMessage(o)}else if("on"==t.type||"off"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onOffline(o)}else if("read"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onRead(o)}else if("startTyping"==t.type||"stopTyping"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onStartStopTyping(o)}else if("new_user"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onNewUser(o)}else if("remove_user"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onRemoveUser(o)}else if("chat_closed"==t.type){var o;(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onChatClosed(o)}},t.prototype.ensureConn=function(t){return u(this,void 0,void 0,function(){var e,r,n,o;return h(this,function(i){switch(i.label){case 0:return this.debug&&(console.log("chatServer: "+this.chatServer),console.log("userId: "+t),console.log("getBearerToken: "+this.getBearerToken())),e=this,r=this.chatServer.replace(/^https/,"wss"),n=r.replace(/(\/\/.*?)\//,"$1/ws/"),this.debug&&console.log("ws server: "+n),!this.nc||this.nc.isClose&&this.nc.isClose()?(o=e,[4,p.connect({url:n,user:t,pass:this.getBearerToken(),reconnect:!0})]):[3,2];case 1:o.nc=i.sent(),i.label=2;case 2:return this.chatUserExternalId=t,[2,e.nc]}})})},t.prototype.disconnect=function(){return u(this,void 0,void 0,function(){var t,e=this;return h(this,function(r){switch(r.label){case 0:if(this.interval)try{clearInterval(this.interval)}catch(t){}if(this.nc&&this.chatUserExternalId&&this.chatUserExternalId.length>0&&this.getBearerToken()&&this.getBearerToken().length>0&&this.setOffLine(this.chatUserExternalId).subscribe(function(){e.debug&&console.log("had set offline")}),!this.nc)return[3,5];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.nc.close()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.debug&&console.error(t),[3,4];case 4:this.nc=void 0,r.label=5;case 5:return this.debug&&console.log("disconect"),[2]}})})},t.prototype.processAndCallback=function(t,e){this.debug&&t&&console.log("Msg Received: "+JSON.stringify(t));var r=new Map;for(var n in t.data)r.set(n,t.data[n]);t.data.all=r,"msg"==t.data.type?e.onMessage(t):"on"==t.data.type||"off"==t.data.type?e.onOffline(t):"read"==t.data.type?e.onRead(t):"startTyping"==t.data.type||"stopTyping"==t.data.type?e.onStartStopTyping(t):"new_user"==t.data.type?e.onNewUser(t):"remove_user"==t.data.type?e.onRemoveUser(t):"chat_closed"==t.data.type&&e.onChatClosed(t)},t.prototype.connectWebsocket=function(t,e){return u(this,void 0,void 0,function(){var r,n,o,i,s,a=this;return h(this,function(u){switch(u.label){case 0:return r=this,this.disconnect(),n=this.getBearerToken(),n&&n.startsWith("Bearer ")?n:"Bearer "+n,o=this.chatServer.split("/")[3],[4,this.ensureConn(e)];case 1:if(i=u.sent(),s="chat4app.config."+o+".user."+e,i.subscribe(s,function(e){a.debug&&console.log(e),a.processAndCallback(JSON.parse(e.data),t)}),this.interval)try{clearInterval(this.interval)}catch(t){}return r.interval=setInterval(function(){r.debug&&console.log("publish chat4app.user.online "+e+" "),r.nc.publish("chat4app.user.online",e)},1e3),this.debug&&console.log("Subscribe online chat4app.user."+e+".online"),[2]}})})},t.prototype.convertChat4AppMessageReceiveToChatMessage4App=function(t){var e,r,n=new m;(n.body=null===(e=null==t?void 0:t.notification)||void 0===e?void 0:e.body,n.chatId=t.data.chatId,n.fromId=t.data.fromId,n.toId=t.data.toId,n.groupId=t.data.groupId,n.replyFrom=t.data.replyFrom,t.data.dateHour&&t.data.dateHour.length>0&&(n.dateHourIncluded=t.data.dateHour.substring(6,10)+"-"+t.data.dateHour.substring(3,5)+"-"+t.data.dateHour.substring(0,2)+t.data.dateHour.substring(10)),n.id=t.data.chatMessageId,t.data.fileId&&t.data.fileId.length>0)&&((r=new I).id=t.data.fileId,r.name=t.data.fileName,r.size=t.data.fileSize,r.type=t.data.fileType,n.chatMessageFile=r);t.data.vFileId&&t.data.vFileId.length>0&&((r=new I).id=t.data.vFileId,r.name=t.data.vFileName,r.size=t.data.vFileSize,r.type=t.data.vFileType,n.chatVoiceFile=r);return n},t}();l.ɵprov=o.ɵɵdefineInjectable({factory:function(){return new l(o.ɵɵinject(i.HttpClient))},token:l,providedIn:"root"}),l.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],l.ctorParameters=function(){return[{type:r.HttpClient}]};var d,g,y,b=function(){},v=function(){},m=function(){},I=function(){},w=function(){},A=function(){this.data=new T,this.notification=new C},T=function(){},C=function(){},E=function(){},O=function(){},S=function(t,e){this.endpoint=t,this.debug=e},N=function(){},_=function(){};t.ChatStatus4App=void 0,(d=t.ChatStatus4App||(t.ChatStatus4App={})).CREATED="CREATED",d.CLOSED="CLOSED",t.ChatUserStatus4App=void 0,(t.ChatUserStatus4App||(t.ChatUserStatus4App={})).REMOVED="REMOVED",t.ChatFilterType=void 0,(g=t.ChatFilterType||(t.ChatFilterType={}))[g.COUNT_NOT_READ=1]="COUNT_NOT_READ",g[g.LAST_MESSAGE=2]="LAST_MESSAGE",t.GroupStatus4App=void 0,(y=t.GroupStatus4App||(t.GroupStatus4App={})).CREATED="CREATED",y.CLOSED="REMOVED";var U=function(){function t(){}return t.prototype.ngOnInit=function(){},t}();U.decorators=[{type:e.Component,args:[{selector:"lib-chat4app-client-angular",template:"\n <p>\n chat4app-client-angular works!\n </p>\n "}]}],U.ctorParameters=function(){return[]};var R=function(){};R.decorators=[{type:e.NgModule,args:[{declarations:[U],imports:[],exports:[U]}]}],t.Chat4App=b,t.Chat4AppConfig=S,t.Chat4AppMessageReceive=A,t.Chat4AppMessageReceiveData=T,t.Chat4AppMessageReceiveNotification=C,t.Chat4AppTranslate=N,t.Chat4appClientAngularComponent=U,t.Chat4appClientAngularModule=R,t.Chat4appClientAngularService=l,t.ChatFilterRequest4App=O,t.ChatGroupApp=_,t.ChatMessage4App=m,t.ChatMessageFile4App=I,t.ChatMessageMeta4App=w,t.ChatUser4App=v,t.ChatUserResponse4App=E,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
8
|
+
var n=r(9),o=r(10),i=r(11);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return h(this,t,e,r)}function h(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=p(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),o=(t=a(t,n)).write(e,r);return o!==n&&(t=t.slice(0,o)),t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|l(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):p(t,e);if("Buffer"===e.type&&i(e.data))return p(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(c(e),t=a(t,e<0?0:0|l(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function p(t,e){var r=e.length<0?0:0|l(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return j(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return _(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return N(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var c=-1;for(i=r;i<a;i++)if(h(t,i)===h(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*s}else-1!==c&&(i-=i-c),c=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,p=0;p<u;p++)if(h(t,i+p)!==h(e,p)){f=!1;break}if(f)return i}return-1}function m(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function I(t,e,r,n){return Y(j(e,t.length-r),t,r,n)}function w(t,e,r,n){return Y(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function A(t,e,r,n){return w(t,e,r,n)}function C(t,e,r,n){return Y(F(e),t,r,n)}function T(t,e,r,n){return Y(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,h=t[o],c=null,f=h>239?4:h>223?3:h>191?2:1;if(o+f<=r)switch(f){case 1:h<128&&(c=h);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&h)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&h)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function N(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function _(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=H(t[i]);return o}function U(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function P(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function M(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function x(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return i||x(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||x(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return h(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return c(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,n,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),h=this.slice(n,o),c=t.slice(e,r),f=0;f<a;++f)if(h[f]!==c[f]){i=h[f],s=c[f];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return I(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return A(this,t,e,r);case"base64":return C(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},u.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||B(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||B(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):M(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):M(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);B(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);B(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):M(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):M(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=u.isBuffer(t)?t:j(new u(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var k=/[^+\/0-9A-Za-z-_]/g;function H(t){return t<16?"0"+t.toString(16):t.toString(16)}function j(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(8))},function(t,e,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){n=Object({})}t.exports=n},function(t,e,r){e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=u(t),s=n[0],a=n[1],h=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),c=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],h[c++]=e>>16&255,h[c++]=e>>8&255,h[c++]=255&e;return 2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,h[c++]=255&e),1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e),h},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(h(t,s,s+16383>a?a:s+16383));return 1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,h=u>>1,c=-7,f=r?o-1:0,p=r?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-c)-1,l>>=-c,c+=a;c>0;i=256*i+t[e+f],f+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+f],f+=p,c-=8);if(0===i)i=1-h;else{if(i===u)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,n),i-=h}return(l?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,h=8*i-o-1,c=(1<<h)-1,f=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=c?(a=0,s=c):s+f>=1?(a=(e*u-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+l]=255&a,l+=d,a/=256,o-=8);for(s=s<<o|a,h+=o;h>0;t[r+l]=255&s,l+=d,s/=256,h-=8);t[r+l-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){r.r(e);var n=r(2),o=r(0),i=r(3),s=r(1),a=r(4),u=r(6);function h(t){return c.connect(t)}var c=function(){function t(t){if(this.closeListeners=[],this.errorListeners=[],this.draining=!1,this.nuid=new u.a,this.options={url:"ws://localhost:4222"},void 0===t.payload&&(t.payload=i.a.STRING),!["json","string","binary"].includes(t.payload))throw o.c.errorForCode(o.a.INVALID_PAYLOAD_TYPE);if(t.user&&t.token)throw o.c.errorForCode(o.a.BAD_AUTHENTICATION);Object(s.b)(this.options,t)}return t.connect=function(e){return new Promise(function(r,n){var o=new t(e);a.e.connect(e,o).then(function(t){o.protocol=t,r(o)}).catch(function(t){n(t)})})},t.prototype.close=function(){this.protocol.close()},t.prototype.publish=function(t,e,r){return void 0===r&&(r=""),0===(t=t||"").length?(this.errorHandler(o.c.errorForCode(o.a.BAD_SUBJECT)),this):(Object(s.d)(e)||(this.options.payload!==i.a.JSON?e=e||"":(e=void 0===e?null:e,e=JSON.stringify(e)),e=Object(s.f)(e)),this.protocol.publish(t,e,r),this)},t.prototype.subscribe=function(t,e,r){var n=this;return void 0===r&&(r={}),new Promise(function(i,u){n.isClosed()&&u(o.c.errorForCode(o.a.CONNECTION_CLOSED)),n.isDraining()&&u(o.c.errorForCode(o.a.CONNECTION_DRAINING));var h=Object(a.k)();Object(s.b)(h,r),h.subject=t,h.callback=e,i(n.protocol.subscribe(h))})},t.prototype.request=function(t,e,r){var n=this;return void 0===e&&(e=1e3),new Promise(function(i,u){n.isClosed()&&u(o.c.errorForCode(o.a.CONNECTION_CLOSED)),n.isDraining()&&u(o.c.errorForCode(o.a.CONNECTION_DRAINING));var h=Object(a.j)();Object(s.b)(h,{max:1}),h.token=n.nuid.next(),h.timeout=setTimeout(function(){c.cancel(),u("timeout")},e),h.callback=function(t){i(t)};var c=n.protocol.request(h);n.publish(t,r,""+n.protocol.muxSubscriptions.baseInbox+h.token)})},t.prototype.flush=function(t){var e=this;if(void 0===t)return new Promise(function(t){e.protocol.flush(function(){t()})});this.protocol.flush(t)},t.prototype.drain=function(){return this.isClosed()?Promise.reject(o.c.errorForCode(o.a.CONNECTION_CLOSED)):this.isDraining()?Promise.reject(o.c.errorForCode(o.a.CONNECTION_DRAINING)):(this.draining=!0,this.protocol.drain())},t.prototype.errorHandler=function(t){this.errorListeners.forEach(function(e){try{e(t)}catch(t){}})},t.prototype.closeHandler=function(){this.closeListeners.forEach(function(t){try{t()}catch(t){}})},t.prototype.addEventListener=function(t,e){"close"===t?this.closeListeners.push(e):"error"===t&&this.errorListeners.push(e)},t.prototype.isClosed=function(){return this.protocol.isClosed()},t.prototype.isDraining=function(){return this.draining},t}(),f=r(5);r.d(e,"DataBuffer",function(){return n.a}),r.d(e,"ErrorCode",function(){return o.a}),r.d(e,"Messages",function(){return o.b}),r.d(e,"NatsError",function(){return o.c}),r.d(e,"connect",function(){return h}),r.d(e,"Connection",function(){return c}),r.d(e,"ParserState",function(){return a.d}),r.d(e,"createInbox",function(){return a.i}),r.d(e,"Connect",function(){return a.a}),r.d(e,"defaultSub",function(){return a.k}),r.d(e,"defaultReq",function(){return a.j}),r.d(e,"Request",function(){return a.f}),r.d(e,"Subscription",function(){return a.g}),r.d(e,"MuxSubscription",function(){return a.c}),r.d(e,"Subscriptions",function(){return a.h}),r.d(e,"MsgBuffer",function(){return a.b}),r.d(e,"ProtocolHandler",function(){return a.e}),r.d(e,"WSTransport",function(){return f.a}),r.d(e,"isArrayBuffer",function(){return s.d}),r.d(e,"extend",function(){return s.b}),r.d(e,"extractProtocolMessage",function(){return s.c}),r.d(e,"buildWSMessage",function(){return s.a}),r.d(e,"settle",function(){return s.e}),r.d(e,"stringToUint8Array",function(){return s.f})}])},t.exports=r()}),l=function(){function t(t){this.http=t,this.chatServer="",this.chatUrl="",this.debug=!1,this.chatUserExternalId="",this.timeoutReconnect=500}return t.prototype.ngOnInit=function(){},t.prototype.config=function(t){this.chatServer=t.endpoint,this.chatUrl=t.endpoint+"/api/v1/",this.debug=t.debug},t.prototype.init=function(t,e,r,n){if(!this.chatServer||0==this.chatServer.trim().length)throw new Error("Endpoint is empty");if(!t||0==t.trim().length)throw new Error("SecurityChatToken is empty");this.setTokenChat4app(t),r&&n&&this.connectWebsocket(r,n),e(t)},t.prototype.getChatUrlDownload=function(t){return this.chatUrl+"chatmessage/getFile?messageFileId="+t+"&token="+this.getBearerToken()},t.prototype.getMessageChat=function(t,e,n){var o=this.chatUrl+"chatmessage/"+t+"/"+e+"/"+n;return this.http.get(o,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getMessageChatByGrop=function(t,e,n){var o=this.chatUrl+"chatmessage/byGroup/"+t+"/"+e+"/"+n;return this.http.get(o,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.addMessageChat=function(t){var e=this.chatUrl+"chatmessage/"+t.chatId;return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.removeUsersChat=function(t,e,n){var o=new Array;e&&e.length>0?e.forEach(function(t){o.push("chatUserId="+t)}):n&&n.length>0&&n.forEach(function(t){o.push("chatUserExternalId="+t)});var i=this.chatUrl+"chatuser/"+t+"?"+o.join("&");return this.http.delete(i,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.removeUserChat=function(t,e,n){var o="";o=e?"chatUserId="+e:"chatUserExternalId="+n;var i=this.chatUrl+"chatuser/"+t+"?"+o;return this.http.delete(i,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.updateUserChat=function(t,e){var n=this.chatUrl+"chatuser/"+t;return this.http.put(n,e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createUserChat=function(t,e){var n=this.chatUrl+"chatuser/"+t;return this.http.post(n,e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createUsersChat=function(t,e){var n=this.chatUrl+"chatuser/users/"+t;return this.http.post(n,e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createChat=function(t){var e=this.chatUrl+"chat";return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createUpdateChat=function(t){var e=this.chatUrl+"chat";return this.http.put(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getChatByExternalId=function(t){var e=this.chatUrl+"chat?externalId="+t;return this.http.get(e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getChatById=function(t){var e=this.chatUrl+"chat?chatId="+t;return this.http.get(e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.listChatByUser=function(t,e,n){var o=this.chatUrl+"chat/listChatByUser/?externalUserId="+t+"&userId="+e+"&chatStatus="+n;return this.http.get(o,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.closeChat=function(t,e){var n=this.chatUrl;return t&&t.length>0&&(n+="chat?chatId="+t),e&&e.length>0&&(n+="chat?externalId="+e),this.http.delete(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.readMessage=function(t,e){var n=this.chatUrl+"chatmessage/read/"+t;return e&&e.length>0&&(n+="/"+e),this.http.put(n,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.online=function(t){var e=this.chatUrl+"chatmessage/online/"+t;return this.http.get(e,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.setOffLine=function(t){var e=this.chatUrl+"chatmessage/set-offline/"+t;return this.http.put(e,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.sendFile=function(t,e,n,o){var i=this.chatUrl+"chatmessage/sendFile/"+t+"/"+e+"/"+n,s=new FormData;return s.append("file",o),this.http.post(i,s,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.sendFileGroup=function(t,e,n,o){var i=this.chatUrl+"chatmessage/sendFileGroup/"+t+"/"+e+"/"+n,s=new FormData;return s.append("file",o),this.http.post(i,s,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.startTyping=function(t,e,n){var o=this.chatUrl+"chatmessage/startTyping/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.startTypingGroup=function(t,e,n){var o=this.chatUrl+"chatmessage/startTypingGroup/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.stopTyping=function(t,e,n){var o=this.chatUrl+"chatmessage/stopTyping/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.stopTypingGroup=function(t,e,n){var o=this.chatUrl+"chatmessage/stopTypingGroup/"+t+"/"+e+"/"+n;return this.http.put(o,null,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.createGroup=function(t){var e=this.chatUrl+"/group";return this.http.post(e,t,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getGroup=function(t,e){var n=this.chatUrl+"/group/"+e+"/"+t;return this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.listGroups=function(t,e){var n=this.chatUrl+"/group/";return t&&t.length>0&&(n+="&chatId="+t),e&&e.length>0&&(n+="&externalId="+e),this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.listFilesGroup=function(t,e){var n=this.chatUrl+"/group/"+t;return e&&e.length>0&&(n+="&groupId="+t),this.http.get(n,{headers:(new r.HttpHeaders).set("Authorization",this.getBearerToken())})},t.prototype.getBearerToken=function(){return"Bearer "+window.sessionStorage.getItem("chat4AppSessionToken")},t.prototype.setTokenChat4app=function(t){window.sessionStorage.setItem("chat4AppSessionToken",t)},t.prototype.onMessageFirebaseReceived=function(t,e){if("msg"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type,o.notification.body=t.body,t.fileId&&t.fileId.length>0&&(o.data.fileId=t.fileId,o.data.fileName=t.fileName,o.data.fileSize=t.fileSize,o.data.fileType=t.fileType);var r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onMessage(o)}else if("on"==t.type||"off"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onOffline(o)}else if("read"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onRead(o)}else if("startTyping"==t.type||"stopTyping"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onStartStopTyping(o)}else if("new_user"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onNewUser(o)}else if("remove_user"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onRemoveUser(o)}else if("chat_closed"==t.type){(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onChatClosed(o)}else if("count_notread"==t.type){var o;(o=new A).data.chatId=t.chatId,o.data.chatMessageId=t.chatMessageId,o.data.externalId=t.externalId,o.data.fromId=t.fromId,o.data.toId=t.toId,o.data.groupId=t.groupId,o.data.dateHour=t.dateHour,o.data.type=t.type;r=new Map;for(var n in t)r.set(n,t[n]);o.data.all=r,e.onCountNotRead(o)}},t.prototype.ensureConn=function(t){return u(this,void 0,void 0,function(){var e,r,n,o;return h(this,function(i){switch(i.label){case 0:return this.debug&&(console.log("chatServer: "+this.chatServer),console.log("userId: "+t),console.log("getBearerToken: "+this.getBearerToken())),e=this,r=this.chatServer.replace(/^https/,"wss"),n=r.replace(/(\/\/.*?)\//,"$1/ws/"),this.debug&&console.log("ws server: "+n),!this.nc||this.nc.isClose&&this.nc.isClose()?(o=e,[4,p.connect({url:n,user:t,pass:this.getBearerToken(),reconnect:!0})]):[3,2];case 1:o.nc=i.sent(),i.label=2;case 2:return this.chatUserExternalId=t,[2,e.nc]}})})},t.prototype.disconnect=function(){return u(this,void 0,void 0,function(){var t,e=this;return h(this,function(r){switch(r.label){case 0:if(this.interval)try{clearInterval(this.interval)}catch(t){}if(this.nc&&this.chatUserExternalId&&this.chatUserExternalId.length>0&&this.getBearerToken()&&this.getBearerToken().length>0&&this.setOffLine(this.chatUserExternalId).subscribe(function(){e.debug&&console.log("had set offline")}),!this.nc)return[3,5];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.nc.close()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.debug&&console.error(t),[3,4];case 4:this.nc=void 0,r.label=5;case 5:return this.debug&&console.log("disconect"),[2]}})})},t.prototype.processAndCallback=function(t,e){this.debug&&t&&console.log("Msg Received: "+JSON.stringify(t));var r=new Map;for(var n in t.data)r.set(n,t.data[n]);t.data.all=r,"msg"==t.data.type?e.onMessage(t):"on"==t.data.type||"off"==t.data.type?e.onOffline(t):"read"==t.data.type?e.onRead(t):"startTyping"==t.data.type||"stopTyping"==t.data.type?e.onStartStopTyping(t):"new_user"==t.data.type?e.onNewUser(t):"remove_user"==t.data.type?e.onRemoveUser(t):"chat_closed"==t.data.type?e.onChatClosed(t):"count_notread"==t.data.type&&e.onCountNotRead(t)},t.prototype.connectWebsocket=function(t,e){return u(this,void 0,void 0,function(){var r,n,o,i,s,a=this;return h(this,function(u){switch(u.label){case 0:return r=this,this.disconnect(),n=this.getBearerToken(),n&&n.startsWith("Bearer ")?n:"Bearer "+n,o=this.chatServer.split("/")[3],[4,this.ensureConn(e)];case 1:if(i=u.sent(),s="chat4app.config."+o+".user."+e,i.subscribe(s,function(e){a.debug&&console.log(e),a.processAndCallback(JSON.parse(e.data),t)}),this.interval)try{clearInterval(this.interval)}catch(t){}return r.interval=setInterval(function(){r.debug&&console.log("publish chat4app.user.online "+e+" "),r.nc.publish("chat4app.user.online",e)},1e3),this.debug&&console.log("Subscribe online chat4app.user."+e+".online"),[2]}})})},t.prototype.convertChat4AppMessageReceiveToChatMessage4App=function(t){var e,r,n=new m;(n.body=null===(e=null==t?void 0:t.notification)||void 0===e?void 0:e.body,n.chatId=t.data.chatId,n.fromId=t.data.fromId,n.toId=t.data.toId,n.groupId=t.data.groupId,n.replyFrom=t.data.replyFrom,t.data.dateHour&&t.data.dateHour.length>0&&(n.dateHourIncluded=t.data.dateHour.substring(6,10)+"-"+t.data.dateHour.substring(3,5)+"-"+t.data.dateHour.substring(0,2)+t.data.dateHour.substring(10)),n.id=t.data.chatMessageId,t.data.fileId&&t.data.fileId.length>0)&&((r=new I).id=t.data.fileId,r.name=t.data.fileName,r.size=t.data.fileSize,r.type=t.data.fileType,n.chatMessageFile=r);t.data.vFileId&&t.data.vFileId.length>0&&((r=new I).id=t.data.vFileId,r.name=t.data.vFileName,r.size=t.data.vFileSize,r.type=t.data.vFileType,n.chatVoiceFile=r);return n},t}();l.ɵprov=o.ɵɵdefineInjectable({factory:function(){return new l(o.ɵɵinject(i.HttpClient))},token:l,providedIn:"root"}),l.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],l.ctorParameters=function(){return[{type:r.HttpClient}]};var d,g,y,b=function(){},v=function(){},m=function(){},I=function(){},w=function(){},A=function(){this.data=new C,this.notification=new T},C=function(){},T=function(){},E=function(){},O=function(){},S=function(t,e){this.endpoint=t,this.debug=e},N=function(){},_=function(){};t.ChatStatus4App=void 0,(d=t.ChatStatus4App||(t.ChatStatus4App={})).CREATED="CREATED",d.CLOSED="CLOSED",t.ChatUserStatus4App=void 0,(t.ChatUserStatus4App||(t.ChatUserStatus4App={})).REMOVED="REMOVED",t.ChatFilterType=void 0,(g=t.ChatFilterType||(t.ChatFilterType={}))[g.COUNT_NOT_READ=1]="COUNT_NOT_READ",g[g.LAST_MESSAGE=2]="LAST_MESSAGE",t.GroupStatus4App=void 0,(y=t.GroupStatus4App||(t.GroupStatus4App={})).CREATED="CREATED",y.CLOSED="REMOVED";var U=function(){function t(){}return t.prototype.ngOnInit=function(){},t}();U.decorators=[{type:e.Component,args:[{selector:"lib-chat4app-client-angular",template:"\n <p>\n chat4app-client-angular works!\n </p>\n "}]}],U.ctorParameters=function(){return[]};var R=function(){};R.decorators=[{type:e.NgModule,args:[{declarations:[U],imports:[],exports:[U]}]}],t.Chat4App=b,t.Chat4AppConfig=S,t.Chat4AppMessageReceive=A,t.Chat4AppMessageReceiveData=C,t.Chat4AppMessageReceiveNotification=T,t.Chat4AppTranslate=N,t.Chat4appClientAngularComponent=U,t.Chat4appClientAngularModule=R,t.Chat4appClientAngularService=l,t.ChatFilterRequest4App=O,t.ChatGroupApp=_,t.ChatMessage4App=m,t.ChatMessageFile4App=I,t.ChatMessageMeta4App=w,t.ChatUser4App=v,t.ChatUserResponse4App=E,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
9
9
|
//# sourceMappingURL=chat4app-client-angular.umd.min.js.map
|