(window["webpackJsonp-sports-asi"]=window["webpackJsonp-sports-asi"]||[]).push([["chunk-2d0ceb93"],{6157:function(e,t,n){"use strict";n.r(t);var a=n("c964"),r=n("276c"),i=n("e954"),s=(n("96cf"),n("d3b7"),n("0438")),o="[SessionManager]",c=function(){var e,t;function n(){Object(r["a"])(this,n),this.playersiteJwtTimer=null,this.heartbeatTimer=null,this.PLAYERSITE_JWT_RENEWAL_INTERVAL=18e5,this.isRenewingJwt=!1}return Object(i["a"])(n,[{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.autoRenew,n=void 0===t||t;this.stop(),n&&this._startPlayersiteJwtRenewal(),this._startHeartbeat()}},{key:"stop",value:function(){this.playersiteJwtTimer&&clearInterval(this.playersiteJwtTimer),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.playersiteJwtTimer=null,this.heartbeatTimer=null,this.isRenewingJwt=!1}},{key:"_startHeartbeat",value:function(){var e=this;this.heartbeatTimer=setInterval((function(){e._sendHeartbeat().catch((function(){}))}),6e4)}},{key:"_sendHeartbeat",value:function(){return(e=e||Object(a["a"])(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(e.prev=0,t=Object(s["i"])(),n=window.sessionStorage.getItem("sjwt"),t&&n){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,fetch("".concat(t,"/api/auth/heartbeat"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}});case 7:e.next=12;break;case 9:e.prev=9,e.t0=e["catch"](0),console.warn("".concat(o," Heartbeat failed:"),e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})))).apply(this,arguments)}},{key:"_startPlayersiteJwtRenewal",value:function(){var e=this;this.playersiteJwtTimer=setInterval((function(){e._renewPlayersiteJwt().catch((function(){}))}),this.PLAYERSITE_JWT_RENEWAL_INTERVAL)}},{key:"_renewPlayersiteJwt",value:function(){return(t=t||Object(a["a"])(regeneratorRuntime.mark((function e(){var t,n,a,r,i,c;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!this.isRenewingJwt){e.next=3;break}return console.warn("".concat(o," JWT renewal already in progress, skipping")),e.abrupt("return");case 3:if(this.isRenewingJwt=!0,e.prev=4,t=Object(s["i"])(),n=window.sessionStorage.getItem("sjwt"),t&&n){e.next=9;break}return e.abrupt("return");case 9:return console.log("".concat(o," Renewing Playersite JWT...")),e.next=12,fetch("".concat(t,"/api/auth/renew"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}});case 12:if(a=e.sent,!a.ok){e.next=21;break}return e.next=16,a.json();case 16:i=e.sent,c=null===i||void 0===i||null===(r=i.result)||void 0===r?void 0:r.sessionId,c&&(window.sessionStorage.setItem("sjwt",c),console.log("".concat(o," JWT renewal completed"))),e.next=22;break;case 21:console.warn("".concat(o," JWT renewal failed with status:"),a.status);case 22:e.next=27;break;case 24:e.prev=24,e.t0=e["catch"](4),console.warn("".concat(o," Playersite JWT renewal failed:"),e.t0);case 27:return e.prev=27,this.isRenewingJwt=!1,e.finish(27);case 30:case"end":return e.stop()}}),e,this,[[4,24,27,30]])})))).apply(this,arguments)}},{key:"getStatus",value:function(){return{timers:{jwtRenewal:null!==this.playersiteJwtTimer,heartbeat:null!==this.heartbeatTimer},flags:{isRenewingJwt:this.isRenewingJwt},intervals:{jwtRenewalMs:this.PLAYERSITE_JWT_RENEWAL_INTERVAL}}}}]),n}(),l=new c;"undefined"!==typeof window&&(window.sessionManager=l),t["default"]=l}}]); //# sourceMappingURL=chunk-2d0ceb93.c66eff7f.js.map