/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/eyeson@1.9.6/dist/eyeson.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("eyeson",[],t):"object"==typeof exports?exports.eyeson=t():e.eyeson=t()}(self,(()=>(()=>{var e={503:function(e,t,n){var r;
/*!
 * Platform.js v1.3.6
 * Copyright 2014-2020 Benjamin Tan
 * Copyright 2011-2013 John-David Dalton
 * Available under MIT license
 */e=n.nmd(e),function(){"use strict";var i={function:!0,object:!0},o=i[typeof window]&&window||this,a=i[typeof t]&&t,s=i.object&&e&&!e.nodeType&&e,c=a&&s&&"object"==typeof n.g&&n.g;!c||c.global!==c&&c.window!==c&&c.self!==c||(o=c);var u=Math.pow(2,53)-1,l=/\bOpera/,d=Object.prototype,h=d.hasOwnProperty,p=d.toString;function f(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function v(e){return e=k(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function m(e,t){for(var n in e)h.call(e,n)&&t(e[n],n,e)}function g(e){return null==e?f(e):p.call(e).slice(8,-1)}function y(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function b(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=u)for(;++n<r;)t(e[n],n,e);else m(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function k(e){return String(e).replace(/^ +| +$/g,"")}var S=function e(t){var n=o,r=t&&"object"==typeof t&&"String"!=g(t);r&&(n=t,t=null);var i=n.navigator||{},a=i.userAgent||"";t||(t=a);var s,c,u,d,h,f=r?!!i.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(p.toString()),S="Object",w=r?S:"ScriptBridgingProxyObject",C=r?S:"Environment",x=r&&n.java?"JavaPackage":g(n.java),T=r?S:"RuntimeObject",_=/\bJava/.test(x)&&n.java,R=_&&g(n.environment)==C,M=_?"a":"α",P=_?"b":"β",E=n.document||{},O=n.operamini||n.opera,D=l.test(D=r&&O?O["[[Class]]"]:g(O))?D:O=null,A=t,I=[],B=null,L=t==a,j=L&&O&&"function"==typeof O.version&&O.version(),F=b([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)})),V=function(e){return b(e,(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)}))}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),U=W([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),N=function(e){return b(e,(function(e,n,r){return e||(n[U]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(U)]||RegExp("\\b"+y(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r}))}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),H=function(e){return b(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),v(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e}))}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function W(e){return b(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=v(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function z(e){return b(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(F&&(F=[F]),/\bAndroid\b/.test(H)&&!U&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(U=k(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),N&&!U?U=W([N]):N&&U&&(U=U.replace(RegExp("^("+y(N)+")[-_.\\s]","i"),N+" ").replace(RegExp("^("+y(N)+")[-_.]?(\\w)","i"),N+" $2")),(s=/\bGoogle TV\b/.exec(U))&&(U=s[0]),/\bSimulator\b/i.test(t)&&(U=(U?U+" ":"")+"Simulator"),"Opera Mini"==V&&/\bOPiOS\b/.test(t)&&I.push("running in Turbo/Uncompressed mode"),"IE"==V&&/\blike iPhone OS\b/.test(t)?(N=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,U=s.product):/^iP/.test(U)?(V||(V="Safari"),H="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==V&&/^Linux\b/i.test(H)?H="Kubuntu":N&&"Google"!=N&&(/Chrome/.test(V)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(U))||/\bAndroid\b/.test(H)&&/^Chrome/.test(V)&&/\bVersion\//i.test(t)?(V="Android Browser",H=/\bAndroid\b/.test(H)?H:"Android"):"Silk"==V?(/\bMobi/i.test(t)||(H="Android",I.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&I.unshift("accelerated")):"UC Browser"==V&&/\bUCWEB\b/.test(t)?I.push("speed mode"):"PaleMoon"==V&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?I.push("identifying as Firefox "+s[1]):"Firefox"==V&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(H||(H="Firefox OS"),U||(U=s[1])):!V||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(V))?(V&&!U&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(V=null),(s=U||N||H)&&(U||N||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(H))&&(V=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(H)?H:s)+" Browser")):"Electron"==V&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&I.push("Chromium "+s),j||(j=z(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",y(V),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==F&&parseFloat(j)>3?"WebKit":/\bOpera\b/.test(V)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(t)&&("Mac OS"==H?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(V)&&"NetFront")&&(F=[s]),"IE"==V&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(V+=" Mobile",H="Windows Phone "+(/\+$/.test(s)?s:s+".x"),I.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(V="IE Mobile",H="Windows Phone 8.x",I.unshift("desktop mode"),j||(j=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=V&&"Trident"==F&&(s=/\brv:([\d.]+)/.exec(t))&&(V&&I.push("identifying as "+V+(j?" "+j:"")),V="IE",j=s[1]),L){if(d="global",h=null!=(u=n)?typeof u[d]:"number",/^(?:boolean|number|string|undefined)$/.test(h)||"object"==h&&!u[d])g(s=n.runtime)==w?(V="Adobe AIR",H=s.flash.system.Capabilities.os):g(s=n.phantom)==T?(V="PhantomJS",j=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof E.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?(j=[j,E.documentMode],(s=+s[1]+4)!=j[1]&&(I.push("IE "+j[1]+" mode"),F&&(F[1]=""),j[1]=s),j="IE"==V?String(j[1].toFixed(1)):j[0]):"number"==typeof E.documentMode&&/^(?:Chrome|Firefox)\b/.test(V)&&(I.push("masking as "+V+" "+j),V="IE",j="11.0",F=["Trident"],H="Windows");else if(_&&(A=(s=_.lang.System).getProperty("os.arch"),H=H||s.getProperty("os.name")+" "+s.getProperty("os.version")),R){try{j=n.require("ringo/engine").version.join("."),V="RingoJS"}catch(e){(s=n.system)&&s.global.system==n.system&&(V="Narwhal",H||(H=s[0].os||null))}V||(V="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(s=n.process)&&("object"==typeof s.versions&&("string"==typeof s.versions.electron?(I.push("Node "+s.versions.node),V="Electron",j=s.versions.electron):"string"==typeof s.versions.nw&&(I.push("Chromium "+j,"Node "+s.versions.node),V="NW.js",j=s.versions.nw)),V||(V="Node.js",A=s.arch,H=s.platform,j=(j=/[\d.]+/.exec(s.version))?j[0]:null));H=H&&v(H)}if(j&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(j)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(L&&i.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(B=/b/i.test(s)?"beta":"alpha",j=j.replace(RegExp(s+"\\+?$"),"")+("beta"==B?P:M)+(/\d+\+?/.exec(s)||"")),"Fennec"==V||"Firefox"==V&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(H))V="Firefox Mobile";else if("Maxthon"==V&&j)j=j.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(U))"Xbox 360"==U&&(H=null),"Xbox 360"==U&&/\bIEMobile\b/.test(t)&&I.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(V)&&(!V||U||/Browser|Mobi/.test(V))||"Windows CE"!=H&&!/Mobi/i.test(t))if("IE"==V&&L)try{null===n.external&&I.unshift("platform preview")}catch(e){I.unshift("embedded")}else(/\bBlackBerry\b/.test(U)||/\bBB10\b/.test(t))&&(s=(RegExp(U.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||j)?(H=((s=[s,/BB10/.test(t)])[1]?(U=null,N="BlackBerry"):"Device Software")+" "+s[0],j=null):this!=m&&"Wii"!=U&&(L&&O||/Opera/.test(V)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==V&&/\bOS X (?:\d+\.){2,}/.test(H)||"IE"==V&&(H&&!/^Win/.test(H)&&j>5.5||/\bWindows XP\b/.test(H)&&j>8||8==j&&!/\bTrident\b/.test(t)))&&!l.test(s=e.call(m,t.replace(l,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),l.test(V)?(/\bIE\b/.test(s)&&"Mac OS"==H&&(H=null),s="identify"+s):(s="mask"+s,V=D?v(D.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(H=null),L||(j=null)),F=["Presto"],I.push(s));else V+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==V&&"+"==s[1].slice(-1)?(V="WebKit Nightly",B="alpha",j=s[1].slice(0,-1)):j!=s[1]&&j!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(j=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==F&&(F=["Blink"]),L&&(f||s[1])?(F&&(F[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),F&&(F[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==V&&(!j||parseInt(j)>45)?j=s:"Chrome"==V&&/\bHeadlessChrome/i.test(t)&&I.unshift("headless")),"Opera"==V&&(s=/\bzbov|zvav$/.exec(H))?(V+=" ",I.unshift("desktop mode"),"zvav"==s?(V+="Mini",j=null):V+="Mobile",H=H.replace(RegExp(" *"+s+"$"),"")):"Safari"==V&&/\bChrome\b/.exec(F&&F[1])?(I.unshift("desktop mode"),V="Chrome Mobile",j=null,/\bOS X\b/.test(H)?(N="Apple",H="iOS 4.3+"):H=null):/\bSRWare Iron\b/.test(V)&&!j&&(j=z("Chrome")),j&&0==j.indexOf(s=/[\d.]+$/.exec(H))&&t.indexOf("/"+s+"-")>-1&&(H=k(H.replace(s,""))),H&&-1!=H.indexOf(V)&&!RegExp(V+" OS").test(H)&&(H=H.replace(RegExp(" *"+y(V)+" *"),"")),F&&!/\b(?:Avant|Nook)\b/.test(V)&&(/Browser|Lunascape|Maxthon/.test(V)||"Safari"!=V&&/^iOS/.test(H)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(V)&&F[1])&&(s=F[F.length-1])&&I.push(s),I.length&&(I=["("+I.join("; ")+")"]),N&&U&&U.indexOf(N)<0&&I.push("on "+N),U&&I.push((/^on /.test(I[I.length-1])?"":"on ")+U),H&&(s=/ ([\d.+]+)$/.exec(H),c=s&&"/"==H.charAt(H.length-s[0].length-1),H={architecture:32,family:s&&!c?H.replace(s[0],""):H,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(A))&&!/\bi686\b/i.test(A)?(H&&(H.architecture=64,H.family=H.family.replace(RegExp(" *"+s),"")),V&&(/\bWOW64\b/i.test(t)||L&&/\w(?:86|32)$/.test(i.cpuClass||i.platform)&&!/\bWin64; x64\b/i.test(t))&&I.unshift("32-bit")):H&&/^OS X/.test(H.family)&&"Chrome"==V&&parseFloat(j)>=39&&(H.architecture=64),t||(t=null);var q={};return q.description=t,q.layout=F&&F[0],q.manufacturer=N,q.name=V,q.prerelease=B,q.product=U,q.ua=t,q.version=V&&j,q.os=H||{architecture:null,family:null,version:null,toString:function(){return"null"}},q.parse=e,q.toString=function(){return this.description||""},q.version&&I.unshift(j),q.name&&I.unshift(V),H&&V&&(H!=String(H).split(" ")[0]||H!=V.split(" ")[0]&&!U)&&I.push(U?"("+H+")":"on "+H),I.length&&(q.description=I.join(" ")),q}();o.platform=S,void 0===(r=function(){return S}.call(t,n,t,e))||(e.exports=r)}.call(this)},916:e=>{
/*!
* screenfull
* v5.2.0 - 2021-11-03
* (c) Sindre Sorhus; MIT License
*/
!function(){"use strict";var t="undefined"!=typeof window&&void 0!==window.document?window.document:{},n=e.exports,r=function(){for(var e,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,o={};r<i;r++)if((e=n[r])&&e[1]in t){for(r=0;r<e.length;r++)o[n[0][r]]=e[r];return o}return!1}(),i={change:r.fullscreenchange,error:r.fullscreenerror},o={request:function(e,n){return new Promise(function(i,o){var a=function(){this.off("change",a),i()}.bind(this);this.on("change",a);var s=(e=e||t.documentElement)[r.requestFullscreen](n);s instanceof Promise&&s.then(a).catch(o)}.bind(this))},exit:function(){return new Promise(function(e,n){if(this.isFullscreen){var i=function(){this.off("change",i),e()}.bind(this);this.on("change",i);var o=t[r.exitFullscreen]();o instanceof Promise&&o.then(i).catch(n)}else e()}.bind(this))},toggle:function(e,t){return this.isFullscreen?this.exit():this.request(e,t)},onchange:function(e){this.on("change",e)},onerror:function(e){this.on("error",e)},on:function(e,n){var r=i[e];r&&t.addEventListener(r,n,!1)},off:function(e,n){var r=i[e];r&&t.removeEventListener(r,n,!1)},raw:r};r?(Object.defineProperties(o,{isFullscreen:{get:function(){return Boolean(t[r.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[r.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[r.fullscreenEnabled])}}}),n?e.exports=o:window.screenfull=o):n?e.exports={isEnabled:!1}:window.screenfull={isEnabled:!1}}()},963:e=>{"use strict";const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){const n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((e=>0===e.indexOf(n)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const n={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e<t.length;e+=2)switch(t[e]){case"raddr":n.relatedAddress=t[e+1];break;case"rport":n.relatedPort=parseInt(t[e+1],10);break;case"tcptype":n.tcpType=t[e+1];break;case"ufrag":n.ufrag=t[e+1],n.usernameFragment=t[e+1];break;default:void 0===n[t[e]]&&(n[t[e]]=t[e+1])}return n},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const n=e.component;"rtp"===n?t.push(1):"rtcp"===n?t.push(2):t.push(n),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let n;const r=e.substring(e.indexOf(" ")+1).split(";");for(let e=0;e<r.length;e++)n=r[e].trim().split("="),t[n[0].trim()]=n[1];return t},t.writeFmtp=function(e){let t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const r=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substring(t+1,r),n.value=e.substring(r+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){const r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");n.profile=r[2];for(let i=3;i<r.length;i++){const o=r[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){const r=t.parseRtpMap(a),i=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(r.parameters=i.length?t.parseFmtp(i[0]):{},r.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),n.codecs.push(r),r.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(r.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{n.headerExtensions.push(t.parseExtmap(e))}));const i=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach((e=>{i.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),n},t.writeRtpDescription=function(e,n){let r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=n.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((e=>{r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));let i=0;return n.codecs.forEach((e=>{e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach((e=>{r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){const n=[],r=t.parseRtpParameters(e),i=-1!==r.fecMechanisms.indexOf("RED"),o=-1!==r.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),s=a.length>0&&a[0].ssrc;let c;const u=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));u.length>0&&u[0].length>1&&u[0][0]===s&&(c=u[0][1]),r.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&c&&(t.rtx={ssrc:c}),n.push(t),i&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:s,mechanism:o?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&s&&n.push({ssrc:s});let l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,n.forEach((e=>{e.maxBitrate=l}))),n},t.parseRtcpParameters=function(e){const n={},r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);const i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;const o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let n;const r=t.matchPrefix(e,"a=msid:");if(1===r.length)return n=r[0].substring(7).split(" "),{stream:n[0],track:n[1]};const i=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return i.length>0?(n=i[0].value.split(" "),{stream:n[0],track:n[1]}):void 0},t.parseSctpDescription=function(e){const n=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:");let i;r.length>0&&(i=parseInt(r[0].substring(19),10)),isNaN(i)&&(i=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:n.fmt,maxMessageSize:i};const a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){const e=a[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){let n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,r){let i;const o=void 0!==n?n:2;i=e||t.generateSessionId();return"v=0\r\no="+(r||"thisisadapterortc")+" "+i+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){const r=t.splitLines(e);for(let e=0;e<r.length;e++)switch(r[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[e].substring(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const n=t.splitLines(e)[0].substring(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){const n=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const n=t.splitLines(e);for(let e=0;e<n.length;e++)if(n[e].length<2||"="!==n[e].charAt(1))return!1;return!0},e.exports=t},633:(e,t,n)=>{var r=n(738).default;function i(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,a=o.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",d=c.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var i=t&&t.prototype instanceof k?t:k,o=Object.create(i.prototype),a=new A(r||[]);return s(o,"_invoke",{value:P(e,n,a)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=p;var v="suspendedStart",m="suspendedYield",g="executing",y="completed",b={};function k(){}function S(){}function w(){}var C={};h(C,u,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(I([])));T&&T!==o&&a.call(T,u)&&(C=T);var _=w.prototype=k.prototype=Object.create(C);function R(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function M(e,t){function n(i,o,s,c){var u=f(e[i],e,o);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==r(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,c)}),(function(e){n("throw",e,s,c)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,c)}))}c(u.arg)}var i;s(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function P(e,n,r){var i=v;return function(o,a){if(i===g)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=E(s,r);if(c){if(c===b)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===v)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var u=f(e,n,r);if("normal"===u.type){if(i=r.done?y:m,u.arg===b)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=y,r.method="throw",r.arg=u.arg)}}}function E(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,E(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=f(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function I(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return S.prototype=w,s(_,"constructor",{value:w,configurable:!0}),s(w,"constructor",{value:S,configurable:!0}),S.displayName=h(w,d,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,h(e,d,"GeneratorFunction")),e.prototype=Object.create(_),e},n.awrap=function(e){return{__await:e}},R(M.prototype),h(M.prototype,l,(function(){return this})),n.AsyncIterator=M,n.async=function(e,t,r,i,o){void 0===o&&(o=Promise);var a=new M(p(e,t,r,i),o);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},R(_),h(_,d,"Generator"),h(_,u,(function(){return this})),h(_,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=I,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(D),!e)for(var n in this)"t"===n.charAt(0)&&a.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:I(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),b}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};return(()=>{"use strict";n.r(r),n.d(r,{ConnectionStatistics:()=>Eo,DeviceManager:()=>Fn,FeatureDetector:()=>et,FullscreenHelper:()=>Ye,Geolocation:()=>da,GiphyApi:()=>ea,LocalStorage:()=>ot,Logger:()=>f,MediaStreamBuilder:()=>Vn,MicMixer:()=>Un,SoundMeter:()=>ra,StreamHelpers:()=>a,SystemPressureMonitor:()=>Sa,WebHIDManager:()=>ka,debounce:()=>pi,default:()=>wa,immediate:()=>Jt,throttle:()=>m});var e={};n.r(e),n.d(e,{fixNegotiationNeeded:()=>pe,shimAddTrackRemoveTrack:()=>de,shimAddTrackRemoveTrackWithNative:()=>le,shimGetSendersWithDtmf:()=>ce,shimGetUserMedia:()=>oe,shimMediaStream:()=>ae,shimOnTrack:()=>se,shimPeerConnection:()=>he,shimSenderReceiverGetStats:()=>ue});var t={};n.r(t),n.d(t,{shimAddTransceiver:()=>we,shimCreateAnswer:()=>Te,shimCreateOffer:()=>xe,shimGetDisplayMedia:()=>ve,shimGetParameters:()=>Ce,shimGetUserMedia:()=>fe,shimOnTrack:()=>me,shimPeerConnection:()=>ge,shimRTCDataChannel:()=>Se,shimReceiverGetStats:()=>be,shimRemoveStream:()=>ke,shimSenderGetStats:()=>ye});var i={};n.r(i),n.d(i,{shimAudioContext:()=>Ie,shimCallbacksAPI:()=>Me,shimConstraints:()=>Ee,shimCreateOfferLegacy:()=>Ae,shimGetUserMedia:()=>Pe,shimLocalStreamsAPI:()=>_e,shimRTCIceServerUrls:()=>Oe,shimRemoteStreamsAPI:()=>Re,shimTrackEventTransceiver:()=>De});var o={};n.r(o),n.d(o,{removeExtmapAllowMixed:()=>He,shimAddIceCandidateNullOrEmpty:()=>We,shimConnectionState:()=>Ne,shimMaxMessageSize:()=>Ve,shimParameterlessSetLocalDescription:()=>ze,shimRTCIceCandidate:()=>je,shimRTCIceCandidateRelayProtocol:()=>Fe,shimSendThrowTypeError:()=>Ue});var a={};function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e){var t=function(e,t){if("object"!=s(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==s(t)?t:t+""}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,u(r.key),r)}}function d(e,t,n){return t&&l(e.prototype,t),n&&l(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}n.r(a),n.d(a,{captureStream:()=>Ht,createExternalStream:()=>Wt,disableAudio:()=>ut,disableCamera:()=>Mt,enableAudio:()=>lt,enableCamera:()=>Pt,getCameraTracks:()=>Tt,getCanvasTracks:()=>Dt,getFacingMode:()=>Nt,getScreenAsVideoTracks:()=>xt,getScreenPresentationTracks:()=>Ct,getScreenTracks:()=>wt,getSenderCodecs:()=>$t,getVbgTracks:()=>_t,hasAudio:()=>st,hasCameraVideo:()=>Ut,hasVideo:()=>ct,initLegacySenderCodecs:()=>qt,isCameraStream:()=>jt,isCanvasPresentationStream:()=>Ft,isCanvasStream:()=>Bt,isNinjaStreamTrack:()=>bt,isPresentationStream:()=>Vt,isScreenAsVideoTrack:()=>gt,isScreenPresentationStream:()=>It,isScreenStream:()=>At,isVBGStream:()=>Lt,isVbgStreamTrack:()=>kt,stopCamera:()=>Rt,stopStream:()=>ft,stopTrack:()=>pt,toggleAudio:()=>dt,toggleCamera:()=>Et,toggleVbgTrack:()=>Ot,toggleVideo:()=>ht});const h={version:"1.9.6",api:"https://api.eyeson.team",allowSafariSFU:!0,screencapture:!0,verbose:!0,vbgScriptPath:"vendor/tflite/",hdCamera:!0},p={widescreen:!1};const f={error:function(){var e;return(e=console).error.apply(e,arguments)},warn:function(){var e;return(e=console).warn.apply(e,arguments)},info:function(){var e;return!1===h.verbose?null:(e=console).log.apply(e,arguments)},debug:function(){var e;return console.debug&&!1!==h.verbose?(e=console).debug.apply(e,arguments):null}};const v=function(){return d((function e(t,n){c(this,e),this.uri=t,this.token=n.replace(/\W+/g,""),this.cache={users:[]},this.errorCallback=null,this._handleError=this._handleError.bind(this)}),[{key:"_request",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return fetch(new Request(this.uri+e),t).then((function(e){var t=e.headers.get("content-type");if(t&&-1!==t.indexOf("application/json")&&e.ok)return e.json();if(e.ok)return e.text();var n=new Error("ComApiError: ".concat(e.status));throw n.status=e.status,n}))}},{key:"_objectToFormData",value:function(e,t,n){var r=t||new FormData,i=null;for(var o in e){if(!e.hasOwnProperty(o))return;if(n)i=n+"["+(isNaN(parseInt(o))?o:"")+"]";else i=o;"object"!==s(e[o])||e[o]instanceof File?r.append(i,e[o]):this._objectToFormData(e[o],r,o)}return r}},{key:"_post",value:function(e,t){return this._request(e,{method:"POST",body:this._objectToFormData(t)})}},{key:"_put",value:function(e,t){var n=new FormData;for(var r in t)n.append(r,t[r]);return this._request(e,{method:"PUT",body:n})}},{key:"_handleError",value:function(e,t){return f.error("ComApi::handleError",t,e),this.errorCallback&&this.errorCallback(e,t),!1}},{key:"onError",value:function(e){this.errorCallback=e}},{key:"getRoom",value:function(e){return this._request("/rooms/".concat(this.token)).then(e).catch((function(t){return e?e({error:t}):{error:t}}))}},{key:"terminateMeeting",value:function(){var e=this;return this._request("/rooms/".concat(this.token),{method:"DELETE"}).catch((function(t){return e._handleError(t,"terminate_meeting")}))}},{key:"getUser",value:function(e,t){var n=this,r=this.cache.users.find((function(t){return t.id===e}));return r?(t(r),null):this._request("/rooms/".concat(this.token,"/users/").concat(e)).then((function(r){var i=n.cache.users.filter((function(t){return t.id!==e})),o=n.addUserAttributes(r,e,e);i.push(o),n.cache.users=i,t(o)})).catch((function(e){return n._handleError(e,"get_user")}))}},{key:"addUserAttributes",value:function(e,t,n){var r=e.avatar;try{r="".concat(e.avatar,"?size=large")}catch(t){f.warn("ComApi::addUserAttributes missing",e)}return Object.assign(e,{id:t,apiId:e.id,clientId:n,sipId:n,largeAvatar:r})}},{key:"kickUser",value:function(e){var t=this;return this._request("/rooms/".concat(this.token,"/users/").concat(e),{method:"DELETE"}).then((function(){if(t.cache.users.find((function(t){return t.id===e}))){var n=t.cache.users.filter((function(t){return t.id!==e}));t.cache.users=n}})).catch((function(e){return t._handleError(e,"kick_user")}))}},{key:"requestUser",value:function(e,t){return this._post("/guests/".concat(this.token),{name:e.name,email:e.email,custom_fields:{locale:e.locale||"en"}}).then(t).catch((function(e){return t({error:e})}))}},{key:"startBroadcast",value:function(e,t){return this._post("/rooms/".concat(this.token,"/broadcasts"),{platform:t,player_url:e.playerUrl||"",stream_url:e.streamUrl})}},{key:"publishBroadcast",value:function(e,t){return this._put("/rooms/".concat(this.token,"/broadcasts/").concat(t),{player_url:e.playerUrl})}},{key:"stopBroadcast",value:function(e){return this._request("/rooms/".concat(this.token,"/broadcasts/").concat(e),{method:"DELETE"})}},{key:"stopAllBroadcasts",value:function(){return this._request("/rooms/".concat(this.token,"/broadcasts"),{method:"DELETE"})}},{key:"startRecording",value:function(){return this._request("/rooms/".concat(this.token,"/recording"),{method:"POST"})}},{key:"stopRecording",value:function(){var e=this;return this._request("/rooms/".concat(this.token,"/recording"),{method:"DELETE"}).catch((function(t){return e._handleError(t,"stop_recording")}))}},{key:"setLayout",value:function(e){var t=this;return this._post("/rooms/".concat(this.token,"/layout"),e).catch((function(e){return t._handleError(e,"set_layout")}))}},{key:"setLayer",value:function(e){var t=this;return this._post("/rooms/".concat(this.token,"/layers"),e).catch((function(e){return t._handleError(e,"set_layer")}))}},{key:"clearFrontLayer",value:function(){var e=this;return this._request("/rooms/".concat(this.token,"/layers/1"),{method:"DELETE"}).catch((function(t){return e._handleError(t,"clear_front_layer")}))}},{key:"takeSnapshot",value:function(){var e=this;return this._request("/rooms/".concat(this.token,"/snapshot"),{method:"POST"}).catch((function(t){return e._handleError(t,"snapshot")}))}},{key:"getSnapshot",value:function(e,t){var n=this;return this._request("/rooms/".concat(this.token,"/snapshots/").concat(e)).then(t).catch((function(e){t?t({error:e}):n._handleError(e,"get_snapshot")}))}},{key:"startPlayback",value:function(e,t){var n=this;return this._post("/rooms/".concat(this.token,"/playbacks"),{playback:e}).then((function(){return t?t({}):null}),(function(e){t?t({error:e}):n._handleError(e,"start_playback")}))}},{key:"stopPlayback",value:function(e){var t=this;return this._request("/rooms/".concat(this.token,"/playbacks/").concat(e.play_id),{method:"DELETE"}).catch((function(e){return t._handleError(e,"stop_playback")}))}},{key:"lockMeeting",value:function(){var e=this;return this._request("/rooms/".concat(this.token,"/lock"),{method:"POST"}).catch((function(t){return e._handleError(t,"lock_meeting")}))}},{key:"sendMessage",value:function(e){var t=this;return this._post("/rooms/".concat(this.token,"/messages"),e).catch((function(e){return t._handleError(e,"send_message")}))}},{key:"startPresentation",value:function(e){var t=this;return this._request("/rooms/".concat(this.token,"/presentation"),{method:"POST"}).then((function(){return e?e({}):null}),(function(n){e?e({error:n}):t._handleError(n,"start_presentation")}))}},{key:"stopPresentation",value:function(){var e=this;return this._request("/rooms/".concat(this.token,"/presentation"),{method:"DELETE"}).catch((function(t){return e._handleError(t,"stop_presentation")}))}},{key:"requestPermalinkMeetingInfo",value:function(e){return this._request("/permalink/".concat(this.token)).then(e).catch((function(t){return e({error:t})}))}},{key:"joinPermalinkUser",value:function(e){return this._post("/permalink/".concat(this.token)).then(e).catch((function(t){return e({error:t})}))}}])}();const m=function(e,t,n){var r,i,o,a=null,s=0;n||(n={});var c=function(){s=!1===n.leading?0:Date.now(),a=null,o=e.apply(r,i),a||(r=i=null)};return function(){var u=Date.now();s||!1!==n.leading||(s=u);var l=t-(u-s);return r=this,i=arguments,l<=0||l>t?(a&&(clearTimeout(a),a=null),s=u,o=e.apply(r,i),a||(r=i=null)):a||!1===n.trailing||(a=setTimeout(c,l)),o}};function g(e,t){if(t&&("object"==s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function k(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}const S=function(){return d((function e(t){c(this,e),this.context=t}),[{key:"handle",value:function(e){f.error("BaseEvent::handle is not implemented",e)}}])}();function w(e,t,n){return t=y(t),g(e,C()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(C=function(){return!!e})()}var x=function(e){function t(){return c(this,t),w(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.startPlayback(e.playback)}}])}(S),T=function(e){function t(){return c(this,t),w(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.stopPlayback(e.playback)}}])}(S);function _(){return _="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},_.apply(null,arguments)}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(R=function(){return!!e})()}const M=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,R()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){"client"!==e._src&&(Reflect.deleteProperty(e,"_src"),this.context.listeners.forEach((function(t){return t(e)})))}}])}(S);function P(e,t,n){return t=y(t),g(e,E()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(E=function(){return!!e})()}var O=function(e){function t(){return c(this,t),P(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(){var e=this;this.context.annotationLoop=window.setInterval((function(){e.context._api.createAnnotation((function(n){return(r=t,i="handle",o=e,s=_(y(1&(a=3)?r.prototype:r),i,o),2&a&&"function"==typeof s?function(e){return s.apply(o,e)}:s)([{type:"annotation",annotation:n}]);var r,i,o,a,s}),(function(){window.clearInterval(e.context.annotationLoop)}))}),1e3)}}])}(M),D=function(e){function t(){return c(this,t),P(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(){window.clearInterval(this.context.annotationLoop),this.context._api.stopAnnotation()}}])}(M);function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(A=function(){return!!e})()}const I=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,A()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){this.context._rtConnection.send({type:"stfu"})}}])}(M);function B(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(B=function(){return!!e})()}const L=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,B()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){}}])}(S);function j(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function F(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){j(o,r,i,a,s,"next",e)}function s(e){j(o,r,i,a,s,"throw",e)}a(void 0)}))}}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function U(e,t){if(e){if("string"==typeof e)return V(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?V(e,t):void 0}}function N(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||U(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var H=n(756),W=n.n(H);function z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(z=function(){return!!e})()}const q=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,z()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context.listeners.forEach((function(t){return t(e)}))}}])}(S);let G=!0,$=!0;function J(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function K(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function X(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(G=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Y(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):($=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Q(){if("object"==typeof window){if(G)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Z(e,t){$&&console.warn(e+" is deprecated, please use "+t+" instead.")}function ee(e){return"[object Object]"===Object.prototype.toString.call(e)}function te(e){return ee(e)?Object.keys(e).reduce((function(t,n){const r=ee(e[n]),i=r?te(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function ne(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?ne(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{ne(e,e.get(t),n)}))})))}function re(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&ne(e,n,i)}))})),i}const ie=Q;function oe(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let a=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&n.length&&t.includes("back")&&(a=n[n.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=r(e.video),ie("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return ie("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function ae(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function se(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else K(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function ce(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function ue(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>re(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),K(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>re(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,r;return this.getSenders().forEach((n=>{n.track===e&&(t?r=!0:t=n)})),this.getReceivers().forEach((t=>(t.track===e&&(n?r=!0:n=t),t.track===e))),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function le(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();n.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function de(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return le(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[n.id];if(i)i.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=s.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((n=>{this._streams[n].getTracks().find((t=>e.track===t))&&(t=this._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function he(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function pe(e,t){K(e,"negotiationneeded",(e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}function fe(e,t){const n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){Z("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function ve(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}function me(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ge(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!i)try{e.forEach((e=>{e.type=n[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(i,o)}}function ye(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function be(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),K(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function ke(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Z("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function Se(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function we(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const n=e.length>0;n&&e.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(n){const{sender:t}=r,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(n).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function Ce(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function xe(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function Te(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function _e(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((n=>t.call(this,n,e))),e.getVideoTracks().forEach((n=>t.call(this,n,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...n){return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach((e=>{n.includes(e.track)&&this.removeTrack(e)}))})}}function Re(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}))}),t.apply(e,arguments)}}}function Me(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,n){const r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){const r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){const r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}function Pe(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(Ee(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function Ee(e){return e&&void 0!==e.video?Object.assign({},e,{video:te(e.video)}):e}function Oe(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];void 0===r.urls&&r.url?(Z("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function De(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ae(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Ie(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Be=n(963),Le=n.n(Be);function je(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const n=new t(e),r=Le().parseCandidate(e.candidate);for(const e in r)e in n||Object.defineProperty(n,e,{value:r[e]});return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,K(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Fe(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||K(e,"icecandidate",(e=>{if(e.candidate){const t=Le().parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function Ve(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=Le().splitSections(e.sdp);return t.shift(),t.some((e=>{const t=Le().parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(e),r=function(e,n){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const i=Le().matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substring(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r}(arguments[0],e);let i;i=0===n&&0===r?Number.POSITIVE_INFINITY:0===n||0===r?Math.max(n,r):Math.min(n,r);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>i}),this._sctp=o}return n.apply(this,arguments)}}function Ue(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},K(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Ne(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}function He(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function We(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function ze(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.setLocalDescription;n&&0!==n.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return n.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return n.apply(this,[e]);return("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>n.apply(this,[e])))})}const qe=function({window:n}={},r={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const a=Q,s=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.userAgentData&&n.userAgentData.brands){const e=n.userAgentData.brands.find((e=>"Chromium"===e.brand));if(e)return{browser:"chrome",version:parseInt(e.version,10)}}if(n.mozGetUserMedia)t.browser="firefox",t.version=J(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=J(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=J(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(n),c={browserDetails:s,commonShim:o,extractVersion:J,disableLog:X,disableWarnings:Y,sdp:Be};switch(s.browser){case"chrome":if(!e||!he||!r.shimChrome)return a("Chrome shim is not included in this adapter release."),c;if(null===s.version)return a("Chrome shim can not determine version, not shimming."),c;a("adapter.js shimming chrome."),c.browserShim=e,We(n,s),ze(n),oe(n,s),ae(n),he(n,s),se(n),de(n,s),ce(n),ue(n),pe(n,s),je(n),Fe(n),Ne(n),Ve(n,s),Ue(n),He(n,s);break;case"firefox":if(!t||!ge||!r.shimFirefox)return a("Firefox shim is not included in this adapter release."),c;a("adapter.js shimming firefox."),c.browserShim=t,We(n,s),ze(n),fe(n,s),ge(n,s),me(n),ke(n),ye(n),be(n),Se(n),we(n),Ce(n),xe(n),Te(n),je(n),Ne(n),Ve(n,s),Ue(n);break;case"safari":if(!i||!r.shimSafari)return a("Safari shim is not included in this adapter release."),c;a("adapter.js shimming safari."),c.browserShim=i,We(n,s),ze(n),Oe(n),Ae(n),Me(n),_e(n),Re(n),De(n),Pe(n),Ie(n),je(n),Fe(n),Ve(n,s),Ue(n),He(n,s);break;default:a("Unsupported browser!")}return c}({window:"undefined"==typeof window?void 0:window}),Ge=qe;var $e=n(503),Je=n.n($e),Ke=n(916),Xe=n.n(Ke);const Ye=function(){return d((function e(){c(this,e),this.onChange=this.onChange.bind(this),this.hasSupport=Boolean(Xe().isEnabled)}),[{key:"toggle",value:function(e,t){return this.hasSupport?Xe().toggle(e,t):null}},{key:"canFullscreen",value:function(){return this.hasSupport}},{key:"isFullscreen",value:function(){return this.hasSupport&&Xe().isFullscreen}},{key:"onChange",value:function(e){this.hasSupport&&Xe().on("change",(function(t){var n=t.target;return e(Xe().isFullscreen,n)}))}},{key:"off",value:function(){this.hasSupport&&Xe().off("change")}}])}();var Qe=function(e){return"object"===s(e)&&null!==e},Ze=null;const et={environment:function(){return{canMix:this.canMix(),canPip:this.hasPipSupport(),canSFU:this.canSFU(),isPhone:this.isPhone(),inIframe:this.inIframe(),isIOSDevice:this.isIOSDevice(),canUseEyeson:this.canUseEyeson(),canFullscreen:this.canFullscreen(),hasMobileDevice:this.hasMobileDevice(),canToggleCamera:this.canToggleCamera(),canPresentFiles:this.canPresentFiles(),canScreenCapture:this.canScreenCapture(),canAdjustSettings:this.canAdjustDeviceSettings(),canStreamLocalMedia:this.canStreamLocalMedia(),isExperimentalBrowser:this.isExperimentalBrowser()}},platform:function(){return Je()},canUseEyeson:function(){return!this.isWebView()&&this.hasGetUserMedia()&&this.canDataChannel()&&this.isMinimumRequiredBrowser()},hasGetUserMedia:function(){return"mediaDevices"in navigator&&"getUserMedia"in navigator.mediaDevices},hasGetDisplayMedia:function(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices},hasPeerConnection:function(){return"RTCPeerConnection"in window},hasCaptureStream:function(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype},hasCanvasCaptureSupport:function(){return"CanvasCaptureMediaStream"in window||"CanvasCaptureMediaStreamTrack"in window},hasSenders:function(){return"RTCRtpSender"in window},hasTrackOnUnmute:function(){return!(this.isSafari()&&this.browserVersion()<13&&!this.isWorkingIOSBrowser())&&"onunmute"in MediaStreamTrack.prototype},hasWebpSupport:function(){return this.isChrome()?Ge.browserDetails.version>=70:!!this.isFF()&&Ge.browserDetails.version>=65},canChangeAudioOutput:function(){return!document||"setSinkId"in HTMLMediaElement.prototype},canChangeMicrophone:function(){var e=!1;return"safari"===Ge.browserDetails.browser&&(e=this.browserVersion()<12&&!this.isWorkingIOSBrowser()),!this.isTestSuite()&&!e},canMultipleDifferentMicrophones:function(){return!(this.isFF()&&this.browserVersion()<101)},canChangeCamera:function(){var e=!1;return"safari"===Ge.browserDetails.browser&&(e=this.browserVersion()<12&&!this.isWorkingIOSBrowser()),!this.isTestSuite()&&!e},canScreenCapture:function(){return!(!h.screencapture||this.isTestSuite()||!this.canUseEyeson()||this.hasMobileDevice())&&(this.hasGetDisplayMedia()||this.isFF()&&this.hasGetUserMedia())},canPresentFiles:function(){return!(this.isTestSuite()||!this.canUseEyeson()||this.isFF()&&Ge.browserDetails.version<=60||this.isIPhone()||this.isIOSDevice()&&this.browserVersion()<13&&!this.isWorkingIOSBrowser())},canStreamLocalMedia:function(){var e=window.AudioContext||window.webkitAudioContext;if("function"!=typeof e)return!1;var t=e.prototype;return["createGain","createMediaStreamSource","createMediaElementSource","createMediaStreamDestination"].every((function(e){return"function"==typeof t[e]}))&&this.hasCanvasCaptureSupport()},requiresLowerConstraints:function(){return this.isSafari()&&this.browserVersion()<13&&!this.isWorkingIOSBrowser()},browserName:function(){return Ge.browserDetails.browser.replace(/\w\S*/g,(function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}))},browserVersion:function(){return"safari"===Ge.browserDetails.browser?Ge.extractVersion(navigator.userAgent,/Version\/(\d+)\./,1):Ge.browserDetails.version},isEdge:function(){return"edge"===Ge.browserDetails.browser},isFF:function(){return"firefox"===Ge.browserDetails.browser},isChrome:function(){return"chrome"===Ge.browserDetails.browser},isSafari:function(){return"safari"===Ge.browserDetails.browser},isMinimumRequiredBrowser:function(){return this.isChrome()?this.isMinimumRequiredChrome():this.isFF()?this.isMinimumRequiredFF():!!this.isSafari()&&this.isMinimumRequiredSafari()},isMinimumRequiredEdge:function(){return!1},isMinimumRequiredFF:function(){return!!this.isFF()&&Ge.browserDetails.version>=52},isMinimumRequiredChrome:function(){return!!this.isChrome()&&Ge.browserDetails.version>=70},isMinimumRequiredSafari:function(){return!!this.isSafari()&&(this.browserVersion()>=10||this.isWorkingIOSBrowser())},isWorkingIOSBrowser:function(){var e=/ [a-zA-Z]+iOS\//.test(navigator.userAgent),t=navigator.userAgent.indexOf(" OPT/")>-1;return(e||t)&&this.hasGetUserMedia()},isExperimentalBrowser:function(){return["safari","edge"].includes(Ge.browserDetails.browser)},hasPipSupport:function(){return!document||Boolean("webkitSupportsPresentationMode"in HTMLVideoElement.prototype||"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled)},iOSPipCheck:function(){var e=this;return new Promise((function(t){var n=e.hasPipSupport();if(n&&e.isIOSDevice()){var r=document.createElement("video");r.preload="none",r.src="about:blank",r.onsuspend=function(){var e=r.webkitSupportsPresentationMode("picture-in-picture");t(e)}}else t(n)}))},isAndroidDevice:function(){return Boolean(navigator.userAgent.match(/Android/i))},isIOSDevice:function(){return(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!window.MSStream},isIPhone:function(){return(/iPhone/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1&&window.screen.height/window.screen.width>=1.5)&&!window.MSStream},isAndroidPhone:function(){var e=/(android)/i.test(navigator.userAgent),t=/(mobile)/i.test(navigator.userAgent);return e&&t},isMacOS:function(){return void 0!==navigator.userAgentData?"macOS"===navigator.userAgentData.platform:0===navigator.platform.indexOf("Mac")},inIframe:function(){try{return window.self!==window.top}catch(e){return!0}},isPhone:function(){return this.isIPhone()||this.isAndroidPhone()},hasMobileDevice:function(){return this.isIOSDevice()||this.isAndroidDevice()},isTouchDevice:function(){return Boolean("ontouchstart"in window||navigator.maxTouchPoints)},canDisplayTooltips:function(){return!this.isIOSDevice()&&!this.isTestSuite()},canAdjustDeviceSettings:function(){return!this.isIOSDevice()},canToggleCamera:function(){return!0},canDrawCamera:function(){return!this.isIOSDevice()},canMix:function(){return this.isChrome()&&this.canScreenCapture()&&this.hasCanvasCaptureSupport()},stopsDeviceActivityIndicatorOnDisable:function(){return!!this.isFF()},supportsBlurOnSVG:function(){return"undefined"!=typeof SVGElement&&void 0!==SVGElement.prototype.blur},hasLocalStorage:function(){try{var e=Qe(window.localStorage);window.localStorage.setItem("eyeson.test","test");var t="test"===window.localStorage.getItem("eyeson.test");return e&&t}catch(e){return f.debug("FeatureDetector::hasLocalStorage:",e.message),!1}},canFullscreen:function(){return(new Ye).canFullscreen()},isFullscreen:function(){return(new Ye).isFullscreen()},canSFU:function(){var e=!1;if(this.isSafari()){if(!h.allowSafariSFU)return!1;if(this.isWorkingIOSBrowser())return!0;var t=navigator.userAgent.match(/Version\/(\d+).(\d+)/);t&&t.length>1&&(e=Number(t[1])<12||12===Number(t[1])&&Number(t[2])<1)}return!e&&!this.isTestSuite()},canDataChannel:function(){return this.hasPeerConnection()&&"function"==typeof RTCPeerConnection.prototype.createDataChannel&&"RTCDataChannel"in window},disallowAudioSyncSrcChange:function(){return this.isSafari()&&this.canSFU()},canShare:function(){return Boolean(navigator.share)},isWebView:function(){return/Version\/|wv/i.test(navigator.userAgent)&&this.isAndroidDevice()},isTestSuite:function(){return"test-suite"===Ge.browserDetails.browser},canVirtualBackground:function(){return!this.isIOSDevice()&&Boolean(window.WebAssembly)&&"function"==typeof WebAssembly.validate&&("function"==typeof WebAssembly.instantiateStreaming||"function"==typeof WebAssembly.instantiate)&&Boolean(window.CanvasRenderingContext2D)&&"function"==typeof window.ImageData&&"function"==typeof window.requestAnimationFrame},canvasBlurSupport:function(){if(null!==Ze)return Ze;if(!(window.CanvasRenderingContext2D&&"filter"in CanvasRenderingContext2D.prototype))return Ze=!1;var e=document.createElement("canvas"),t=document.createElement("canvas");e.width=10,e.height=10,t.width=10,t.height=10;var n=e.getContext("2d"),r=t.getContext("2d");n.filter="blur(5px)",n.fillStyle="#000000",n.fillRect(3,3,4,4),r.fillStyle="#000000",r.fillRect(3,3,4,4);var i=n.getImageData(5,5,1,1),o=r.getImageData(5,5,1,1);return Ze=i.data[3]!==o.data[3]},canStereo:function(){return!(this.isSafari()||this.isAndroidDevice())},canChooseDisplaySurface:function(){return this.hasGetDisplayMedia()&&navigator.mediaDevices.getSupportedConstraints().displaySurface},hasPipCamSupport:function(){return this.isChrome()&&this.hasPipSupport()},canMonitorSystemPressure:function(){var e="object"!==s(document.featurePolicy)||"function"!=typeof document.featurePolicy.allowedFeatures||document.featurePolicy.allowedFeatures().includes("compute-pressure");return"function"==typeof window.PressureObserver&&Array.isArray(PressureObserver.knownSources)&&PressureObserver.knownSources.includes("cpu")&&e},canSetCodecs:function(){return this.canSetCodecPreferences()||this.canSetCodecsLegacy()},canSetCodecPreferences:function(){return window.RTCRtpTransceiver&&"function"==typeof RTCRtpTransceiver.prototype.setCodecPreferences},canSetCodecsLegacy:function(){var e=window.RTCPeerConnection&&"addTransceiver"in RTCPeerConnection.prototype;return!this.canSetCodecPreferences()&&e},canGeolocation:function(){return Reflect.has(window,"navigator")&&Reflect.has(navigator,"geolocation")&&"function"==typeof navigator.geolocation.getCurrentPosition}};const tt=function(){return d((function e(){c(this,e),this._stream=this.createStream()}),[{key:"stream",get:function(){return this._stream}},{key:"createStream",value:function(){var e=Object.assign(document.createElement("canvas"),{width:0,height:0});e.id="eyeson-ninja-stream",e.getContext("2d").fillRect(0,0,0,0);var t=e.captureStream(),n=N(t.getVideoTracks(),1)[0];return window.CanvasCaptureMediaStream&&t instanceof window.CanvasCaptureMediaStream&&(n.type="canvas-track",n.canvas=e),t}}])}();var nt,rt,it;const ot=(nt="eyeson.",rt={},it=et.hasLocalStorage(),{store:function(e,t){if(!it)return rt[e]=t,!0;try{window.localStorage.setItem(nt+e,JSON.stringify(t))}catch(e){return f.error("LocalStorage::store",e),!1}return!0},load:function(e,t){var n=t;if(Qe(n)&&!Array.isArray(n)&&(n=Object.assign({},n)),!it)return rt[e]||n;var r=window.localStorage.getItem(nt+e);if(!r)return n;try{return JSON.parse(r)}catch(t){return f.error("LocalStorage::load",e,t),n}}});var at=window.CanvasCaptureMediaStream||window.CanvasCaptureMediaStreamTrack,st=function(e){return Boolean(e&&e.getAudioTracks().length>0&&e.getAudioTracks()[0].enabled)},ct=function(e){return Boolean(e&&e.getVideoTracks().length>0&&e.getVideoTracks()[0].enabled)},ut=function(e){return e&&e.getAudioTracks().forEach((function(e){return e.enabled=!1})),e},lt=function(e){return e&&e.getAudioTracks().forEach((function(e){return e.enabled=!0})),e},dt=function(e,t){return e&&e.getAudioTracks().forEach((function(e){return e.enabled=t})),e},ht=function(e,t){return e&&e.getVideoTracks().forEach((function(e){return e.enabled=t})),e},pt=function(e){return e.stop(),e.dispatchEvent(new Event("stopped"))},ft=function(e){e&&e.getTracks().forEach(pt)},vt=function(e){return/screen|monitor|window|web-contents-media-stream/i.test(e.label)||"screen-track"===e.type||"screen-video-track"===e.type},mt=function(e){return vt(e)&&"screen-video-track"!==e.type},gt=function(e){return vt(e)&&"screen-video-track"===e.type},yt=function(e){return Boolean(("canvas-track"===e.type||e instanceof at)&&e.canvas&&"eyeson-ninja-stream"!==e.canvas.id&&"eyeson-vbg-stream"!==e.canvas.id)},bt=function(e){return Boolean(("canvas-track"===e.type||e instanceof at)&&e.canvas&&"eyeson-ninja-stream"===e.canvas.id)},kt=function(e){return Boolean(("canvas-track"===e.type||e instanceof at)&&e.canvas&&"eyeson-vbg-stream"===e.canvas.id)},St=function(e){return!yt(e)&&!vt(e)&&!kt(e)},wt=function(e){return e?e.getVideoTracks().filter(vt):[]},Ct=function(e){return e?e.getVideoTracks().filter(mt):[]},xt=function(e){return e?e.getVideoTracks().filter(gt):[]},Tt=function(e){return e?e.getVideoTracks().filter(St):[]},_t=function(e){return e?e.getVideoTracks().filter(kt):[]},Rt=function(e){Tt(e).forEach(pt)},Mt=function(e){return Tt(e).forEach((function(e){return e.enabled=!1})),e},Pt=function(e){return Tt(e).forEach((function(e){return e.enabled=!0})),e},Et=function(e,t){return Tt(e).forEach((function(e){return e.enabled=t})),e},Ot=function(e,t){return _t(e).forEach((function(e){return e.enabled=t})),e},Dt=function(e){return e instanceof at?e.getVideoTracks():e?e.getVideoTracks().filter(yt):[]},At=function(e){return ct(e)&&e.getVideoTracks().some(vt)},It=function(e){return ct(e)&&e.getVideoTracks().some(mt)},Bt=function(e){return!(!et.hasCanvasCaptureSupport()||!e)&&e.getVideoTracks().some(yt)},Lt=function(e){return!(!et.hasCanvasCaptureSupport()||!e)&&(ct(e)&&e.getVideoTracks().some(kt))},jt=function(e){return ct(e)&&!At(e)&&!Bt(e)&&!Lt(e)},Ft=function(e){return!!e&&(Bt(e)&&e.getVideoTracks().some(yt))},Vt=function(e){return It(e)||Bt(e)},Ut=function(e){return Tt(e).some((function(e){return e.enabled}))},Nt=function(e){var t=Tt(e);if(t.length>0){var n=N(t,1)[0];if("function"==typeof n.getSettings){var r=n.getSettings();if(r&&"facingMode"in r)return r.facingMode}}return null},Ht=function(e){e.getContext("2d");var t=e.captureStream(20),n=N(t.getVideoTracks(),1)[0];return"requestFrame"in n||(n.type="canvas-track",n.canvas=e,n.requestFrame=function(){return t.requestFrame()}),t},Wt=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&e instanceof MediaStream&&e.getTracks().length>0){var n=e.getAudioTracks().find((function(e){return"live"===e.readyState})),r=e.getVideoTracks().find((function(e){return"live"===e.readyState})),i=n||function(){try{var e=new(window.AudioContext||window.webkitAudioContext),t=e.createMediaStreamDestination().stream,n=N(t.getAudioTracks(),1)[0];return n.type="fake-audio",n.enabled=!1,ft(t),e.close(),n}catch(e){f.warn("StreamHelpers::createFakeAudioTrack Unable to create audio track",e)}return null}(),o=r||function(){try{var e=document.createElement("canvas");e.getContext("2d").fillRect(0,0,e.width,e.height);var t=e.captureStream(),n=N(t.getVideoTracks(),1)[0];return n.type="fake-video",n.enabled=!1,ft(t),n}catch(e){f.warn("StreamHelpers::createFakeVideoTrack Unable to create video track",e)}return null}(),a=[];return i&&a.push(i),o&&!t&&a.push(o),new MediaStream(a)}return!1},zt="",qt=function(){var e=F(W().mark((function e(){var t,n,r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,zt){e.next=11;break}return t=new RTCPeerConnection,n=t.addTransceiver("audio"),r=t.addTransceiver("video"),n.direction="sendonly",r.direction="sendonly",e.next=9,t.createOffer();case 9:i=e.sent,zt=i.sdp;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(0),f.error("initLegacySenderCodecs",e.t0);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),Gt=function(e){if(!zt)return[];var t=Le().getMediaSections(zt),n=[];return t.forEach((function(t){var r=Le().getKind(t);if(r===e){var i=Le().parseRtpParameters(t),o=!1;i.codecs.forEach((function(e){if(!o||"rtx"!==e.name){var t={clockRate:e.clockRate,mimeType:"".concat(r,"/").concat(e.name)};"audio"===r&&(t.channels=e.channels);var i,a=(i=e.parameters,Object.entries(i).map((function(e){var t=N(e,2),n=t[0],r=t[1];return r?"".concat(n,"=").concat(r):n})).join(";"));a&&"rtx"!==e.name&&(t.sdpFmtpLine=a),n.push(t),"rtx"===e.name&&(o=!0)}}))}})),n},$t=function(e){try{if(et.canSetCodecsLegacy())return Gt(e);if(et.canSetCodecPreferences())return function(e){var t=RTCRtpReceiver.getCapabilities(e).codecs.map((function(e){return JSON.stringify(e)}));return RTCRtpSender.getCapabilities(e).codecs.map((function(e){return JSON.stringify(e)})).map((function(n){var r=t.find((function(e){return n===e})),i=JSON.parse(n);if(!r&&!i.sdpFmtpLine){var o=RTCRtpReceiver.getCapabilities(e).codecs.find((function(e){return e.mimeType===i.mimeType}));if(o)return o}return i}))}(e)}catch(e){f.error("StreamHelpers::getSenderCodecs",e)}return[]};const Jt=function(){var e=[],t="com.eyeson.immediate";window.addEventListener("message",(function(n){if(n.source===window&&n.data===t){n.stopPropagation();var r=e.shift();r&&r()}}));return function(n){e.push(n),window.postMessage(t,"*")}}();const Kt=function(e,t){var n=null,r=!0,i=!1,o=0,a=1e3/t,s=function(){var t=Date.now(),r=t-o;r<=a?n=requestAnimationFrame(s):(o=t-r%a,e())},c=function(){var t=Date.now(),n=t-o;n<=a?Jt(c):(o=t-n%a,i||e())},u={requestAnimationFrame:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(){r?n=requestAnimationFrame(s):(i&&(i=!1),Jt(c))})),cancelAnimationFrame:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(){i=!0,n&&(cancelAnimationFrame(n),n=null)}))};return document.addEventListener("visibilitychange",(function(){!(r="visible"===document.visibilityState)&&n&&(u.cancelAnimationFrame(),u.requestAnimationFrame())})),u};const Xt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new Promise((function(n,r){var i=new URL(e,location.href),o=document.createElement("script");o.async=!0,o.onload=function(){o.parentNode&&o.remove(),n(o)},o.onerror=function(){o.parentNode&&o.remove(),r(new Error("Unable to initiate script "+e))},t&&(o.integrity=t.algo+"-"+t.hash),o.src=i,document.head.append(o)}))};var Yt="function"==typeof window.CacheStorage;const Qt={storeBlobURL:function(){var e=F(W().mark((function e(t,n){var r,i,o;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Yt){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,fetch(t);case 5:return r=e.sent,e.next=8,r.blob();case 8:return i=e.sent,e.next=11,caches.open("store");case 11:return o=e.sent,e.next=14,o.put(n,new Response(i));case 14:e.next=18;break;case 16:e.prev=16,e.t0=e.catch(2);case 18:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t,n){return e.apply(this,arguments)}}(),loadBlobURL:function(){var e=F(W().mark((function e(t){var n,r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Yt){e.next=16;break}return e.prev=1,e.next=4,caches.open("store");case 4:return n=e.sent,e.next=7,n.match(t);case 7:return r=e.sent,e.next=10,r.blob();case 10:return i=e.sent,e.abrupt("return",URL.createObjectURL(i));case 14:e.prev=14,e.t0=e.catch(1);case 16:return e.abrupt("return",!1);case 17:case"end":return e.stop()}}),e,null,[[1,14]])})));return function(t){return e.apply(this,arguments)}}(),deleteBlob:function(){var e=F(W().mark((function e(t){var n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Yt){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,caches.open("store");case 5:return n=e.sent,e.next=8,n.delete(t);case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}()};var Zt=[1,57,41,21,203,34,97,73,227,91,149,62,105,45,39,137,241,107,3,173,39,71,65,238,219,101,187,87,81,151,141,133,249,117,221,209,197,187,177,169,5,153,73,139,133,127,243,233,223,107,103,99,191,23,177,171,165,159,77,149,9,139,135,131,253,245,119,231,224,109,211,103,25,195,189,23,45,175,171,83,81,79,155,151,147,9,141,137,67,131,129,251,123,30,235,115,113,221,217,53,13,51,50,49,193,189,185,91,179,175,43,169,83,163,5,79,155,19,75,147,145,143,35,69,17,67,33,65,255,251,247,243,239,59,29,229,113,111,219,27,213,105,207,51,201,199,49,193,191,47,93,183,181,179,11,87,43,85,167,165,163,161,159,157,155,77,19,75,37,73,145,143,141,35,138,137,135,67,33,131,129,255,63,250,247,61,121,239,237,117,29,229,227,225,111,55,109,216,213,211,209,207,205,203,201,199,197,195,193,48,190,47,93,185,183,181,179,178,176,175,173,171,85,21,167,165,41,163,161,5,79,157,78,154,153,19,75,149,74,147,73,144,143,71,141,140,139,137,17,135,134,133,66,131,65,129,1],en=[0,9,10,10,14,12,14,14,16,15,16,15,16,15,15,17,18,17,12,18,16,17,17,19,19,18,19,18,18,19,19,19,20,19,20,20,20,20,20,20,15,20,19,20,20,20,21,21,21,20,20,20,21,18,21,21,21,21,20,21,17,21,21,21,22,22,21,22,22,21,22,21,19,22,22,19,20,22,22,21,21,21,22,22,22,18,22,22,21,22,22,23,22,20,23,22,22,23,23,21,19,21,21,21,23,23,23,22,23,23,21,23,22,23,18,22,23,20,22,23,23,23,21,22,20,22,21,22,24,24,24,24,24,22,21,24,23,23,24,21,24,23,24,22,24,24,22,24,24,22,23,24,24,24,20,23,22,23,24,24,24,24,24,24,24,23,21,23,22,23,24,24,24,22,24,24,24,23,22,24,24,25,23,25,25,23,24,25,25,24,22,25,25,25,24,23,24,25,25,25,25,25,25,25,25,25,25,25,25,23,25,23,24,25,25,25,25,25,25,25,25,25,24,22,25,25,23,25,25,20,24,25,24,25,25,22,24,25,24,25,24,25,25,24,25,25,25,25,22,25,25,25,24,25,24,25,18];const tn=function(){var e=null,t=null,n=!1,r=null,i=null,o=null,a=null,s=null;return{run:function(c){if(n&&e)return n=!1,e;n=!0;var u=parseFloat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:0),l=c.width,d=c.height;e||(e=document.createElement("canvas"),t=e.getContext("2d",{alpha:!1,desynchronized:!0}),e.width=l,e.height=d),t.drawImage(c,0,0);var h=t.getImageData(0,0,l,d),p=h.data,f=l-1,v=d-1,m=u+1,g=Zt[u],y=en[u];r||(r=new Uint32Array(p.length/4),i=new Uint32Array(p.length/4),o=new Uint32Array(p.length/4),a=new Uint32Array(l),s=new Uint32Array(l));for(var b=2,k=0,S=0,w=0;b-- >0;){for(var C=0,x=0,T=0;T<d;T++){for(var _=p[C]*m,R=p[C+1]*m,M=p[C+2]*m,P=1;P<=u;P++)k=C+((P>f?f:P)<<2),_+=p[k++],R+=p[k++],M+=p[k++];for(var E=0;E<l;E++)r[x]=_,i[x]=R,o[x]=M,0===T&&(a[E]=((k=E+m)<f?k:f)<<2,s[E]=(k=E-u)>0?k<<2:0),S=C+a[E],w=C+s[E],_+=p[S++]-p[w++],R+=p[S++]-p[w++],M+=p[S++]-p[w++],x++;C+=l<<2}for(var O=0;O<l;O++){for(var D=O,A=r[D]*m,I=i[D]*m,B=o[D]*m,L=1;L<=u;L++)A+=r[D+=L>v?0:l],I+=i[D],B+=o[D];x=O<<2;for(var j=0;j<d;j++)p[x]=A*g>>>y,p[x+1]=I*g>>>y,p[x+2]=B*g>>>y,0===O&&(a[j]=((k=j+m)<v?k:v)*l,s[j]=(k=j-u)>0?k*l:0),S=O+a[j],w=O+s[j],A+=r[S]-r[w],I+=i[S]-i[w],B+=o[S]-o[w],x+=l<<2}}return t.putImageData(h,0,0),e},reset:function(){e=null,t=null,n=!1,r=null,i=null,o=null,a=null,s=null}}};window.exports=window.exports||{};var nn="function"==typeof window.OffscreenCanvas&&function(){try{return new OffscreenCanvas(1,1).getContext("2d"),!0}catch(e){}return!1}(),rn=nn&&Boolean(window.OffscreenCanvasRenderingContext2D)&&"filter"in OffscreenCanvasRenderingContext2D.prototype,on="function"==typeof window.createImageBitmap,an="function"==typeof window.MediaStreamTrackProcessor,sn=window.WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11])),cn=function(){try{return new EventTarget,!0}catch(e){}return!1}(),un=Math.max,ln=cn?new EventTarget:document.createElement("i"),dn="selfie_segmentation_landscape",hn=256,pn=144,fn=36864,vn=null,mn=!1,gn=!1,yn=null,bn=null,kn=null,Sn=null,wn=function(){var e=F(W().mark((function e(){var t,n,r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!vn){e.next=2;break}return e.abrupt("return");case 2:return gn=!0,ln.dispatchEvent(new Event("change")),t=h.vbgScriptPath,e.next=7,Promise.all([Xt(sn?t+"tflite-simd.js":t+"tflite.js"),fetch("".concat(t,"models/").concat(dn,".tflite"))]);case 7:return n=e.sent,e.next=10,window.exports[sn?"createTFLiteSIMDModule":"createTFLiteModule"]();case 10:return vn=e.sent,e.next=13,n[1].arrayBuffer();case 13:r=e.sent,i=vn._getModelBufferMemoryOffset(),vn.HEAPU8.set(new Uint8Array(r),i),vn._loadModel(r.byteLength),yn=vn._getInputMemoryOffset()/4,bn=vn._getOutputMemoryOffset()/4,gn=!1,mn=!0,ln.dispatchEvent(new Event("change"));case 22:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Cn=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={canvas:null,ctx:null};return nn&&("blur"===(arguments.length>3?arguments[3]:void 0)&&rn)?(r.canvas=new OffscreenCanvas(e,t),r.ctx=r.canvas.getContext("2d",n),r):(r.canvas=document.createElement("canvas"),r.canvas.width=e,r.canvas.height=t,r.ctx=r.canvas.getContext("2d",Object.assign({desynchronized:!0},n)),r)};F(W().mark((function e(){var t;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("image:blob"!==ot.load("virtualBackgroundType")){e.next=6;break}return e.next=4,Qt.loadBlobURL("/virtualBackgroundLocalImage");case 4:(t=e.sent)&&(kn=t);case 6:case"end":return e.stop()}}),e)})))();var xn,Tn=function(e,t){return new Promise((function(n){if(t&&"ready"===t.state&&t.emitLoading(!0),"blob"!==e||kn){var r=new Image;r.onerror=function(){return n(null)},r.onload=function(){return n(r)},/^([\w]+:)?\/\//.test(e)&&-1===e.indexOf(location.host)&&(r.crossOrigin="anonymous"),r.src="blob"===e&&kn?kn:e}else n(null)})).then((function(e){return t&&"ready"===t.state&&t.emitLoading(!1),e}))},_n=function(e){return new Promise((function(t,n){var r=new Image;r.onerror=function(){return n(new TypeError("Invalid image file"))},r.onload=function(){return t()},/^([\w]+:)?\/\//.test(e)&&-1===e.indexOf(location.host)&&(r.crossOrigin="anonymous"),r.src=e}))},Rn=(xn=null,function(e){xn||(xn=Object.assign(document.createElement("input"),{type:"file",accept:"image/*"})),xn.onchange=function(t){var n=t.target.files;if(n.length>0){var r=URL.createObjectURL(n[0]);_n(r).then((function(){kn&&kn!==Sn&&URL.revokeObjectURL(kn),kn=r,e()}),e)}xn.onchange=null,xn.value=""},xn.click()}),Mn=function(e,t,n){var r=t/e.width,i=n/e.height,o=un(r,i),a=e.width*o,s=e.height*o,c=(t-a)/2,u=(n-s)/2,l=Cn(t,n,{alpha:!1});return l.ctx.drawImage(e,0,0,e.width,e.height,c,u,a,s),l.canvas},Pn=function(e,t,n){var r=Cn(t,n,{alpha:!1}),i=r.ctx;return i.fillStyle="#ffffff",i.fillRect(0,0,t,n),i.drawImage(e,15,15),r.canvas},En=function(e,t,n){var r=Cn(e,t,{alpha:!1}),i=r.ctx,o=i.createLinearGradient(n.startX,n.startY,n.endX,n.endY);return o.addColorStop(0,n.color1),o.addColorStop(1,n.color2),i.fillStyle=o,i.fillRect(0,0,e,t),r.canvas},On=function(e,t,n,r){var i=2*(2*r),o=t+i,a=n+i;e.blurCanvas=Cn(o,a,{alpha:!1},"blur"),e.imageCanvas=Cn(o,a,{alpha:!1}),e.blurCanvas.ctx.filter="blur(".concat(r,"px)")},Dn=/^(off|eyeson|generali:.*|color:.+|image:.+|blur:\d+)/,An=function(){return mn?"ready":gn?"initialize":""};const In=function(){return d((function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"global";c(this,e),f.info("VirtualBackgroundMixer::constructor",n),this.name=n,this.canvas=null,this.ctx=null,this.originalStream=null,this.outStream=null,this.video=null,this.reader=null,this.size={width:0,height:0},this.segmentationMaskCanvas=null,this.segmentationMaskCtx=null,this.segmentationMask=null,this.videoCanvas=null,this.videoCtx=null,this.playPromise=null,this.abort=!1,this.paused=!1,this.raf=Kt(this.drawVideo.bind(this),20),this.backgroundOld=null,this.backgroundType=null,this.backgroundValue=null,this.blurInit=!1,this.blurCanvas=null,this.canvasBlur=tn(),this.imageCanvas=null,this.state=An(),this.loadingListener=[],this.handleStateChange=function(){var e=An();t.state=e,t.emitLoading("initialize"===e)},ln.addEventListener("change",this.handleStateChange)}),[{key:"storeLocalImageFile",value:function(){kn&&(Sn=kn)}},{key:"resetLocalImageFile",value:function(){Sn&&(kn&&kn!==Sn&&URL.revokeObjectURL(kn),kn=Sn,Sn=null)}},{key:"saveLocalImageFile",value:function(){Sn&&(kn&&kn!==Sn&&URL.revokeObjectURL(Sn),Sn=null)}},{key:"updateCache",value:function(e){"image:blob"===e?kn&&Qt.storeBlobURL(kn,"/virtualBackgroundLocalImage"):Qt.deleteBlob("/virtualBackgroundLocalImage")}},{key:"onLoading",value:function(e){this.loadingListener.push(e)}},{key:"offLoading",value:function(e){this.loadingListener=this.loadingListener.filter((function(t){return t!==e}))}},{key:"emitLoading",value:function(e){this.loadingListener.forEach((function(t){return t(e)}))}},{key:"initiateStream",value:function(e){var t=this;f.info("VirtualBackgroundMixer::initiate",this.name),wn();var n=e.getVideoTracks();if(0===n.length)return f.warn("VirtualBackgroundMixer::initiate",this.name,"missing track"),e;var r=N(n,1)[0],i=r.getSettings();if("live"!==r.readyState||!i.width||!i.height)return f.warn("VirtualBackgroundMixer::initiate",this.name,"0 width or height, or not ready",r.readyState,i.width,i.height),e;this.originalStream&&(f.warn("VirtualBackgroundMixer::initiate",this.name,"existing originalStream!",this.originalStream.id,e.id),this.originalStream.id!==e.id&&this.stopOriginalStream(),this.terminate()),this.originalStream=e,this.canvas=document.createElement("canvas"),this.canvas.id="eyeson-vbg-stream",this.ctx=this.canvas.getContext("2d",{desynchronized:!0}),this.ctx.imageSmoothingEnabled=!1,this.size.width=i.width,this.size.height=i.height,this.canvas.width=i.width,this.canvas.height=i.height;var o=N(this.canvas.captureStream(20).getVideoTracks(),1)[0];o.canvas||(o.type="canvas-track",o.canvas=this.canvas);var a={};return"function"==typeof o.getSettings&&Object.assign(a,o.getSettings()),Object.assign(a,i),o.getSettings=function(){return a},o.srcLabel=r.label,o.srcDeviceId=i.deviceId,this.outStream=new MediaStream([o]),e.getAudioTracks().forEach((function(e){return t.outStream.addTrack(e)})),this.start(),this.outStream}},{key:"start",value:function(){var e=this;f.info("VirtualBackgroundMixer::start",this.name);var t=null,n=null,r=this.size,i=r.width,o=r.height;if(i&&o){if(an)try{var a=N(this.originalStream.getVideoTracks(),1)[0],s=new MediaStreamTrackProcessor(a);this.reader=s.readable.getReader()}catch(e){}this.reader||((n=document.createElement("video")).playsInline=!0,n.muted=!0,n.width=i,n.height=o,n.srcObject=this.originalStream,this.video=n),this.segmentationMask=new ImageData(hn,pn),t=Cn(hn,pn,{willReadFrequently:!0}),this.segmentationMaskCanvas=t.canvas,this.segmentationMaskCtx=t.ctx,this.segmentationMaskCtx.imageSmoothingEnabled=!1,n&&!on&&(t=Cn(i,o),this.videoCanvas=t.canvas,this.videoCtx=t.ctx),this.abort=!1,this.paused=!1,this.blurInit=!1,this.canvasBlur.reset(),this.initBackground(),this.reader?(f.info("VirtualBackgroundMixer::start::videoTrackProcessor",this.name),this.raf.requestAnimationFrame()):(n.onloadeddata=function(){f.info("VirtualBackgroundMixer::start::video.loadeddata",e.name),e.raf.requestAnimationFrame()},this.playPromise=n.play(),this.playPromise.catch((function(t){f.error("VirtualBackgroundMixer::start::video.play",e.name,t)})))}else f.warn("VirtualBackgroundMixer::start 0 width or height",this.name,i,o)}},{key:"drawVideo",value:(n=F(W().mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,p,f,v,m,g,y,b;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.abort){e.next=3;break}return e.abrupt("return");case 3:if(n=this.ctx,r=this.size,i=this.paused,o=this.segmentationMask,a=this.segmentationMaskCtx,s=this.segmentationMaskCanvas,!this.reader){e.next=15;break}return e.prev=5,e.next=8,this.reader.read();case 8:c=e.sent,(u=c.value)&&(u.width=u.displayWidth,u.height=u.displayHeight,t=u),e.next=15;break;case 13:e.prev=13,e.t0=e.catch(5);case 15:if(mn&&!i){e.next=19;break}n.drawImage(t||this.video,0,0),e.next=36;break;case 19:if(t){e.next=33;break}if(!on){e.next=31;break}return e.prev=21,e.next=24,createImageBitmap(this.video);case 24:t=e.sent,e.next=29;break;case 27:e.prev=27,e.t1=e.catch(21);case 29:e.next=33;break;case 31:this.videoCtx.drawImage(this.video,0,0),t=this.videoCanvas;case 33:if(!this.abort){e.next=35;break}return e.abrupt("return");case 35:if(t&&t.width>0&&t.height>0){for(a.drawImage(t,0,0,t.width,t.height,0,0,hn,pn),l=a.getImageData(0,0,hn,pn),d=l.data,h=vn.HEAPF32,p=o.data,f=fn,v=0,m=0,g=0;g<f;g++)m=4*g,h[v=yn+3*g]=d[m]/255,h[v+1]=d[m+1]/255,h[v+2]=d[m+2]/255;for(vn._runInference(),y=0,b=0;y<f;y++)b=h[bn+y],p[4*y+3]=b<.5?255*b:255;a.putImageData(o,0,0),n.globalCompositeOperation="copy",n.filter="blur(2px)",n.drawImage(s,0,0,hn,pn,0,0,r.width,r.height),n.globalCompositeOperation="source-in",n.filter="none",n.drawImage(t,0,0),this.backgroundType&&this.drawBackground(t)}case 36:!i&&this.paused&&(n.filter="none",n.globalCompositeOperation="source-over"),t&&"function"==typeof t.close&&t.close(),this.abort||this.raf.requestAnimationFrame();case 39:case"end":return e.stop()}}),e,this,[[5,13],[21,27]])}))),function(){return n.apply(this,arguments)})},{key:"suspend",value:function(){var e=this.ctx;this.paused=!0,e&&(e.filter="none",e.globalCompositeOperation="source-over")}},{key:"resume",value:function(){this.paused=!1}},{key:"drawBackground",value:function(e){var t=this.backgroundType,n=this.ctx,r=this.blurCanvas,i=this.imageCanvas,o=this.backgroundValue,a=this.size;if(t&&n)if(n.globalCompositeOperation="destination-over","blur"===t)if(et.canvasBlurSupport()){var s=2*Number(o),c=2*s;this.blurInit||(i.ctx.drawImage(e,0,0,a.width,a.height,0,0,a.width+c,a.height+c),this.blurInit=!0),i.ctx.drawImage(e,0,0,a.width,a.height,s,s,a.width,a.height),r.ctx.drawImage(i.canvas,0,0),n.drawImage(r.canvas,s,s,a.width,a.height,0,0,a.width,a.height)}else{var u=this.canvasBlur.run(e,o);n.drawImage(u,0,0)}else"color"===t?(n.fillStyle=o,n.fillRect(0,0,a.width,a.height)):i?n.drawImage(i,0,0):n.drawImage(e,0,0)}},{key:"initBackground",value:(t=F(W().mark((function e(){var t,n,r,i,o,a,s,c;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.backgroundType,n=this.backgroundValue,r=this.size,i=r.width,o=r.height,a=!1,i&&o){e.next=5;break}return e.abrupt("return");case 5:if("eyeson"!==t){e.next=10;break}this.imageCanvas=En(i,o,{startX:0,startY:0,endX:i,endY:50,color1:"#ff7676",color2:"#9e206c"}),a=!0,e.next=27;break;case 10:if("generali"!==t){e.next=18;break}return this.setBackgroundFallback(),e.next=14,Tn(n,this);case 14:(s=e.sent)&&(this.backgroundType="image",this.backgroundValue=n,this.imageCanvas=Pn(s,i,o),a=!0),e.next=27;break;case 18:if("image"!==t){e.next=26;break}return this.setBackgroundFallback(),e.next=22,Tn(n,this);case 22:(c=e.sent)&&(this.backgroundType="image",this.backgroundValue=n,this.imageCanvas=Mn(c,i,o),a=!0),e.next=27;break;case 26:"blur"===t?(this.blurInit=!1,On(this,i,o,Number(n)),this.canvasBlur.reset(),a=!0):(this.imageCanvas=null,a=!0);case 27:a&&(this.backgroundOld={type:t,value:n});case 28:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"setBackgroundFallback",value:function(){var e=this.backgroundOld;if(e)this.backgroundType=e.type,this.backgroundValue=e.value;else{if(!this.imageCanvas){var t=this.size,n=t.width,r=t.height;this.blurInit=!1,On(this,n,r,8)}this.backgroundType="blur",this.backgroundValue="8"}}},{key:"changeBackground",value:function(e){if(f.info("VirtualBackgroundMixer::changeBackground",this.name,e),"string"==typeof e){var t=e.indexOf(":");-1===t?(this.backgroundType="off"===e?null:e,this.backgroundValue=null):(this.backgroundType=e.substring(0,t),this.backgroundValue=e.substring(t+1)),this.abort||this.initBackground()}}},{key:"stop",value:function(){if(f.info("VirtualBackgroundMixer::stop",this.name),this.abort=!0,this.raf&&this.raf.cancelAnimationFrame(),this.video){var e=this.video,t=this.playPromise;t&&e&&t.then((function(){return e.pause()})),this.video.onloadeddata=null,this.video=null,this.playPromise=null}this.reader&&(this.reader=null),this.segmentationMaskCanvas=null,this.segmentationMaskCtx=null,this.segmentationMask=null,this.videoCanvas=null,this.videoCtx=null,this.backgroundOld=null,this.imageCanvas=null,this.blurCanvas=null,this.canvasBlur.reset()}},{key:"stopOriginalStream",value:function(){f.info("VirtualBackgroundMixer::stopOriginalStream",this.name,this.originalStream),this.stop(),ft(this.originalStream)}},{key:"terminate",value:function(){var e=this;f.info("VirtualBackgroundMixer::terminate",this.name),this.stop(),this.outStream&&_t(this.outStream).forEach((function(t){pt(t),f.info("VirtualBackgroundMixer::terminate stop track",e.name,t)})),this.originalStream=null,this.outStream=null,this.canvas=null,this.ctx=null,this.video=null}},{key:"destroy",value:function(){f.info("VirtualBackgroundMixer::destroy",this.name),ln.removeEventListener("change",this.handleStateChange),this.loadingListener.length=0,this.canvasBlur=null}}],[{key:"isTypeAllowed",value:function(e){return Dn.test(e)}},{key:"checkExternalImage",value:(e=F(W().mark((function e(t){var n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!/^image:([\w]+:)?\/\//i.test(t)){e.next=4;break}return n=t.substring(6),e.next=4,_n(n);case 4:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})},{key:"loadLocalImage",value:function(e){Rn(e)}},{key:"getImageBlobOrFallback",value:function(){return kn&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])?"image:blob":"blur:8"}}]);var e,t,n}();var Bn=function(e,t){if(e.length!==t.length)return!0;for(var n,r=function(n,r){if(n=e[s],!(r=t.find((function(e){return n.deviceId===e.deviceId&&n.groupId===e.groupId&&n.label===e.label&&n.kind===e.kind}))))return{v:!0};i=n,o=r},i=null,o=!1,a=e.length,s=0;s<a;s++)if(n=r(i,o))return n.v;return!1},Ln=/virtual/i,jn=function(e,t){return Ln.test(e.label)&&Ln.test(t.label)?0:Ln.test(t.label)?-1:1};const Fn=function(){function e(t){var n=this;c(this,e),this.sinkId="default",this.options=t||{audio:!0,video:!0,eco:!1,audioPassthrough:!1},this.stream=null,this.cameras=[],this.listeners=[],this.speakers=[],this.microphones=[],this.constraints={},this.terminationInProgress=!1,this.virtualBackground=new In("DeviceManager"),this.virtualBackgroundType="off",e.getSinkId().then((function(e){return n.sinkId=e})),this.setStream=this.setStream.bind(this),this.handleError=this.handleError.bind(this),this.verifyStream=this.verifyStream.bind(this),this.storeConstraints=this.storeConstraints.bind(this),this.adjustAudioTrack=this.adjustAudioTrack.bind(this),this.initiateVirtualBackground=this.initiateVirtualBackground.bind(this)}return d(e,[{key:"setVirtualBackgroundType",value:(t=F(W().mark((function e(t){var n,r;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(In.isTypeAllowed(t)){e.next=3;break}return f.warn("DeviceManage::setVirtualBackgroundType type not allowed",t),e.abrupt("return");case 3:return e.next=5,In.checkExternalImage(t);case 5:n="off"===this.virtualBackgroundType,r="off"===t,this.virtualBackgroundType=t,this.virtualBackground.changeBackground(t),this.stream&&(n&&!r||!n&&r)&&this.update();case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"loadLocalImageForVirtualBackground",value:function(e){var t=this;In.loadLocalImage((function(n){n||t.setVirtualBackgroundType("image:blob"),e(n)}))}},{key:"start",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.watchForNewDevices();var r=n?"getMobileConstraints":"getConstraints";return e.fetchDevices().then((function(e){return t.setDevices(e)})).then((function(){return e[r](t.options)})).then((function(e){return t.constraints=e,navigator.mediaDevices.getUserMedia({video:!t.options.eco&&t.constraints.video,audio:t.constraints.audio||!0})})).then(this.adjustAudioTrack).then(this.initiateVirtualBackground).then(this.setStream).catch(this.handleError)}},{key:"stopStream",value:function(){this.stream&&(this.virtualBackground.originalStream?(this.virtualBackground.stopOriginalStream(),this.virtualBackground.terminate()):ft(this.stream),this.stream=null)}},{key:"stop",value:function(){this.stopStream()}},{key:"terminate",value:function(){var e=this;navigator.mediaDevices.ondevicechange=null,this.terminationInProgress=!0,window.setTimeout((function(){e.stop(),e.virtualBackground.destroy()}),10)}},{key:"setDevices",value:function(e){var t=Bn(this.cameras,e.cameras),n=Bn(this.microphones,e.microphones),r=Bn(this.speakers,e.speakers);this.cameras=e.cameras,this.microphones=e.microphones,this.speakers=e.speakers,this.options.audio=this.microphones.length>0&&this.options.audio,this.options.video=this.cameras.length>0&&this.options.video,(t||n||r)&&this.emit(e)}},{key:"watchForNewDevices",value:function(){var t=this;navigator.mediaDevices.ondevicechange=function(){e.fetchDevices().then((function(e){return t.setDevices(e)})).catch(t.handleError)}}},{key:"onChange",value:function(e){this.listeners.push(e)}},{key:"removeListener",value:function(e){this.listeners=this.listeners.filter((function(t){return t!==e}))}},{key:"update",value:function(e){return this.constraints=e||this.constraints,this.stop(),this.watchForNewDevices(),navigator.mediaDevices.getUserMedia(this.constraints).then(this.initiateVirtualBackground).then(this.setStream).catch(this.handleError)}},{key:"updateWithOptions",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.options=t||this.options,this.stop(),this.watchForNewDevices(),e[r?"getMobileConstraints":"getConstraints"](this.options).then((function(e){return n.constraints=e,navigator.mediaDevices.getUserMedia({video:!n.options.eco&&n.constraints.video,audio:n.constraints.audio||!0})})).then(this.adjustAudioTrack).then(this.initiateVirtualBackground).then(this.setStream).catch(this.handleError)}},{key:"adjustAudioTrack",value:function(e){return 1===e.getAudioTracks().length&&(e.getAudioTracks()[0].enabled=this.options.audio),e}},{key:"initiateVirtualBackground",value:function(e){return"off"!==this.virtualBackgroundType&&e&&1===e.getVideoTracks().length?this.virtualBackground.initiateStream(e):e}},{key:"storeConstraints",value:function(){var e=this.constraints,t=e.video,n=e.audio;f.debug("DeviceManager::storeConstraints",e),ot.store("mediaConstraints",e),ot.store("sinkId",this.sinkId),ot.store("virtualBackgroundType",this.virtualBackgroundType),t&&t.deviceId&&t.deviceId.exact&&ot.store("videoId",t.deviceId.exact),n&&n.deviceId&&n.deviceId.exact&&ot.store("audioId",n.deviceId.exact),this.virtualBackground.updateCache(this.virtualBackgroundType)}},{key:"setStream",value:function(t){var n=this,r=null===this.stream;if(this.stream=t,this.terminationInProgress)return this.stop(),Promise.resolve();var i=function(){n.emit({stream:n.stream,constraints:n.constraints,options:n.options}),n.verifyStream()};return r?e.fetchDevices().then((function(e){n.setDevices(e),i()})):(i(),Promise.resolve())}},{key:"verifyStream",value:function(){this.constraints.video&&this.stream&&0===this.stream.getVideoTracks().length&&!this.options.eco&&this.handleError({name:"EyesonCameraError"}),this.constraints.audio&&this.stream&&0===this.stream.getAudioTracks().length&&this.handleError({name:"EyesonMicrophoneError"})}},{key:"setVideoInput",value:function(e){var t={};return Object.assign(t,this.constraints.video,{deviceId:{exact:e}}),this.constraints.video=t,this.update()}},{key:"setAudioInput",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};return Object.assign(n,this.constraints.audio,{deviceId:{exact:e}}),this.constraints.audio=n,!0===t.preventUpdate?Promise.resolve():this.update()}},{key:"setAudioPassthrough",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.options.audioPassthrough=t,e.adjustAudioConstraints(this.constraints,this.options),!0===n.preventUpdate?Promise.resolve():this.update()}},{key:"setAudioOutput",value:function(e){this.sinkId=e||"default",ot.store("sinkId",this.sinkId),this.emit({sinkId:this.sinkId})}},{key:"handleError",value:function(e){f.error("DeviceManager::",e),this.emit({error:e,constraints:this.constraints})}},{key:"emit",value:function(e){this.listeners.forEach((function(t){return t(e)}))}}],[{key:"getDevices",value:function(){return"mediaDevices"in navigator?navigator.mediaDevices.enumerateDevices().then((function(e){return 2===e.length&&e.every((function(e){return"audioinput"===e.kind&&""===e.deviceId}))?[{deviceId:"",groupId:"",kind:"audioinput",label:""},{deviceId:"",groupId:"",kind:"videoinput",label:""}]:e})):Promise.resolve([])}},{key:"getConstraints",value:function(t){var n=t||{audio:!0,video:!0,eco:!1,audioPassthrough:!1};return e.getDevices().then((function(t){return e.determineConstraintsForDevices(t,n)})).catch((function(e){f.error("DeviceManager::getConstraints ",e)}))}},{key:"determineConstraintsForDevices",value:function(t,n){var r=ot.load("mediaConstraints",n),i={channelCount:et.canStereo()&&!n.eco?2:1},o={width:h.hdCamera?1280:640,height:h.hdCamera?960:480};if(Reflect.deleteProperty(r,"eco"),Reflect.deleteProperty(r,"audioPassthrough"),Qe(r.video)&&Object.assign(r.video,o),Reflect.has(r,"audio")||(r.audio=i),Reflect.has(r,"video")||(r.video=o),Qe(r.audio)&&r.audio.deviceId){var a=r.audio.deviceId.exact;t.find((function(e){return e.deviceId===a}))||(r.audio=!!n.audio&&i)}if(Qe(r.video)&&r.video.deviceId){var s=r.video.deviceId.exact;t.find((function(e){return e.deviceId===s}))||(r.video=!!n.video&&o)}return(!0===n.audio&&!1===r.audio||!0===r.audio)&&(r.audio=i),r.audio&&r.audio.channelCount!==i.channelCount&&(r.audio.channelCount=i.channelCount),!1!==n.video||n.eco||(r.video=!1),(!0===n.video&&!1===r.video||!0===r.video)&&(r.video=o),0===t.filter((function(e){return"videoinput"===e.kind})).length&&(r.video=!1),e.applyLastUsedDevices(r,t),e.adjustAudioConstraints(r,n),e.adjustVideoConstraints(r),r}},{key:"applyLastUsedDevices",value:function(e,t){var n=ot.load("videoId"),r=ot.load("audioId");e.audio&&r&&t.find((function(e){return e.deviceId===r}))&&(e.audio.deviceId={exact:r}),e.video&&n&&t.find((function(e){return e.deviceId===n}))&&(e.video.deviceId={exact:n})}},{key:"adjustVideoConstraints",value:function(e){var t=p.widescreen,n=p.idealCameraResolution,r=p.idealCameraFramerate,i=window.Number.isInteger;!0===e.video&&(e.video={}),Qe(n)&&i(n.width)&&i(n.height)?e.video&&Object.assign(e.video,{width:n.width,height:n.height}):t?e.video&&Object.assign(e.video,{width:h.hdCamera?1280:640,height:h.hdCamera?720:360}):e.video&&Object.assign(e.video,{width:h.hdCamera?1280:640,height:h.hdCamera?960:480}),i(r)?e.video&&Object.assign(e.video,{frameRate:r}):e.video&&Reflect.has(e.video,"frameRate")&&Reflect.deleteProperty(e.video,"frameRate")}},{key:"adjustAudioConstraints",value:function(e,t){var n=Reflect.has(t,"audioPassthrough")&&!0===t.audioPassthrough;if(e.audio){var r=e.audio;Qe(r)&&(n?(r.autoGainControl=!1,r.echoCancellation=!1,r.noiseSuppression=!1):(Reflect.deleteProperty(r,"echoCancellation"),Reflect.deleteProperty(r,"autoGainControl"),Reflect.deleteProperty(r,"noiseSuppression")))}}},{key:"getMobileConstraints",value:function(t){var n=Object.assign({audio:!0,video:{facingMode:"user",width:h.hdCamera?1280:640,height:h.hdCamera?960:480}},t);return!0===n.video&&(n.video={facingMode:"user",width:h.hdCamera?1280:640,height:h.hdCamera?960:480}),e.adjustVideoConstraints(n),Promise.resolve(n)}},{key:"getSinkId",value:function(){var t=ot.load("sinkId","");return e.getDevices().then((function(e){return e.find((function(e){return e.deviceId===t}))||(t="default"),t}))}},{key:"fetchDevices",value:function(){return e.getDevices().then((function(e){var t=e.filter((function(e){return"audiooutput"===e.kind}));return t.length>0&&-1===t.findIndex((function(e){return"default"===e.deviceId}))&&t.unshift({deviceId:"default",kind:"audiooutput",groupId:"default",label:"System default"}),{cameras:e.filter((function(e){return"videoinput"===e.kind})).sort(jn),microphones:e.filter((function(e){return"audioinput"===e.kind})).sort(jn),speakers:t.sort(jn)}}))}},{key:"fetchInputDevices",value:function(){return e.getDevices().then((function(e){return e.filter((function(e){return e.kind.includes("input")}))}))}},{key:"getStoredVirtualBackgroundType",value:function(e){var t=ot.load("virtualBackgroundType","off");return"image:blob"===t?In.getImageBlobOrFallback(e):t}}]);var t}();const Vn=function(){return d((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{eco:!1,audio:!0,video:!0,screen:!1,surface:null,screenStream:null,canvas:null,existingStream:null,micMixer:null,vbgMixer:null,isPresentation:!1,virtualBackground:!1,deviceMonitor:null,audioPassthrough:!1};c(this,e),this.options=t,this.tempStream=null,this.brokenTrackCallback=null,this.bindMethods()}),[{key:"bindMethods",value:function(){this.getMediaStream=this.getMediaStream.bind(this),this.addNinjaTrack=this.addNinjaTrack.bind(this),this.addCanvasTrack=this.addCanvasTrack.bind(this),this.addScreenTrack=this.addScreenTrack.bind(this),this.adjustAudioTrack=this.adjustAudioTrack.bind(this),this.adjustVideoTrack=this.adjustVideoTrack.bind(this),this.addScreenStreamTrack=this.addScreenStreamTrack.bind(this),this.initializeVirtualBackground=this.initializeVirtualBackground.bind(this)}},{key:"start",value:function(){var e=this;f.debug("MediaStreamBuilder::start",this.options);var t=this.options,n=t.existingStream,r=t.video,i=t.audio,o=t.screen,a=t.canvas,s=t.micMixer,c=t.screenStream;return et.isIOSDevice()&&n&&"boolean"==typeof r&&n.active&&Tt(n).length>0&&"ended"!==Tt(n)[0].readyState?new Promise((function(t){var o=N(Tt(n),1)[0];if(o.enabled=r,o.onended=r&&e.brokenTrackCallback?function(){f.error("iOS video track broken"),n.getTracks().forEach((function(e){return e.stop()})),e.brokenTrackCallback()}:null,"boolean"==typeof i&&dt(n,i),a){var s=new MediaStream(n.getTracks()),c=Ht(a),u=N(Dt(c),1)[0];return s.addTrack(u),void t(s)}t(n)})):et.isSafari()&&o&&s&&!a?(c?Promise.resolve(c):this.getDisplayMedia()).then((function(t){var n={audio:e.options.audio,audioPassthrough:e.options.audioPassthrough};return Fn.getConstraints(n).then((function(n){var r=new MediaStream;return e.addScreenStreamTrack(r,t),e.tempStream=new MediaStream(t.getTracks()),navigator.mediaDevices.getUserMedia({audio:n.audio}).then((function(n){return e.adjustAudioTrack(n),n.getTracks().forEach((function(t){return e.tempStream.addTrack(t)})),s.mixScreenshareAudio(n,t,r),s.active&&s.setMicOnlyStream(n,t),r}))}))})).then((function(t){return e.tempStream=null,t})).catch((function(t){return e.tempStream&&(ft(e.tempStream),e.tempStream=null),f.error("MediaStreamBuilder::start ",t,t.message),Promise.reject(t)})):Fn.fetchInputDevices().then(this.getMediaStream).then(this.adjustVideoTrack).then(this.adjustAudioTrack).then(this.initializeVirtualBackground).then(this.addCanvasTrack).then(this.addScreenTrack).then(this.addNinjaTrack).then((function(t){return e.tempStream=null,e.options.deviceMonitor&&e.options.deviceMonitor.applyTempTracks(),t})).catch((function(t){return e.cleanupTempStream(),e.options.deviceMonitor&&e.options.deviceMonitor.discardTempTracks(),f.error("MediaStreamBuilder::start ",t,t.message),Promise.reject(t)}))}},{key:"getMediaStream",value:function(e){var t=this;if(0===e.length)return this.options={audio:!1,video:!1},this.tempStream=(new tt).stream,this.tempStream;var n=this.options,r=n.eco,i=n.video,o=n.existingStream,a=n.audioPassthrough,s={video:!et.hasCanvasCaptureSupport()&&!r||i,audio:!0,audioPassthrough:a};!1===i&&!r&&et.isIOSDevice()&&(s.video=!0);var c=Fn.getConstraints;return et.canMultipleDifferentMicrophones()||ft(o),(et.isPhone()||et.isIOSDevice())&&(ft(o),c=Fn.getMobileConstraints),c(s).then((function(e){return navigator.mediaDevices.getUserMedia(e).then((function(e){return t.tempStream=e,e}))}))}},{key:"adjustVideoTrack",value:function(e){if(1===e.getVideoTracks().length){var t=N(e.getVideoTracks(),1)[0];t.enabled=this.options.video,!1!==this.options.video||et.isIOSDevice()||pt(t),this.options.deviceMonitor&&this.options.deviceMonitor.addVideoTrack(t)}return e}},{key:"initializeVirtualBackground",value:function(e){var t=this.options,n=t.screen,r=t.virtualBackground,i=t.vbgMixer;return!n&&r&&e&&1===e.getVideoTracks().length?i.initiateStream(e):e}},{key:"adjustAudioTrack",value:function(e){if(1===e.getAudioTracks().length){var t=N(e.getAudioTracks(),1)[0];t.enabled=this.options.audio,this.options.deviceMonitor&&this.options.deviceMonitor.addAudioTrack(t)}return e}},{key:"addCanvasTrack",value:function(e){var t=this.options,n=t.canvas,r=t.existingStream;if(n){var i=Ht(n),o=N(Dt(i),1)[0];e.addTrack(o)}if(Ft(r)){var a=N(Dt(r),1)[0];e.addTrack(a)}return e}},{key:"addScreenTrack",value:(e=F(W().mark((function e(t){var n,r,i,o,a,s,c,u,l;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.options.screenStream,r=this.options,i=r.screen,o=r.existingStream,a=r.micMixer,!i||!a){e.next=13;break}if(null!=n){e.next=7;break}return e.next=6,this.getDisplayMedia();case 6:n=e.sent;case 7:return s=new MediaStream,this.addScreenStreamTrack(s,n),a.mixScreenshareAudio(t,n,s),a.active&&a.setMicOnlyStream(t,n),this.tempStream=new MediaStream(t.getTracks().concat(n.getTracks())),e.abrupt("return",s);case 13:return It(o)&&(c=Ct(o),u=N(c,1),l=u[0],t.addTrack(l)),e.abrupt("return",t);case 15:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"addScreenStreamTrack",value:function(e,t){var n=N(t.getVideoTracks(),1)[0];n.type=this.options.isPresentation?"screen-track":"screen-video-track",e&&e.addTrack(n)}},{key:"getDisplayMedia",value:function(){if(et.hasGetDisplayMedia()){var e={channelCount:et.canStereo()&&!this.options.eco?2:1},t={height:{max:1080},frameRate:{max:15}};return et.isChrome()&&et.isMacOS()&&(e.echoCancellation=!1),this.options.surface&&et.canChooseDisplaySurface()&&(t.displaySurface=this.options.surface),navigator.mediaDevices.getDisplayMedia({audio:e,video:t,surfaceSwitching:"include",selfBrowserSurface:"include",systemAudio:"include"})}return navigator.mediaDevices.getUserMedia({video:{mediaSource:"screen",width:{max:1920},height:{max:1040},frameRate:{max:15}}})}},{key:"addNinjaTrack",value:function(e){var t=this.options,n=t.eco,r=t.video;if(n||!et.hasCanvasCaptureSupport())return e;if(0===e.getVideoTracks().length){var i=N((new tt).stream.getVideoTracks(),1)[0];i.enabled=r,e.addTrack(i)}return e}},{key:"cleanupTempStream",value:function(){var e=this.tempStream;if(e){var t=this.options,n=t.existingStream,r=t.screenStream;if(Ft(n)){var i=N(Dt(n),1)[0];e.removeTrack(i)}if(At(n)){var o=N(wt(n),1)[0];e.removeTrack(o)}if(It(r)){var a=N(Ct(r),1)[0];e.removeTrack(a)}ft(e),this.tempStream=null}}},{key:"onBrokenTrackError",value:function(e){return this.brokenTrackCallback=e,this}}]);var e}();const Un=function(){return d((function e(){c(this,e),this.active=!1,this.audioContext=null,this.acOut=null,this.micOnlyStream=null,this.originalStream=null}),[{key:"setMicOnlyStream",value:function(e,t){this.micOnlyStream=new MediaStream;var n=e.getAudioTracks(),r=t.getVideoTracks();return n.length>0&&this.micOnlyStream.addTrack(n[0]),r.length>0&&this.micOnlyStream.addTrack(r[0]),this.micOnlyStream}},{key:"getMicOnlyStream",value:function(){return this.micOnlyStream}},{key:"getOriginalStream",value:function(){return this.originalStream}},{key:"stopOriginalStream",value:function(){ft(this.originalStream)}},{key:"noMix",value:function(e,t){var n=e.getAudioTracks();n.length>0&&t.addTrack(n[0])}},{key:"initMixScreenshareMix",value:function(e,t,n){this.audioContext=new(window.AudioContext||window.webkitAudioContext),this.acOut=this.audioContext.createMediaStreamDestination(),this.audioContext.createMediaStreamSource(t).connect(this.acOut),this.audioContext.createMediaStreamSource(e).connect(this.acOut),n.addTrack(this.acOut.stream.getAudioTracks()[0])}},{key:"mixScreenshareAudio",value:function(e,t,n){this.originalStream=t;var r=t.getAudioTracks();if(0===r.length)this.noMix(e,n);else try{this.initMixScreenshareMix(e,t,n),this.active=!0}catch(t){f.error("MicMixer::mixScreenshareAudio",t),pt(r[0]),this.noMix(e,n)}}},{key:"destroy",value:function(){var e=this;if(this.stopOriginalStream(),this.micOnlyStream=null,this.originalStream=null,this.audioContext)return ft(this.acOut.stream),void this.audioContext.close().then((function(){e.audioContext=null,e.acOut=null,e.active=!1}));this.active=!1}}])}();function Nn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Nn=function(){return!!e})()}var Hn=function(e,t,n){e.getAudioTracks().forEach((function(e){return e.enabled=t})),e.getVideoTracks().forEach((function(e){return e.enabled=n}))};const Wn=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Nn()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.audio,n=e.video,r=e.screen,i=void 0!==r&&r,o=e.surface;f.debug("ChangeLocalStreamEvent::handle");var a=this.context._session;if(!a)throw new Error("Session does not exist");var s=a.localStream,c=a.vbgMixer;if(et.isIOSDevice()||et.stopsDeviceActivityIndicatorOnDisable())return c&&(n?c.resume():c.suspend(),c.originalStream&&c.originalStream!==s&&Hn(c.originalStream,t,n)),Hn(s,t,n),s.locallyChanged=!0,void a.emit({type:"stream_update",localStream:s});a.micMixer&&(a.micMixer.destroy(),a.micMixer=null),c&&(c.stopOriginalStream(),c.terminate());var u={audio:t,video:n,virtualBackground:a.options.virtualBackground,existingStream:s,vbgMixer:c,deviceMonitor:a.deviceMonitor,audioPassthrough:a.options.audioPassthrough};i&&(a.micMixer=new Un,u.video=!1,u.screen=!0,u.surface=o,u.virtualBackground=!1,u.micMixer=a.micMixer),new Vn(u).start().then((function(e){var t=N(xt(e),1)[0];return t&&t.addEventListener("ended",(function(){a.emit({type:"stop_screen_video"})})),e})).then((function(e){e.locallyChanged=!0,a.setStream(e)})).catch((function(e){if(f.error("ChangeLocalStreamEvent",e),i){var t="error_Screen_".concat(e.name);e.message.indexOf("not start audio")>-1&&(t="error_Screen_".concat(e.name,"_Audio")),a.emit({type:"screen_capture_error",name:t}),a.emit({type:"stop_screen_video"})}}))}}])}(S);function zn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(zn=function(){return!!e})()}var qn=function(e){if(e){var t=N(e.getVideoTracks(),1)[0],n=void 0===t?null:t;if(n&&"function"==typeof n.getSettings){var r=n.getSettings().width;return void 0===r?0:r}}return 0};const Gn=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,zn()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){f.debug("PodiumEvent::handle",e);var t=this.context._session;if(!t)throw new Error("Session does not exist");t&&!t.externalStream&&(this.scanMessageForLocalStreamOptimization(t,e),this.adjustResolution(t,e)),new q(this.context).handle(e)}},{key:"scanMessageForLocalStreamOptimization",value:function(e,t){var n=e.localStream,r=t.video,i=t.isSource,o=t.isPresenter,a=t.hasPresenter;if(n){var s={isCameraStream:jt(n),isVBGStream:Lt(n),hasVideo:ct(n),hasAudio:st(n),locallyChanged:n.locallyChanged};if(e.lastPodiumSettings&&function(e,t){return Object.keys(e).every((function(n){return e[n]===t[n]}))}(e.lastPodiumSettings,Object.assign({},t,s)))f.debug("scanMessageForLocalStreamOptimization: no change");else{if(e.lastPodiumSettings=Object.assign({video:r,isSource:i,isPresenter:o,hasPresenter:a},s),i&&(!r&&(s.isCameraStream||s.isVBGStream)||r&&!s.hasVideo&&s.locallyChanged&&!a)){var c={audio:s.hasAudio,video:r};new Wn(this.context).handle(c)}r&&!o&&a&&new Wn(this.context).handle({audio:s.hasAudio,video:!1})}}}},{key:"adjustResolution",value:(n=F(W().mark((function e(t,n){var r,i,o,a,s,c,u,l,d;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h.hdCamera){e.next=2;break}return e.abrupt("return");case 2:if(r=null,i=n.video,o=n.userDimensions,a=n.isPresenter,t.lastResolution={video:i,userDimensions:o,isPresenter:a},a?r=1:i&&o&&(s=t.localStream)&&(At(s)?r=1:(c=o.w,u=o.h,r=c>=640||u>(p.widescreen?360:480)||qn(s)<=640?1:.5)),null===r){e.next=19;break}return e.prev=7,l=null,d=null,f.info("PodiumEvent::adjustResolution",.5===r?"half":"full"),.5===r&&(l=640,d=p.widescreen?360:480),e.next=14,t.sipSession.sessionDescriptionHandler.scaleResolution(r,l,d);case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(7),f.warn("PodiumEvent::adjustResolution",e.t0);case 19:case"end":return e.stop()}}),e,null,[[7,16]])}))),function(e,t){return n.apply(this,arguments)})}]);var n}(S);function $n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return($n=function(){return!!e})()}const Jn=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,$n()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){this.context._api.takeSnapshot()}}])}(S);function Kn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Kn=function(){return!!e})()}const Xn=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Kn()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.setLayer(e.params)}}])}(S);function Yn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Yn=function(){return!!e})()}const Qn=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Yn()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.sendMessage({type:"chat",content:e.content})}}])}(S);function Zn(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Zn=function(){return!!e})()}const er=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Zn()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n=this;this.context._api.stopBroadcast("generic").then((function(){return(r=t,i="handle",o=n,s=_(y(1&(a=3)?r.prototype:r),i,o),2&a&&"function"==typeof s?function(e){return s.apply(o,e)}:s)([{type:e.type}]);var r,i,o,a,s})).catch((function(e){return f.warn(e)}))}}])}(M);function tr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(tr=function(){return!!e})()}const nr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,tr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.setLayout(e.params)}}])}(S);function rr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(rr=function(){return!!e})()}const ir=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,rr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t,n=this.context,r=n._api,i=n._session,o=((t=e.url).endsWith("/")?t:t+"/")+e.key;r.startBroadcast({streamUrl:o},"generic").catch((function(e){i.emit({type:"start_broadcast_error",platform:"generic",error:e})}))}}])}(S);var or=function(){try{return new EventTarget,!0}catch(e){}return!1}();const ar=function(){return d((function e(){c(this,e),this.listeners=new Map,this.target=or?new EventTarget:document.createElement("i")}),[{key:"onEvent",value:function(e){var t=function(t){var n=t.detail;return e(n)};this.target.addEventListener("event",t),this.listeners.set(e,t)}},{key:"offEvent",value:function(e){var t=this.listeners.get(e);t&&(this.target.removeEventListener("event",t),this.listeners.delete(e))}},{key:"removeAllListeners",value:function(){var e=this.listeners,t=this.target;e.forEach((function(e){return t.removeEventListener("event",e)})),e.clear()}},{key:"emit",value:function(e){var t=new CustomEvent("event",{detail:e});this.target.dispatchEvent(t)}}])}();function sr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(sr=function(){return!!e})()}const cr=function(e){function t(e){var n,r,i,o;return c(this,t),r=this,i=y(i=t),(n=g(r,sr()?Reflect.construct(i,o||[],y(r).constructor):i.apply(r,o))).connection=null,n.options=e,n.wasOpen=!1,n}return k(t,e),d(t,[{key:"connect",value:function(){var e=this,t=this.options;this.wasOpen=!1;var n=new WebSocket("".concat(t.endpoint,"?auth_token=").concat(t.auth_token));n.onopen=function(){e.wasOpen=!0,e.emit({type:"connected"})},n.onmessage=function(t){var n=t.data;e.emit({type:"message",message:n})},n.onerror=function(){e.emit({type:"transportError"})},n.onclose=function(){e.destroy()},this.connection=n}},{key:"isConnected",value:function(){var e=this.connection;return!!e&&e.readyState===WebSocket.OPEN}},{key:"send",value:function(e){var t=this.connection;return!!t&&(t.send(e),!0)}},{key:"destroy",value:function(){var e=this.connection,t=this.wasOpen;e&&(this.connection=null,e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.readyState<=WebSocket.OPEN&&e.close(),this.emit({type:"disconnected",was_open:t})),this.removeAllListeners()}}])}(ar);var ur=/\r\n|\r(?!\n)|\n/g;const lr=function(e){return e.replace(ur,"\r\n")};const dr=function(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(e){return!1}};var hr="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID;const pr=function(){if(hr)return crypto.randomUUID();var e=0,t=crypto.getRandomValues(new Uint8Array(31));return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(function(n){var r=t[e];return e+=1,(n^r&15>>n/4).toString(16)}))};function fr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(fr=function(){return!!e})()}var vr=function(){try{if(/^\d+\.\d+\.\d+$/.test(h.version))return h.version}catch(e){}return""};const mr={UserAgent:function(e){function t(e){var n,r,i,o,a,s,u,l,d,h;return c(this,t),r=this,i=y(i=t),n=g(r,fr()?Reflect.construct(i,o||[],y(r).constructor):i.apply(r,o)),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="";if(["client_id","conf_id","client_name","sessionDescriptionHandlerFactory","transportOptions"].some((function(n){return!!e[n]||(t=n,!1)})),t||["auth_token","endpoint"].some((function(n){return!!e.transportOptions[n]||(t="transportOptions.".concat(n),!1)})),t)throw new Error("Invalid options - ".concat(t))}(e),n.callId=null,n.sessionDescriptionHandler=null,n.options=e,n.initAuthToken(),n.debouncedHandleSDPUpdate=(a=n.handleSdpUpdate,s=250,u=n,l=[],d=!1,h=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];d?l.push(t):(d=!0,setTimeout((function(){if(d=!1,l.length>0){var e=l.shift();Reflect.apply(h,null,e)}}),s),Reflect.apply(a,u,t))},h),n}return k(t,e),d(t,[{key:"onMessage",value:(i=F(W().mark((function e(t){var n,r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=JSON.parse(t),r=n.type,i=n.data,this.verifySender(n),"call_accepted"!==r){e.next=10;break}return this.setCallId(i.call_id),e.next=7,this.sessionDescriptionHandler.setDescription(i.sdp);case 7:this.emit({type:"accepted"}),e.next=11;break;case 10:"call_resumed"===r?(this.sessionDescriptionHandler.setDescription(i.sdp),this.emit({type:"resumed"})):"call_rejected"===r?(this.termination=!0,this.setCallId(null),this.emit({type:"terminated",reason:"reject",code:i.reject_code}),this.terminate()):"call_terminated"===r?(this.termination=!0,this.setCallId(null),this.emit({type:"terminated",reason:"bye",code:i.term_code}),this.terminate()):"sdp_update"===r?this.debouncedHandleSDPUpdate(i):(i.type=r,this.emit({type:"message",data:i}));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"initAuthToken",value:function(){var e=this.options,t=dr(e.transportOptions.auth_token);if(!1===t||t.client_id!==e.client_id||t.conf_id!==e.conf_id||!t.exp)throw new Error("Invalid auth token")}},{key:"setCallId",value:function(e){this.callId=e}},{key:"verifySender",value:function(e){var t=this.options;e.from===t.conf_id&&e.to===t.client_id||console.error(new Error("Invalid message sender",e))}},{key:"handleSdpUpdate",value:(r=F(W().mark((function e(t){var n,r,i,o;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.callId,r=t.sdp,n&&n===t.call_id){e.next=4;break}throw new Error("Invalid call id");case 4:return this.emit({type:"sdp_update",sdp:r}),e.next=7,this.sessionDescriptionHandler.updateDescription(r);case 7:i=e.sent,"offer"===r.type&&i&&(o={type:i.type,sdp:lr(i.sdp)},this.message("sdp_update",{call_id:n,sdp:o}));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"message",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"message",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.options,r=JSON.stringify({type:e,msg_id:pr(),from:n.client_id,to:n.conf_id,data:t});this.transport.send(r)}},{key:"connect",value:function(){var e=this,t=this.options,n=new cr(t.transportOptions);this.transport=n,this.termination=!1,this.emit({type:"transportCreated",transport:n}),n.onEvent((function(n){var r=n.type;"connected"===r?e.sessionDescriptionHandler||(e.sessionDescriptionHandler=t.sessionDescriptionHandlerFactory(t.sessionDescriptionHandlerFactoryOptions),e.emit({type:"registered"})):"message"===r?e.onMessage(n.message):"disconnected"===r&&(e.termination||e.emit({type:"terminated",reason:"disconnect",code:n.was_open?0:-1}))})),n.connect()}},{key:"call",value:(n=F(W().mark((function e(){var t,n,r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.sessionDescriptionHandler,n=this.options,t){e.next=3;break}throw new Error("Invalid sessionDescriptionHandler");case 3:return e.next=5,t.getDescription();case 5:r=e.sent,i={type:r.type,sdp:lr(r.sdp)},this.message("call_start",{sdp:i,display_name:n.client_name,mute_video:n.mute_video,platform:"web-".concat(vr())});case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resume",value:function(e){var t=this;if(!this.callId)throw new Error("Session was already closed");this.options.transportOptions.auth_token=e;try{this.initAuthToken()}catch(e){return void this.emit({type:"terminated",reason:"disconnect",code:-1})}var n=function(e){"transportCreated"===e.type&&(t.offEvent(n),t.transport.onEvent(function(){var e=F(W().mark((function e(n){var r,i,o,a;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("connected"!==n.type){e.next=17;break}if(r=t.transport,i=t.sessionDescriptionHandler,t.callId){e.next=5;break}throw r.destroy(),new Error("Session was already closed");case 5:return e.prev=5,e.next=8,i.getDescription();case 8:o=e.sent,a={type:o.type,sdp:lr(o.sdp)},t.message("call_resume",{call_id:t.callId,sdp:a}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(5),r.destroy(),new Error("Unable to reconnect");case 17:case"end":return e.stop()}}),e,null,[[5,13]])})));return function(t){return e.apply(this,arguments)}}()))};this.onEvent(n),this.connect()}},{key:"terminate",value:function(){var e=this.sessionDescriptionHandler,t=this.transport,n=this.callId;this.callId=null,e&&e.close(),t&&(t.isConnected()&&n&&(this.termination=!0,this.message("call_terminate",{call_id:n,term_code:0}),this.emit({type:"terminated",reason:"terminate",code:0})),this.transport=null,t.destroy())}}]);var n,r,i}(ar)},gr=["chat","recording","memberlist","source_update","voice_activity"];const yr=function(){return d((function e(t,n){c(this,e);var r=t.src,i=void 0===r?[]:r,o=t.psrc,a=t.asrc,s=t.vsrc,u=t.dims;this.clientId=n,this.sources=i,this.presenterIdx=o,this.audioSources=a,this.videoSources=s,this.dimensions=u,this.userSourceIndex=i.indexOf(n),this.layers=this.parseLayer(t)}),[{key:"isSolo",get:function(){return 1===Array.from(new Set(this.sources)).length&&this.sources[0]===this.clientId}},{key:"isSource",get:function(){return this.sources.includes(this.clientId)}},{key:"isPresenter",get:function(){return this.hasPresenter&&this.presenter===this.clientId}},{key:"presenter",get:function(){return this.hasPresenter&&this.sources[this.presenterIdx]}},{key:"hasMedia",get:function(){return this.sources.some((function(e){return e.startsWith("media-")}))}},{key:"hasPresenter",get:function(){return Number.isInteger(this.presenterIdx)&&this.presenterIdx>-1}},{key:"hasVideoSources",get:function(){return Boolean(this.videoSources)}},{key:"hasAudioPosition",get:function(){return this.audioSources.includes(this.userSourceIndex)}},{key:"hasVideoPosition",get:function(){return this.videoSources.includes(this.userSourceIndex)}},{key:"hasMutedVideoPeers",get:function(){var e=this;return!this.hasPresenter&&0===this.videoSources.filter((function(t){return t!==e.userSourceIndex})).length}},{key:"userDimensions",get:function(){var e=this.videoSources.indexOf(this.userSourceIndex);return e>-1?this.dimensions[e]:null}},{key:"allUserDimensions",get:function(){for(var e=this.dimensions,t=this.videoSources,n=this.sources,r=e.length,i=new Array(r),o=0;o<r;o++){var a={},s=t[o],c=s>-1?n[s]:"",u=c.startsWith("media-");a.clientId=u?"":c,a.playId=u?c.substring(6):"",i[o]=Object.assign(a,e[o])}return i}},{key:"parseLayer",value:function(e){var t=[];return Reflect.has(e,"fg_img_id")&&t.push({zIndex:1,id:e.fg_img_id}),Reflect.has(e,"bg_img_id")&&t.push({zIndex:-1,id:e.bg_img_id}),t}}])}();const br=function(){return d((function e(t){c(this,e),this.clientId=t,this.stamp=this.stamp.bind(this),this.default=this.default.bind(this),this.process=this.process.bind(this),this.sourceUpdate=this.sourceUpdate.bind(this),this.voiceActivity=this.voiceActivity.bind(this)}),[{key:"stamp",value:function(e){return Object.assign({_src:"sig"},e)}},{key:"process",value:function(e){return({source_update:this.sourceUpdate,voice_activity:this.voiceActivity}[e.type]||this.default)(this.stamp(e))}},{key:"default",value:function(e){return f.debug("SipMessageTransformer::default",e),e}},{key:"sourceUpdate",value:function(e){f.debug("SipMessageTransformer::sourceUpdate",e);var t=new yr(e,this.clientId);return{type:"podium",solo:t.isSolo,audio:t.hasAudioPosition,video:t.hasVideoPosition,media:t.hasMedia,layers:t.layers,sources:t.sources,isSource:t.isSource,presenter:t.presenter,isPresenter:t.isPresenter,hasPresenter:t.hasPresenter,videoSources:t.videoSources,userDimensions:t.userDimensions,hasVideoSources:t.hasVideoSources,hasDesktopSources:t.hasDesktopSources,allUserDimensions:t.allUserDimensions,hasMutedVideoPeers:t.hasMutedVideoPeers}}},{key:"voiceActivity",value:function(e){return f.debug("SipMessageTransformer::voiceActivity",e),Object.assign({type:"voice_activity_raw",on:e.on,userId:e.cid})}}])}();const kr=function(){return d((function e(t){c(this,e),this.datachannel=null,this.peerConnection=null,this.localStream=null,this.remoteStream=null,this.connected=!1,this.iceCheckingTimer=null,this.peerConnectionReady=null,this.options=t||{},this.connection=t.connection,this.handleConnectionStateChange=this.handleConnectionStateChange.bind(this),this.initPeerConnection()}),[{key:"getDescription",value:(i=F(W().mark((function e(){var t,n,r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.options,n=this.peerConnection,f.debug("SessionDescriptionHandler::getDescription:",t),this.localStream=t.stream,e.next=5,n.createOffer(t.RTCOfferOptions);case 5:return r=e.sent,t.SDPModifiers.active.forEach((function(e){r.sdp=e(r.sdp,t)})),e.next=9,n.setLocalDescription(r);case 9:return e.next=11,this.peerConnectionReady;case 11:return i=n.localDescription.sdp,t.SDPModifiers.passive.forEach((function(e){i=e(i,t)})),f.debug("SessionDescriptionHandler::getDescription offer",i),e.abrupt("return",{type:"offer",sdp:i});case 15:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setDescription",value:(r=F(W().mark((function e(t){var n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.datachannel,f.debug("SessionDescriptionHandler::setDescription:",t),t&&t.sdp&&(this.connection.seppMessaging=t.sdp.includes("a=eyeson-sepp-messaging")),e.next=5,this.peerConnection.setRemoteDescription(new RTCSessionDescription(t));case 5:if(this.options.remoteDescriptionUpdate(t),"connecting"!==n.readyState){e.next=9;break}return e.next=9,new Promise((function(e){n.onopen=function(){n.onopen=null,e()}}));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateDescription",value:(n=F(W().mark((function e(t){var n,r,i,o;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.options,r=this.peerConnection,f.debug("SessionDescriptionHandler::updateDescription:",t),"offer"!==t.type){e.next=24;break}return e.prev=3,e.next=6,r.setRemoteDescription(new RTCSessionDescription(t));case 6:return e.next=8,r.createAnswer();case 8:return i=e.sent,n.SDPModifiers.active.forEach((function(e){i.sdp=e(i.sdp,n)})),e.next=12,r.setLocalDescription(i);case 12:return this.options.remoteDescriptionUpdate(t),o=r.localDescription.sdp,n.SDPModifiers.passive.forEach((function(e){o=e(o,n)})),f.debug("SessionDescriptionHandler::updateDescription answer",o),e.abrupt("return",{type:"answer",sdp:o});case 19:e.prev=19,e.t0=e.catch(3),f.error("SessionDescriptionHandler::updateDescription",e.t0);case 22:e.next=28;break;case 24:if("answer"!==t.type){e.next=28;break}return e.next=27,r.setRemoteDescription(new RTCSessionDescription(t));case 27:this.options.remoteDescriptionUpdate(t);case 28:return e.abrupt("return",null);case 29:case"end":return e.stop()}}),e,this,[[3,19]])}))),function(e){return n.apply(this,arguments)})},{key:"close",value:function(){f.debug("SessionDescriptionHandler::close"),clearTimeout(this.iceCheckingTimer),this.peerConnection&&(this.stopAllTracks(),this.peerConnection.close(),this.peerConnection=null,this.datachannel&&["connecting","open"].includes(this.datachannel.readyState)&&(this.datachannel.close(),this.datachannel=null),f.debug("SessionDescriptionHandler::close Stopped streams and closed peerConnection."))}},{key:"initPeerConnection",value:function(){var e=this.options,t=this.buildPeerConnectionOptions();f.debug("SessionDescriptionHandler::initPeerConnection with",t);var n=null;this.peerConnectionReady=new Promise((function(e){return n=e}));try{var r=new RTCPeerConnection(t);this.peerConnection=r,this.initPeerConnectionStreamTracks();var i=r.createDataChannel("data",{negotiated:!0,id:0});this.handleDatachannel(i),r.onicecandidate=function(e){var t=e.candidate;t?f.debug("SessionDescriptionHandler::gotIceCandidate",t.candidate):n()},r.onicegatheringstatechange=function(){"complete"===r.iceGatheringState&&n()},!0===e.sendOnly?r.addEventListener("connectionstatechange",this.handleConnectionStateChange):r.ontrack=this.handleOntrack.bind(this),this.iceCheckingTimer=setTimeout((function(){return n()}),3e3),this.applyCodecSelection()}catch(e){f.error("SessionDescriptionHandler::initPeerConnection failed:",e,this.connection.uaOptions)}}},{key:"initPeerConnectionStreamTracks",value:function(){var e=this.peerConnection,t=this.options;Qe(t.sendEncodings)?t.stream.getTracks().forEach((function(n){try{var r=t.sendEncodings[n.kind];Qe(r)?e.addTransceiver(n,{sendEncodings:[r],streams:[t.stream]}):e.addTrack(n,t.stream)}catch(r){f.error("SessionDescriptionHandler::initPeerConnectionStreamTracks",r),e.addTrack(n,t.stream)}})):t.stream.getTracks().forEach((function(n){e.addTrack(n,t.stream)}))}},{key:"handleOntrack",value:function(e){var t=e.track,n=e.streams,r=this.options,i=N(n,1);this.remoteStream=i[0],f.debug("SessionDescriptionHandler::handleOntrack:",t.kind),t.onunmute=function(){return r.handleUnmute(t)},r.handleAccept(this.remoteStream)}},{key:"handleConnectionStateChange",value:function(){"connected"!==this.peerConnection.connectionState||this.connected||(this.connected=!0,this.options.handleAccept())}},{key:"handleDatachannel",value:function(e){this.datachannel=e,this.connection.initDatachannel(e)}},{key:"buildPeerConnectionOptions",value:function(){var e=this.options,t=[];return e.stun_servers.length>0&&t.push({urls:e.stun_servers}),e.turn_servers.forEach((function(e){e.credential=e.password,t.push(e)})),{sdpSemantics:"unified-plan",iceServers:t}}},{key:"getLocalStream",value:function(){return this.localStream}},{key:"getRemoteStream",value:function(){return this.remoteStream}},{key:"setStream",value:function(e){var t=this;return new Promise((function(n,r){var i=t.getLocalStream();t.localStream=e,t.stopUnusedTracks(i,e);var o=N(e.getAudioTracks(),1)[0],a=N(Ft(e)?Dt(e):e.getVideoTracks(),1)[0];if(t.tracksExist()){var s=t.peerConnection.getSenders(),c=s.find((function(e){return e.track&&"audio"===e.track.kind})),u=s.find((function(e){return e.track&&"video"===e.track.kind}));Promise.all([c?c.replaceTrack(o):null,u?u.replaceTrack(a):null]).then((function(){n({newStream:e,remoteStream:t.remoteStream})})).catch(r)}else n({newStream:e,remoteStream:t.remoteStream})}))}},{key:"stopUnusedTracks",value:function(e,t){this.connection.hasExternalStream||e.getTracks().filter((function(e){return!t.getTracks().includes(e)})).forEach(pt)}},{key:"tracksExist",value:function(){return Boolean(this.peerConnection.getSenders().find((function(e){return null!==e.track})))}},{key:"scaleResolution",value:(t=F(W().mark((function e(t){var n,r,i,o,a,s,c,u=arguments;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.length>1&&void 0!==u[1]?u[1]:null,r=u.length>2&&void 0!==u[2]?u[2]:null,e.prev=2,i=Math.max(1/Math.max(t,.1),1),o=this.peerConnection.getSenders().find((function(e){return"video"===e.track.kind})),(a=o.getParameters()).encodings||(a.encodings=[{}]),s=N(a.encodings,1),c=s[0],1!==i){e.next=15;break}if(!Reflect.has(c,"scaleResolutionDownBy")&&!Reflect.has(c,"scaleResolutionDownTo")){e.next=14;break}return Reflect.deleteProperty(c,"scaleResolutionDownTo"),Reflect.deleteProperty(c,"scaleResolutionDownBy"),e.next=14,o.setParameters(a);case 14:return e.abrupt("return");case 15:if(c.scaleResolutionDownBy===i){e.next=20;break}return null!==n&&null!==r&&(c.scaleResolutionDownTo={maxWidth:n,maxHeight:r}),c.scaleResolutionDownBy=i,e.next=20,o.setParameters(a);case 20:e.next=25;break;case 22:e.prev=22,e.t0=e.catch(2),f.error("SessionDescriptionHandler::scaleResolution failed:",e.t0);case 25:case"end":return e.stop()}}),e,this,[[2,22]])}))),function(e){return t.apply(this,arguments)})},{key:"limitFramerate",value:(e=F(W().mark((function e(t){var n,r;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,n=this.peerConnection.getSenders().find((function(e){return"video"===e.track.kind})),(r=n.getParameters()).encodings||(r.encodings=[{}]),r.encodings[0].maxFramerate===t){e.next=8;break}return t?r.encodings[0].maxFramerate=t:Reflect.deleteProperty(r.encodings[0],"maxFramerate"),e.next=8,n.setParameters(r);case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),f.error("SessionDescriptionHandler::limitFramerate failed:",e.t0);case 13:case"end":return e.stop()}}),e,this,[[0,10]])}))),function(t){return e.apply(this,arguments)})},{key:"setSendEncodings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.peerConnection.getSenders().forEach(function(){var t=F(W().mark((function t(n){var r,i,o,a,s;return W().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e[n.track.kind],Qe(r)){t.next=3;break}return t.abrupt("return");case 3:return t.prev=3,(i=n.getParameters()).encodings||(i.encodings=[{}]),o=N(i.encodings,1),a=o[0],s=["maxBitrate","maxFramerate","scaleResolutionDownBy"],Object.keys(r).forEach((function(e){s.includes(e)&&(a[e]=r[e])})),Object.keys(a).forEach((function(e){!Reflect.has(r,e)&&s.includes(e)&&Reflect.deleteProperty(a,e)})),t.next=12,n.setParameters(i);case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(3),f.error("SessionDescriptionHandler::setSendEncodings",t.t0);case 17:case"end":return t.stop()}}),t,null,[[3,14]])})));return function(e){return t.apply(this,arguments)}}())}},{key:"applyCodecSelection",value:function(){var e=this.peerConnection,t=this.options.codecSelection||{audio:null,video:null},n=t.audio,r=t.video;if(et.canSetCodecPreferences()){if(et.isIOSDevice()&&!r&&(r=function(){var e=navigator.userAgent.match(/Version\/(\d+).(\d+)/);if(e&&e.length>1){if(Number(e[1])<17||17===Number(e[1])&&Number(e[2])<5)return RTCRtpSender.getCapabilities("video").codecs.filter((function(e){var t=e.mimeType;return"video/VP9"!==t&&"video/AV1"!==t}));if(Number(e[1])<18)return RTCRtpSender.getCapabilities("video").codecs.filter((function(e){return"video/AV1"!==e.mimeType}))}return null}()),Array.isArray(n)&&n.length>0)try{var i=e.getTransceivers().find((function(e){return e.sender&&"audio"===e.sender.track.kind}));i&&i.setCodecPreferences(n)}catch(e){f.error("SessionDescriptionHandler::applyCodecSelection::audio",e)}if(Array.isArray(r)&&r.length>0)try{var o=e.getTransceivers().find((function(e){return e.sender&&"video"===e.sender.track.kind}));o&&o.setCodecPreferences(r)}catch(e){f.error("SessionDescriptionHandler::applyCodecSelection::video",e)}}}},{key:"stopAllTracks",value:function(){f.debug("SessionDescriptionHandler::stopAllTracks");var e=this.peerConnection.getReceivers?this.peerConnection.getReceivers():[];this.peerConnection.getSenders().concat(e).forEach((function(e){e.track&&pt(e.track)}))}}]);var e,t,n,r,i}();const Sr=function(){return d((function e(t,n){c(this,e),this.listeners=[],this.messageListener=[],this.datachannel=null,this.uaOptions=this.initUserAgentOptions(t,n),this.clientId=this.uaOptions.client_id,this.userAgent=null,this.transformer=new br(this.clientId),this.seppMessaging=!1}),[{key:"initUserAgentOptions",value:function(e,t){if("sepp"!==e.type)return{client_id:null};var n=e.options;return{client_id:n.client_id,conf_id:n.conf_id,client_name:t.name,mute_video:!1,sessionDescriptionHandlerFactory:function(e){return new kr(e)},sessionDescriptionHandlerFactoryOptions:{stun_servers:n.stun_servers,turn_servers:n.turn_servers},transportOptions:{auth_token:n.auth_token,endpoint:n.endpoint}}}},{key:"start",value:function(){var e=this;return new Promise((function(t){if(!e.uaOptions.client_id)throw new TypeError("Invalid signaling data");e.userAgent=new mr.UserAgent(e.uaOptions),t()}))}},{key:"startSession",value:function(e){var t=this;return Object.assign(this.uaOptions.sessionDescriptionHandlerFactoryOptions,e),e.mediaOptions&&(this.uaOptions.mute_video=!e.mediaOptions.video),this.userAgent.onEvent((function(e){var n=e.type,r=e.data;"registered"===n?t.userAgent.call():"message"===n&&t.handleMessage(r)})),this.userAgent.connect(),this.userAgent}},{key:"updateAuthAndRestartSession",value:function(e){f.debug("updateAuthAndRestartSession",e),e.error||(this.uaOptions.transportOptions.auth_token=e.signaling.options.auth_token),this.userAgent.connect()}},{key:"updateAuthAndResume",value:function(e){f.debug("updateAuthAndResume",e),this.userAgent?e.error?this.userAgent.resume(null):this.userAgent.resume(e.signaling.options.auth_token):f.warn("updateAuthAndResume","userAgent already gone")}},{key:"initDatachannel",value:function(e){var t=this;this.datachannel=e,f.debug("SigConnection::initDatachannel",e),e.onmessage=function(n){if('{"type":"ping"}'!==n.data||"open"!==e.readyState){f.debug("SigConnection::dataChannelMessage",n.data);var r=JSON.parse(n.data);"ack"!==r.type&&t.handleMessage(r)}else e.send('{"type":"pong"}')}}},{key:"close",value:function(){var e=this.datachannel,t=this.userAgent;this.datachannel=null,this.userAgent=null,e&&"open"===e.readyState&&e.close(),t&&(t.removeAllListeners(),t.terminate())}},{key:"onMessage",value:function(e){this.messageListener.push(e)}},{key:"handleMessage",value:function(e){if(gr.includes(e.type)){var t=this.transformer.process(e);this.messageListener.forEach((function(e){return e(t)}))}else f.debug('SigConnection::handleMessage ignoring "'.concat(e.type,'" message.'))}},{key:"send",value:function(e){if(this.seppMessaging)this.sendSeppMessage(e);else{var t=this.datachannel;e.cid=this.uaOptions.client_id;var n=JSON.stringify(e);if(t&&"open"===t.readyState&&n.length<32768)return f.debug("SigConnection::send datachannel",n),void t.send(n);f.error("SigConnection::send failed",e)}}},{key:"sendSeppMessage",value:function(e){var t=this.userAgent;if(t&&t.callId){if(e.cid=this.uaOptions.client_id,e.call_id=t.callId,JSON.stringify(e).length<32768)return f.debug("SigConnection::send sepp",e),void t.message(e.type,e);f.error("SigConnection::send failed",e)}}},{key:"onError",value:function(e){return this.listeners.push(e),this}},{key:"emit",value:function(e){this.listeners.forEach((function(t){return t(e)}))}}])}();function wr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(wr=function(){return!!e})()}const Cr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,wr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n,r,i,o,a;if((n=t,r="handle",i=this,a=_(y(1&(o=3)?n.prototype:n),r,i),2&o&&"function"==typeof a?function(e){return a.apply(i,e)}:a)([e]),this.context.rtData=e.content,!0===e.content.ready){var s=e.content,c=s.user,u=s.room,l=s.signaling,d=s.links,h=s.options;this.context._eyeson.room=u,this.context._eyeson.user=this.context._api.addUserAttributes(c,c.id,l.options.client_id),this.context._eyeson.links=d,p.widescreen=Boolean(h.widescreen),this.context._connection?f.debug("RoomReceived double room_ready"):function(e,t,n){e.connection=new Sr(t,n),e._connection.onError((function(t){return e.send(t)})).start().then((function(){return e.send({type:"connection",connectionStatus:"ready"})})).catch((function(){return e.send({type:"connection",connectionStatus:"transport_error"})}))}(this.context,l,c)}else f.debug("RoomReceived not ready:",e.content)}}])}(M);function xr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(xr=function(){return!!e})()}const Tr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,xr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){var e=this;this.context._api.getRoom((function(n){return(r=t,i="handle",o=e,s=_(y(1&(a=3)?r.prototype:r),i,o),2&a&&"function"==typeof s?function(e){return s.apply(o,e)}:s)([{type:"fetch_room",room:n}]);var r,i,o,a,s}))}}])}(M);function _r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_r=function(){return!!e})()}const Rr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,_r()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.deleteFile(e.file)}}])}(S);function Mr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Mr=function(){return!!e})()}const Pr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Mr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.uploadFile(e.file,this.addFile.bind(this))}},{key:"addFile",value:function(e){var n,r,i,o,a;(n=t,r="handle",i=this,a=_(y(1&(o=3)?n.prototype:n),r,i),2&o&&"function"==typeof a?function(e){return a.apply(i,e)}:a)([{type:"add_file",file:e}])}}])}(M);function Er(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Er=function(){return!!e})()}const Or=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Er()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.cid.split("@").shift();this.msg=e,this.context._api.getUser(t,this.forwardMessage.bind(this))}},{key:"forwardMessage",value:function(e){var n,r,i,o,a,s=Date.parse(this.msg.ts||this.msg.created_at);(n=t,r="handle",i=this,a=_(y(1&(o=3)?n.prototype:n),r,i),2&o&&"function"==typeof a?function(e){return a.apply(i,e)}:a)([{type:this.msg.type,user:e,timestamp:new Date(s),content:this.msg.content}])}}])}(M);function Dr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Dr=function(){return!!e})()}const Ar=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Dr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=this,n=e.audio,r=void 0===n||n,i=e.video,o=void 0===i||i,a=e.virtualBackground,s=void 0!==a&&a,c=e.screen,u=void 0!==c&&c,l=e.surface,d=void 0===l?null:l,h=e.audioPassthrough,p=void 0!==h&&h;f.debug("StartStreamEvent::handle audio: ".concat(r," video: ").concat(o," screen: ").concat(u));var v=this.context,m=v._session,g=v._connection;if(!m)throw new Error("Session does not exist");if(m.micMixer&&(m.micMixer.destroy(),m.micMixer=null),m.options.virtualBackground=s,m.options.audioPassthrough=p,m.vbgMixer){var y=Fn.getStoredVirtualBackgroundType();m.vbgMixer.stopOriginalStream(),m.vbgMixer.terminate(),m.vbgMixer.changeBackground(y)}m.localStream&&!et.canMultipleDifferentMicrophones()&&ft(m.localStream);var b={audio:r,video:o,virtualBackground:m.options.virtualBackground,vbgMixer:m.vbgMixer,deviceMonitor:m.deviceMonitor,audioPassthrough:m.options.audioPassthrough};return u&&(m.micMixer=new Un,b.video=!1,b.screen=!0,b.surface=d,b.virtualBackground=!1,b.micMixer=m.micMixer),new Vn(b).start().then((function(e){var t=N(xt(e),1)[0];return t&&t.addEventListener("ended",(function(){m.emit({type:"stop_screen_video"})})),e})).then(m.setStream).then((function(){return m.send({type:"mute_video",on:!(o||u)})})).then((function(){(m.externalStream&&(m.externalStream=null,g.hasExternalStream=!1),m.lastResolution)&&new Gn(t.context).adjustResolution(m,m.lastResolution)})).catch((function(e){if(f.error("StartStreamEvent",e),u){m.micMixer&&(m.micMixer.destroy(),m.micMixer=null);var t="error_Screen_".concat(e.name);e.message.indexOf("not start audio")>-1&&(t="error_Screen_".concat(e.name,"_Audio")),m.emit({type:"screen_capture_error",name:t})}}))}}])}(S);function Ir(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Ir=function(){return!!e})()}const Br=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Ir()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.audio,n=void 0===t||t,r=e.video,i=void 0===r||r,o=e.screen,a=void 0!==o&&o,s=e.surface;f.debug("ChangeStreamEvent::handle audio: ".concat(n," video: ").concat(i," screen: ").concat(a));var c=this.context._session;if(!c)throw new Error("Session does not exist");c.micMixer&&(c.micMixer.destroy(),c.micMixer=null);return c.externalStream?(dt(c.externalStream,n),ht(c.externalStream,i),c.send({type:"mute_video",on:!i}),Promise.resolve()):new Promise((function(e,t){if(et.stopsDeviceActivityIndicatorOnDisable()&&!a){var r=N(c.localStream.getVideoTracks(),1)[0],o=N(c.localStream.getAudioTracks(),1)[0];if(!(i&&bt(r)||"ended"===r.readyState||"ended"===o.readyState||gt(r)))return c.vbgMixer&&c.vbgMixer.originalStream?(c.vbgMixer[i?"start":"stop"](),Ot(c.localStream,i),Et(c.vbgMixer.originalStream,i)):Et(c.localStream,i),dt(c.localStream,n),void e(c.localStream)}c.vbgMixer&&(c.vbgMixer.stopOriginalStream(),c.vbgMixer.terminate());var u={audio:n,video:i,virtualBackground:c.options.virtualBackground,existingStream:c.localStream,vbgMixer:c.vbgMixer,deviceMonitor:c.deviceMonitor,audioPassthrough:c.options.audioPassthrough};a&&(c.micMixer=new Un,u.screen=!0,u.video=!1,u.surface=s,u.virtualBackground=!1,u.vbgMixer=null,u.micMixer=c.micMixer),new Vn(u).onBrokenTrackError((function(){c.emit({type:"broken_track_error"})})).start().then(e).catch(t)})).then((function(e){var t=N(xt(e),1)[0];return t&&t.addEventListener("ended",(function(){c.emit({type:"stop_screen_video"})})),e})).then(c.setStream).then((function(e){Ft(e)?c.canvasMixer.setStream(e):c.send({type:"mute_video",on:!(i||a)})})).catch((function(e){if(f.error(e),e instanceof Error&&["NotReadableError","DevicesNotFoundError","NotFoundError"].includes(e.name)&&c.emit({type:"warning",name:"error_"+e.name}),a){c.micMixer&&(c.micMixer.destroy(),c.micMixer=null);var t="error_Screen_".concat(e.name);e.message.indexOf("not start audio")>-1&&(t="error_Screen_".concat(e.name,"_Audio")),c.emit({type:"screen_capture_error",name:t})}}))}}])}(S);function Lr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Lr=function(){return!!e})()}const jr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Lr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=Wt(e.stream);if(!t)return f.error("ReplaceStreamEvent::handle invalid stream",e.stream),Promise.reject(new TypeError("Invalid stream"));var n=this.context,r=n._session,i=n._connection;if(!r)throw new Error("Session does not exist");return r.micMixer&&(r.micMixer.destroy(),r.micMixer=null),r.vbgMixer&&(r.vbgMixer.stopOriginalStream(),r.vbgMixer.terminate()),r.options.audio=st(t),r.options.video=ct(t),r.setStream(t).then((function(){r.externalStream=t,i.hasExternalStream=!0,r.send({type:"mute_video",on:!ct(t)})})).catch((function(e){r.externalStream=null,i.hasExternalStream=!1,f.error(e)}))}}])}(S);function Fr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Fr=function(){return!!e})()}const Vr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Fr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.facingMode;f.debug("ToggleCameraEvent::handle",t);var n=this.context._session;if(!n)throw new Error("Session does not exist");new Vn({audio:n.localStream.getAudioTracks()[0].enabled,video:{facingMode:t},existingStream:n.localStream,deviceMonitor:n.deviceMonitor}).start().then(n.setStream).catch(f.error)}}])}(S);function Ur(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Ur=function(){return!!e})()}const Nr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Ur()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n,r,i,o,a,s=e.type,c=e.session.sessionDescriptionHandler,u=c.getLocalStream(),l=c.getRemoteStream();(n=t,r="handle",i=this,a=_(y(1&(o=3)?n.prototype:n),r,i),2&o&&"function"==typeof a?function(e){return a.apply(i,e)}:a)([{type:s,localStream:u,remoteStream:l}])}}])}(M);function Hr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Hr=function(){return!!e})()}const Wr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Hr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.stopRecording(e)}}])}(M);function zr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(zr=function(){return!!e})()}const qr=function(e){function t(e){var n,r,i,o;return c(this,t),r=this,o=[e],i=y(i=t),(n=g(r,zr()?Reflect.construct(i,o||[],y(r).constructor):i.apply(r,o))).getUser=n.getUser.bind(n),n}return k(t,e),d(t,[{key:"getUser",value:function(e){var t=this;return new Promise((function(n){t.context._api.getUser(e,n)}))}},{key:"handle",value:function(e){var t=this;this.getUser(e.userId).then((function(n){t.context.send({type:"voice_activity",user:n,on:e.on})}),(function(e){f.error("VoiceActivityEvent::handle",e)}))}}])}(S);function Gr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Gr=function(){return!!e})()}const $r=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Gr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=this.context,n=t._api,r=t._session;n.startRecording(e).catch((function(e){return r.emit({type:"recording_error",error:e})}))}}])}(M);function Jr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Jr=function(){return!!e})()}const Kr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Jr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.audio,n=e.screen,r=void 0!==n&&n,i=e.screenStream,o=e.surface,a=this.context._session;if(!a)throw new Error("Session does not exist");a.micMixer&&a.micMixer.destroy(),a.micMixer=new Un;new Vn({audio:t,video:!1,screen:r,surface:o,screenStream:i,existingStream:a.localStream,micMixer:a.micMixer,isPresentation:!0,deviceMonitor:a.deviceMonitor,audioPassthrough:a.options.audioPassthrough}).start().then((function(e){var t="screen",n=N(Ct(e),1)[0];if(n){n.addEventListener("ended",(function(){a.emit({type:"stop_presenting"})}));var r=function(e){if(e&&"function"==typeof e.getSettings){var t=e.getSettings();if(Reflect.apply(Object.prototype.hasOwnProperty,t,["displaySurface"]))return t.displaySurface}return""}(n);r&&(t="screen-".concat(r))}a.emit({type:"start_presenting",stream:e,present:t})})).catch((function(e){if(f.error("ScreenCaptureEvent",e),r){var t="error_Screen_".concat(e.name);e.message.indexOf("not start audio")>-1&&(t="error_Screen_".concat(e.name,"_Audio")),a.emit({type:"capture_error",name:t})}a.emit({type:"stop_presenting"})}))}}])}(S);function Xr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Xr=function(){return!!e})()}const Yr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Xr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"streamVideo",value:function(){var e=this,t=this.context._session;new Vn({audio:t.localStream.getAudioTracks()[0].enabled,video:!1,deviceMonitor:t.deviceMonitor}).start().then((function(n){var r=t.videoPlayer.invokeStream(n);return e.handle({stream:r})})).catch((function(e){f.error("StartPresentingEvent",e),e.name.match(/notallowed|permission/i)||t.emit({type:"capture_error",name:"error_".concat(e.name)}),t.emit({type:"stop_presenting"})}))}},{key:"handle",value:(n=F(W().mark((function e(t){var n,r,i,o,a,s,c,u;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.stream,r=void 0===n?null:n,i=t.present,o=void 0===i?"":i,a=this.context,s=a._session,c=a._api,s){e.next=4;break}throw new Error("Session does not exist");case 4:if(s.vbgMixer&&(s.vbgMixer.stopOriginalStream(),s.vbgMixer.terminate()),!s.videoPlayer||s.videoPlayer.isStreaming()){e.next=9;break}this.streamVideo(),e.next=15;break;case 9:return u=r||s.localStream,s.canvasMixer&&s.canvasMixer.stream&&(u=s.canvasMixer.stream),e.next=13,s.setStream(u);case 13:c.startPresentation((function(e){e.error&&s.emit({type:"stop_presenting"})})),s.emit({type:"presentation_started",present:o});case 15:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}]);var n}(S);function Qr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Qr=function(){return!!e})()}const Zr=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Qr()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){var e=this.context,t=e._session,n=e._api;if(!t)throw new Error("Session does not exist");t.canvasMixer&&(t.canvasMixer.vbgMixer&&(t.canvasMixer.vbgMixer.stopOriginalStream(),t.canvasMixer.vbgMixer.terminate(),t.canvasMixer.vbgMixer=null),t.canvasMixer.stop(),t.canvasMixer=null),t.micMixer&&(t.micMixer.destroy(),t.micMixer=null),t.videoPlayer&&(t.videoPlayer.destroy(),t.videoPlayer=null),n.stopPresentation(),t.emit({type:"presentation_ended"}),t.stopPresentingSet=!0}}])}(S);function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ei=function(){return!!e})()}const ti=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,ei()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n=this;this.context._api.stopAllBroadcasts().then((function(){return(r=t,i="handle",o=n,s=_(y(1&(a=3)?r.prototype:r),i,o),2&a&&"function"==typeof s?function(e){return s.apply(o,e)}:s)([{type:e.type}]);var r,i,o,a,s}))}}])}(M);function ni(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ni=function(){return!!e})()}const ri=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,ni()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){this.context._api.clearFrontLayer()}}])}(S);function ii(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ii=function(){return!!e})()}function oi(e,t,n,r){var i=_(y(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}const ai=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,ii()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n=this;return new v(e.api,e.token).requestUser({name:e.name,email:e.email,locale:e.locale},(function(e){if(!e.access_key){var r=e.locked;return e.error&&"ComApiError: 423"===e.error.message&&(r=!0),void oi(t,"handle",n,3)([{type:"error",content:"Request guest user failed",locked:r}])}oi(t,"handle",n,3)([{type:"guest_user",token:e.access_key}])}))}}])}(M);function si(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(si=function(){return!!e})()}const ci=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,si()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){this.context._eyeson.destroy()}}])}(S);function ui(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ui=function(){return!!e})()}const li=function(e){function t(e){var n,r,i,o;return c(this,t),r=this,o=[e],i=y(i=t),(n=g(r,ui()?Reflect.construct(i,o||[],y(r).constructor):i.apply(r,o))).getUser=n.getUser.bind(n),n}return k(t,e),d(t,[{key:"getUser",value:function(e){var t=this;return new Promise((function(n,r){if(t.context._api)try{t.context._api.getUser(e,n)}catch(e){r(e)}else r(new Error("missing ComAPI"))}))}},{key:"handle",value:function(e){var t=this;(e.add||[]).forEach((function(e,n,r){var i=e.cid,o=t.context._connection.clientId,a=Boolean(r.find((function(e){return e.cid===o})));t.getUser(i).then((function(e){t.context.send({type:"add_user",user:e,initial:a})})).catch((function(e){return f.error(e)}))})),(e.del||[]).forEach((function(e){var n=e;t.getUser(n).then((function(e){t.context.send({type:"remove_user",userId:n,user:e})})).catch((function(e){return f.error(e)}))}))}}])}(S);var di=function(e){return Number(parseFloat(e).toFixed(2))};const hi=function(e,t,n){var r=Math.min(n.width/e,n.height/t);return{width:di(e*r),height:di(t*r)}};const pi=function(e,t,n){var r;return function(){var i=this,o=arguments,a=n&&!r;clearTimeout(r),r=setTimeout((function(){r=null,n||e.apply(i,o)}),t),a&&e.apply(i,o)}};var fi=1e3/15,vi={width:220,height:140},mi={width:320,height:240},gi={width:420,height:340},yi={width:0,height:0},bi="function"==typeof window.MediaStreamTrackProcessor,ki={getSettings:function(){return{width:0,height:0}},addEventListener:function(){return null}},Si=et.isIOSDevice(),wi=function(e){var t=N(e.getVideoTracks(),1)[0];if(!t)return null;if(bi)return new MediaStreamTrackProcessor(t).readable.getReader();var n=t.getSettings(),r=n.width,i=n.height,o=document.createElement("video");return o.playsInline=!0,o.muted=!0,o.width=r,o.height=i,o.srcObject=e,t.addEventListener("stopped",(function(){o.srcObject=null})),o.play().catch((function(e){return f.warn("bindVideoToStream: play",e,e.message)})),o},Ci=function(){return d((function e(t,n){c(this,e),this.canvas=t,this.stream=n,this.camera=null,this.screen=null,this.canvasTrack=null,this.context=this.canvas.getContext("2d",{alpha:!1,desynchronized:!0}),this.xPos=0,this.camSize=mi,this.isCanvasCapture=!1,this.draw=this.draw.bind(this),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.onError=this.onError.bind(this),this.onRedraw=this.onRedraw.bind(this),this.setStream=this.setStream.bind(this),this.setCamera=this.setCamera.bind(this),this.drawFrame=this.drawFrame.bind(this),this.calcSizesAndPositions=this.calcSizesAndPositions.bind(this),this.bouncedDraw=pi(this.draw,fi)}),[{key:"onError",value:function(e){this.errorCallback=e}},{key:"onRedraw",value:function(e){this.redrawCallback=e}},{key:"start",value:function(){var e,t=N(Dt(this.stream),1)[0];this.canvasTrack=t,Si?((e=this).cameraStream={getVideoTracks:function(){return[]}},e.screenStream={getVideoTracks:function(){return[]}},this.setCamera({horizontal:"right",vertical:"bottom"},"none")):(this.setCamera({horizontal:"right",vertical:"bottom"},"medium"),this.setStream(this.stream)),this.draw()}},{key:"stop",value:function(){this.stream&&(ft(this.stream),this.stream=null,this.camera=null,this.screen=null,this.screenStream=null,this.cameraStream=null,this.canvasTrack=null)}},{key:"setStream",value:function(e){this.stream=e,this.cameraStream=new MediaStream(Lt(e)?_t(e):Tt(e)),this.screenStream=new MediaStream(Ct(this.stream));var t=function(e){if(e&&e.getVideoTracks().length>0){var t=N(e.getVideoTracks(),1)[0];if("canvas"in t)return t.canvas}return null}(this.cameraStream);t?(this.isCanvasCapture=!0,this.camera=t):(this.isCanvasCapture=!1,this.camera=wi(this.cameraStream)),this.screen=wi(this.screenStream),this.calcSizesAndPositions(),this.redrawQueued=!0}},{key:"setCamera",value:function(e,t){this.cameraPosition=e||this.cameraPosition,this.cameraSizeInWords=t||this.cameraSizeInWords,this.redrawQueued=!0}},{key:"calcSizesAndPositions",value:function(){var e,t,n,r,i,o,a,s,c=N(this.screenStream.getVideoTracks(),1)[0],u=(void 0===c?ki:c).getSettings(),l=(e=this.canvas,n=(t=u).width/t.height,r=e.width/e.height,i=e.width,o=e.height,a=0,s=0,n<r&&(i=t.width*(o/t.height),a=(e.width-i)/2),n>r&&(o=t.height*(i/t.width),s=(e.height-o)/2),{x:a,y:s,width:i,height:o}),d=N(this.cameraStream.getVideoTracks(),1)[0],h=(void 0===d?ki:d).getSettings();this.camSize={small:vi,medium:mi,large:gi,none:yi}[this.cameraSizeInWords];var p=hi(h.width,h.height,this.camSize);this.sizes={screen:{width:l.width,height:l.height},camera:{width:p.width,height:p.height}};var f={x:"right"===this.cameraPosition.horizontal?this.canvas.width-this.sizes.camera.width:0,y:"bottom"===this.cameraPosition.vertical?this.canvas.height-this.sizes.camera.height:0};this.positions={screen:{x:l.x,y:l.y},camera:{x:f.x,y:f.y}}}},{key:"draw",value:(e=F(W().mark((function e(){var t,n,r,i,o,a;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.stream&&this.stream.active){e.next=3;break}return e.abrupt("return");case 3:if(this.calcSizesAndPositions(),this.redrawCallback&&this.redrawQueued&&(this.redrawCallback(),this.redrawQueued=!1),t=performance.now(),!this.screen){e.next=14;break}if(n=this.screen,!(bi&&this.screen instanceof ReadableStreamDefaultReader)){e.next=13;break}return e.next=11,this.screen.read();case 11:r=e.sent,n=r.value;case 13:this.drawFrame(n,this.positions.screen,this.sizes.screen,!1,!0);case 14:if(i=this.camera,!(bi&&this.camera instanceof ReadableStreamDefaultReader)){e.next=20;break}return e.next=18,this.camera.read();case 18:o=e.sent,i=o.value;case 20:this.drawFrame(i,this.positions.camera,this.sizes.camera,this.isCanvasCapture,!1),(a=performance.now())-t>=fi&&f.warn("Mixer::drawFrame took ".concat(a-t,"ms."));try{this.canvasTrack&&this.canvasTrack.requestFrame()}catch(e){f.warn("CanvasMixer draw requestFrame error - ".concat(e.message))}this.bouncedDraw(),e.next=31;break;case 27:e.prev=27,e.t0=e.catch(0),f.error(e.t0),this.errorCallback(e.t0);case 31:case"end":return e.stop()}}),e,this,[[0,27]])}))),function(){return e.apply(this,arguments)})},{key:"drawFrame",value:function(e,t,n,r,i){var o=this.context,a=this.canvas;if(e&&(r||!(e instanceof HTMLVideoElement)||e.srcObject&&e.srcObject.active))i&&!r&&o.clearRect(0,0,a.width,a.height),o.drawImage(e,t.x,t.y,n.width,n.height),bi&&"function"==typeof e.close&&e.close();else{var s=o.createImageData(1,1);o.putImageData(s,0,0)}}}]);var e}();const xi=Ci;function Ti(e,t,n){return t=y(t),g(e,_i()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function _i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_i=function(){return!!e})()}var Ri=function(e){function t(){return c(this,t),Ti(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.audio,n=e.video,r=e.canvas,i=e.screen,o=void 0!==i&&i,a=e.surface,s=e.onRedraw,c=e.changeStream,u=void 0!==c&&c,l=e.present,d=void 0===l?"mixer":l,h=this.context._session;if(!h)throw new Error("Session does not exist");var p=Fn.getStoredVirtualBackgroundType(),v=new In("canvasmixer");v.changeBackground(p);var m=function(e){f.error("StartMixerEvent",e),!h.canvasMixer&&v&&v.terminate(),!e.name.match(/notallowed|permission/i)&&o&&h.emit({type:"capture_error",name:"error_".concat(e.name)}),h.emit({type:"stop_presenting"})};new Vn({audio:t,video:n,virtualBackground:h.options.virtualBackground,screen:o,surface:a,canvas:r,existingStream:h.localStream,vbgMixer:v,deviceMonitor:h.deviceMonitor,audioPassthrough:h.options.audioPassthrough}).start().then((function(e){var t=N(Ct(e),1)[0];return t&&t.addEventListener("ended",(function(){h.emit({type:"stop_presenting"}),pt(t)})),h.canvasMixer=new xi(r,e),h.canvasMixer.vbgMixer=v,h.canvasMixer.onError(m),h.canvasMixer.onRedraw(s),h.canvasMixer.start(),e})).then((function(e){u?h.emit({type:"start_presenting",stream:e,present:d}):h.emit({type:"stream_update",presentationStream:e})})).catch(m)}}])}(S),Mi=function(e){function t(){return c(this,t),Ti(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(e){var t=e.position,n=e.size,r=this.context._session;if(!r)throw new Error("Session does not exist");try{r.canvasMixer.setCamera(t,n)}catch(e){f.error(e)}}}])}(S),Pi="function"==typeof HTMLVideoElement.prototype.requestVideoFrameCallback,Ei=et.isIOSDevice();const Oi=function(){return d((function e(t){var n=t.canvas,r=t.file,i=t.onReady,o=t.onDuration,a=t.onTimeUpdate,s=t.onEnd,u=t.performAction;c(this,e),this.ac=null,this.acOut=null,this.gainNode=null,this.timer=null,this.canvas=n,this.url=URL.createObjectURL(r),this.ctx=n.getContext("2d"),this.video=document.createElement("video"),this.callback={onReady:i,onDuration:o,onTimeUpdate:a,onEnd:s,performAction:u},this.errorCallback=null,this.boundDrawVideoFrame=this.drawVideoFrame.bind(this),this.boundInitCanvasStream=this.initCanvasStream.bind(this),this.isPlaying=!1,this.blockTimeUpdate=!1,this.micOnlyStream=null,this.userMediaStream=null,this.initTimeout=null,this.invokationTimer=null,this.initVideo()}),[{key:"drawVideoFrame",value:function(){this.ctx.drawImage(this.video,0,0),this.timer=Pi?this.video.requestVideoFrameCallback(this.boundDrawVideoFrame):requestAnimationFrame(this.boundDrawVideoFrame)}},{key:"initVideo",value:function(){var e=this,t=this.video;t.playsInline=!0,t.autoplay=Boolean(Ei),t.preload="",t.onplaying=this.onVideoPlay.bind(this),t.onpause=this.onVideoPause.bind(this),t.onseeked=this.onVideoSeeked.bind(this),t.ontimeupdate=this.onVideoTimeUpdate.bind(this),t.onloadeddata=this.onVideoReady.bind(this),t.onerror=this.onVideoError.bind(this),t.onended=this.onVideoEnd.bind(this),this.initTimeout=setTimeout((function(){return e.onVideoError()}),6e3),t.src=this.url}},{key:"onVideoReady",value:function(){var e=this.video,t=this.canvas;clearTimeout(this.initTimeout),this.callback.onDuration(e.duration),t.width=e.videoWidth,t.height=e.videoHeight,this.ac=new(window.AudioContext||window.webkitAudioContext),this.gainNode=this.ac.createGain(),this.ac.createMediaElementSource(e).connect(this.gainNode),this.gainNode.connect(this.ac.destination),Pi&&(this.timer=e.requestVideoFrameCallback(this.boundDrawVideoFrame)),this.callback.performAction(this.onVideoAction.bind(this));try{this.ctx.drawImage(e,0,0)}catch(e){return void(this.errorCallback&&this.errorCallback(e))}this.callback.onReady(),e.autoplay&&setTimeout((function(){e.pause(),e.currentTime=0}))}},{key:"onVideoAction",value:function(e,t){return"play"===e?this.onPlayAction():"pause"===e?this.onPauseAction():("time"===e?this.onTimeAction(t):"volume"===e&&this.onVolumeAction(t),Promise.resolve())}},{key:"onPlayAction",value:function(){var e=this.video;return e.paused&&!this.isPlaying?e.play().then((function(){return e.paused}),(function(){return e.paused})):Promise.resolve(e.paused)}},{key:"onPauseAction",value:function(){var e=this.video;return!e.paused&&this.isPlaying&&e.pause(),Promise.resolve(e.paused)}},{key:"onTimeAction",value:function(e){var t=this.video;this.blockTimeUpdate=!0,e>=t.duration?t.currentTime=t.duration-.1:t.currentTime=e,this.blockTimeUpdate=!1}},{key:"onVolumeAction",value:function(e){this.gainNode&&(this.gainNode.gain.value=e)}},{key:"onVideoPlay",value:function(){this.isPlaying=!0,Pi||(this.timer=requestAnimationFrame(this.boundDrawVideoFrame)),this.invokationTimer&&(cancelAnimationFrame(this.invokationTimer),this.invokationTimer=null)}},{key:"onVideoPause",value:function(){this.isPlaying=!1,!Pi&&this.timer&&cancelAnimationFrame(this.timer)}},{key:"onVideoSeeked",value:function(){Pi||this.isPlaying||this.ctx.drawImage(this.video,0,0)}},{key:"onVideoTimeUpdate",value:function(){this.blockTimeUpdate||this.callback.onTimeUpdate(this.video.currentTime)}},{key:"onVideoError",value:function(){var e=this.video,t=e&&e.error?e.error:new TypeError("VideoPlayer failed");f.error("VideoPlayer failed",t),this.errorCallback&&this.errorCallback(t)}},{key:"onVideoEnd",value:function(){this.callback.onEnd()}},{key:"initCanvasStream",value:function(){this.ctx.drawImage(this.video,0,0),this.invokationTimer=requestAnimationFrame(this.boundInitCanvasStream)}},{key:"invokeStream",value:function(e){var t=N(this.canvas.captureStream(25).getVideoTracks(),1)[0];t.canvas||(t.type="canvas-track",t.canvas=this.canvas);var n=new MediaStream([t]);return this.acOut=this.ac.createMediaStreamDestination(),this.gainNode.connect(this.acOut),this.ac.createMediaStreamSource(e).connect(this.acOut),this.acOut.stream.getAudioTracks().forEach((function(e){return n.addTrack(e)})),this.userMediaStream=e,this.micOnlyStream=new MediaStream(e.getAudioTracks().concat(t)),this.isPlaying||(this.invokationTimer=requestAnimationFrame(this.boundInitCanvasStream)),n}},{key:"isStreaming",value:function(){return Boolean(this.micOnlyStream)}},{key:"getMicOnlyStream",value:function(){return this.micOnlyStream}},{key:"onError",value:function(e){this.errorCallback=e}},{key:"destroy",value:function(){var e=this,t=this.video;clearTimeout(this.initTimeout),this.url&&(URL.revokeObjectURL(this.url),this.url=null),this.timer&&(Pi?t.cancelVideoFrameCallback(this.timer):cancelAnimationFrame(this.timer),this.timer=null),this.invokationTimer&&(cancelAnimationFrame(this.invokationTimer),this.invokationTimer=null),this.userMediaStream&&(ft(this.userMediaStream),this.userMediaStream=null),this.micOnlyStream&&(ft(this.micOnlyStream),this.micOnlyStream=null),this.acOut&&(ft(this.acOut.stream),this.acOut=null),this.ac&&(this.gainNode.disconnect(),this.ac.close().then((function(){e.ac=null,e.gainNode=null}))),t&&(t.pause(),t.onplaying=null,t.onpause=null,t.ontimeupdate=null,t.onloadeddata=null,t.onseeked=null,t.onerror=null,t.onended=null,this.video=null),this.callback=null,this.errorCallback=null,this.ctx=null,this.canvas=null,this.boundDrawVideoFrame=null}}])}();function Di(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Di=function(){return!!e})()}var Ai=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Di()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=this.context._session;if(!t)throw new Error("Session does not exist");var n=function(e){f.error("StartMediaEvent",e);var n=e&&(e instanceof MediaError||e instanceof DOMException)?"error_VideoError":"error_TypeError";t.emit({type:"warning",name:n}),t.emit({type:"stop_presenting"})};try{t.videoPlayer=new Oi(e),t.videoPlayer.onError(n)}catch(e){n(e)}}}])}(S);function Ii(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Ii=function(){return!!e})()}const Bi=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Ii()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){this.context._api.lockMeeting()}}])}(S);function Li(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Li=function(){return!!e})()}const ji=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Li()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){this.context._api.terminateMeeting()}}])}(S);function Fi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Fi=function(){return!!e})()}const Vi=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Fi()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){this.context._api.kickUser(e.userId)}}])}(S);function Ui(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Ui=function(){return!!e})()}const Ni=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Ui()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var t=this.context._session;if(!t)throw new Error("Session does not exist");t.vbgMixer&&("suspend"===e.state?(t.vbgMixer.suspend(),t.canvasMixer&&t.canvasMixer.vbgMixer&&t.canvasMixer.vbgMixer.suspend()):"resume"===e.state&&(t.vbgMixer.resume(),t.canvasMixer&&t.canvasMixer.vbgMixer&&t.canvasMixer.vbgMixer.resume()))}}])}(S);function Hi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Hi=function(){return!!e})()}var Wi=function(e){e.micMixer&&(e.micMixer.destroy(),e.micMixer=null)},zi=function(e){var t="error_Screen_".concat(e.name);return e.message.indexOf("not start audio")>-1&&(t="error_Screen_".concat(e.name,"_Audio")),t};const qi=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Hi()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:(n=F(W().mark((function e(t){var n,r,i,o,a,s,c,u,l;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.surface,r=null,i=this.context._session){e.next=5;break}throw new Error("Session does not exist");case 5:return e.prev=5,o=new Vn({surface:n}),e.next=9,o.getDisplayMedia();case 9:r=e.sent,e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(5),f.error("ScreenVideoChangeEvent",e.t0),i.emit({type:"warning",name:zi(e.t0)}),e.abrupt("return");case 17:return Wi(i),i.micMixer=new Un,a={audio:i.localStream.getAudioTracks()[0].enabled,video:!1,screen:!0,surface:n,micMixer:i.micMixer,screenStream:r},e.prev=20,e.next=23,new Vn(a).start();case 23:s=e.sent,c=xt(s),u=N(c,1),(l=u[0])&&l.addEventListener("ended",(function(){i.emit({type:"stop_screen_video"})})),i.setStream(s),e.next=35;break;case 29:e.prev=29,e.t1=e.catch(20),f.error("ScreenVideoChangeEvent",e.t1),Wi(i),i.emit({type:"screen_capture_error",name:zi(e.t1)}),i.emit({type:"screen_video_ended"});case 35:case"end":return e.stop()}}),e,this,[[5,12],[20,29]])}))),function(e){return n.apply(this,arguments)})}]);var n}(S);function Gi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Gi=function(){return!!e})()}const $i=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Gi()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(){var e=this.context._session;if(!e)throw new Error("Session does not exist");e.micMixer&&(e.micMixer.destroy(),e.micMixer=null),e.emit({type:"screen_video_ended"})}}])}(S);function Ji(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Ji=function(){return!!e})()}const Ki=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Ji()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n,r,i,o,a;(n=t,r="handle",i=this,a=_(y(1&(o=3)?n.prototype:n),r,i),2&o&&"function"==typeof a?function(e){return a.apply(i,e)}:a)([e]);var s=this.context._session;if(s){var c=e.presentation,u=s.localStream;c||!Vt(u)||s.stopPresentingSet||s.emit({type:"stop_presenting"})}}}])}(M);function Xi(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Xi=function(){return!!e})()}function Yi(e,t,n,r){var i=_(y(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}const Qi=function(e){function t(){return c(this,t),e=this,r=arguments,n=y(n=t),g(e,Xi()?Reflect.construct(n,r||[],y(e).constructor):n.apply(e,r));var e,n,r}return k(t,e),d(t,[{key:"handle",value:function(e){var n=this,r=new v(e.api,e.token),i=function(e){if(e.error)return f.debug("requestPermalinkMeetingInfo::error",e.error),void Yi(t,"handle",n,3)([{type:"error",content:"Request permalink meeting info failed"}]);if("string"==typeof e.permalink.expires_at){var o=Date.parse(e.permalink.expires_at);if(!isNaN(o)&&o<Date.now())return f.debug("requestPermalinkMeetingInfo::expired",e.permalink),void Yi(t,"handle",n,3)([{type:"error",content:"Permalink is already expired"}])}f.debug("requestPermalinkMeetingInfo::info",e.room),Yi(t,"handle",n,3)([{type:"permalink_meeting_info",room:e.room}]),null===e.room.started_at&&setTimeout((function(){r.requestPermalinkMeetingInfo(i)}),5e3)};f.debug("requestPermalinkMeetingInfo::start"),r.requestPermalinkMeetingInfo(i)}}])}(M);var Zi=et.isIOSDevice();const eo=function(){return d((function e(){c(this,e),this.tempAudioTrack=null,this.tempVideoTrack=null,this.audioTrack=null,this.videoTrack=null,this.audioEnded=null,this.videoEnded=null,this.defaultMic=null,this.boundOnAudioEnd=this.onAudioEnd.bind(this),this.boundOnVideoEnd=this.onVideoEnd.bind(this),this.boundOnAudioDeviceChange=this.onAudioDeviceChange.bind(this),this.listeners=[]}),[{key:"addAudioTrack",value:function(e){!Zi&&e&&"ended"!==e.readyState&&(this.tempAudioTrack=e)}},{key:"addVideoTrack",value:function(e){!Zi&&e&&"ended"!==e.readyState&&(this.tempVideoTrack=e)}},{key:"applyTempTracks",value:function(){this.clearTracks(),this.tempAudioTrack&&(this.audioTrack=this.tempAudioTrack,this.tempAudioTrack=null,this.audioTrack.addEventListener("ended",this.boundOnAudioEnd),this.checkDefaultMic()),this.tempVideoTrack&&(this.videoTrack=this.tempVideoTrack,this.tempVideoTrack=null,this.videoTrack.addEventListener("ended",this.boundOnVideoEnd))}},{key:"discardTempTracks",value:function(){this.tempAudioTrack=null,this.tempVideoTrack=null}},{key:"checkDefaultMic",value:(t=F(W().mark((function e(){var t;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,"default"!==this.audioTrack.getSettings().deviceId){e.next=7;break}return e.next=5,Fn.getDevices();case 5:(t=e.sent.find((function(e){var t=e.deviceId;return"audioinput"===e.kind&&"default"===t})))&&(this.defaultMic=t,navigator.mediaDevices.addEventListener("devicechange",this.boundOnAudioDeviceChange));case 7:e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(){return t.apply(this,arguments)})},{key:"onAudioDeviceChange",value:(e=F(W().mark((function e(){var t,n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=this.defaultMic,this.abortAudioDeviceChange(),e.next=5,Fn.getDevices();case 5:(n=e.sent.find((function(e){var t=e.deviceId;return"audioinput"===e.kind&&"default"===t})))&&t&&(t.label!==n.label||t.groupId!==n.groupId)&&(this.audioTrack.stop(),this.onAudioEnd()),e.next=11;break;case 9:e.prev=9,e.t0=e.catch(0);case 11:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(){return e.apply(this,arguments)})},{key:"abortAudioDeviceChange",value:function(){this.defaultMic=null,navigator.mediaDevices.removeEventListener("devicechange",this.boundOnAudioDeviceChange)}},{key:"onAudioEnd",value:function(){var e=this;if(this.abortAudioDeviceChange(),this.videoEnded)return clearTimeout(this.videoEnded),void this.emit({type:"all_devices_ended"});this.audioEnded=setTimeout((function(){e.videoEnded?(clearTimeout(e.videoEnded),e.emit({type:"all_devices_ended"})):e.emit({type:"audio_device_ended"})}),1e3)}},{key:"onVideoEnd",value:function(){var e=this;this.videoEnded=setTimeout((function(){e.audioEnded||e.emit({type:"video_device_ended"})}),1e3)}},{key:"onEvent",value:function(e){this.listeners.push(e)}},{key:"emit",value:function(e){this.listeners.forEach((function(t){return t(e)}))}},{key:"clearTracks",value:function(){clearTimeout(this.audioEnded),clearTimeout(this.videoEnded),this.abortAudioDeviceChange(),this.audioTrack&&(this.audioTrack.removeEventListener("ended",this.boundOnAudioEnd),this.audioTrack=null),this.videoTrack&&(this.videoTrack.removeEventListener("ended",this.boundOnVideoEnd),this.videoTrack=null),this.audioEnded=null,this.videoEnded=null,this.defaultMic=null}},{key:"destroy",value:function(){this.listeners.length=0,this.discardTempTracks(),this.clearTracks()}}]);var e,t}();const to=function(){return d((function e(t){c(this,e),this.video=null,this.stream=null,this.canvasStream=null,this.vbgMixer=null,this.deviceMonitor=null,this.session=t,this.isActive=!1,this.startTimer=null}),[{key:"start",value:(o=F(W().mark((function e(){var t,n=this;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.session,et.hasPipCamSupport()){e.next=4;break}return t.emit({type:"pip_cam_warning_unsupported"}),e.abrupt("return");case 4:return e.prev=4,this.startTimer=setTimeout((function(){return n.onError(new Error("Starting timeout 5s"))}),5e3),this.initFakeStream(),e.next=9,this.initVideoAndPip();case 9:return e.next=11,this.initCamera();case 11:clearTimeout(this.startTimer),this.isActive=!0,t.emit({type:"pip_cam",active:!0}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),this.onError(e.t0);case 19:case"end":return e.stop()}}),e,this,[[4,16]])}))),function(){return o.apply(this,arguments)})},{key:"onError",value:function(e){var t=this.session;clearTimeout(this.startTimer),f.error("PipCam error",e),t?(t.emit({type:"pip_cam_error"}),t.emit({type:"stop_pip_cam"})):this.stop()}},{key:"updateCamera",value:(i=F(W().mark((function e(){var t,n,r,i,o,a=this;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isActive){e.next=2;break}return e.abrupt("return");case 2:return t=this.video,n=this.stream,r=this.canvasStream,i=this.vbgMixer,o=this.deviceMonitor,this.startTimer=setTimeout((function(){return a.onError(new Error("Starting timeout 5s"))}),5e3),e.prev=4,t.srcObject=r,e.next=8,t.play();case 8:return o&&(o.destroy(),this.deviceMonitor=null),i&&(i.stopOriginalStream(),i.terminate(),this.vbgMixer=null),n&&(ft(n),this.stream=null),e.next=13,this.initCamera();case 13:clearTimeout(this.startTimer),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),this.onError(e.t0);case 19:case"end":return e.stop()}}),e,this,[[4,16]])}))),function(){return i.apply(this,arguments)})},{key:"initFakeStream",value:function(){var e=p.widescreen,t=document.createElement("canvas"),n=t.getContext("2d",{alpha:!1});t.width=640,t.height=e?360:480,n.fillStyle="#404040",n.fillRect(0,0,t.width,t.height);var r=new Path2D(e?"M320 180c31 0 56-25 56-56s-25-56-56-56-56 25-56 56 25 56 56 56zm0 28c-37 0-112 19-112 56v28h224v-28c0-37-75-56-112-56z":"M320 240c31 0 56-25 56-56s-25-56-56-56-56 25-56 56 25 56 56 56zm0 28c-37 0-112 19-112 56v28h224v-28c0-37-75-56-112-56z");n.fillStyle="#212121",n.fill(r),this.canvasStream=t.captureStream()}},{key:"initVideoAndPip",value:(r=F(W().mark((function e(){var t,n=this;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=document.createElement("video"),this.video=t,t.muted=!0,t.playsInline=!0,t.onleavepictureinpicture=function(){return n.onExitPip()},t.onpause=function(e){var t=e.target;return n.onVideoPause(t)},t.srcObject=this.canvasStream,e.next=9,t.play();case 9:return e.next=11,t.requestPictureInPicture();case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"initCamera",value:(n=F(W().mark((function e(){var t,n,r,i=this;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=this.session.options.virtualBackground)&&(n=Fn.getStoredVirtualBackgroundType(),this.vbgMixer=new In("PipCam"),this.vbgMixer.changeBackground(n)),this.deviceMonitor=new eo,this.deviceMonitor.onEvent((function(e){return i.onDeviceEvent(e)})),r={audio:!1,video:!0,virtualBackground:t,vbgMixer:this.vbgMixer,deviceMonitor:this.deviceMonitor},e.next=7,new Vn(r).start();case 7:return this.stream=e.sent,this.video.srcObject=this.stream,e.next=11,this.video.play();case 11:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"onExitPip",value:function(){this.session?this.session.emit({type:"stop_pip_cam"}):this.stop()}},{key:"onVideoPause",value:function(e){setTimeout((function(){return e.play().catch((function(){}))}))}},{key:"onDeviceEvent",value:function(e){e.type.endsWith("_ended")&&(clearTimeout(this.startTimer),this.session?(this.session.emit({type:"pip_cam_warning_video_ended"}),this.session.emit({type:"stop_pip_cam"})):this.stop())}},{key:"stop",value:(t=F(W().mark((function e(){var t,n,r,i,o;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.video,n=this.stream,r=this.canvasStream,i=this.vbgMixer,o=this.deviceMonitor,clearTimeout(this.startTimer),!t){e.next=15;break}if(t.onpause=null,t.onleavepictureinpicture=null,document.pictureInPictureElement!==t){e.next=13;break}return e.prev=6,e.next=9,document.exitPictureInPicture();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(6);case 13:t.srcObject=null,this.video=null;case 15:o&&(o.destroy(),this.deviceMonitor=null),i&&(i.stopOriginalStream(),i.terminate(),this.vbgMixer=null),n&&(ft(n),this.stream=null),r&&(ft(r),this.canvasStream=null),this.isActive&&(this.session&&this.session.emit({type:"pip_cam",active:!1}),this.isActive=!1);case 20:case"end":return e.stop()}}),e,this,[[6,11]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:(e=F(W().mark((function e(){return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.stop();case 2:this.session=null;case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t,n,r,i,o}();function no(e,t,n){return t=y(t),g(e,ro()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function ro(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ro=function(){return!!e})()}var io=function(e){function t(){return c(this,t),no(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(){var e=this.context._session;if(!e)throw new Error("Session does not exist");e.pipCam?e.emit({type:"pip_cam",active:e.pipCam.isActive}):(e.pipCam=new to(e),e.pipCam.start())}}])}(S),oo=function(e){function t(){return c(this,t),no(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(){var e=this.context._session;if(!e)throw new Error("Session does not exist");e.pipCam?(e.pipCam.destroy(),e.pipCam=null):e.emit({type:"pip_cam",active:!1})}}])}(S),ao=function(e){function t(){return c(this,t),no(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:function(){var e=this.context._session;if(!e)throw new Error("Session does not exist");e.pipCam&&e.pipCam.updateCamera()}}])}(S);function so(e,t,n){return t=y(t),g(e,co()?Reflect.construct(t,n||[],y(e).constructor):t.apply(e,n))}function co(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(co=function(){return!!e})()}function uo(e,t,n,r){var i=_(y(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}var lo=function(e){function t(){return c(this,t),so(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:(n=F(W().mark((function e(n){var r,i,o,a,s,c,u,l,d,h,p;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.context._session,e.prev=1,i=st(r.localStream),o=ct(r.localStream),e.next=6,new Br(this.context).handle({audio:i,video:o});case 6:if(!((a=r.localStream.getAudioTracks())&&a.length>0)){e.next=16;break}return s=N(a,1),c=s[0],e.next=11,Fn.fetchInputDevices();case 11:u=e.sent,l=c.getSettings(),d=l.deviceId,h=u.find((function(e){return e.deviceId===d})),et.canMultipleDifferentMicrophones()||((p=ot.load("mediaConstraints")).audio={deviceId:{exact:d}},ot.store("mediaConstraints",p),ot.store("audioId",d)),h&&(n.newAudioDevice=h.label);case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(1),f.error("AudioDeviceEndEvent",e.t0);case 21:uo(t,"handle",this,3)([n]);case 22:case"end":return e.stop()}}),e,this,[[1,18]])}))),function(e){return n.apply(this,arguments)})}]);var n}(M),ho=function(e){function t(){return c(this,t),so(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:(n=F(W().mark((function e(n){var r,i;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.context._session,e.prev=1,i=st(r.localStream),e.next=5,new Br(this.context).handle({audio:i,video:!1});case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),f.error("VideoDeviceEndEvent",e.t0);case 10:uo(t,"handle",this,3)([n]);case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e){return n.apply(this,arguments)})}]);var n}(M),po=function(e){function t(){return c(this,t),so(this,t,arguments)}return k(t,e),d(t,[{key:"handle",value:(n=F(W().mark((function e(n){var r,i,o,a,s,c,u,l,d,h;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.context._session,e.prev=1,i=st(r.localStream),e.next=5,new Br(this.context).handle({audio:i,video:!1});case 5:if(!((o=r.localStream.getAudioTracks())&&o.length>0)){e.next=15;break}return a=N(o,1),s=a[0],e.next=10,Fn.fetchInputDevices();case 10:c=e.sent,u=s.getSettings(),l=u.deviceId,d=c.find((function(e){return e.deviceId===l})),et.canMultipleDifferentMicrophones()||((h=ot.load("mediaConstraints")).audio={deviceId:{exact:l}},ot.store("mediaConstraints",h),ot.store("audioId",l)),d&&(n.newAudioDevice=d.label);case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(1),f.error("AllDevicesEndEvent",e.t0);case 20:uo(t,"handle",this,3)([n]);case 21:case"end":return e.stop()}}),e,this,[[1,17]])}))),function(e){return n.apply(this,arguments)})}]);var n}(M),fo=function(){return d((function e(){c(this,e),this.listeners=[],this._eyeson=null,this._session=null,this._monitor=null,this._connection=null,this._rtConnection=null,this.send=this.send.bind(this)}),[{key:"destroy",value:function(){this._monitor&&this._monitor.destroy(),this._connection&&this._connection.close(),this._rtConnection&&this._rtConnection.close(),this._session&&(this._session.vbgMixer&&(this._session.vbgMixer.stopOriginalStream(),this._session.vbgMixer.terminate(),this._session.vbgMixer.destroy()),this._session.end()),this._api=null,this._session=null,this._monitor=null,this._connection=null,this._rtConnection=null}},{key:"connection",get:function(){return null},set:function(e){this._connection?f.error("A connection is already set. If you are trying to start a new session you have to end the current one first."):(this._connection=e,this._connection.onMessage(this.send))}},{key:"rtConnection",get:function(){return null},set:function(e){this._rtConnection?f.error("A real-time connection is already set. If you are trying to start a new session you have the close the current before."):(this._rtConnection=e,this._rtConnection.onMessage(this.send))}},{key:"monitor",get:function(){return this._monitor},set:function(e){this._monitor?f.error("A monitor is already set. If you are trying to start a new session you have to end the current one first."):(this._monitor=e,this._monitor.onEvent(this.send))}},{key:"session",get:function(){return null},set:function(e){this._session?f.error("A session is already set. If you are trying to start a new session you have to end the current one first."):(this._session=e,this._session.onEvent(this.send))}},{key:"api",get:function(){return null},set:function(e){this._api=e}},{key:"rtData",get:function(){return null},set:function(e){this._rtData=e}},{key:"eyeson",get:function(){return null},set:function(e){this._eyeson=e}},{key:"onReceive",value:function(e){f.debug("EventHandler::onReceive"),this.listeners.includes(e)||this.listeners.push(e)}},{key:"removeListener",value:function(e){e?this.listeners=this.listeners.filter((function(t){return t!==e})):this.listeners.length=0}},{key:"send",value:function(e){e.silenced||f.debug("EventHandler::send",e),new({stfu:q,chat:Or,accept:Nr,podium:Gn,snapshot:Jn,send_chat:Qn,set_layer:Xn,set_layout:nr,fetch_room:Tr,room_ready:Cr,room_setup:Cr,memberlist:li,upload_file:Pr,delete_file:Rr,request_stfu:I,change_stream:Br,replace_stream:jr,toggle_camera:Vr,stop_playback:T,playback_update:q,start_playback:x,start_stream:Ar,stop_recording:Wr,start_screen_capture:Kr,stop_broadcasts:ti,start_recording:$r,stop_presenting:Zr,start_presenting:Yr,stop_annotation:D,start_annotation:O,clear_front_layer:ri,request_guest_user:ai,request_permalink_meeting_info:Qi,voice_activity_raw:qr,start_mixer:Ri,update_mixer:Mi,lock_meeting:Bi,terminate_meeting:ji,kick_user:Vi,session_termination:ci,start_media:Ai,change_screen_video:qi,stop_screen_video:$i,stop_rtmp:er,start_rtmp:ir,suspend_virtual_background:Ni,audio_device_ended:lo,video_device_ended:ho,all_devices_ended:po,start_pip_cam:io,stop_pip_cam:oo,update_pip_cam:ao,presentation_update:Ki,capture_error:q,voice_activity:q,options_update:q,ext_not_installed:q,broadcasts_update:q,presentation_ended:q,recording:L,ext_cancel:L,ext_installed:L,message_status:L,moderator_info:L}[e.type]||M)(this).handle(e)}}])}();const vo=fo;var mo="\r\n",go=function(e){var t=e.split(mo),n=t.findIndex((function(e){return e.startsWith("t=")})),r=1;return et.canSFU()&&(t.splice(n+r,0,"a=sfu-capable"),r++,et.disallowAudioSyncSrcChange()&&(t.splice(n+r,0,"a=disallow-audio-ssrc-change"),r++)),et.canDataChannel()&&t.splice(n+r,0,"a=eyeson-datachan-capable","a=eyeson-datachan-keepalive","a=eyeson-sepp-messaging"),t.join(mo)},yo=function(e,t){var n=t.receiveConstraints,r=n.audio,i=void 0===r?{}:r,o=n.video,a=void 0===o?{}:o,s=window.Number.isInteger;if(!s(i.maxBitrate)&&!s(a.maxBitrate))return e;var c=[],u=[];s(i.maxBitrate)&&c.push("max-bitrate="+Math.floor(i.maxBitrate/1e3)),s(a.maxBitrate)&&u.push("max-bitrate="+Math.floor(a.maxBitrate/1e3));var l=e.split(mo);if(c.length>0){for(var d=l.findIndex((function(e){return e.startsWith("m=audio")}))+1;l[d].startsWith("c=")||l[d].startsWith("i=");)d++;l.splice(d,0,"a=eyeson-recv-constraints:".concat(c.join(" ")))}if(u.length>0){for(var h=l.findIndex((function(e){return e.startsWith("m=video")}))+1;l[h].startsWith("c=")||l[h].startsWith("i=");)h++;l.splice(h,0,"a=eyeson-recv-constraints:".concat(u.join(" ")))}return l.join(mo)},bo=function(e){var t=et.canStereo(),n=e.match(/^a=rtpmap:(\d+) opus/m);if(n){var r=new RegExp("^a=fmtp:".concat(n[1]," (.+)$"),"m"),i=e.match(r);if(i){var o={};i[1].split(";").forEach((function(e){var t=N(e.split("="),2),n=t[0],r=t[1];o[n]=r})),o.stereo=t?"1":"0";var a=Object.entries(o).map((function(e){var t=N(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})).join(";");return e.replace(r,"a=fmtp:".concat(n[1]," ").concat(a))}}return e},ko=function(e){var t=e.split(mo),n=!1;return t.forEach((function(e,r){e.startsWith("m=audio")||e.startsWith("m=video")?n=!0:e.startsWith("m=application")?n=!1:"a=sendrecv"===e&&n&&(t[r]="a=sendonly")})),t.join(mo)},So=function(e,t){var n=t.codecSelection;return Le().splitSections(e).map((function(e){var t=Le().getKind(e),r=n[t];if(Array.isArray(r)&&r.length>0){var i=Le().parseRtpParameters(e),o=Le().writeRtpDescription(t,i),a=[];if(r.forEach((function(e){var n=i.codecs.find((function(n){var r,i=(r=n.parameters,Object.entries(r).map((function(e){var t=N(e,2),n=t[0],r=t[1];return r?"".concat(n,"=").concat(r):n})).join(";")),o="".concat(t,"/").concat(n.name),a=e.mimeType===o;return e.sdpFmtpLine?a&&e.sdpFmtpLine===i:a}));n&&a.push(n)})),0===a.length)return e;i.codecs=a;var s=function(e,t){var n=Le().splitLines(e),r=Le().splitLines(t);return n.filter((function(e){return!r.includes(e)&&!e.startsWith("a=rtpmap:")})).join(mo)}(e,o);return(o=Le().writeRtpDescription(t,i))+s+mo}return e})).join("")},wo=function(e){var t={active:[bo],passive:[go]};return!0===e.sendOnly&&t.active.push(ko),e.receiveConstraints&&t.passive.push(yo),e.codecSelection&&et.canSetCodecsLegacy()&&t.active.push(So),t};const Co=function(){return d((function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c(this,e),this.options=r,this.options.RTCConstraints=Object.assign({},this.defaultRTCConstraints,{offerToReceiveVideo:!this.options.eco}),this.accepted=!1,this.listeners=[],this.restarting=!1,this.connection=t,this.comApi=n,this.sipSession=null,this.startAttempts=0,this.maxStartAttempts=3,this.tryAuthUpdate=!0,this.tryResume=!0,this.tryWaitResume=!0,this.resumeTimer=null,this.waitResumeTimer=null,this.end=this.end.bind(this),this.emit=this.emit.bind(this),this.setStream=this.setStream.bind(this),this.endSession=this.endSession.bind(this),this.initSession=this.initSession.bind(this),this.handleFailed=this.handleFailed.bind(this),this.handleAccept=this.handleAccept.bind(this),this.handleUnmute=this.handleUnmute.bind(this),this.restartSession=this.restartSession.bind(this),this.tryRecoveryFrom=this.tryRecoveryFrom.bind(this),this.terminateSession=this.terminateSession.bind(this),this.remoteDescriptionUpdate=this.remoteDescriptionUpdate.bind(this)}),[{key:"peerConnection",get:function(){return this.sipSession&&this.sipSession.sessionDescriptionHandler?this.sipSession.sessionDescriptionHandler.peerConnection:null}},{key:"localStream",get:function(){return this.sipSession&&this.sipSession.sessionDescriptionHandler?this.sipSession.sessionDescriptionHandler.localStream:null}},{key:"remoteStream",get:function(){return this.sipSession&&this.sipSession.sessionDescriptionHandler?this.sipSession.sessionDescriptionHandler.remoteStream:null}},{key:"defaultRTCConstraints",get:function(){return{offerToReceiveAudio:!0,offerToReceiveVideo:!0}}},{key:"start",value:function(){this.options.stream?this.initExternalStream():(this.initDeviceMonitor(),this.initVirtualBackground(),new Vn(this.options).start().then(this.initSession).catch(this.handleFailed))}},{key:"initExternalStream",value:function(){var e=!ct(this.options.stream)&&this.options.eco,t=Wt(this.options.stream,e);t?(this.externalStream=t,this.options.audio=st(t),this.options.video=ct(t),this.initSession(this.externalStream)):this.handleFailed({name:"invalid_stream"})}},{key:"initVirtualBackground",value:function(){var e=Fn.getStoredVirtualBackgroundType();this.vbgMixer=new In,this.vbgMixer.changeBackground(e),this.options.vbgMixer=this.vbgMixer}},{key:"initDeviceMonitor",value:function(){var e=this;this.deviceMonitor=new eo,this.deviceMonitor.onEvent((function(t){return e.emit(t)})),this.options.deviceMonitor=this.deviceMonitor}},{key:"buildSessionOptions",value:function(e){var t=this.options;return!0===t.sendOnly&&(t.RTCConstraints={}),{stream:e,sendOnly:t.sendOnly,sendEncodings:t.sendEncodings,codecSelection:t.codecSelection,receiveConstraints:t.receiveConstraints,SDPModifiers:wo({sendOnly:t.sendOnly,codecSelection:t.codecSelection,receiveConstraints:t.receiveConstraints}),connection:this.connection,handleAccept:this.handleAccept,handleUnmute:this.handleUnmute,RTCConstraints:t.RTCConstraints,remoteDescriptionUpdate:this.remoteDescriptionUpdate,mediaOptions:{audio:t.audio,video:t.video}}}},{key:"initSession",value:function(e){var t=this;this.tryResume=!0,this.tryAuthUpdate=!0,this.tryWaitResume=!0;var n=this.buildSessionOptions(e);this.sipSession=this.connection.startSession(n),this.onUnmute(e),this.sipSession.onEvent((function(e){"accepted"===e.type?t.adjustVideoPodium():"resumed"===e.type?(clearTimeout(t.resumeTimer),clearTimeout(t.waitResumeTimer),t.tryResume=!0,t.tryAuthUpdate=!0,t.tryWaitResume=!0):"terminated"===e.type&&t.handleTermination(e.reason,e.code)})),this.externalStream&&(this.connection.hasExternalStream=!0),window&&window.addEventListener(et.isIOSDevice()?"pagehide":"beforeunload",this.endSession)}},{key:"end",value:function(){this.listeners=[],this.endSession(),this.accepted=!1,this.sipSession=null,this.connection=null}},{key:"endSession",value:function(){f.debug("ConferenceSession::endSession"),clearTimeout(this.resumeTimer),clearTimeout(this.waitResumeTimer),this.sipSession&&(this.sipSession.removeAllListeners(),this.terminateSession()),this.connection&&this.connection.close(),this.deviceMonitor&&this.deviceMonitor.destroy()}},{key:"terminateSession",value:function(){f.debug("ConferenceSession::terminateSession");try{this.sipSession.terminate()}catch(e){f.error(e)}}},{key:"setStream",value:(e=F(W().mark((function e(t){var n,r;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.sipSession){e.next=2;break}return e.abrupt("return",null);case 2:return e.prev=2,n=this.sipSession.sessionDescriptionHandler,e.next=6,n.setStream(t);case 6:return r=e.sent,this.stopPresentingSet=!1,this.micMixer&&this.micMixer.active&&(r.newStream=this.micMixer.getMicOnlyStream(),n.localStream=r.newStream),this.videoPlayer&&this.videoPlayer.isStreaming()&&(r.newStream=this.videoPlayer.getMicOnlyStream(),n.localStream=r.newStream),this.onUnmute(r.newStream),this.emit({type:"stream_update",localStream:r.newStream,stream:r.remoteStream}),e.abrupt("return",r.newStream);case 15:return e.prev=15,e.t0=e.catch(2),f.error("ConferenceSession::setStream",e.t0),this.emit({type:"stream_update",localStream:this.localStream,stream:this.remoteStream}),e.abrupt("return",this.localStream);case 20:case"end":return e.stop()}}),e,this,[[2,15]])}))),function(t){return e.apply(this,arguments)})},{key:"onUnmute",value:function(e){var t=this;e&&e.getTracks().forEach((function(e){e.onunmute=function(){return t.emit({type:"local_track_unmuted",track:e})}}))}},{key:"setMonitor",value:function(e){this.monitor=e}},{key:"handleAccept",value:function(e){this.monitor&&this.monitor.observe(this.peerConnection),this.accepted||(this.emit({type:"accept",session:this.sipSession}),this.accepted=!0),e&&this.emit({type:"stream_update",stream:e})}},{key:"handleUnmute",value:function(e){this.emit({type:"track_unmuted",track:e})}},{key:"remoteDescriptionUpdate",value:function(e){f.debug("ConferenceSession::remoteDescriptionUpdate",e.sdp);var t=!1,n=e.sdp.split("\r\n").find((function(e){return e.startsWith("a=sfu-mode")}));n&&(t=n.includes("on")),this.emit({type:"remote_description_update",update:{sfu:t}})}},{key:"adjustVideoPodium",value:function(){this.send({type:"mute_video",on:!this.options.video})}},{key:"handleTermination",value:function(e,t){var n=this;if(f.debug("ConfSession::handleTermination",e,t),clearTimeout(this.resumeTimer),clearTimeout(this.waitResumeTimer),"bye"===e&&200===t||"terminate"===e)this.handleExit();else if("disconnect"===e)if(-1===t){if(this.tryAuthUpdate)return this.tryAuthUpdate=!1,void this.comApi.getRoom((function(e){return n.connection.updateAuthAndRestartSession(e)}));if(this.tryWaitResume&&this.connection)return this.tryWaitResume=!1,this.waitResumeTimer=setTimeout((function(){n.comApi.getRoom((function(e){n.connection&&n.connection.updateAuthAndResume(e)}))}),5e3),void(this.resumeTimer=setTimeout((function(){n.handleFailed({name:503})}),15e3));this.handleFailed({name:503})}else{if(this.tryResume&&this.connection)return this.tryResume=!1,this.tryAuthUpdate=!1,this.comApi.getRoom((function(e){n.connection&&n.connection.updateAuthAndResume(e)})),void(this.resumeTimer=setTimeout((function(){return n.handleFailed({name:410})}),1e4));this.handleFailed({name:410})}else this.handleFailed({name:t});this.restarting||this.emit({type:"session_termination"})}},{key:"handleExit",value:function(){this.emit({type:"exit",reason:"bye"})}},{key:"handleFailed",value:function(e){f.warn("ConferenceSession::handleFailed: ",e),clearTimeout(this.resumeTimer),clearTimeout(this.waitResumeTimer);var t="Desert";if(e&&e.name&&(t=e.name),!this.tryRecoveryFrom(t)){var n={NotFoundError:"devices",NotAllowedError:"permission",DevicesNotFoundError:"devices",PermissionDeniedError:"permission",NotReadableError:"not_readable",403:"session_in_use",410:"abrupt_disconnect",413:"request_too_large",426:"ice_error",486:"session_in_use",607:"meeting_locked"}[t]||"session_failed";this.emit({type:"error",name:n,code:this.errorCodeName(t,n)})}}},{key:"errorCodeName",value:function(e,t){return["permission","devices","not_readable","meeting_locked","session_in_use","transport_error"].includes(t)?"":String(e)}},{key:"tryRecoveryFrom",value:function(e){var t=this;f.debug("ConferenceSession::tryRecoveryFrom: ",e);var n={404:{condition:function(){return t.startAttempts<t.maxStartAttempts},action:function(){return t.restartSession()}}}[e];return this.startAttempts>=this.maxStartAttempts?(this.restarting=!1,!1):Boolean(n&&n.condition()&&n.action())}},{key:"restartSession",value:function(){var e=this;return f.debug("ConferenceSession::restartSession: ",this.startAttempts),this.restarting=!0,this.startAttempts+=1,setTimeout((function(){e.endSession(),e.start()}),1e3),!0}},{key:"onEvent",value:function(e){this.listeners.push(e)}},{key:"emit",value:function(e){this.listeners.forEach((function(t){return t(e)}))}},{key:"send",value:function(e){return this.connection.send(e)}}]);var e}();function xo(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return To(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?To(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function To(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var _o={NO_CONNECTION:3,BAD:2,OK:1,GOOD:0},Ro=function(e,t){e.length<3?e.push(Object.assign({},t)):Object.assign(function(e){for(var t=N(e,1)[0],n=e.length,r=1;r<n;r++)e[r].time<t.time&&(t=e[r]);return t}(e),t)},Mo=function(e){var t,n=e.length,r={jitter:0,packetLoss:0,packetLossRecv:0,roundTripTime:0,nack:0,bitrateSend:0,bitrateRecv:0,status:_o.GOOD},i=function(e){for(var t=N(e,1)[0],n=e.length,r=1;r<n;r++)e[r].time>t.time&&(t=e[r]);return t}(e),o=xo(e);try{for(o.s();!(t=o.n()).done;){var a=t.value;r.jitter+=a.jitter,r.packetLoss+=a.packetLoss,r.packetLossRecv+=a.packetLossRecv,r.roundTripTime+=a.roundTripTime,r.nack+=a.nack,r.bitrateSend+=a.bitrateSend,r.bitrateRecv+=a.bitrateRecv}}catch(e){o.e(e)}finally{o.f()}return r.jitter=null===i.jitter?null:r.jitter/n,r.packetLoss=null===i.packetLoss?null:r.packetLoss/n,r.packetLossRecv=null===i.packetLossRecv?null:r.packetLossRecv/n,r.roundTripTime=null===i.roundTripTime?null:r.roundTripTime/n,r.nack=null===i.nack?null:r.nack/n,r.bitrateSend/=n,r.bitrateRecv/=n,r.status=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return n>1||e>.2||t>.5||r>.2?_o.BAD:n>.3||e>.1||t>.3||r>.1?_o.OK:_o.GOOD}(r.packetLoss,r.jitter,r.roundTripTime,r.nack),r},Po=function(){return d((function e(){c(this,e),this.peerConnection=null,this.timer=null,this.listeners=[],this.history=[],this.entry={jitter:0,packetLoss:0,packetLossRecv:0,roundTripTime:0,nack:0,time:0,bitrateSend:0,bitrateRecv:0},this.lastStat={time:null,bytesSent:null,bytesReceived:null,audio:{out:{packetsSent:null,packetsLost:null,bytesSent:null},in:{bytesReceived:null,packetsReceived:null,packetsLost:null}},video:{out:{packetsSent:null,packetsLost:null,bytesSent:null,nackCount:null},in:{bytesReceived:null,packetsReceived:null,packetsLost:null}}},this.boundPrintStats=this.printStats.bind(this)}),[{key:"init",value:function(e){this.peerConnection=e}},{key:"printStats",value:(e=F(W().mark((function e(){var t,n,r,i,o,a,s,c;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.peerConnection,n=this.entry,r=this.lastStat,i=this.history,e.next=3,t.getStats();case 3:o=e.sent,a=Date.now(),s=null,Object.keys(n).forEach((function(e){n[e]=0})),n.jitter=null,n.packetLoss=null,n.packetLossRecv=null,n.roundTripTime=null,n.nack=null,n.time=a,o.forEach((function(e){if("inbound-rtp"===e.type){var t=e.kind||e.mediaType;if(r.time){var i=(a-r.time)/1e3,c=Math.max(e.bytesReceived-r[t].in.bytesReceived,0);n.bitrateRecv+=8*c/i}if(r[t]){var u=e.packetsLost-r[t].in.packetsLost,l=e.packetsReceived-r[t].in.packetsReceived,d=l>0?u/l:0;n.packetLossRecv=Math.max(n.packetLossRecv,d)}r[t].in.bytesReceived=e.bytesReceived,r[t].in.packetsLost=e.packetsLost,r[t].in.packetsReceived=e.packetsReceived}else if("outbound-rtp"===e.type){var h=e.kind||e.mediaType;if(r.time){var p=(a-r.time)/1e3,f=e.bytesSent-r[h].out.bytesSent;n.bitrateSend+=8*f/p}r[h].out.bytesSent=e.bytesSent}else if("remote-inbound-rtp"===e.type){var v=e.kind||e.mediaType;if(r[v]){var m=o.get(e.localId),g=void 0!==e.roundTripTime,y=void 0!==e.jitter,b=void 0!==e.packetsLost,k=void 0!==m.nackCount;if(r.time){var S=e.packetsLost-r[v].out.packetsLost,w=m.packetsSent-r[v].out.packetsSent,C=w>0?S/w:0;if(n.jitter=y?Math.max(n.jitter,w>0?e.jitter:0):null,n.packetLoss=b?Math.max(n.packetLoss,C):null,n.roundTripTime=g?Math.max(n.roundTripTime,e.roundTripTime):null,"video"===v){var x=m.nackCount-r[v].out.nackCount,T=w>0?x/w:0;n.nack=k?Math.max(n.nack,T):null}}"video"===v&&(r[v].out.nackCount=m.nackCount),r[v].out.packetsSent=m.packetsSent,r[v].out.packetsLost=e.packetsLost}}else"candidate-pair"===e.type&&"succeeded"===e.state&&"currentRoundTripTime"in e&&(s=e.currentRoundTripTime)})),null===n.roundTripTime&&null!==s&&(n.roundTripTime=s),Ro(i,n),c=Mo(i),!1===navigator.onLine&&(c.status=_o.BAD),["disconnected","failed","closed"].includes(t.iceConnectionState)&&(c.status=_o.NO_CONNECTION),this.emit(c),r.time=a;case 21:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCurrentStatistics",value:function(){return Mo(this.history)}},{key:"onUpdate",value:function(e){var t=this.listeners,n=this.timer;0===t.length&&null===n&&(this.timer=setInterval(this.boundPrintStats,1e3),this.peerConnection.addEventListener("iceconnectionstatechange",this.boundPrintStats),window.addEventListener("offline",this.boundPrintStats)),t.push(e)}},{key:"emit",value:function(e){this.listeners.forEach((function(t){try{t(e)}catch(e){f.error("ConnectionStatistics::emit",e)}}))}},{key:"destroy",value:function(){clearInterval(this.timer),window.removeEventListener("offline",this.boundPrintStats),this.peerConnection&&(this.peerConnection.removeEventListener("iceconnectionstatechange",this.boundPrintStats),this.peerConnection=null),this.timer=null,this.history.length=0,this.listeners.length=0}}]);var e}();Po.Status=_o;const Eo=Po;const Oo=function(){return d((function e(){c(this,e),this.pc=null,this.statistics=new Eo,this.listeners=[],this.disconnectTimer=null,this.prevIceState="initial",this.onOffline=this.onOffline.bind(this),this.handleIceStateChange=this.handleIceStateChange.bind(this),this.handleConnectionStateChange=this.handleConnectionStateChange.bind(this),this.addEventListeners()}),[{key:"addEventListeners",value:function(){window.addEventListener("offline",this.onOffline)}},{key:"onOffline",value:function(){this.emit({type:"offline"})}},{key:"observe",value:function(e){this.pc||(this.pc=e,this.pc.oniceconnectionstatechange=this.handleIceStateChange,this.pc.onconnectionstatechange=this.handleConnectionStateChange,this.statistics.init(e),this.emit({type:"statistics_ready",statistics:this.statistics}))}},{key:"destroy",value:function(){var e=this.pc,t=this.statistics;clearTimeout(this.disconnectTimer),t&&(t.destroy(),this.statistics=null),e&&(e.onconnectionstatechange=null,e.oniceconnectionstatechange=null,this.pc=null),window.removeEventListener("offline",this.onOffline)}},{key:"onEvent",value:function(e){this.listeners.push(e)}},{key:"emit",value:function(e){this.listeners.forEach((function(t){return t(e)}))}},{key:"handleConnectionStateChange",value:function(e){e.currentTarget&&f.warn("connectionStateChange: ",e.currentTarget.connectionState)}},{key:"handleIceStateChange",value:function(e){var t=this;if(e.currentTarget){var n=e.currentTarget.iceConnectionState;"disconnected"===n&&(this.emit({type:"warning",name:"ice_disconnected"}),clearTimeout(this.disconnectTimer),this.disconnectTimer=window.setTimeout((function(){t.pc&&"connected"!==t.pc.iceConnectionState&&t.emit({type:"error",name:"ice_failed",code:"Goldfinger"})}),2e3)),"failed"===n&&this.emit({type:"error",name:"ice_failed",code:"Thunderball"}),"disconnected"===this.prevIceState&&["completed","connected"].includes(n)&&this.emit({type:"clear_warning",name:"ice_disconnected"}),this.prevIceState=n}}}])}();var Do={logger:"undefined"!=typeof console?console:void 0,WebSocket:"undefined"!=typeof WebSocket?WebSocket:void 0},Ao={log(...e){this.enabled&&(e.push(Date.now()),Do.logger.log("[ActionCable]",...e))}};const Io=()=>(new Date).getTime(),Bo=e=>(Io()-e)/1e3;class Lo{constructor(e){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=e,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=Io(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),Ao.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=Io(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),Ao.log("ConnectionMonitor stopped"))}isRunning(){return this.startedAt&&!this.stoppedAt}recordMessage(){this.pingedAt=Io()}recordConnect(){this.reconnectAttempts=0,delete this.disconnectedAt,Ao.log("ConnectionMonitor recorded connect")}recordDisconnect(){this.disconnectedAt=Io(),Ao.log("ConnectionMonitor recorded disconnect")}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout((()=>{this.reconnectIfStale(),this.poll()}),this.getPollInterval())}getPollInterval(){const{staleThreshold:e,reconnectionBackoffRate:t}=this.constructor;return 1e3*e*Math.pow(1+t,Math.min(this.reconnectAttempts,10))*(1+(0===this.reconnectAttempts?1:t)*Math.random())}reconnectIfStale(){this.connectionIsStale()&&(Ao.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${Bo(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?Ao.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${Bo(this.disconnectedAt)} s`):(Ao.log("ConnectionMonitor reopening"),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return Bo(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&Bo(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){"visible"===document.visibilityState&&setTimeout((()=>{!this.connectionIsStale()&&this.connection.isOpen()||(Ao.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())}),200)}}Lo.staleThreshold=6,Lo.reconnectionBackoffRate=.15;var jo={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart",remote:"remote"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]};const{message_types:Fo,protocols:Vo}=jo,Uo=Vo.slice(0,Vo.length-1),No=[].indexOf;class Ho{constructor(e){this.open=this.open.bind(this),this.consumer=e,this.subscriptions=this.consumer.subscriptions,this.monitor=new Lo(this),this.disconnected=!0}send(e){return!!this.isOpen()&&(this.webSocket.send(JSON.stringify(e)),!0)}open(){if(this.isActive())return Ao.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{const e=[...Vo,...this.consumer.subprotocols||[]];return Ao.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${e}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new Do.WebSocket(this.consumer.url,e),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:e}={allowReconnect:!0}){if(e||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(Ao.log(`Reopening WebSocket, current state is ${this.getState()}`),!this.isActive())return this.open();try{return this.close()}catch(e){Ao.log("Failed to reopen WebSocket",e)}finally{Ao.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return No.call(Uo,this.getProtocol())>=0}isState(...e){return No.call(e,this.getState())>=0}getState(){if(this.webSocket)for(let e in Do.WebSocket)if(Do.WebSocket[e]===this.webSocket.readyState)return e.toLowerCase();return null}installEventHandlers(){for(let e in this.events){const t=this.events[e].bind(this);this.webSocket[`on${e}`]=t}}uninstallEventHandlers(){for(let e in this.events)this.webSocket[`on${e}`]=function(){}}}Ho.reopenDelay=500,Ho.prototype.events={message(e){if(!this.isProtocolSupported())return;const{identifier:t,message:n,reason:r,reconnect:i,type:o}=JSON.parse(e.data);switch(this.monitor.recordMessage(),o){case Fo.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case Fo.disconnect:return Ao.log(`Disconnecting. Reason: ${r}`),this.close({allowReconnect:i});case Fo.ping:return null;case Fo.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,"connected",{reconnected:!0})):this.subscriptions.notify(t,"connected",{reconnected:!1});case Fo.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",n)}},open(){if(Ao.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return Ao.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(e){if(Ao.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){Ao.log("WebSocket onerror event")}};class Wo{constructor(e,t={},n){this.consumer=e,this.identifier=JSON.stringify(t),function(e,t){if(null!=t)for(let n in t){const r=t[n];e[n]=r}}(this,n)}perform(e,t={}){return t.action=e,this.send(t)}send(e){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(e)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}}class zo{constructor(e){this.subscriptions=e,this.pendingSubscriptions=[]}guarantee(e){-1==this.pendingSubscriptions.indexOf(e)?(Ao.log(`SubscriptionGuarantor guaranteeing ${e.identifier}`),this.pendingSubscriptions.push(e)):Ao.log(`SubscriptionGuarantor already guaranteeing ${e.identifier}`),this.startGuaranteeing()}forget(e){Ao.log(`SubscriptionGuarantor forgetting ${e.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter((t=>t!==e))}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout((()=>{this.subscriptions&&"function"==typeof this.subscriptions.subscribe&&this.pendingSubscriptions.map((e=>{Ao.log(`SubscriptionGuarantor resubscribing ${e.identifier}`),this.subscriptions.subscribe(e)}))}),500)}}class qo{constructor(e){this.consumer=e,this.guarantor=new zo(this),this.subscriptions=[]}create(e,t){const n="object"==typeof e?e:{channel:e},r=new Wo(this.consumer,n,t);return this.add(r)}add(e){return this.subscriptions.push(e),this.consumer.ensureActiveConnection(),this.notify(e,"initialized"),this.subscribe(e),e}remove(e){return this.forget(e),this.findAll(e.identifier).length||this.sendCommand(e,"unsubscribe"),e}reject(e){return this.findAll(e).map((e=>(this.forget(e),this.notify(e,"rejected"),e)))}forget(e){return this.guarantor.forget(e),this.subscriptions=this.subscriptions.filter((t=>t!==e)),e}findAll(e){return this.subscriptions.filter((t=>t.identifier===e))}reload(){return this.subscriptions.map((e=>this.subscribe(e)))}notifyAll(e,...t){return this.subscriptions.map((n=>this.notify(n,e,...t)))}notify(e,t,...n){let r;return r="string"==typeof e?this.findAll(e):[e],r.map((e=>"function"==typeof e[t]?e[t](...n):void 0))}subscribe(e){this.sendCommand(e,"subscribe")&&this.guarantor.guarantee(e)}confirmSubscription(e){Ao.log(`Subscription confirmed ${e}`),this.findAll(e).map((e=>this.guarantor.forget(e)))}sendCommand(e,t){const{identifier:n}=e;return this.consumer.send({command:t,identifier:n})}}class Go{constructor(e){this._url=e,this.subscriptions=new qo(this),this.connection=new Ho(this),this.subprotocols=[]}get url(){return function(e){"function"==typeof e&&(e=e());if(e&&!/^wss?:/i.test(e)){const t=document.createElement("a");return t.href=e,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}return e}(this._url)}send(e){return this.connection.send(e)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(e){this.subprotocols=[...this.subprotocols,e]}}function $o(e=function(e){const t=document.head.querySelector(`meta[name='action-cable-${e}']`);if(t)return t.getAttribute("content")}("url")||jo.default_mount_path){return new Go(e)}const Jo=function(){return d((function e(t){c(this,e),this.channels={},this.onMessageHandler=this.defaultMessageHandler,this.onReceived=this.onReceived.bind(this),this.offMessage=this.offMessage.bind(this),this.onConnected=this.onConnected.bind(this),this.startSession=this.startSession.bind(this),this.onDisconnected=this.onDisconnected.bind(this),this.cable=$o(t)}),[{key:"startSession",value:function(){this.channels.RoomChannel=this.cable.subscriptions.create({channel:"RoomChannel"},{connected:this.onConnected,received:this.onReceived,disconnected:this.onDisconnected}),this.channels.UserChannel=this.cable.subscriptions.create({channel:"UserChannel"},{received:this.onReceived})}},{key:"onConnected",value:function(){this.disconnectTimestamp&&this.handleReconnect(),f.debug("ActionCableConnection::onConnected")}},{key:"handleReconnect",value:function(){this.onMessageHandler({type:"reconnect"})}},{key:"onReceived",value:function(e){f.debug("ActionCableConnection::onReceived",e),e._src="actioncable",this.onMessageHandler(e)}},{key:"onDisconnected",value:function(){f.debug("ActionCableConnection::onDisconnected"),this.disconnectTimestamp=Date.now(),this.onMessageHandler({type:"disconnect"})}},{key:"onMessage",value:function(e){"function"==typeof e&&(this.onMessageHandler=e)}},{key:"offMessage",value:function(){this.onMessageHandler=this.defaultMessageHandler}},{key:"defaultMessageHandler",value:function(e){f.debug("ActionCableConnection::defaultMessageHandler: ",e)}},{key:"send",value:function(e){var t=e.channel,n=void 0===t?"RoomChannel":t,r=e.type,i=void 0===r?"ping":r,o=this.channels[n];o?o.perform(i):f.warn("ActionCableConnection::send no subscription found! ",n)}},{key:"close",value:function(){this.cable.disconnect(),this.offMessage(),this.channels={},this.cable=null}}])}();var Ko=function(e,t){return e.core.eventHandler.send({type:"connection",connectionStatus:t})},Xo=function(e){var t=e.core;Ko(e,"fetch_room"),t.eventHandler.eyeson=e,t.comApi.onError((function(e,n){t.eventHandler.send({type:"warning",name:"error:comapi",id:n,status:e.status})})),t.comApi.getRoom((function(n){if(n.error)return f.warn("eyeson::prepareConnection",n.error),void Ko(e,"access_denied");Ko(e,"received_room"),t.rtConnection=new Jo(n.links.websocket),t.eventHandler.rtConnection=t.rtConnection,t.rtConnection.startSession(),t.eventHandler.monitor=new Oo,t.eventHandler.api=t.comApi,function(e){e.core.keepRoomAlive=setInterval((function(){e.core.rtConnection.send({type:"user_joins"})}),3e4)}(e),function(e){var t=1;e.core.pollingFallbackInterval=setInterval((function(){var n=e.core;return 200===t?(f.debug("eyeson::pollingFallback: max count exceeded, clearing interval."),void clearInterval(n.pollingFallbackInterval)):n.eventHandler._connection?(f.debug("eyeson::pollingFallback: connection set, clearing interval."),void clearInterval(n.pollingFallbackInterval)):void n.comApi.getRoom((function(e){if(!0===e.ready)return f.debug("eyeson::pollingFallback: room ready"),void n.eventHandler.send({type:"room_ready",content:e});f.debug("eyeson::pollingFallback: room not ready",t),t+=1}))}),5e3)}(e)}))},Yo=function(){function e(){c(this,e),this.config=h,this.core={eventHandler:new vo},this.room={},this.user={},this.links={},this.options=p,Qe(navigator.audioSession)&&Reflect.has(navigator.audioSession,"type")&&(navigator.audioSession.type="play-and-record")}return d(e,[{key:"onEvent",value:function(e){"function"==typeof e?this.core.eventHandler.onReceive(e):f.error("A listener to eyeson events has to be of type function. The argument passed to onEvent is of type "+s(e)+".")}},{key:"offEvent",value:function(e){this.core.eventHandler.removeListener(e)}},{key:"connect",value:function(e){f.debug("eyeson::connect",e),this.core.comApi=new v(this.config.api,e),Xo(this)}},{key:"connectPermalink",value:function(e){var t=this;f.debug("eyeson::connectPermalink",e);var n=new v(this.config.api,e);Ko(this,"fetch_room"),n.joinPermalinkUser((function(e){if(e.error)return f.warn("eyeson::connectPermalink",e.error),void Ko(t,"access_denied");t.core.eventHandler.send({type:"permalink_ready",content:e}),t.core.comApi=new v(t.config.api,e.access_key),Xo(t)}))}},{key:"join",value:function(e){f.debug("eyeson::join",e),function(e,t){var n=e.core;if(n.eventHandler._connection){var r=new Co(n.eventHandler._connection,n.comApi,t);r.setMonitor(n.eventHandler.monitor),n.eventHandler.session=r,r.start(),function(e){var t=e.core,n=t.eventHandler._rtData,r=n.broadcasts,i=n.presentation;r&&t.eventHandler.send({type:"broadcasts_update",broadcasts:r}),i&&t.eventHandler.send({type:"presentation_update",presentation:i})}(e),clearInterval(n.keepRoomAlive),e.session=r}else f.error("You tried to join a session that is not yet available. Before calling join, a connection status of connected has to be received.")}(this,e)}},{key:"start",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};f.debug("eyeson::start");var r=function(e){"ready"===e.connectionStatus&&(t.offEvent(r),t.join(n))};this.onEvent(r),this.connect(e)}},{key:"destroy",value:function(){var e=this.core;f.debug("eyeson::destroy"),clearInterval(e.keepRoomAlive),clearInterval(e.pollingFallbackInterval),e.eventHandler.destroy(),e.eventHandler=new vo}},{key:"send",value:function(e){e._src="client",this.core.eventHandler.send(e)}},{key:"throttledSend",value:function(e){var t=this;return this._throttledSend||(this._throttledSend=m((function(e){return t.send(e)}),500)),this._throttledSend(e)}},{key:"createInstance",value:function(){return new e}}])}();const Qo=new Yo;function Zo(e){return function(e){if(Array.isArray(e))return V(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||U(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const ea=function(){return d((function e(t){c(this,e),this.roomUrl=t}),[{key:"search",value:function(e){return this.request("".concat(this.roomUrl,"/search?q=").concat(e)).then((function(e){return e.data}))}},{key:"random",value:function(){return this.request("".concat(this.roomUrl,"/random")).then((function(e){return e.data}))}},{key:"trending",value:function(){var e=this;return this.request("".concat(this.roomUrl,"/trending?limit=9")).then((function(t){var n=t.data;return e.staff().then((function(e){return[].concat(Zo(n),Zo(e))}))}))}},{key:"staff",value:function(){return this.request("".concat(this.roomUrl,"/staff")).then((function(e){return e.data}))}},{key:"randomForQuery",value:function(e){var t=this;return new Promise((function(n,r){t.search(e).then((function(e){return Array.isArray(e)?e.filter((function(e){return e.images.original_mp4.mp4_size>=4e4})):[]})).then((function(e){if(0===e.length)throw new TypeError("No data found");n(e[Math.floor(Math.random()*e.length)])})).catch(r)}))}},{key:"request",value:function(e){return fetch(new Request(e)).then((function(e){return e.json()})).catch((function(t){return f.warn("GiphyApi",e,t),{data:[]}}))}}])}();function ta(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return na(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?na(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function na(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const ra=function(){return d((function e(){c(this,e),this.level=0,this.instant=0,this.silenceDuration=0,this.intervalCounter=0,this.track=null,this.context=null,this.source=null,this.analyser=null,this.volumes=null,this.listener=[],this.timer=null,this.errorTimer=null,this.boundOnTrackEnded=this.onTrackEnded.bind(this),this.initError=!1,this.init()}),[{key:"init",value:function(){var e=window.AudioContext||window.webkitAudioContext;void 0!==e?(this.context=new e,this.context.onstatechange=function(e){var t=e.target;"suspended"===t.state&&f.error("SoundMeter::init AudioContext: ",t.state)}):f.error("AudioContext is not available. Probably the current user agent does not support this feature. Use the feature detector to hide not supported elements. Any call on onUpdate will not send values.")}},{key:"connectToSource",value:function(e){var t=this;if(!this.context)return this;if(!e||e.getAudioTracks().length<1)return this.initError=!0,this.onTrackEnded(),this;f.debug("SoundMeter::connectToSource",e);var n=N(e.getAudioTracks(),1);if(this.track=n[0],"live"!==this.track.readyState)return this.initError=!0,this.onTrackEnded(),this;this.track.addEventListener("ended",this.boundOnTrackEnded),this.source=this.context.createMediaStreamSource(e);var r=this.context.createAnalyser();return r.fftSize=512,r.minDecibels=-127,r.maxDecibels=0,r.smoothingTimeConstant=.5,this.source.connect(r),this.analyser=r,this.volumes=new Uint8Array(r.frequencyBinCount),!this.running&&this.listener.length>0&&(this.running=!0,this.timer=setInterval((function(){return t.analyse()}),100)),this}},{key:"analyse",value:function(){var e=this,t=this.analyser,n=this.volumes,r=this.level;if(t){t.getByteFrequencyData(n);var i,o=0,a=ta(n);try{for(a.s();!(i=a.n()).done;){o+=i.value}}catch(e){a.e(e)}finally{a.f()}var s=o/n.length,c=Math.min(Math.round(100*s/127),100);if(0===r&&0===c&&10===this.intervalCounter&&(this.silenceDuration++,this.silenceDuration>30&&!this.errorTimer&&(this.errorTimer=setTimeout((function(){e.emit({warning:"MicrophoneSilenceWarning"}),e.resetSilenceCounter()}),1e3))),r!==c)this.silenceDuration>0&&this.resetSilenceCounter(),Math.abs(r-c)>=1&&(this.level=c,this.emit({value:c}));this.intervalCounter<10&&this.intervalCounter++}}},{key:"resetSilenceCounter",value:function(){clearTimeout(this.errorTimer),this.errorTimer=null,this.silenceDuration=0}},{key:"stop",value:function(){this.offUpdate(),this.track&&(this.track.removeEventListener("ended",this.boundOnTrackEnded),this.track=null),this.analyser&&(this.analyser.disconnect(),this.analyser=null),this.source&&(this.source.disconnect(),this.source=null),this.volumes=null,this.context&&this.context.stop&&"closed"!==this.context.state&&(this.context.onstatechange=null,this.context.close(),this.context=null)}},{key:"onUpdate",value:function(e){var t=this;this.listener.push(e),this.initError?this.onTrackEnded():!this.running&&this.context&&this.track&&(this.running=!0,this.timer=setInterval((function(){return t.analyse()}),100))}},{key:"offUpdate",value:function(){clearTimeout(this.errorTimer),this.listener.length=0,this.running&&(clearInterval(this.timer),this.running=!1)}},{key:"onTrackEnded",value:function(){this.emit({error:"EyesonMicrophoneError"}),this.stop()}},{key:"emit",value:function(e){this.listener.forEach((function(t){return t(e)}))}}])}();var ia=/https:\/\/www\.openstreetmap\.org\/.*#.*map=\d+\/(-?[0-9.]+)\/(-?[0-9.]+)/,oa=/https:\/\/www\.google\.com\/maps\/.*@(-?[0-9.]+),(-?[0-9.]+),\d+z/,aa=/https:\/\/www\.google\.com\/maps\/search\/\?api=1.*&query=(-?[0-9.]+),(-?[0-9.]+)/,sa=/https:\/\/www\.bing\.com\/maps\/.*\?.*cp=(-?[0-9.]+)~(-?[0-9.]+)/,ca=/https:\/\/wego\.here\.com\/.*\?.*map=(-?[0-9.]+),(-?[0-9.]+)/,ua=function(){var e=F(W().mark((function e(){var t,n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,new Promise((function(e,t){return navigator.geolocation.getCurrentPosition(e,t,{enableHighAccuracy:!0,maximumAge:0,timeout:12e3})}));case 3:return t=e.sent,n=t.coords,e.abrupt("return",n);case 8:throw e.prev=8,e.t0=e.catch(0),e.t0 instanceof window.GeolocationPositionError&&(e.t0.name=[null,"NotAllowedError","PositionUnavailableError","TimeoutError"][e.t0.code]),f.warn("Geolocation::getCurrentPosition",e.t0),e.t0;case 13:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}(),la=function(e){try{return decodeURIComponent(e.replace(/%(?![0-9a-zA-Z])/g,"%25"))}catch(t){return e}};const da={getPermissionStatus:function(){var e=F(W().mark((function e(){var t,n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"geolocation"});case 3:return t=e.sent,n=t.state,e.abrupt("return",n);case 8:return e.prev=8,e.t0=e.catch(0),f.warn("Geolocation::getPermissionStatus",e.t0),e.abrupt("return","prompt");case 12:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}(),getCurrentPosition:ua,linkContainsCoordinates:function(e){var t=la(e);return[aa,oa,ia,sa,ca].some((function(e){return e.test(t)}))},generateLinkFromCoordinates:function(e,t){return{what3words:"https://what3words.com/".concat(e,",").concat(t),googleMaps:"https://www.google.com/maps/search/?api=1&query=".concat(e,",").concat(t),openStreetMap:"https://www.openstreetmap.org/?mlat=".concat(e,"&mlon=").concat(t,"#map=17/").concat(e,"/").concat(t),bingMaps:"https://www.bing.com/maps/?cp=".concat(e,"~").concat(t,"&lvl=17"),wegoHere:"https://wego.here.com/?map=".concat(e,",").concat(t,",17,omv")}},parseCoordinatesFromLink:function(e){var t=la(e),n=[aa,oa,ia,sa,ca].find((function(e){return e.test(t)}));if(!n)return null;var r=n.exec(t);return{latitude:Number(r[1]),longitude:Number(r[2])}}};var ha=null,pa={524297:"mute",524311:"offHook",720928:"hookSwitch",720943:"phoneMute"},fa=function(e){return Number(e).toString(16).toUpperCase().padStart(4,"0")},va=function(e){var t={hookSwitch:null,mute:null,offHook:null,phoneMute:null,allInputs:[],allOutputs:[]},n=function(e,n){if(e.reportId&&Array.isArray(e.items)){var r=0;e.items.forEach((function(i){Reflect.has(i,"reportCount")&&Reflect.has(i,"reportSize")&&(Array.isArray(i.usages)&&i.usages.forEach((function(o,a){var s={usage:fa(o),id:pa[o],reportId:e.reportId,bit:r+a*i.reportSize,isAbsolute:!!Reflect.has(i,"isAbsolute")&&i.isAbsolute};pa[o]&&(t[pa[o]]=s),n.push(s)})),r+=i.reportCount*i.reportSize)}))}};return Array.isArray(e.collections)&&e.collections.forEach((function(e){e&&11===e.usagePage&&(Array.isArray(e.inputReports)&&e.inputReports.forEach((function(e){return n(e,t.allInputs)})),Array.isArray(e.outputReports)&&e.outputReports.forEach((function(e){return n(e,t.allOutputs)})))})),t},ma=function(e,t){var n=e.bit,r=Math.trunc(n/8),i=new Uint8Array(r+1),o=n%8;return i[r]=t<<o,i},ga=function(){var e=F(W().mark((function e(t,n,r,i){var o;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=5;break}return o=ma(n,r),e.next=4,t.sendReport(n.reportId,o);case 4:i&&f.debug("WebHIDManager::sendReport",t.productName,n.id||n.usage,"reportId",n.reportId,"data",o[0]);case 5:case"end":return e.stop()}}),e)})));return function(t,n,r,i){return e.apply(this,arguments)}}(),ya=function(){var e=F(W().mark((function e(t,n,r,i){var o,a;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=n.allOutputs,a=o.map(function(){var e=F(W().mark((function e(n){var o;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,o=0,r&&("offHook"===n.id&&r.call.active||"mute"===n.id&&r.mute.active)&&(o=1),e.next=5,ga(t,n,o,i);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),f.error(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t){return e.apply(this,arguments)}}()),e.next=4,Promise.allSettled(a);case 4:case"end":return e.stop()}}),e)})));return function(t,n,r,i){return e.apply(this,arguments)}}(),ba=function(e,t,n,r){if(!e||e.reportId!==t)return!1;var i=Math.trunc(e.bit/8);if(i>=n.byteLength)return!1;var o=e.bit%8,a=!!(n.getUint8(i)&1<<o);if(e.isAbsolute){if(r.active!==a)return r.active=a,!0}else if(a)return r.active=!r.active,!0;return!1};const ka=function(){function e(t){c(this,e);var n=(t||{}).verbose,r=void 0===n||n;this.status={call:{active:!1},mute:{active:!1}},this.verbose=r,this.devices=new Map,this.listeners=[],this.channel=null,this.boundOnInputReport=this.onInputReport.bind(this),this.boundOnBeforeUnload=this.onBeforeUnload.bind(this),this.boundOnDeviceConnect=this.onDeviceConnect.bind(this),this.boundOnDeviceDisconnect=this.onDeviceDisconnect.bind(this)}return d(e,[{key:"restrictMultipleInstances",value:function(){var e=this;return new Promise((function(t){"function"==typeof window.BroadcastChannel?(e.channel=new BroadcastChannel("eyeson-webhid-manager"),e.channel.onmessage=function(n){var r=n.data;"hello"===r&&e.channel.postMessage("stop"),"stop"===r&&(e.blocked=!0,t())},e.channel.postMessage("hello"),setTimeout(t,100)):t()}))}},{key:"onEvent",value:function(e){"function"==typeof e&&this.listeners.push(e)}},{key:"offEvent",value:function(e){"function"==typeof e?this.listeners=this.listeners.filter((function(t){return t!==e})):this.listeners.length=0}},{key:"emit",value:function(e){this.listeners.forEach((function(t){return t(e)}))}},{key:"setMuteActive",value:function(e){var t=this;"boolean"==typeof e?this.status.mute.active!==e&&(this.status.mute.active=e,this.devices.forEach(function(){var n=F(W().mark((function n(r,i){var o,a;return W().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=r.deviceStatus,a=r.deviceInfo,o.mute.active===e){n.next=11;break}return n.prev=2,o.mute.active=e,n.next=6,ga(i,a.mute,Number(e),t.verbose);case 6:n.next=11;break;case 8:n.prev=8,n.t0=n.catch(2),f.error("WebHIDManager::setMuteActive",n.t0);case 11:case"end":return n.stop()}}),n,null,[[2,8]])})));return function(e,t){return n.apply(this,arguments)}}())):f.error("WebHIDManager::setMuteActive",'"Active" must be type boolean',e)}},{key:"setCallActive",value:function(e){var t=this;"boolean"==typeof e?this.status.call.active!==e&&(this.status.call.active=e,this.devices.forEach(function(){var n=F(W().mark((function n(r,i){var o,a;return W().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=r.deviceStatus,a=r.deviceInfo,o.offHook.active===e){n.next=11;break}return n.prev=2,o.offHook.active=e,n.next=6,ga(i,a.offHook,Number(e),t.verbose);case 6:n.next=11;break;case 8:n.prev=8,n.t0=n.catch(2),f.error("WebHIDManager::setCallActive",n.t0);case 11:case"end":return n.stop()}}),n,null,[[2,8]])})));return function(e,t){return n.apply(this,arguments)}}())):f.error("WebHIDManager::setCallActive",'"Active" must be type boolean',e)}},{key:"initDeviceList",value:(a=F(W().mark((function t(){var n,r,i=this;return W().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.supported&&!this.blocked){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,navigator.hid.getDevices();case 5:return n=t.sent,this.verbose&&f.debug("WebHIDManager::initDeviceList",n),r=n.map((function(e){return i.initDevice(e)})),t.next=10,Promise.allSettled(r);case 10:this.emitDeviceList(),t.next=17;break;case 13:t.prev=13,t.t0=t.catch(2),f.error("WebHIDManager::initDeviceList",t.t0),this.emit({type:"error",id:"initialize_failed",message:"WebHID initializing failed"});case 17:case"end":return t.stop()}}),t,this,[[2,13]])}))),function(){return a.apply(this,arguments)})},{key:"emitDeviceList",value:function(){var e=[];this.devices.forEach((function(t,n){var r=t.id;e.push({id:r,vendorId:fa(n.vendorId),productId:fa(n.productId),productName:n.productName})})),this.emit({type:"devicelist",devices:e})}},{key:"pairDeviceRequest",value:(o=F(W().mark((function t(){var n,r,i;return W().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.supported&&!this.blocked){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,navigator.hid.requestDevice({filters:[{usagePage:11}]});case 5:if(n=t.sent,r=N(n,1),i=r[0],this.verbose&&f.debug("WebHIDManager::pairDeviceRequest",i),i){t.next=11;break}return t.abrupt("return");case 11:return t.next=13,this.initDevice(i);case 13:if(t.t0=t.sent,!1!==t.t0){t.next=17;break}return this.emit({type:"error",id:"invalid_device",message:"Invalid device"}),t.abrupt("return");case 17:this.emitDeviceList(),t.next=24;break;case 20:t.prev=20,t.t1=t.catch(2),f.error("WebHIDManager::pairDeviceRequest",t.t1),this.emit({type:"error",id:"pair_request_failed",message:"Device pair request failed"});case 24:case"end":return t.stop()}}),t,this,[[2,20]])}))),function(){return o.apply(this,arguments)})},{key:"initDevice",value:(i=F(W().mark((function e(t){var n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t){e.next=3;break}return e.abrupt("return",!1);case 3:if(!this.devices.has(t)){e.next=15;break}if(t.opened){e.next=14;break}return e.prev=5,e.next=8,t.open();case 8:e.next=14;break;case 10:return e.prev=10,e.t0=e.catch(5),f.error("WebHIDManager::initDevice",e.t0),e.abrupt("return",!1);case 14:return e.abrupt("return",!0);case 15:if(n=va(t),this.verbose&&f.debug("WebHIDManager::initDevice",t.productName,n),n.hookSwitch&&n.offHook||n.phoneMute&&n.mute){e.next=28;break}return t.removeEventListener("inputreport",this.boundOnInputReport),e.prev=19,e.next=22,t.forget();case 22:e.next=27;break;case 24:e.prev=24,e.t1=e.catch(19),f.error("WebHIDManager::initDevice",e.t1);case 27:return e.abrupt("return",!1);case 28:if(t.opened){e.next=31;break}return e.next=31,t.open();case 31:return this.devices.set(t,{id:(r=t,i=void 0,o=void 0,i=r.vendorId,o=r.productId,"".concat(fa(i),":").concat(fa(o))),deviceStatus:{offHook:{active:this.status.call.active},mute:{active:this.status.mute.active}},deviceInfo:n}),e.next=34,ya(t,n,this.status,this.verbose);case 34:t.addEventListener("inputreport",this.boundOnInputReport),e.next=52;break;case 37:if(e.prev=37,e.t2=e.catch(0),f.error("WebHIDManager::initDevice",e.t2),!t){e.next=51;break}return t.removeEventListener("inputreport",this.boundOnInputReport),e.prev=42,e.next=45,t.forget();case 45:e.next=50;break;case 47:e.prev=47,e.t3=e.catch(42),f.error(e.t3);case 50:this.devices.delete(t);case 51:return e.abrupt("return",!1);case 52:return e.abrupt("return",!0);case 53:case"end":return e.stop()}var r,i,o}),e,this,[[0,37],[5,10],[19,24],[42,47]])}))),function(e){return i.apply(this,arguments)})},{key:"onInputReport",value:function(e){var t=e.device,n=e.reportId,r=e.data;if(this.devices.has(t)){var i=this.devices.get(t),o=i.deviceStatus,a=i.deviceInfo;!this.verbose||n!==a.hookSwitch.reportId&&n!==a.phoneMute.reportId||f.debug("WebHIDManager::onInputReport",t.productName,"reportId",n,"data",r.getUint8(0)),ba(a.phoneMute,n,r,o.mute)&&this.onStatusChange("togglemute",this.status.mute,o.mute,"mute",t),ba(a.hookSwitch,n,r,o.offHook)&&this.onStatusChange("togglecall",this.status.call,o.offHook,"offHook",t)}}},{key:"onStatusChange",value:function(e,t,n,r,i){var o=this;t.active!==n.active&&(t.active=n.active,this.devices.forEach(function(){var e=F(W().mark((function e(n,a){return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a===i||n.deviceStatus[r].active===t.active){e.next=10;break}return e.prev=1,n.deviceStatus[r].active=t.active,e.next=5,ga(a,n.deviceInfo[r],Number(t.active),o.verbose);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),f.error("WebHIDManager::onStatusChange",e.t0);case 10:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t,n){return e.apply(this,arguments)}}()),this.emit({type:e,active:t.active}))}},{key:"onDeviceConnect",value:(r=F(W().mark((function e(t){var n;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.device,this.verbose&&f.debug("WebHIDManager::onDeviceConnected",n),e.next=4,new Promise((function(e){return setTimeout(e,2e3)}));case 4:return e.next=6,this.initDeviceList();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"onDeviceDisconnect",value:function(e){var t=e.device;this.verbose&&f.debug("WebHIDManager::onDeviceDisconnected",t),this.devices.has(t)&&(this.devices.delete(t),this.emitDeviceList())}},{key:"removeDevice",value:(n=F(W().mark((function e(t){var n,r;return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,n=null,r=null,Array.from(this.devices.entries()).some((function(e){return e[1].id===t&&(n=e[0],r=e[1].deviceInfo,!0)})),n){e.next=6;break}return e.abrupt("return");case 6:if(n.removeEventListener("inputreport",this.boundOnInputReport),!r){e.next=10;break}return e.next=10,ya(n,r,null,this.verbose);case 10:return e.prev=10,e.next=13,n.forget();case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(10),f.error(e.t0);case 18:this.devices.delete(n),this.emitDeviceList(),e.next=25;break;case 22:e.prev=22,e.t1=e.catch(0),f.error("WebHIDManager::removeDevice",e.t1);case 25:case"end":return e.stop()}}),e,this,[[0,22],[10,15]])}))),function(e){return n.apply(this,arguments)})},{key:"onBeforeUnload",value:function(){var e=this;this.devices.forEach((function(t,n){var r=t.deviceInfo;n.removeEventListener("inputreport",e.boundOnInputReport),ya(n,r,null,e.verbose)}))}},{key:"destroy",value:function(){window.removeEventListener("beforeunload",this.boundOnBeforeUnload),e.supported&&(navigator.hid.removeEventListener("connect",this.boundOnDeviceConnect),navigator.hid.removeEventListener("disconnect",this.boundOnDeviceDisconnect)),this.offEvent(),this.channel&&(this.channel.onmessage=null,this.channel.close(),this.channel=null),this.onBeforeUnload(),this.devices.clear(),this.boundOnInputReport=null,this.boundOnBeforeUnload=null,this.boundOnDeviceConnect=null,this.boundOnDeviceDisconnect=null}}],[{key:"supported",get:function(){if(null!==ha)return ha;var e=!Reflect.has(document,"featurePolicy")||document.featurePolicy.allowsFeature("hid");return ha=Reflect.has(navigator,"hid")&&e}},{key:"initialize",value:(t=F(W().mark((function t(n){var r;return W().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new e(n),t.next=3,r.restrictMultipleInstances();case 3:if(e.supported&&!r.blocked){t.next=6;break}return r.destroy(),t.abrupt("return",r);case 6:return navigator.hid.addEventListener("connect",r.boundOnDeviceConnect),navigator.hid.addEventListener("disconnect",r.boundOnDeviceDisconnect),window.addEventListener("beforeunload",r.boundOnBeforeUnload,{passive:!0}),r.initDeviceList(),t.abrupt("return",r);case 11:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]);var t,n,r,i,o,a}();const Sa=function(){return d((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),this._listener=[],this._monitor=null,this._running=!1,this.state=null,this.sampleInterval=t.sampleInterval||1e3}),[{key:"onUpdate",value:function(e){"function"==typeof e&&this._listener.push(e)}},{key:"offUpdate",value:function(e){"function"==typeof e?this._listener=this._listener.filter((function(t){return t!==e})):this._listener.length=0}},{key:"_emit",value:function(e){var t=e[e.length-1].state;t!==this.state&&(this.state=t,f.debug("SystemPressureMonitor::emit",t),this._listener.forEach((function(e){try{e(t)}catch(e){f.error("SystemPressureMonitor::emit",e)}})))}},{key:"start",value:(e=F(W().mark((function e(){return W().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==et.canMonitorSystemPressure()){e.next=3;break}return f.error("SystemPressureMonitor is not supported"),e.abrupt("return");case 3:if(e.prev=3,this._monitor||(this._monitor=new PressureObserver(this._emit.bind(this))),this._running){e.next=9;break}return e.next=8,this._monitor.observe("cpu",{sampleInterval:this.sampleInterval});case 8:this._running=!0;case 9:null===this.state&&this._emit([{state:"nominal"}]),f.debug("SystemPressureMonitor::start"),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(3),f.error("SystemPressureMonitor::start",e.t0);case 16:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(){return e.apply(this,arguments)})},{key:"stop",value:function(){this._monitor&&this._running&&(this._monitor.disconnect(),this._running=!1)}},{key:"destroy",value:function(){this.stop(),this.offUpdate(),this.state=null,this._monitor=null}}]);var e}(),wa=Qo})(),r})()));
//# sourceMappingURL=eyeson.js.map