text: /**
   * Minified by jsDelivr using Terser v3.14.1.
   * Original file: /npm/@microsoft/signalr@3.0.0/dist/esm/WebSocketTransport.js
   * 
   * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
   */
  var __awaiter=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))(function(n,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){e.done?n(e.value):new o(function(t){t(e.value)}).then(i,a)}c((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var o,r,n,s,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;i;)try{if(o=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){i.label=s[1];break}if(6===s[0]&&i.label<n[1]){i.label=n[1],n=s;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(s);break}n[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{o=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};import{LogLevel}from"./ILogger";import{TransferFormat}from"./ITransport";import{Arg,getDataDetail,Platform}from"./Utils";var WebSocketTransport=function(){function e(e,t,o,r,n){this.logger=o,this.accessTokenFactory=t,this.logMessageContent=r,this.webSocketConstructor=n,this.httpClient=e,this.onreceive=null,this.onclose=null}return e.prototype.connect=function(e,t){return __awaiter(this,void 0,void 0,function(){var o,r=this;return __generator(this,function(n){switch(n.label){case 0:return Arg.isRequired(e,"url"),Arg.isRequired(t,"transferFormat"),Arg.isIn(t,TransferFormat,"transferFormat"),this.logger.log(LogLevel.Trace,"(WebSockets transport) Connecting."),this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(o=n.sent())&&(e+=(e.indexOf("?")<0?"?":"&")+"access_token="+encodeURIComponent(o)),n.label=2;case 2:return[2,new Promise(function(o,n){var s;e=e.replace(/^http/,"ws");var i=r.httpClient.getCookieString(e);Platform.isNode&&i&&(s=new r.webSocketConstructor(e,void 0,{headers:{Cookie:""+i}})),s||(s=new r.webSocketConstructor(e)),t===TransferFormat.Binary&&(s.binaryType="arraybuffer"),s.onopen=function(t){r.logger.log(LogLevel.Information,"WebSocket connected to "+e+"."),r.webSocket=s,o()},s.onerror=function(e){var t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:new Error("There was an error with the transport."),n(t)},s.onmessage=function(e){r.logger.log(LogLevel.Trace,"(WebSockets transport) data received. "+getDataDetail(e.data,r.logMessageContent)+"."),r.onreceive&&r.onreceive(e.data)},s.onclose=function(e){return r.close(e)}})]}})})},e.prototype.send=function(e){return this.webSocket&&this.webSocket.readyState===this.webSocketConstructor.OPEN?(this.logger.log(LogLevel.Trace,"(WebSockets transport) sending data. "+getDataDetail(e,this.logMessageContent)+"."),this.webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")},e.prototype.stop=function(){return this.webSocket&&(this.webSocket.onclose=function(){},this.webSocket.onmessage=function(){},this.webSocket.onerror=function(){},this.webSocket.close(),this.webSocket=void 0,this.close(void 0)),Promise.resolve()},e.prototype.close=function(e){this.logger.log(LogLevel.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!e||!1!==e.wasClean&&1e3===e.code?this.onclose():this.onclose(new Error("WebSocket closed with status code: "+e.code+" ("+e.reason+").")))},e}();export{WebSocketTransport};
  //# sourceMappingURL=/sm/b7e5032b37b6b146fed97dbe63a6f0c71f777195b214d71b910ad3d41d40f2ec.map