UNPKG

@stormstreaming/stormstreamer

Version:

A JavaScript library containing core webrtc streamer functionality for embedding live-video streams on a website. Part of StormStreaming Suite.

34 lines 129 kB
/* * StormStreaming JavaScript Streamer * Copyright © 2021-2025 Web-Anatomy s.c. All rights reserved. * contact@stormstreaming.com * https://stormstreaming.com * * Version: 1.0.8 * Version: 2/24/2026, 4:44:50 PM * * LEGAL NOTICE: * This software is subject to the terms and conditions defined in * separate license conditions ('LICENSE.txt') * */var stormStreamer=function(){"use strict";function a(e,o,a,h){return new(a=a||Promise)(function(i,t){function s(e){try{r(h.next(e))}catch(e){t(e)}}function n(e){try{r(h.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?i(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(s,n)}r((h=h.apply(e,o||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(e,t,i=443,s=!0){this.host=e,this.application=t,this.port=i,this.isSSL=s,this.hasFaild=!1}getHost(){return this.host}getApplication(){return this.application}getPort(){return this.port}getIfSSL(){return this.isSSL}getIfFaild(){return this.hasFaild}setAsFaild(e){this.hasFaild=e}getData(){return{serverURL:this.getHost(),application:this.getHost(),serverPort:this.getPort(),isSSL:this.getIfSSL()}}toString(){return"host: "+this.host+" | application: "+this.application+" | port: "+this.port+" | isSSL: "+this.isSSL}}class o{constructor(e){this._serverList=new Array,this._sourceList=new Array,this._streamKey=null,this.parse(e)}parse(e){if(this._streamConfig=e,!this._streamConfig)throw new Error("Stream configuration is missing. Please check stream config!");if(void 0===this._streamConfig.serverList||null===this._streamConfig.serverList)throw new Error("StormLibrary: Server list configuration is missing. Please check the config!");if(0===this._streamConfig.serverList.length)throw new Error("StormLibrary: Server list configuration is empty. Please check the config!");for(let i=0;i<this._streamConfig.serverList.length;i++){let e,t;if(null==this._streamConfig.serverList[i].host)throw new Error('Error while parsing server object ("host" field is missing). Please check player config!');if(e=this._streamConfig.serverList[i].host,null==this._streamConfig.serverList[i].application)throw new Error('Error while parsing server object ("application" field is missing). Please check player config!');t=this._streamConfig.serverList[i].application;var s=null!=(s=this._streamConfig.serverList[i].port)?s:o.DEFAULT_CONNECTION_PORT,n=null!=(n=this._streamConfig.serverList[i].ssl)?n:o.IS_SSL_BY_DEFAULT;this._serverList.push(new r(e,t,s,n))}this._streamKey=null!=(e=this._streamConfig.streamKey)?e:this._streamKey}getServerList(){return this._serverList}getSourceList(){return this._sourceList}get streamKey(){return this._streamKey}set streamKey(e){this._streamKey=e}set serverList(e){this._serverList=e}set sourceList(e){this._sourceList=e}clearSourceList(){this._sourceList=new Array}clearServerList(){this._serverList=new Array}print(t,e=!1){if(o.PRINT_ON_STARTUP||e){t.info(this,"Server List:");for(let e=0;e<this._serverList.length;e++)t.info(this,"=> ["+e+"] "+this._serverList[e].toString());t.info(this,"StreamKey: "+this._streamKey)}}}var n,i,s;o.PRINT_ON_STARTUP=!0,o.DEFAULT_CONNECTION_PORT=443,o.IS_SSL_BY_DEFAULT=!0,(v=n=n||{}).FILL="fill",v.LETTER_BOX="letterbox",v.CROP="crop",v.ORIGINAL="original",(v=i=i||{}).CLIENT_DIMENSIONS="clientDimensions",v.BOUNDING_BOX="boundingBox",v.FULL_BOX="fullBox";class t{constructor(e){this._scalingMode=n.LETTER_BOX,this._aspectRatio="none",this._videoWidthValue=100,this._isVideoWidthInPixels=!1,this._wasVideoWidthProvided=!1,this._videoHeightValue=100,this._isVideoHeightInPixels=!1,this._wasVideoHeightProvided=!1,this._resizeDebounce=250,this._parentSizeCalculationMethod=i.CLIENT_DIMENSIONS,this.parse(e)}parse(e){if(this.videoConfig=e,null==this.videoConfig)throw new Error("Missing video configuration. Please check player config!");if(null!=this.videoConfig.aspectRatio){var e=new RegExp("^[0-9]*\\.?[0-9]+:[0-9]*\\.?[0-9]+$"),t=this.videoConfig.aspectRatio;if(!e.test(t))throw new Error('Parameter "aspectRatio" - must match "number:number" pattern ');this._aspectRatio=t,this._aspectRatio=this.videoConfig.aspectRatio}if(null!=this.videoConfig.scalingMode)switch(this.videoConfig.scalingMode.toLowerCase()){case"fill":this._scalingMode=n.FILL;break;case"letterbox":this._scalingMode=n.LETTER_BOX;break;case"crop":this._scalingMode=n.CROP;break;case"original":this._scalingMode=n.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}if(void 0!==this.videoConfig.width){if(null===this.videoConfig.width)throw new Error('Parameter "width" cannot be empty');if("number"==typeof this.videoConfig.width)this._videoWidthValue=this.videoConfig.width,this._isVideoWidthInPixels=!0;else{if("string"!=typeof this.videoConfig.width)throw new Error('Unknown type for parameter "width" - it must be a number or a string! ');this.videoConfig.width.toLowerCase().endsWith("px")?(this._videoWidthValue=parseInt(this.videoConfig.width),this._isVideoWidthInPixels=!0):this.videoConfig.width.toLowerCase().endsWith("%")&&(this._videoWidthValue=parseInt(this.videoConfig.width),this._isVideoWidthInPixels=!1)}this._wasVideoWidthProvided=!0}if(void 0!==this.videoConfig.height){if(null===this.videoConfig.height)throw new Error('Parameter "height" cannot be empty');if("number"==typeof this.videoConfig.height)this._videoHeightValue=this.videoConfig.height,this._isVideoHeightInPixels=!0;else{if("string"!=typeof this.videoConfig.height)throw new Error('Unknown type for parameter "height" - it must be a number or a string!');this.videoConfig.height.toLowerCase().endsWith("px")?(this._videoHeightValue=parseInt(this.videoConfig.height),this._isVideoHeightInPixels=!0):this.videoConfig.height.toLowerCase().endsWith("%")&&(this._videoHeightValue=parseInt(this.videoConfig.height),this._isVideoHeightInPixels=!1)}this._wasVideoHeightProvided=!0}if(void 0!==this.videoConfig.sizeCalculationMethod&&null!==this.videoConfig.sizeCalculationMethod)switch(this.videoConfig.sizeCalculationMethod){case"clientDimensions":this._parentSizeCalculationMethod=i.CLIENT_DIMENSIONS;break;case"boundingBox":this._parentSizeCalculationMethod=i.BOUNDING_BOX;break;case"fullBox":this._parentSizeCalculationMethod=i.FULL_BOX}this._containerID=null!=(e=this.videoConfig.containerID)?e:null,this._resizeDebounce=null!=(t=this.videoConfig.resizeDebounce)?t:this._resizeDebounce}get scalingMode(){return this._scalingMode}get containerID(){return this._containerID}get videoWidthValue(){return this._videoWidthValue}get videoWidthInPixels(){return this._isVideoWidthInPixels}get videoWidthProvided(){return this._wasVideoWidthProvided}get videoHeightValue(){return this._videoHeightValue}get videoHeightInPixels(){return this._isVideoHeightInPixels}get videoHeightProvided(){return this._wasVideoHeightProvided}get aspectRatio(){return this._aspectRatio}get resizeDebounce(){return this._resizeDebounce}set resizeDebounce(e){this._resizeDebounce=e}set videoWidthValue(e){this._videoWidthValue=e}set videoWidthInPixels(e){this._isVideoWidthInPixels=e}set videoHeightValue(e){this._videoHeightValue=e}set videoHeightInPixels(e){this._isVideoHeightInPixels=e}set containerID(e){this._containerID=e}set scalingMode(e){switch(e.toLowerCase()){case"fill":this._scalingMode=n.FILL;break;case"letterbox":this._scalingMode=n.LETTER_BOX;break;case"crop":this._scalingMode=n.CROP;break;case"original":this._scalingMode=n.ORIGINAL;break;default:throw new Error("Unknown video scaling mode. Please check player config!")}}get parentSizeCalculationMethod(){return this._parentSizeCalculationMethod}print(e){let t="";switch(this._scalingMode){case n.FILL:t="fill";break;case n.LETTER_BOX:t="letterbox";break;case n.CROP:t="crop";break;case n.ORIGINAL:t="original"}e.info(this,"VideoConfig :: containerID: "+this._containerID),e.info(this,"VideoConfig :: scalingMode: "+t),e.info(this,"VideoConfig :: width: "+this._videoWidthValue+(this._isVideoWidthInPixels?"px":"%")+(this._wasVideoWidthProvided?" (provided)":" (default)")),e.info(this,"VideoConfig :: height: "+this._videoHeightValue+(this._isVideoHeightInPixels?"px":"%")+(this._wasVideoHeightProvided?" (provided)":" (default)")),e.info(this,"VideoConfig :: aspectRatio: "+this._aspectRatio)}}(v=s=s||{})[v.TRACE=0]="TRACE",v[v.INFO=1]="INFO",v[v.SUCCESS=2]="SUCCESS",v[v.WARNING=3]="WARNING",v[v.ERROR=4]="ERROR";class h{constructor(e){this._consoleLogEnabled=!1,this._enabledConsoleTypes=[s.INFO,s.ERROR,s.SUCCESS,s.TRACE,s.WARNING],this._consoleMonoColor=!1,this._containerLogEnabled=!1,this._enabledContainerTypes=[s.INFO,s.ERROR,s.SUCCESS,s.TRACE,s.WARNING],this._containerLogMonoColor=!1,this._stageController=!0,this._streamerController=!0,this.parse(e)}parse(e){this._debugConfig=e,this._debugConfig&&(this._consoleLogEnabled=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.enabled)?e:this._consoleLogEnabled,this._consoleMonoColor=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.monoColor)?e:this._consoleMonoColor,this._enabledConsoleTypes=null!=(e=this.parseLogTypes(null==(e=null==(e=this._debugConfig)?void 0:e.console)?void 0:e.logTypes))?e:this._enabledConsoleTypes,this._containerLogEnabled=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.enabled)?e:this._containerLogEnabled,this._containerLogMonoColor=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.monoColor)?e:this._containerLogMonoColor,this._enabledContainerTypes=null!=(e=this.parseLogTypes(null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.logTypes))?e:this._enabledContainerTypes,this._containerID=null!=(e=null==(e=null==(e=this._debugConfig)?void 0:e.container)?void 0:e.containerID)?e:this._containerID,this._streamerController=null!=(e=null==(e=this._debugConfig)?void 0:e.streamerController)?e:this._streamerController,this._stageController=null!=(e=null==(e=this._debugConfig)?void 0:e.stageController)?e:this._stageController)}parseLogTypes(e){return null==e?void 0:e.map(e=>{switch(e.toLowerCase()){case"info":return s.INFO;case"error":return s.ERROR;case"warning":return s.WARNING;case"success":return s.SUCCESS;case"trace":return s.TRACE;default:throw new Error("Unsupported log type: "+e)}})}get consoleLogEnabled(){return this._consoleLogEnabled}set consoleLogEnabled(e){this._consoleLogEnabled=e}get enabledConsoleTypes(){return this._enabledConsoleTypes}set enabledConsoleTypes(t){this._enabledConsoleTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this._enabledConsoleTypes.push(s.INFO);break;case"error":this._enabledConsoleTypes.push(s.ERROR);break;case"warning":this._enabledConsoleTypes.push(s.WARNING);break;case"success":this._enabledConsoleTypes.push(s.SUCCESS);break;case"trace":this._enabledConsoleTypes.push(s.TRACE)}}get containerLogEnabled(){return this._containerLogEnabled}set containerLogEnabled(e){this._consoleLogEnabled=e}get consoleLogMonoColor(){return this._consoleMonoColor}set consoleLogMonoColor(e){this._consoleMonoColor=e}get enabledContainerTypes(){return this._enabledContainerTypes}set enabledContainerTypes(t){this._enabledContainerTypes=new Array;for(let e=0;e<t.length;e++)switch(t[e].toLowerCase()){case"info":this._enabledContainerTypes.push(s.INFO);break;case"error":this._enabledContainerTypes.push(s.ERROR);break;case"warning":this._enabledContainerTypes.push(s.WARNING);break;case"success":this._enabledContainerTypes.push(s.SUCCESS);break;case"trace":this._enabledContainerTypes.push(s.TRACE)}}get containerID(){return this._containerID}set containerID(e){this._containerID=e}get containerLogMonoColor(){return this._containerLogMonoColor}set containerLogMonoColor(e){this._containerLogMonoColor=e}get stageControllerDebug(){return this._stageController}get streamerControllerDebug(){return this._streamerController}print(e,t=!1){if(h.PRINT_ON_STARTUP||t){let t="";for(let e=0;e<this._enabledConsoleTypes.length;e++)switch(this._enabledConsoleTypes[e]){case s.TRACE:t+="TRACE, ";break;case s.SUCCESS:t+="SUCCESS, ";break;case s.WARNING:t+="WARNING, ";break;case s.INFO:t+="INFO, ";break;case s.ERROR:t+="ERROR, "}e.info(this,"Console:: enabled: "+this._consoleLogEnabled),e.info(this,"Console:: logTypes: "+t),e.info(this,"Console:: monoColor: "+this._consoleMonoColor);let i="";for(let e=0;e<this._enabledContainerTypes.length;e++)switch(this._enabledContainerTypes[e]){case s.TRACE:i+="TRACE, ";break;case s.SUCCESS:i+="SUCCESS, ";break;case s.WARNING:i+="WARNING, ";break;case s.INFO:i+="INFO, ";break;case s.ERROR:i+="ERROR, "}e.info(this,"Container:: enabled: "+this._containerLogEnabled),e.info(this,"Container:: logTypes: "+i),e.info(this,"Container:: containerID: "+this._containerID),e.info(this,"Container:: monoColor: "+this._consoleMonoColor)}}}h.PRINT_ON_STARTUP=!0;class l{constructor(e){this._startVolume=100,this._isMuted=!1,this.parse(e)}parse(e){this._audioConfig=e,this._audioConfig&&(this._startVolume=null!=(e=null==(e=this._audioConfig)?void 0:e.startVolume)?e:this._startVolume,this._isMuted=null!=(e=null==(e=this._audioConfig)?void 0:e.muted)?e:this._isMuted)}get startVolume(){return this._startVolume}set startVolume(e){this._startVolume=e}get muted(){return this._isMuted}set muted(e){this._isMuted=e}print(e,t=!1){(l.PRINT_ON_STARTUP||t)&&e.info(this,"Audio :: startVolume: "+this._startVolume+" | isMuted: "+this._isMuted)}}l.PRINT_ON_STARTUP=!0;class d{constructor(e){this._enabled=!0,this._prefix="storm",this.parse(e)}parse(e){this._storageConfig=e,this._enabled=null!=(e=null==(e=this._storageConfig)?void 0:e.enabled)?e:this._enabled,this._prefix=null!=(e=null==(e=this._storageConfig)?void 0:e.prefix)?e:this._prefix}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get prefix(){return this._prefix}set prefix(e){this._prefix=e}print(e,t=!1){(d.PRINT_ON_STARTUP||t)&&e.info(this,"Storage :: startVolume: "+this._enabled+" | prefix: "+this._prefix)}}d.PRINT_ON_STARTUP=!0;class c{constructor(e){this._restartOnError=!0,this._reconnectTime=1,this._autoStart=!1,this._autoConnect=!0,this.startOnDOMReady=!1,this.iOSOnDomReadyFix=!0,this._restartOnFocus=!0,this._preselectDevices=!0,this._cancelPublishOnError=!0,this.parse(e)}parse(e){this._settingsConfig=e,this._autoConnect=null!=(e=this._settingsConfig.autoConnect)?e:this._autoConnect,this._autoStart=null!=(e=this._settingsConfig.autoStart)?e:this._autoStart,this._restartOnFocus=null!=(e=this._settingsConfig.restartOnFocus)?e:this._restartOnFocus,this._restartOnError=null!=(e=this._settingsConfig.restartOnError)?e:this._restartOnError,this._reconnectTime=null!=(e=this._settingsConfig.reconnectTime)?e:this._reconnectTime,this._preselectDevices=null!=(e=this._settingsConfig.preselectDevices)?e:this._preselectDevices,this._cancelPublishOnError=null!=(e=this._settingsConfig.cancelPublishOnError)?e:this._cancelPublishOnError,this._videoData=new t(null!=(e=this._settingsConfig.video)?e:null),this._audioData=new l(null!=(e=this._settingsConfig.audio)?e:null),this._storageData=new d(null!=(e=this._settingsConfig.storage)?e:null),this._debugData=new h(null!=(e=this._settingsConfig.debug)?e:null)}getAudioData(){return this._audioData}getVideoData(){return this._videoData}getStorageData(){return this._storageData}getIfRestartOnError(){return this._restartOnError}getReconnectTime(){return this._reconnectTime}get autoStart(){return this._autoStart}set autoStart(e){this._autoStart=e}get autoConnect(){return this._autoConnect}get restartOnFocus(){return this._restartOnFocus}getDebugData(){return this._debugData}getIfForceSelection(){return this._preselectDevices}getIfCancelPublishOnError(){return this._cancelPublishOnError}getIfStartOnDOMReadyEnabled(){return this.startOnDOMReady}getIfIOSOnDomStartFixEnabled(){return this.iOSOnDomReadyFix}print(e,t=!1){(c.PRINT_ON_STARTUP||t)&&(e.info(this,"SettingsConfig :: autoConnect: "+this._autoConnect),e.info(this,"SettingsConfig :: autoStart: "+this._autoStart),e.info(this,"SettingsConfig :: restartOnError: "+this._restartOnError),e.info(this,"SettingsConfig :: reconnectTime: "+this._reconnectTime),e.info(this,"SettingsConfig :: enabledProtocols: "),this._videoData.print(e),this._audioData.print(e),this._debugData.print(e),this._debugData.print(e))}}c.PRINT_ON_STARTUP=!0;class g{constructor(e){this.PRINT_ON_STARTUP=!0,this.demoMode=!1,this.parse(e)}parse(e){if(this.configTemplate=e,null==this.configTemplate.stream)throw new Error("No stream field was provided. Please check your player config!");this.streamData=new o(this.configTemplate.stream),this.settingsData=new c(null!=(e=this.configTemplate.settings)?e:null),this.demoMode=null!=(e=this.configTemplate.demoMode)&&e}getStreamData(){return this.streamData}getSettingsData(){return this.settingsData}getIfDemoMode(){return this.demoMode}print(e,t=!1){(this.PRINT_ON_STARTUP||t)&&(this.streamData.print(e),this.settingsData.print(e))}}class _{static addLeadingZero(e){return e<10?"0"+e:String(e)}static isNear(e,t,i){return Math.abs(e-t)<=i}static generateUniqueString(t){let i="";var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=s.length;for(let e=0;e<t;e++)i+=s.charAt(Math.floor(Math.random()*n));return i}}_.parseValue=e=>{var t;return"string"==typeof e?(t=e.toLowerCase().endsWith("px"),{value:parseInt(e,10),isPixels:t}):{value:e,isPixels:!0}};class u{constructor(e,t){this.colorOrder=["red","green","blue","orange","black","violet"],this._logMemory=[],this._streamerInstanceID=-1,this._debugConfig=e,this._stormStreamer=t,this._streamerInstanceID=this._stormStreamer.getStreamerID();e=this.colorOrder.length<t.getStreamerID()?this.colorOrder.length-1:t.getStreamerID();this._monoColor=this.colorOrder[e]}info(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(s.INFO)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:u.INFO_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(s.INFO)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:u.INFO_COLOR,this.writeToContainer(e,t))}warning(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(s.WARNING)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:u.WARNING_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(s.WARNING)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:u.WARNING_COLOR,this.writeToContainer(e,t))}decoratedLog(e,t){var i=["0️⃣","1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣","8️⃣","9️⃣","🔟"],s=this._stormStreamer.getStreamerID(),t={"dark-blue":"#4c9fee","dark-green":"#4bcb64","dark-orange":"#daa33a","dark-red":"#f86464","dark-pink":"#f864e8","dark-yellow":"#e1f864"}[t];t&&console.log(`%c 🎦️${0<=s&&s<i.length?i[s]:`[${s}]`} `+e,`background: black; color: ${t}; border: 1px solid ${t}; padding: 5px 5px 5px 0px`)}error(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(s.ERROR)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:u.ERROR_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(s.ERROR)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:u.ERROR_COLOR,this.writeToContainer(e,t))}success(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(s.SUCCESS)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:u.SUCCESS_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(s.SUCCESS)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:u.SUCCESS_COLOR,this.writeToContainer(e,t))}trace(e,t){e=this.logData(e,t);this._debugConfig.consoleLogEnabled&&0<=this._debugConfig.enabledConsoleTypes.indexOf(s.TRACE)&&(t=this._debugConfig.consoleLogMonoColor?this._monoColor:u.TRACE_COLOR,console.log("%c "+e,"color: "+t)),this._debugConfig.containerLogEnabled&&0<=this._debugConfig.enabledContainerTypes.indexOf(s.TRACE)&&(t=this._debugConfig.containerLogMonoColor?this._monoColor:u.TRACE_COLOR,this.writeToContainer(e,t))}logData(e,t){var i=new Date,s=_.addLeadingZero(i.getHours()),n=_.addLeadingZero(i.getMinutes()),i=_.addLeadingZero(i.getSeconds());let r=String(this._streamerInstanceID);0<=this._streamerInstanceID&&(r+="|"+this._streamerInstanceID);s="[Storm-ID:"+r+"] ["+s+":"+n+":"+i+"] :: "+t;return this._logMemory.push(s),s}writeToContainer(e,t){var i,s=this._debugConfig.containerID;s&&(s=document.getElementById(s),(i=document.createElement("span")).innerText=e,i.style.color=t,s.appendChild(i))}setPlayerID(e){this._streamerInstanceID=e}getAllLogs(){return this._logMemory}}u.INFO_COLOR="blue",u.WARNING_COLOR="orange",u.ERROR_COLOR="red",u.SUCCESS_COLOR="green",u.TRACE_COLOR="black";class m{static hasWebSocketsSupport(){return null!=window.WebSocket}static isMobile(){return new RegExp("Mobile|mini|Fennec|Android|iP(ad|od|hone)").test(navigator.userAgent)}static isCookieEnabled(){let e=!!navigator.cookieEnabled;return"undefined"!=typeof navigator.cookieEnabled||e||(document.cookie="testcookie",e=-1!=document.cookie.indexOf("testcookie")),e}static getOSVersion(){let e="Unknown version",t=m.getOS();if(null!=t){var i;switch(new RegExp("Windows").test(t)&&(i=new RegExp("Windows (.*)"),e=null!=i.exec(t)[1]?i.exec(t)[1]:e,t="Windows"),t){case"Mac OS":case"Mac OS X":case"Android":var s=new RegExp("(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\\.\\_\\d]+)");e=s.exec(navigator.userAgent)[1];break;case"iOS":s=new RegExp("OS (\\d+)_(\\d+)_?(\\d+)?");e=(e=s.exec(navigator.userAgent))[1]+"."+e[2]+"."+(0|e[3])}}return e}static getBrowserName(){return m.getFullBrowser().name}static getBrowserVersion(){return m.getFullBrowser().version}static getFullBrowser(){var e=navigator.userAgent;let t=navigator.appName,i=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10),n,r,o;return-1!=(r=e.indexOf("Opera"))?(t="Opera",i=e.substring(r+6),-1!=(r=e.indexOf("Version"))&&(i=e.substring(r+8))):-1!=(r=e.indexOf("MSIE"))?(t="Microsoft Internet Explorer",i=e.substring(r+5)):"Netscape"==t&&-1!=e.indexOf("Trident/")?(t="Microsoft Internet Explorer",i=e.substring(r+5),-1!=(r=e.indexOf("rv:"))&&(i=e.substring(r+3))):-1!=(r=e.indexOf("Chrome"))?(t="Chrome",(-1<e.indexOf("FBAV")||-1<e.indexOf("FBAN"))&&(t="Facebook"),-1<e.indexOf("OPR")&&(t="Opera"),-1<e.indexOf("SamsungBrowser")&&(t="Samsung"),i=e.substring(r+7)):-1!=(r=e.indexOf("Safari"))?(t="Safari",i=e.substring(r+7),-1!=(r=e.indexOf("Version"))&&(i=e.substring(r+8)),-1!=e.indexOf("CriOS")&&(t="Chrome"),-1!=e.indexOf("FxiOS")&&(t="Firefox")):-1!=(r=e.indexOf("Firefox"))?(t="Firefox",i=e.substring(r+8)):(n=e.lastIndexOf(" ")+1)<(r=e.lastIndexOf("/"))&&(t=e.substring(n,r),i=e.substring(r+1),t.toLowerCase()==t.toUpperCase())&&(t=navigator.appName),-1!=(o=(i=-1!=(o=(i=-1!=(o=i.indexOf(";"))?i.substring(0,o):i).indexOf(" "))?i.substring(0,o):i).indexOf(")"))&&(i=i.substring(0,o)),s=parseInt(""+i,10),isNaN(s)&&(i=""+parseFloat(navigator.appVersion),s=parseInt(navigator.appVersion,10)),{name:t,fullVersion:i,version:s}}static getOS(){let e="Unknown OS";var t,i=[{os:"Windows 10",code:"(Windows 10.0|Windows NT 10.0)"},{os:"Windows 8.1",code:"(Windows 8.1|Windows NT 6.3)"},{os:"Windows 8",code:"(Windows 8|Windows NT 6.2)"},{os:"Windows 7",code:"(Windows 7|Windows NT 6.1)"},{os:"Windows Vista",code:"Windows NT 6.0"},{os:"Windows Server 2003",code:"Windows NT 5.2"},{os:"Windows XP",code:"(Windows NT 5.1|Windows XP)"},{os:"Windows 2000",code:"(Windows NT 5.0|Windows 2000)"},{os:"Windows ME",code:"(Win 9x 4.90|Windows ME)"},{os:"Windows 98",code:"(Windows 98|Win98)"},{os:"Windows 95",code:"(Windows 95|Win95|Windows_95)"},{os:"Windows NT 4.0",code:"(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)"},{os:"Windows CE",code:"Windows CE"},{os:"Windows 3.11",code:"Win16"},{os:"Android",code:"Android"},{os:"Open BSD",code:"OpenBSD"},{os:"Sun OS",code:"SunOS"},{os:"Chrome OS",code:"CrOS"},{os:"Linux",code:"(Linux|X11(?!.*CrOS))"},{os:"iOS",code:"(iPhone|iPad|iPod)"},{os:"Mac OS X",code:"Mac OS X"},{os:"Mac OS",code:"(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)"},{os:"QNX",code:"QNX"},{os:"UNIX",code:"UNIX"},{os:"BeOS",code:"BeOS"},{os:"OS/2",code:"OS\\/2"},{os:"Search Bot",code:"(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\\/Teoma|ia_archiver)"}];for(t in i){var s=i[t];if(new RegExp(s.code).test(navigator.userAgent)){e=s.os;break}}return e}static hasWebRTCSupport(){let t=!1;try{navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||window.RTCPeerConnection;t=!0}catch(e){t=!1}return t}static hasHLSSupport(e){return null!==e&&Boolean(e.canPlayType("application/vnd.apple.mpegURL")||e.canPlayType("audio/mpegurl"))}static hasMSESupport(){var e=window.MediaSource=window.MediaSource||window.WebKitMediaSource;return window.SourceBuffer=window.SourceBuffer||window.WebKitSourceBuffer,e&&"function"==typeof e.isTypeSupported}static hasMMSSupport(){return window.ManagedMediaSource}static isSSL(){return"https:"===location.protocol}}class e{constructor(e){var t;this.LOG_ACTIVITY=!1,this.isEnabled=!0,this.prefix="",this.logger=e.getLogger(),this.isEnabled=null!=(t=null==(t=null==(t=e.getConfigManager())?void 0:t.getSettingsData())?void 0:t.getStorageData().enabled)?t:this.isEnabled,this.prefix=null!=(t=null==(e=null==(t=e.getConfigManager())?void 0:t.getSettingsData())?void 0:e.getStorageData().prefix)?t:this.prefix,this.LOG_ACTIVITY&&this.logger.info(this,"Creating new StorageManager")}saveField(e,t){1==this.isEnabled&&(this.LOG_ACTIVITY&&this.logger.info(this,"Saving data: "+e+" | "+t),localStorage.setItem(this.prefix+e,t))}removeField(e){this.isEnabled&&(this.LOG_ACTIVITY&&this.logger.info(this,"Removing data: "+e),localStorage.removeItem(this.prefix+e))}getField(e){var t;return 1==this.isEnabled?(t=localStorage.getItem(this.prefix+e),this.LOG_ACTIVITY&&this.logger.info(this,"Grabbing data: "+e+" | "+t),t):null}}var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function C(){return H.Date.now()}var f=NaN,S="[object Symbol]",W=/^\s+|\s+$/g,x=/^[-+]0x[0-9a-f]+$/i,V=/^0b[01]+$/i,F=/^0o[0-7]+$/i,U=parseInt,v="object"==typeof v&&v&&v.Object===Object&&v,E="object"==typeof self&&self&&self.Object===Object&&self,H=v||E||Function("return this")(),B=Object.prototype.toString,z=Math.max,$=Math.min;function b(e){var t=typeof e;return e&&("object"==t||"function"==t)}function D(e){if("number"==typeof e)return e;if("symbol"==typeof(i=e)||!!(t=i)&&"object"==typeof t&&B.call(i)==S)return f;var t;if("string"!=typeof(e=b(e)?b(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(W,"");var i=V.test(e);return i||F.test(e)?U(e.slice(2),i?2:8):x.test(e)?f:+e}var I,y,T,w,L,G=p(function(s,i,e){var n,r,o,a,h,l,d=0,c=!1,g=!1,t=!0;if("function"!=typeof s)throw new TypeError("Expected a function");function _(e){var t=n,i=r;return n=r=void 0,d=e,a=s.apply(i,t)}function u(e){var t=e-l;return void 0===l||i<=t||t<0||g&&o<=e-d}function m(){var e,t=C();if(u(t))return v(t);h=setTimeout(m,(e=i-((t=t)-l),g?$(e,o-(t-d)):e))}function v(e){return h=void 0,t&&n?_(e):(n=r=void 0,a)}function p(){var e=C(),t=u(e);if(n=arguments,r=this,l=e,t){if(void 0===h)return d=e=l,h=setTimeout(m,i),c?_(e):a;if(g)return h=setTimeout(m,i),_(l)}return void 0===h&&(h=setTimeout(m,i)),a}return i=D(i)||0,b(e)&&(c=!!e.leading,g="maxWait"in e,o=g?z(D(e.maxWait)||0,i):o,t="trailing"in e?!!e.trailing:t),p.cancel=function(){void 0!==h&&clearTimeout(h),n=l=r=h=void(d=0)},p.flush=function(){return void 0===h?a:v(C())},p});class K{constructor(e){this.LOG_ACTIVITY=!0,this._volume=100,this._isMuted=!1,this._isMutedByBrowser=!1,this._loadedMetadataHandler=null,this._volumeChangeHandler=null,this.onForceMute=()=>{this._isMuted=!0,this._isMutedByBrowser=!0,this.dispatchVolumeEvent()},this._main=e,this._logger=e.getLogger(),this._videoElement=document.createElement("video"),this._main.addEventListener("playbackForceMute",this.onForceMute,!1);let t=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getAudioData().startVolume)?e:100,i=null!=(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData().getAudioData().muted)&&e;null!=(null==(e=this._main.getStorageManager())?void 0:e.getField("volume"))&&(t=Number(this._main.getStorageManager().getField("volume"))),null!=(null==(e=this._main.getStorageManager())?void 0:e.getField("muted"))&&"true"==this._main.getStorageManager().getField("muted")&&(i=!0,this._isMutedByBrowser=!0),this._volume=t,this._isMuted=i,this.LOG_ACTIVITY&&this._logger.info(this,"VideoElement :: Start Volume: "+this._volume+" | Muted: "+this._isMuted),this._videoElement.volume=this._volume/100,this._videoElement.muted=this._isMuted,this._videoElement.setAttribute("playsinline","playsinline"),this._videoElement.setAttribute("webkit-playsinline","webkit-playsinline"),this._main.dispatchEvent("videoElementCreate",{ref:this._main,videoElement:this._videoElement}),this.initialize()}initialize(){this._videoElement.onload=function(e){},this._videoElement.onstalled=e=>{this._logger.info(this,"VideoElement :: onstalled")},this._videoElement.onerror=e=>{this._logger.info(this,"VideoElement :: onerror :: "+JSON.stringify(e))},this._volumeChangeHandler=()=>{this.dispatchVolumeEvent()},this._videoElement.onvolumechange=this._volumeChangeHandler,this._videoElement.onpause=()=>{},this._loadedMetadataHandler=()=>{this._main.dispatchEvent("metadata",{ref:this._main,videoWidth:this._videoElement.videoWidth,videoHeight:this._videoElement.videoHeight})},this._videoElement.addEventListener("loadedmetadata",this._loadedMetadataHandler),this._videoElement.ontimeupdate=function(e){},this._videoElement.onended=e=>{this._logger.info(this,"VideoElement :: onended")},this._videoElement.onplay=()=>{}}setVolume(e){this._isMuted&&0<e&&this.setMuted(!1),this._volume=e,this._videoElement.volume=e/100,this._main.getStorageManager().saveField("volume",String(e)),0==e&&this.setMuted(!0)}getVolume(){return this._volume}setMuted(e){this._isMuted=e,this._videoElement.muted=e,this._isMutedByBrowser=!1,this._main.getStorageManager().saveField("muted",String(e)),0!=this.getVolume()||e||this.setVolume(100)}getIfMuted(){return this._isMuted}dispatchVolumeEvent(){var e=this._isMutedByBrowser?"browser":"user",t={volume:this._volume,isMuted:this._isMuted,type:e};this.LOG_ACTIVITY&&this._logger.info(this,"ScreenElement :: Event: onVolumeChange: "+JSON.stringify(t)),this._main.dispatchEvent("volumeChange",{ref:this._main,volume:this._volume,muted:this._isMuted,invokedBy:e})}getVideoElement(){return this._videoElement}destroy(){this._logger.info(this,"Destroying ScreenElement...");try{this._main.removeEventListener("playbackForceMute",this.onForceMute),this._videoElement.srcObject instanceof MediaStream&&this._videoElement.srcObject.getTracks().forEach(e=>{e.enabled=!1,e.stop()}),this._videoElement.pause(),this._videoElement.onload=null,this._videoElement.onstalled=null,this._videoElement.onerror=null,this._videoElement.onvolumechange=null,this._videoElement.onpause=null,this._videoElement.ontimeupdate=null,this._videoElement.onended=null,this._videoElement.onplay=null,this._videoElement.onloadstart=null,this._videoElement.onloadeddata=null,this._videoElement.onloadedmetadata=null,this._videoElement.oncanplay=null,this._videoElement.oncanplaythrough=null,this._videoElement.onprogress=null,this._videoElement.onseeking=null,this._videoElement.onseeked=null,this._videoElement.onwaiting=null,this._videoElement.ondurationchange=null,this._videoElement.onratechange=null,this._videoElement.onsuspend=null,this._videoElement.onemptied=null,this._loadedMetadataHandler&&(this._videoElement.removeEventListener("loadedmetadata",this._loadedMetadataHandler),this._loadedMetadataHandler=null),this._videoElement.removeAttribute("src"),this._videoElement.srcObject=null;try{this._videoElement.load()}catch(e){}this._videoElement.removeAttribute("playsinline"),this._videoElement.removeAttribute("webkit-playsinline"),this._videoElement.parentNode&&this._videoElement.parentNode.removeChild(this._videoElement),this._volumeChangeHandler=null,this._logger.success(this,"ScreenElement successfully destroyed")}catch(e){this._logger.error(this,"Error during ScreenElement destroy: "+e)}}}class M{constructor(e){this._containerWidth=0,this._tempContainerWidth=0,this._containerHeight=0,this._tempContainerHeight=0,this._videoWidth=0,this._videoHeight=0,this._scalingMode=n.FILL,this.isInFullScreenMode=!1,this._isResizing=!1,this._autoResizeEnabled=!0,this._parentOriginalOverflow="",this._debug=!1,this._animationFrameId=null,this._isDestroying=!1,this._fullscreenChangeHandler=null,this._transitionEndHandler=null,this.onFullScreenChange=()=>{null==document.fullscreenElement?(this.isInFullScreenMode=!1,this._logger.info(this,"The library has exited FullScreen mode!"),this._main.dispatchEvent("fullScreenExit",{ref:this._main})):(this.isInFullScreenMode=!0,this._logger.info(this,"The library has entered FullScreen mode!"),this._main.dispatchEvent("fullScreenEnter",{ref:this._main}))},this._main=e,this._logger=e.getLogger(),this._logger.info(this,"Creating new StageController"),this.initialize()}initialize(){var e=null!=(e=null==(e=null==(e=null==(e=this._main.getConfigManager())?void 0:e.getSettingsData())?void 0:e.getVideoData())?void 0:e.containerID)?e:null,t=(this._scalingMode=null!=(t=null==(t=this._main.getConfigManager())?void 0:t.getSettingsData().getVideoData().scalingMode)?t:n.FILL,this._debug=null!=(t=null==(t=this._main.getConfigManager())?void 0:t.getSettingsData().getDebugData().stageControllerDebug)?t:this._debug,this._videoContainer=document.createElement("div"),this._videoContainer.setAttribute("id","stormStreamer_"+this._main.getStreamerID()),this._videoContainer.style.overflow="hidden",this._videoContainer.style.position="relative",this._videoContainer.classList.add("stormStreamer"),this._screenElement=new K(this._main),this._videoContainer.appendChild(this._screenElement.getVideoElement()),this._main.getConfigManager().getSettingsData().getVideoData().resizeDebounce);this._resizeObserver=0<t?new ResizeObserver(G(()=>{this._autoResizeEnabled&&this._parentElement&&this.handleResize()},t,{leading:!1,trailing:!0})):new ResizeObserver(()=>{this._autoResizeEnabled&&this._parentElement&&this.handleResize()}),this._fullscreenChangeHandler=this.onFullScreenChange,this._transitionEndHandler=()=>{this.handleResize()},document.addEventListener("fullscreenchange",this._fullscreenChangeHandler,!1),document.addEventListener("webkitfullscreenchange",this._fullscreenChangeHandler,!1),document.addEventListener("mozfullscreenchange",this._fullscreenChangeHandler,!1),document.addEventListener("webkitendfullscreen",this._fullscreenChangeHandler,!1),this._screenElement.getVideoElement().addEventListener("webkitendfullscreen",this._fullscreenChangeHandler,!1),this._main.addEventListener("metadata",e=>{this._videoWidth=e.videoWidth,this._videoHeight=e.videoHeight,this.handleResize()},!1),e?this.attachToParent(e):this._logger.warning(this,'Could not create HTMLObject for the library - "containerID" was not provided')}attachToParent(e){let t=!1,i=null;var s;return"string"==typeof e?(this._logger.info(this,"Attaching container to ID: "+e),i=document.getElementById(e)):e instanceof HTMLElement&&(this._logger.info(this,"Attaching container to HTMLElement: "+e),i=e),i===this._parentElement?(this._debug&&this._logger.decoratedLog("Attaching Failed (container is the same)","dark-pink"),this._logger.warning(this,"attachToParent :: container is the same"),!1):(i&&this._videoContainer?(this._debug&&this._logger.decoratedLog("Attach To Parent: "+e+" (success)","dark-pink"),this._parentElement=i,this._parentElement.appendChild(this._videoContainer),this._screenElement&&null!=(s=this._screenElement.getVideoElement())&&s.srcObject&&s.play().catch(()=>{}),this._resizeObserver.observe(this._parentElement),this._parentElement.addEventListener("transitionend",this._transitionEndHandler),this._main.dispatchEvent("containerChange",{ref:this._main,container:this._parentElement}),this.handleResize(),t=!0):(this._debug&&this._logger.decoratedLog("Attach To Parent: "+e+" (failure - container not found)","dark-pink"),this._logger.warning(this,'attachToParent :: container "'+e+'"+ was not found')),t)}detachFromParent(){this._debug&&this._logger.decoratedLog("Detach From Parent","dark-pink");let e=!1;return null!=this._parentElement&&null!=this._videoContainer?(this._logger.info(this,"Detaching from parent: "+this._videoContainer),null!==this._animationFrameId&&(cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null,this._isResizing&&(this._parentElement.style.overflow=this._parentOriginalOverflow),this._isResizing=!1),this._transitionEndHandler&&this._parentElement.removeEventListener("transitionend",this._transitionEndHandler),this._parentElement.removeChild(this._videoContainer),this._resizeObserver&&this._resizeObserver.unobserve(this._parentElement),this._main.dispatchEvent("containerChange",{ref:this._main,container:null}),e=!0):this._logger.info(this,"Failed detaching from parent!"),this._parentElement=null,e}handleResize(){!this._parentElement||this._isResizing||this._isDestroying||(null!==this._animationFrameId&&cancelAnimationFrame(this._animationFrameId),this._isResizing=!0,this._parentOriginalOverflow=this._parentElement.style.overflow,this._parentElement.style.overflow="hidden",this._animationFrameId=requestAnimationFrame(()=>{this._isDestroying||!this._parentElement?(this._isResizing=!1,this._animationFrameId=null):(this.calculateNewDimensions(),this._parentElement&&(this._parentElement.style.overflow=this._parentOriginalOverflow),this._isResizing=!1,this._animationFrameId=null,this._tempContainerWidth===this._containerWidth&&this._tempContainerHeight===this._containerHeight||this._main.dispatchEvent("resizeUpdate",{ref:this._main,width:this._tempContainerWidth,height:this._tempContainerHeight}))}))}calculateNewDimensions(){if(this._parentElement){var e=this._main.getConfigManager().getSettingsData().getVideoData().parentSizeCalculationMethod;switch(e){case i.CLIENT_DIMENSIONS:this._tempContainerWidth=this._parentElement.clientWidth,this._tempContainerHeight=this._parentElement.clientHeight;break;case i.BOUNDING_BOX:var t=this._parentElement.getBoundingClientRect();this._tempContainerWidth=t.width,this._tempContainerHeight=t.height;break;case i.FULL_BOX:t=class{static calculateDimensionsWithMargins(e){var t=window.getComputedStyle(e),e=e.getBoundingClientRect(),i=parseFloat(t.paddingLeft),s=parseFloat(t.paddingRight),n=parseFloat(t.paddingTop),r=parseFloat(t.paddingBottom),o=parseFloat(t.borderLeftWidth),a=parseFloat(t.borderRightWidth),h=parseFloat(t.borderTopWidth),t=parseFloat(t.borderBottomWidth);return{width:e.width-i-s-o-a,height:e.height-n-r-h-t}}}.calculateDimensionsWithMargins(this._parentElement);this._tempContainerWidth=t.width,this._tempContainerHeight=t.height}this._logger.info(this,`New dimensions calculated: ${this._tempContainerWidth}x${this._tempContainerHeight} (${e})`),this.resizeVideoContainer(),this.scaleVideo()}}resizeVideoContainer(){var e=this._main.getConfigManager().getSettingsData().getVideoData().videoWidthInPixels,t=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightInPixels,i=this._main.getConfigManager().getSettingsData().getVideoData().videoWidthValue,s=this._main.getConfigManager().getSettingsData().getVideoData().videoHeightValue,n=this._main.getConfigManager().getSettingsData().getVideoData().aspectRatio;let r=0,o=0;var a=Number(n.split(":")[0]),h=Number(n.split(":")[1]);"none"==n?(e?r=i:null!=this._parentElement&&(r=this._tempContainerWidth*i/100),t?o=s:null!=this._parentElement&&0==(o=this._tempContainerHeight*s/100)&&0!=this._videoHeight&&0!=this._videoWidth&&(o=this._videoHeight*r/this._videoWidth)):(e?r=i:null!=this._parentElement&&(r=this._tempContainerWidth*i/100),o=r*h/a),this._containerWidth=Math.ceil(r),this._containerHeight=Math.ceil(o),null!==this._videoContainer&&(this._videoContainer.style.width=this._containerWidth+"px",this._videoContainer.style.height=this._containerHeight+"px")}scaleVideo(){if(null!==this._screenElement){let e=0,t=0,i=0,s=0;switch(this._scalingMode){case n.FILL:i=this._containerWidth,s=this._containerHeight;break;case n.CROP:i=this._containerWidth,(s=this._videoHeight*this._containerWidth/this._videoWidth)>=this._containerHeight?(e=0,t=(s-this._containerHeight)/2*-1):(s=this._containerHeight,i=this._videoWidth*this._containerHeight/this._videoHeight,t=0,e=(i-this._containerWidth)/2*-1);break;case n.LETTER_BOX:i=this._containerWidth,(!((s=this._videoHeight*this._containerWidth/this._videoWidth)<=this._containerHeight)||(e=0,t=(s-this._containerHeight)/2*-1,s>this._containerHeight))&&(s=this._containerHeight,i=this._videoWidth*this._containerHeight/this._videoHeight,t=0,e=(i-this._containerWidth)/2*-1);break;case n.ORIGINAL:i=this._videoWidth,s=this._videoHeight,e=(this._videoWidth-this._containerWidth)/-2,t=(this._videoHeight-this._containerHeight)/-2}this._screenElement.getVideoElement().style.left=Math.floor(e)+"px",this._screenElement.getVideoElement().style.top=Math.floor(t)+"px",this._screenElement.getVideoElement().style.width=Math.ceil(i)+"px",this._screenElement.getVideoElement().style.height=Math.ceil(s)+"px",this._screenElement.getVideoElement().style.position="absolute",this._screenElement.getVideoElement().style.objectFit="fill"}}enterFullScreen(){var e;null!=(e=this._screenElement)&&e.getVideoElement().webkitEnterFullScreen?null!=(e=this._screenElement)&&e.getVideoElement().webkitEnterFullScreen():null!=(e=this._screenElement)&&e.getVideoElement().requestFullscreen()}exitFullScreen(){var e;null!=(e=this._screenElement)&&e.getVideoElement().webkitExitFullscreen?document.webkitExitFullscreen():document.exitFullscreen()}isFullScreenMode(){return this.isInFullScreenMode}setDimension(e,t){var i="width"===e?"videoWidth":"videoHeight";let s,n;if("number"==typeof t)n=t,s=!0;else{if("string"!=typeof t)throw new Error(`Unknown value for parameter "${e}" - it must be a number or a string!`);n=parseInt(t),s=t.toLowerCase().endsWith("px")}this._main.getConfigManager().getSettingsData().getVideoData()[i+"Value"]=n,this._main.getConfigManager().getSettingsData().getVideoData()[i+"InPixels"]=s,this.resizeVideoContainer(),this.scaleVideo()}setSize(e,t){this.setDimension("width",e),this.setDimension("height",t)}setWidth(e){this.setDimension("width",e)}setHeight(e){this.setDimension("height",e)}getParentElement(){return this._parentElement}setScalingMode(e){switch(e.toLowerCase()){case"fill":this._scalingMode=n.FILL;break;case"crop":this._scalingMode=n.CROP;break;case"letterbox":this._scalingMode=n.LETTER_BOX;break;case"original":this._scalingMode=n.ORIGINAL}this.scaleVideo()}getContainerWidth(){return this._containerWidth}getContainerHeight(){return this._containerHeight}getScalingModeAsString(){let e="";switch(this._scalingMode){case n.FILL:e="fill";break;case n.CROP:e="crop";break;case n.LETTER_BOX:e="letterbox";break;case n.ORIGINAL:e="original"}return e}getScalingMode(){return this._scalingMode}getScreenElement(){return this._screenElement}getContainer(){return this._videoContainer}destroy(){var e,t;this._logger.info(this,"Starting StageController destroy..."),this._isDestroying=!0;try{null!==this._animationFrameId&&(cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null),this.detachFromParent(),this._resizeObserver&&this._resizeObserver.disconnect(),this._fullscreenChangeHandler&&(document.removeEventListener("fullscreenchange",this._fullscreenChangeHandler),document.removeEventListener("webkitfullscreenchange",this._fullscreenChangeHandler),document.removeEventListener("mozfullscreenchange",this._fullscreenChangeHandler),document.removeEventListener("webkitendfullscreen",this._fullscreenChangeHandler),null!=(e=this._screenElement)&&e.getVideoElement()&&this._screenElement.getVideoElement().removeEventListener("webkitendfullscreen",this._fullscreenChangeHandler),this._fullscreenChangeHandler=null),this._screenElement&&((t=this._screenElement.getVideoElement())&&(t.srcObject instanceof MediaStream&&t.srcObject.getTracks().forEach(e=>{e.enabled=!1,e.stop()}),t.pause(),t.removeAttribute("src"),t.srcObject=null,t.load(),t.parentNode)&&t.parentNode.removeChild(t),"function"==typeof this._screenElement.destroy&&this._screenElement.destroy(),this._screenElement=null),this._videoContainer&&(this._videoContainer.parentNode&&this._videoContainer.parentNode.removeChild(this._videoContainer),this._videoContainer=null),this._containerWidth=0,this._containerHeight=0,this._tempContainerWidth=0,this._tempContainerHeight=0,this._videoWidth=0,this._videoHeight=0,this.isInFullScreenMode=!1,this._isResizing=!1,this._autoResizeEnabled=!1,this._transitionEndHandler=null,this._logger.success(this,"StageController successfully destroyed")}catch(e){this._logger.error(this,"Error during destroy: "+e)}finally{this._isDestroying=!1}}}M.LOG_ACTIVITY=!0;class O{constructor(){}addAudio(e,t){let i="",s="",n=!1;for(const r of e.split(/\r\n/))r.length<=0||(0===r.indexOf("m=audio")?i="audio":0===r.indexOf("m=video")&&(i="video"),s=s+r+"\r\n","audio"!==i)||0!=="a=rtcp-mux".localeCompare(r)||n||(s+=t,n=!0);return s}addVideo(e,t){e=e.split(/\r\n/);let i="",s=!1,n=!1;for(const o of e)o.length<=0||(o.includes("a=rtcp-rsize")&&(n=!0),o.includes("a=rtcp-mux"));let r=!1;for(const a of e)a.startsWith("m=video")&&(r=!0),i=i+a+"\r\n",r&&(0==="a=rtcp-rsize".localeCompare(a)&&!s&&n&&(i+=t,s=!0),0==="a=rtcp-mux".localeCompare(a)&&s&&!n&&(i+=t,s=!0),0!=="a=rtcp-mux".localeCompare(a)||s||n||(s=!0));return i}deliverCheckLine(e,t){for(const s in O.SDPOutput){var i=O.SDPOutput[s];if(i.includes(e)){if(e.includes("VP9")||e.includes("VP8")){let e="";for(const n of i.split(/\r\n/))e=e+n+"\r\n";return t.includes("audio")&&(O.audioIndex=parseInt(s)),t.includes("video")&&(O.videoIndex=parseInt(s)),e}return t.includes("audio")&&(O.audioIndex=parseInt(s)),t.includes("video")&&(O.videoIndex=parseInt(s)),i}}return""}checkLine(t){if(t.startsWith("a=rtpmap")||t.startsWith("a=rtcp-fb")||t.startsWith("a=fmtp")){var i=t.split(":");if(1<i.length){i=i[1].split(" ");if(!isNaN(parseInt(i[0]))&&!i[1].startsWith("http")&&!i[1].startsWith("ur")){let e=O.SDPOutput[i[0]];return e=e||"",e+=t+"\r\n",O.SDPOutput[i[0]]=e,!1}}}return!0}getrtpMapID(e){var t=new RegExp("a=rtpmap:(\\d+) (\\w+)/(\\d+)"),e=e.match(t);return e&&3<=e.length?e:null}mungeSDPPublish(e,t){O.SDPOutput={},O.videoChoice=t.videoCodec||"42e01f",O.audioChoice=t.audioCodec||"opus",O.videoIndex=-1,O.audioIndex=-1;const i=t.videoFrameRate?Math.min(Math.max(t.videoFrameRate,1),60):30;let s="";for(const d of e.split(/\r\n/))d.length<=0||this.checkLine(d)&&(s+=d+"\r\n");s=this.addAudio(s,this.deliverCheckLine(O.audioChoice,"audio"));e=(s=this.addVideo(s,this.deliverCheckLine(O.videoChoice,"video"))).split(/\r\n/);s="";let n="header",r=!1;for(const c of e)if(!(c.length<=0))if(0===c.indexOf("m=audio")&&-1!==O.audioIndex){var o=c.split(" ");s+=`${o[0]} ${o[1]} ${o[2]} ${O.audioIndex}\r\n`,n="audio",r=!1}else if(0===c.indexOf("m=video")&&-1!==O.videoIndex){o=c.split(" ");s=(s=(s=(s+=`${o[0]} ${o[1]} ${o[2]} ${O.videoIndex}\r\n`)+`a=framerate:${i}\r `)+`a=x-google-max-framerate:${i}\r `)+`a=max-fr:${i}\r `,n="video",r=!1}else{s+=c,0===c.indexOf("a=rtpmap")&&(null===(h=this.getrtpMapID(c))||"vp9"!==(a=h[2].toLowerCase())&&"vp8"!==a&&"h264"!==a||(s+=(a=h[1],void 0,`\r a=rtcp-fb:${a} ccm fir`+`\r a=rtcp-fb:${a} nack`+`\r a=rtcp-fb:${a} nack pli`+`\r a=rtcp-fb:${a} goog-remb`+`\r a=fmtp:${a} max-fr=${i};max-fps=`+i)),n="bandwidth",r=!1);var a,h=m.getBrowserName().toLowerCase();if("chrome"===h||"safari"===h)0!==c.indexOf("a=mid:")&&0!==c.indexOf("a=rtpmap")||r||("video"===n&&t.videoBitrate&&(s=(s=(s=(s=(s+=`\r b=CT:`+t.videoBitrate)+`\r b=AS:`+t.videoBitrate)+`\r b=TIAS:`+1e3*parseInt(t.videoBitrate))+`\r a=framerate:`+i)+`\r a=x-google-max-framerate:`+i,r=!0),"chrome"!==h)||"bandwidth"!==n||null===(a=this.getrtpMapID(c))||"vp9"!==(l=a[2].toLowerCase())&&"vp8"!==l&&"h264"!==l&&"red"!==l&&"ulpfec"!==l&&"rtx"!==l||(s+=`\r a=fmtp:${a[1]} x-google-min-bitrate=${t.videoBitrate};`+`x-google-max-bitrate=${t.videoBitrate};`+`x-google-start-bitrate=${t.videoBitrate};`+`max-fr=${i};x-google-max-framerate=`+i);else if("firefox"===h&&0===c.indexOf("c=IN")&&"video"===n&&t.videoBitrate){var l="string"==typeof t.videoBitrate?parseInt(t.videoBitrate):t.videoBitrate;s=(s=(s=(s+=`\r b=TIAS:${1e3*(1e3*l*.95-16e3)}\r `)+`b=AS:${l}\r `+`b=CT:${l}\r `)+`a=framerate:${i}\r `)+`a=max-fr:${i}\r `;continue}s+="\r\n"}return s}mungeSDPPlay(e){let s="";for(const o of e.split(/\r\n/))if(0!==o.length){if(o.includes("profile-level-id")){var n=o.substr(o.indexOf("profile-level-id")+17,6);let e=Number("0x"+n.substr(0,2)),t=Number("0x"+n.substr(2,2)),i=Number("0x"+n.substr(4,2));66<e&&(e=66,t=224,i=31),0===t&&(t=224);var r=("00"+e.toString(16)).slice(-2).toLowerCase()+("00"+t.toString(16)).slice(-2).toLowerCase()+("00"+i.toString(16)).slice(-2).toLowerCase();s+=o.replace(n,r)}else s+=o;s+="\r\n"}return s}}O.SDPOutput={},(v=I=I||{})[v.VIDEO_INPUT=0]="VIDEO_INPUT",v[v.AUDIO_INPUT=1]="AUDIO_INPUT";class R{constructor(e,t){if(this._groupID="",this._isSelected=!1,null==e)throw new Error("no input device");if(void 0===e.deviceId||null===e.deviceId)throw new Error("no deviceID");if(this._id=e.deviceId,void 0===e.kind||null===e.kind)throw new Error("no device kind");switch(e.kind){case"videoinput":this._inputType