text: /*! AgoraRTC|BUILD v3.1.2-0-ge669c7b */
  !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("AgoraRTC",[],t):"object"==typeof exports?exports.AgoraRTC=t():e.AgoraRTC=t()}(window,(function(){return function(e){var t={};function n(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(a,i,function(t){return e[t]}.bind(null,i));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=40)}([function(e,t,n){"use strict";n.r(t);var a,i=n(9),o=n.n(i),r=function(){var e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()},s=n(11),c=n(3),d=n(2),u=n(22),l=n.n(u),p=n(23),f=n.n(p),g=new Array(32).fill(void 0);function m(e){return g[e]}g.push(void 0,null,!0,!1);var v=g.length;function S(e){var t=m(e);return function(e){e<36||(g[e]=v,v=e)}(e),t}var E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});E.decode();var _=null;function h(){return null!==_&&_.buffer===a.memory.buffer||(_=new Uint8Array(a.memory.buffer)),_}function I(e,t){return E.decode(h().subarray(e,e+t))}function b(e){v===g.length&&g.push(g.length+1);var t=v;return v=g[t],g[t]=e,t}var T=0,R=new TextEncoder("utf-8"),A="function"==typeof R.encodeInto?function(e,t){return R.encodeInto(e,t)}:function(e,t){var n=R.encode(e);return t.set(n),{read:e.length,written:n.length}};var y=null;function O(){return null!==y&&y.buffer===a.memory.buffer||(y=new Int32Array(a.memory.buffer)),y}var C=function(){function e(){l()(this,e)}return f()(e,[{key:"free",value:function(){var e=this.ptr;this.ptr=0,a.__wbg_signmanager_free(e)}},{key:"get_digest",value:function(e){return S(a.signmanager_get_digest(this.ptr,b(e)))}}],[{key:"__wrap",value:function(t){var n=Object.create(e.prototype);return n.ptr=t,n}},{key:"new",value:function(){var t=a.signmanager_new();return e.__wrap(t)}}]),e}(),N=!1,w=null;var D,k=0,L="free",P=[],M=[],U=0;(w?Promise.resolve(w):new Promise((function(e){N||a||function e(){var t={wbg:{}};t.wbg.__wbindgen_object_drop_ref=function(e){S(e)},t.wbg.__wbindgen_string_new=function(e,t){return b(I(e,t))},t.wbg.__wbindgen_string_get=function(e,t){var n=m(t),i="string"==typeof n?n:void 0,o=null==i?0:function(e,t,n){if(void 0===n){var a=R.encode(e),i=t(a.length);return h().subarray(i,i+a.length).set(a),T=a.length,i}for(var o=e.length,r=(i=t(o),h()),s=0;s<o;s++){var c=e.charCodeAt(s);if(c>127)break;r[i+s]=c}if(s!==o){0!==s&&(e=e.slice(s)),i=n(i,o,o=s+3*e.length);var d=h().subarray(i+s,i+o);s+=A(e,d).written}return T=s,i}(i,a.__wbindgen_malloc,a.__wbindgen_realloc),r=T;O()[e/4+1]=r,O()[e/4+0]=o},t.wbg.__wbindgen_throw=function(e,t){throw new Error(I(e,t))};for(var n=Uint8Array.from(atob("55ZBgM/2Bzm2JGhNn//ljJsSorhWUYE66a1Hf8O7pfQGR2zfol8qRP6CDhsi3iG7nFZu9stSyPq/qu2Rr2w8QkTGP6Gm2cg3J5qsQgq5bcHA9mDpGv/b24uEwsixZVl1eGkdV4SB/6ayw2v48hLmNA+w5UlnTCiWwerzESQPidpSUMbamXL3pU815EQm12GhhZ9aWzo568gdZvXevBc/WHfFKQSuTgWva4e4eSmW7UxpH8sY4HlDsCTMu0WwEB8B95XsZwOp3GLgfOQmJBw036DgIKU+XGn4KpIEq77WE/h6R7sZKsFUp+u+2cDnW7IPNe7xfd9areFo0EUh0/9K9CqxUkLqMB5hlgS1fwQHRzKPhQ7gALyc6HwMCPooS0M1NrzjdfH3vUn0PeQ1GBlnrnXgiu8TunfHg5TcbBfPEbxbyiiow1Np+VEBlHNh00PiAWyu024NHaPbDGfMtzu4WF02fgkh8Pxb7bCSpCZndjTytQgAzfZxk2bbe6NoHHFnsviqYzHVpxoPEk7icHRWcZC28d2muthq673KCMQay1fJcPqSTuYhWUZS5eylIguT33lP+TBbOWQI8KtCzBN5FzqILfKzRkzrJ3L192BUF8SILdwmriv10HU9ZlQAyQA1VdegnzOl/dYk2GGsB3724y7w/7aJLHJzEfwrfIzFd5CoAft7ct+zQW2G4Wm2kpoz6uJfgrNyykQgwCO6pkPy1ADrBUuJon9ySjhgcFru6AKa99wTlIhzBw3FKFt9Aa1/1KWWy7W1wAIGzRTs/7rLXRkKFjNqGVXBdoVNTpHFtfEFsuX0X98ISr0Bennlx0h2Yl/CGNb5Kc7i3bio1XJHX24avcMsEAwfdfskCki4/dkStn7QC97YJC3z+7gD84IiEEeGcnn7gHJyeALr0ssbqDUcKqxEyheyFs9FToJziLB+eYw6nMQLmYTrQyrg3b+3YBdgx7pzNEDSyz3tmaPaikwcLSyB/Igo6U/oP/fS2TZLtmN03m4iS76YrDJAgI+2W1GboabuixVcLdxm6SQ4CzUnHSPl1knhcGhW/+OcKa53tB5j5C4wEpiENv6T9PUu4K0YwtEAqFbd/eN2wVAYCKn/nlVA8uiESxCfgs0411mRFk4i1pixJLPP5AFPG9QFZnj6X19TqmhmIhl8D6Q1rOvPCqPZV/z04HjayX4qPzPzP/5NVilN/sHhQe7ulriGmU/3rj5QEuiOymsL7EdCQMc/4mXDPdVrDBfbt6dnv11oLYGmqOP1oSBj02FtsmYrMn9pRg7HJoCh86jAnzuOYn4tGnQ4gw/89sb64NAXcoIbTIjyiHBAQCCK2Yn4I/fNF10rkQlvSvkpqLG2eYpJmpWrcouNDEUtJFR607oNraLdmUKyLc1g7SNpS+ofp1FL6rua/HFSrb5kTF2Vcy2gl+6MACbFRChKoP/un7IbYJuOima/JWFZcs/MXokIx+ijuqjMtVKaYRTzNI5ncPa2y/EXTNdUUFpMhbE7sa39Uoh6Hci/viXy2KFTNbiw+BkWOPnyOr04LjIYKlJ8ud/KvjuvNUGQOHJvj6tpZJxj97tr0OrgZCAxSHGU5JQfqEd/U0QfzGM8Wh3zdsnd9LhoIIRJAtyA2PmjwJk4zTxeYlgwPqAVTU3+9bA1QD+jLZZ3Ffk3MRq+Ar2RT8YN6ASR4bItt3omBj0LJe0zeGY3OzfhljL6LA1m4+IUp+CzeWo0aEjnvRk3iCJeajgdC+NUGB5qh8PWKtBeC58woavnRjvRNphXS4b9M7Aymcfq26B2YY2lS+wLf763OnGJlVdV/srgyAUJJZjarxom4zrYy23kLFB8zFzWuwSMue5Xm1YWape91JGDuRLIctrJWU47/XfLm6Zgei4xOwq1RcjikGuaZtDwcFg9aKtO+JOGJsCjy9AiPnmt+rmdX83GsT3KtTETnLv6ZQcnGtmt4H8AjFgGYePdQc40cj8VAOV8NCLspyW5w63b3g37GXJrzjm9Fym3fh27psjo5RuTs7XCSrNENxKm9jCcXPqWxyuXJSn6dhdWnw5SAnUjixXviWS4HsnYjw4Xt4cSwkqCB9naLstVXt5D2HgG4fzHFNHvnETft0mrhU81IBDTSyNFdDvFEX8cifoc6FcNq7pzXlotl2ZS1FIzNXddZrdXpBNYZPV52gtCok6ePpUR/Y8jyJpE9P3q8dmFVivVGgmKTcBKMDDbzeOfl4MpOGBtBX/Lab/kzqG42sTyOyGUyOoFXYGMUWJ33GPI2KNa/mW8zVl+imshfbj7PiK1qRUn74KjAkH4wjKnu50AONYUaiveSdwnEc1zCjZSJ3dmBKSxhWAcO2PdHBg5m9+JCiPGCVfK9dzoM8Bm7xx9noJiqt4hNiVa5di1Fd1JRN4rnd1DbKglKpAVSoqvJPxmuyH56TFE4BQjhfKbDMZezQJqx+KXDiW1JWGeDYaPVBWPYeZX6STIzC/DjS7UFlqoKgGGAGP17x8wmMRE6O/axG5jDzloCGxCmrymT0ZGCh4g54O1iDYUtmJr7Bo1d+H9RQj2Y10BxcMkLFTIZVjm9e3vtIbeRx0OdXE1Ou37J/WeJZyPXn1fszvp/KonCqVnt862LrxfoB/0sF5gk4Y/f6LVneU5hun9/V1OVre9XrnDBhcVaQa9Ye6gs8sHW9HCNchaFbkUpxSiyxVEFZIlbejbjSPFlkYOLhtQHduwZWRHWA9akqykJNG3PKvOZAaJG5nWQq8+e4K0JF/AXTKIIr4J7zDt8ZR4xb9T2gxjl1nfqzidMRIY5B4rkw0oetta+j8rqkFpTEGA+hU/tw7bDtpkPYvCguwncnCjwULNFT9I9jXx3H4Ws3WWMCit29F7kGq2Ka+rU/MjnuP0lsXkoB1rr8LawHH5gaf8rajq/BhKrGTIfjDiZG5qz+L7SZBZsMSZZ9pM1QhKju+GTD9iC+9HlhfXMtj94gz8U4h7eGXziEO7lo7LwLL6/DVMrGbkv68JYUYhGz2yBm/8cbQEh5vhakbhmpv1K6XYM9rzdsd9bwYcYt3cfKE3m+/NrUa42+RpJBdFg7cAmxsZ7/0TMyVw6Aqu2gzldb2ag4iLrPNEyW1ywaJ2DXMgPi/sjnDzhuo+vIUrc86j4ZLhT4GAN6uqwbnXq5UDzX7TfuB48oMvvE1sK5q6owkdWfklgnC6pSBpK7wl+e3kuvaYnGRGJJMBQuVgWL1awHrVtfOTsSE1vc0ZdG+a/Jbza6pHbyfi5L7FXJAGdQTk0EP3VT54+F7RZ/MJ9fj56aMxzhJRwQJ6df3cM26qSc5bW/zP3PFXypTOBwzCvVtwGQzkGvDW7XGwgLbTNHDpQXOd2BQ5Zd9bjQqGg+S+kIqWZVZCqVLfyFPF9bEOHfPepL6nRDJUD2l5uRnXqeTvidaSIoqS1Fbc6mLPtYnbp6uuts6Qo8TbMzFuI7NuaPuKnQIyVu7vUGJ8jg1uVOjlMNKdVtLPr9/ZEKVZVj7lsFA+nm3zRjjr1DRKhr/wY1CI1iXKVTeQZ0i2PSnN99j4iVTSwNAYQLWWD+KyZ/xRLVxmZQPuSkLeKBRAkavxjWnIFQb1dn72wMSUdcB9cNCNJNdyTkrl44MRR+pUuiVrTAnTlzL33X32eEYwT+vn564yxFJLUDyIMNjJ0nx+GreKSOglI2et0kAwRHKYFclH9GVTiVlB0TWeUJGD+7JYogF7BizjTGyPOUEWQCguIEmtC4fHD5461T80Z3Mp7rhNTI+Cswuknr9hrIZmpRyFSrSrP8R4S1Cf34Tu4RNrDxpofVK9nGTklZPsYM6eiP29Lx264fsX9oLdYhq7vCwcrRMJ1a5d0QHXUYRV5IqTFBoUSpxkQ6IHHL8ckM4NCzwk8K0CA3pj5Jp2a9wZjfKq7R/eukzQFuhMxV2qgHf2E3t7/SA8N7sMvsmF0p3J96QRE3rA85ekH1q8nrBVujlIqahmL0Qto3+JxdqAfnKMCblQGSKVWZgWLMm82MG/9pjhdkMzG7C2GRLGMty2y8NhX1pZWHNbLOmvaC424LNz/Nl5tkPv7fVbCT2ItB+/dx3ZhVhmgSLd1zL+2PsNFmj7VGBruTttezlo1mDKErjY27nTswjf2fY/Uq8lPcVAgRpJM+m7jS/8dk8cdl7fkY7Tuj4TfiSe0tiNSoJgZwom4+9haoBQ65AifaB7pUiTc0MAXCvG+nDydkRIbKx5fL6gAlyMAnBbQf+Qh1naLfzzwLVTP0EEyoenW2W1zKqfMql5rwGlyCB9mSa2s25yHf4SDSBlgEVMJtplpRgegZvDakpWDKgx3UR4W7yKW+RD7bd7rEa/GQmA/q0RYAOIaXfO/2CgEUPtNhPS2uqy29lBYFPPv5SHQ0t/jRxQLBpe09ateAWKypt9TWS7Z5gynOePS5M2NC16AhF0Xz6s7DUjtI0xNho9Y6GK16J5V8HqHypV/OAz7+VBzTaiR57XGH4r62GoAiJqfWOM7okzKCeeSBnOIKPHtwgM0SQbvCvv7rmS6ZAacu4BbXZ5R9gOhdR9H3bi7lWLBNnqqLPIy0k6m4XBhtl40B6z/5AcJxjtKfwvIExl7VsQRqbW8gpPMsmJZfSp3uC35g1AkP+BJlju3RVoFZNo3JR18A5uc60NGD4zvzIdGTAOth4ZAZx0ZGQItHuNcLz/0CiavJdkjD65h4avf1vf7LFZ1uogJz6vLK3uDisXIBIGkXOlIpxTdjjjTQt6Khy50bYbXsG9JBrSUGhsBWpeRUnq2cZWOifhfueY95gFIDAu37oKR3FQ1YxGMg3UMq+L2VN2rtqodelSHof8SyYZVQWs7L0bjtgolId1tAAjHI7J1/+JIRXeUBjjaGGQAU+az9XFfiqn+VRAGG8JDdP/WmEqjhYpcy00LIBIBzCF9I9mbXCv8IX9fhPlI5NqWGO/v0ikpfn+hb5U16FcPYsx+xLb4la6nSbvrTDP5MthPyeLIIY7ZE/rNU4ajgPmI0/3RvD7WtEbo8UGPjnev55N2ELuFpEPzkNu9MzXqq8K0cWxk4lT2DQPi3rDO8x8i5jX7wWQi8e0neCMb0SUO67zRfaekZONGfaFl47LByciUuy5dhqxMPokhTE2WbzxqCyt/s2TqG66R0ocYHmzv9f7tJ+TES8NFyzL3fhNoZoW5IxWNE+stYWutd3LPwa7HKhhRAbl5uCEbEGjrUzTXwbzG0qvpmNtpnYnmKjzTaSAFNCxfw9edcjaxCiRKKIDd6GS/eDsGBgTvJexDfwGmVWm9jadZhee9jRFiZFtL6m7sY1oQa8F9ycxSuPANXCqWkApcaEfQLkt1yyfeRs5yC5O/6XGJ4TEtJmCTPJFRr95au20STIPgkoEF1mzZ+5ZRtWKUYuWJVZDwcA/lTy6oYp0/d0LGPRUXnXRm0qtIXQVdnoVhKZPeWACt9rujRL57MEDi2kHtfV/ucu+k03bN0fQlbalUJ0faY99GC6L8MO8MXTSmqDAxNSpqpIFPhgHgAg0YK/GZhlQjbQXE4tMDEDO9obNfp4W6m8fdznMesSSRINBG5FDf//DkT9pSRQsIdSg4VK7W7j2d2jsQUIyjJmbd/2zCTaqh0Yq0cH6mS/5g/cq3eGOiJbaCNo6oVwGURzXVAeVaGIfJFhd2A59sVp+rVfe1f8B6bVbCLIKgGUgpUokO0vTg6ouAxXGQKtveMhhBT83ukPIRZ02+qF1kvM+nNCVy8uzrB0+W9QIKbMio2m/7zW78xd5Tf9itocpLbRuNC5cuS/GyRGXw6fzFzjM1UITlQ5dlvoyYxuvb7ol4S1MyhkfMNZbif6/xic0wB3uSScez3oFTRbCHBd0cbJL3cLwfQjCBpGBrRVC7174qW4XWnw0eYGSSzTVSEDOlMaTUIGJO+s7/z8JxaZprcEsoB4+vt9/+uwtM/iyqLVPidu8ZTh+F1rsEWKwZhDAg/giVc6VzRq+DJCrhn81b/LYlLJOdgoAjID2VnwgU+mQhCL6KhgIqqiVraD25UIYEqxMcZ1aRcZvHa8x5gh5onPtsVcl53Xek9BOYqkyj64acX921zwqoY0lmNA81NE7BzVts3cwWDZ4Dk6uuzwtfJuJc7vVS+fdVDEg3ATwC9oG5/Vb1swTyzTsl2V4m+93bSQo5STFG5AruTDWTym6Lxtt4OrAeIVgdoyTJL+keHiHTNiL0/nO5oYwftSQK1aYBuA0e12t/FVN+LsCk0L/hfCCcke89LuP4d46qnFo3NLpHb+NFrvekXVT4GiZgMW2H0orIY0TpS15wlxVUaGCUo7YSN0yWDRU5+p41dCOs5/vXq1do7K+Byjj35/mPlQ+VEDqqF7OIBQrXfHgCXYPy8ye3Ih3io+tYA6nK0/2clIERrpA0AMHKLTGEO7q/IzIcOCwYN9W/ISH4v4uk9MhzNu7Fg2IPCq5CQF1GLuzQu+wNv2h94NIA2UJydawv5X2bHkZjv+kB/WQCYjxUNEU8ssUdxDZstpv2qNAHmI6BMD84olxMiwFdK5J80zc9x7de/cz3ZNIkkGIpMCZJqKKkaLVo1MLnR/h/hQeUvfqJmvkPeIre3EjnliNkKJKL0KNaupHzY7Eoztaj0cNOhJ5dxIRB2is3kLcSK1FZswRJR0B5OXX+Q4UlFIrhR10lIge3Fg5DnaGoZoOyFaaHztrdF251JubDsCZRDSWA0y6ysykO+h4jhXtuWF7D5Wp7B4Hx3EQvKsmPPZYcLevowjlWghHbRBEhwPI3bzjhNWXlqtym5ObYAeYxuHyvyYue2X4651f7Om3+m8KT7Y/JqLWXwgayCdzxHuJidti1ITuf/oXzeCfTRbG5ytXlDk/epX061W6BO074jI7nV518OkYtRJDnPqdDFAf0uWcATfk0h17+gP7GHjy0Rc0Ive9XmvA6gCkoMjNjMEA7GQ3xy7e12DzfNpIfND7GKKojMifTrvkDXrfa3o4wNYktY6/VlBdHtrcH9F7uMWICej/BjZXVX83WFGcVHx3nOXxSL59kE9bSmHc3Xp8iDbPuSG5GIRp3fTFHnmTzzGedl6al2gUbGFKtkC0jFNtKTk2rr8LEObiGgfCoSpTWknvAYDQBoj93s0KiRNPOqgY++Xka2cQiDwqUsLl8/i57YC/V6sy5/NvhViRRZgCzcyjNHGzZsYA5YMtUntyfC1gNFP7cL3AwVA+326NJI7MQJoxTqcHL/YhntsnYTR5R6GVVvFYIlW8Nv9qn3daoGXMz0MoAsXpCzbiHZ0XWkfw2qlJkmZjgQtMAEhHXNgokGRPfOprmtlvNZaNlGB1EjQTVX1Y4tCyJFZhdhID4CowB23uQF16NifyxH+DGnQrnxeklnG7UQV2BRVdr6ZEKZYv7Gj+PbpojzAskvbdtaFsataqPrLDoejjc6ZfPA5zA0iYcCvcNjzuy9SuT0uG8NWMTLv2OsImL++PQV1sifUENAwi4O3yBvzTy4J77B7mMBpjCYGXAyjFGFZL4eAazSmvZ8thJ0FFW+keLHL+ft1dQBKmXY6JatelGebcIC/PyLBHdfX9bRcauGg4xEO7mMl8AjlcPMczkPniNQpiQFqcDJYrFGoxMV2hskxMn0bRQT8Ajc6w6sQYkGl0CQUImPrGfie9dsk4mrCLMIFOqcm0WT8O8AiREEGmooBTO7WI0qk506NsV7ffvc0rVJERJKcyRyCmFZdTSn/SrBfjV7SXT3pQlgluoY4FBUCDDkzwBgjkrE1oFUA3ls+xVP10w5jjBIMwKBSQqRVAEDXw+Dyj+jH3ila8czULWsCKhWd4qGsMFN7++OGBAz9eXHjAO9m++mTXF6qiyG35Q+61yjYQKsBrjR4NNexrwVGqBwAZA6cr5mp8AhoyzPomJ6TLfWEJjEeRI3QsX5oQkNuyF7u650QFka+VjFeNRY6ALklleTW9I0v4ABKDCXTGkjv80vqVNk+FTL0bJK7ndSjjMJD7OBFIEywBPJFrxTdyzocmxEgG0zu1VDgsQuXITYCx1RRty89A/F+CdSAlbMlIkptCC0GrF/jFS8PAU+6TNV1eBqJrCr9BgH1mth8FtdfE7druR+xyZKn5idfUKzGW6ACGF4M61IRoSs9o6xmaj3dnAVQvFWUsMcR6MI3xTKJNyMxkhXhhvT0IxialnG7i/BBzXfMXYh5jl4BXzCSNlxU4+aboEgIDr48/+pfj8J3WcNccFfzV6eiX05qkNktmafoBcxrEsrM8WQV0VVSRybQyXPOqJ1yndwBI6BOGO9oGxGDAd+HcKaZlptCMJsR1Cp3m7F9HpBFSu/NYVj+WSDY7jWSFBlTBSCFyyPEUn8S9NmBVa+mwGVsz0Q+fxe23w1w6wVO7sVnZqRpmXJeXg72QFkl7Qda1lBzn/FW+rRwLvFxCsuad67Wmzab1RJdzPGsuq8AzW6tL+JiwW/VPUSBbBmV1+EjqQ28x1u9W5Eoy7zhsU8NT87CtNbZ0lPEpsoWMewxC80kPanfWPrQXmixWDXXz7uf1kBTr1J/iYuls7fUsyAChXjKcKOaCF4ySqkhMTGmjNqYiG5joBUi/SZpWvgxk28pyIPhf28YULINiqmbWPBKuTCLFruV7JfRgGM87XfNEFc7tgnYx503k/0UXJfpmjx6wKbKcvV5fqrctx+OrIn++TxRxSKlTScEIwd2vG5mg/p5wsQDpiD+X91XbkReKLB25Jvp/IJaJh715RXqBzwCwlY3URonyy+oZoTD8Ym8XMMv/dMllh0LCFZkZFn2gYcLG9iO+I5S/GyxwjajQLQtwH7o+n50vimC+ES8ePOpPDwlu4oG8KhS7NL/OTdIWPIHbSa6/9DfjOq9W66EpaK57R78PpEzVNLkTP2L6lllqDT6SDhIDIvQS3SQbxG96khXgvW/rME+tiXFXi+BC0udi9keyGlc3sLBN3CP3QXzswhBGTxvz2LmRMkU3rLuSkYR1Gzr7vj1VxTN1y1iciA0DswsPZ38eB6X10Uzk6HZqjzBK+EJ5osJJJ/s3b0MFRIWYlM15TPm1uzeOk1zQ96quClQLEZbpxmV/eAduIotXUYQZjWAkTulBJt7kw9uEnLo7OpZrf8k+0ZQP0agcOTLbfrekHji86Mxr7rTwve82mePKoAkkEthE45VI+f1VqpyWNW1kbBbVVfuatKt6MEKqyTUyxSFGHk81kY7CxkgMNexiikN0+IeiUNsfuktjfOAiMfDhbTe4rtxSEPvO4CCUGaktA58TGnSO8rHdCicmGkNrwWsnXgUWjhp8bllNcnQN10TbwxYPAwQKW/JJiYQadr4THXO+vWudiq3I47vqmEM/Ab3Dlq11Q7RmRWntYOEyESbTI8PZYwbtsmjcSwBtTAIHQ5h3I633h3FpOkT2c0PlMjzj0Q/OuqaTVt639fowVppqvSlNcK5KupBnrxfKHQK+SoKSuaO8PNMkYkbcEAc9F0I4uzPfRVP/q5QkvJVsVoJ8BEWW/q1+kivHEMQfb+J2NfJjSTG+WhjHjL8eqi7FgfVewxwmqG9IOnTkwDjAHUaJMIyhVkadW/+GQjLyNP4zyHcLAdWcB5zQ2kc/blAx2RKfG+ON3RfC+iQ5Th7V2i5abkoy0pjfyOwTjIvaq9slSCtoNGBZggBDOiWwau0CX4NAIThFyqu9VWCLr8TsqhQZvQP+xrywovGs6A079U7YBjhEXyQw4Q3rbQY1EQnxTPXNlHfn9vQnuhsJnzx6PZrCqry8fidPz2U1scmAMVPHxa/injIf+hDziEU02xWm9ou67OgebktON9V6wwVotoNOzVNJhiDBlHbktBwOjX1BlJHybLox5y/7NhR7uc8f85O6xdxueabhwtJjYcBzac56v6RbuI9IRvPzOnNbltj8Hh0ftwwhWyHAyiEat0oDSEVZ925jmxJKAqTo4/uHnkozgMDsnkzXPXBDJ1sDTawXy23mXuTJOYV6ZVWrervMaGGGQpgQjAnfP7KPZro+OKt/MpnoM0NeGQgIFAiH7dU7Nl1QbcMiwO6/5nIosJtrFB8w1kpqb6OjI9BgZHG1nzTMGA++HNrl4WQNcq3SajD4C9utQYAu/fETPFMMJeCDwHRCnPuRAlqJ5t0E5h3Wlh1Nw57LQ36kDjC3lS9w0a89eI8ym6BzEA25Cdz3LQAyz94Fvjqp7MyHrpm3PzmsV/tbSLF9NJBjFmzWPQ8Tfgvj3fi8dg78tXvEatqtUhLxsNp2VCU6IzSqafxWw93+Wk47skJv5qxM+tv7CrpYKvWLEylJNEXlh7GHm9UenNf2/szZOl+54P4ZWksh1r6+rphL68QYhmqW7DqKVrc2rjzPYcvFDmKtCGL/F62i3riMV9z+LoLnuVaMn4dtpNNFmQEQ4uEhDfLYU4x8G2OHCz7gnxLCa4zE4CFo9m/+ECmdzziVumHM/P00/BESH2rxUYMBL8/9NRG5fiskFJr4AO0qNUKUCgTRgEiFsTbGXtP4DTTzc8ZAmfNJuJQE5Kp7W7U7QZnBXKepfSHkYTEqgOhqo95Jw9i56kYGt4BWwX50mC27CCW92SVMl4tbUEhBDSB36zgztz5Zts0563Kjc34B+6ZUnMIk+BiQNvqSkZHnk3rHNSaYthO72IWLIxij0hcv7n228yc82FsQLK9jmptjY6estDfH3OSMaAj+poCLKwRFXvXWb6jwM9mG4nu1yug0Cc4L89w4EYek6dnV17VBfIxB2dmFFQdp0kqx3BM9gdMAr0KS7WLOSf3cn5eDItDLP2UW7MWaIR+GJ0EGcEL3ejBdu0to6vDh04JcRMNU55usmSn3jp74myzWE3azMIT96wr39F62c3G/ldGskbqTIMTk3gMg61vNBQ0cJSIxVdcgNb3xFDowwVyIqYz54F8Rqg0uQE4FIiUGZxJhND/AWhkukqIqLLZEpxj07kPBN6Zb2pWht/X5JrC8yJzPlvFhfJndQ4jcgjFyhvymr/a17uxTKHpKNWDEoL4nNa9/Prf7TYRw6Gyo6vcwYcUHk17SMb9aEdVnx24msNCDEKbj0OVzRaA3gFJeXZPObqJKvWqFlavGpxXnP+4ZYTl0Dmcri6vMdwX687ApG+ygiGHZDwNzU68F4JMPQ9JB45vLkCsE2w50QNP1kJZlI56dVGzfK1MyRqP4J6VshesfOT4hzR6MYq373IoONlLvENdYXN6pTxo5eRzQkwk2tZ1zmZqczCytqTEhpweKcBCCZ/FhizgLm8/x5ScBlO0wEXHZm90mpmL1gR/J2CUnz3wDU99YFFKqm01AZ8q2S5Fnh81CbD687c7K2OjWlZgdvEJA9M0JT3eKdIRd9GCx6g1TO5PWTE8OOphUDKdazyYnmMqFhFxfJ//cWJTsgYbol2a7Ob/Q69Fy3kb9K7aZLzH+Kl/uCzWnqTOrQonVL7LTFPr7wbTaepfAl5zSgMInjrGXY+Gspw+fCNgEU1zyC0Suum6VFyHBjdKWft7strrOXqOSQwxsYXp4F013mN9gZyu4Hc84A4dzIHN5UNXmxNn+vPjS82JM6klySWB9pLCzLBUgXiMDllaG6fT2PSBv/b+yaruyWBVcpsOKuEaQ37W3A3t9YFRcgB5rFMDjwOn3c0lfsg+5V+dBX2EmWLTSelNZkeq67CFnxaKtnlsAJRPBqYvoWVZcJKn0zSelrO2TwnailO7zgAHaMRmQYbXo9beBs16JWf7V8LjYGS/DYUKTTE1zKECC/pK1EKf6mxIgmV+mJ+Mc8h04qep+okIIEXaN351J3N0VUk7cEEaOLE1rFF3W4vqRcodPfbLqINF6QtTsfny1+O46J5ahlamZEyxglZtpjEkKd9yKDsgwnzqoAPN5o76IsI+FRaBc8u1qLBWxpKU615chTVegNFR5V4o1T2JGwVkueD6CjAhOplPnRyv8sauMnMy2wEMARR6AmCQ8S5ebL0nCEqjSztMoUyAEjQ6FDYqkGweu48DkBR5HjwlBloKVawYcDezxKBH8WWnMpJKZj1Ol+OHMmg5iq9xDswLx0iTNkujgatOkeRU0c/GmSSH+7GTTMLQJdj51l3EkojjEwWOjw8XBOm88GqC4bWPEE+U/5XYtZNJG/X4FYjgIvVd69RYVbMEMfPSKJ825e3XQ6RBesp/G+lkMk4VIxRakyUBPLO1u0UYnNG9ExAnPdOO0OfFvcPOL9rBJO8bR+q9Lp9/i+fH32KkaNR2WgoxQY3FY+rS2NUvtCOgZAaF9vny16WG/3zeUtRP9V28PcGivAHAwwCcRk0D0iohjAfgL/EKXJkr8gIFqbNq7lXUFRKqMbpBa182ol77SqJq1M5setGUJuSBKqYBYKdDZv3XdT/u6J5aKKkLvA5ez6PuWX0RT7kELSKDKfg9w9nwSmMmJHjbnr0blM2WvpiirR/nLid6SRN9+5KoLUb+pLw3QzD8JlS3X2q0m4BNRxfltr5KWqryOuuGDt6IOHSE8/zqGXMiTqgrUOfDH58NoWe0te4mFc1GxswvhZXWJZmaWaMJo2SBnuXa7+jIfFbnhNH74Z6jygwcqXsldYfI/Zh8BZbqTh2I7Hu44dilfbX8Uh18NVB3phRnTwpUonKquUs/iZXRnDFjtEmKg2YRQm2CP1FWRb/B92HqJlHT7Hs/Tpl3RrlxvkoskpNlW53/6Ujse0fkHLNeUm97TlDsaRXpfZkR1uWMTwhPv4oYM2Bv941R+c7nQ0yBdFNVQpZRkpejmIfjFrdQUA7DPwR69aq6Pzmk3IXarIMKG6R4MBdkB3j3HWxohnZLWpaNy/BMxS+84e4vPPfO/7+nLWVZsdpUY/nGDkQts0NGnRpZK/lW60tmncMoTepY5fMbow1GyKhqSXLbOZkz59l8DG9v9ZHPwA1roKz3MW/j2tN/U+lPQVYXTa6h1ePQkSWR2bp9OHmCCvT6s8v9PVG2ufK7dkbpY500gNx7fdArzH3yCjY33Fa5TbOuybLNdW8juJyJtikDn+5jMnMzIWP/+v12XkaXj195xk6eOKuvA5zeKk1i1PrSnmWA46Ca2ldgNqJ0rvLqM9X2EPn/QuMjLnLg0iVJ4H4r5S2PgpGdSdfVoiX/rBAq6yVDc30v8DOUae4oquSM0YDCIafLQ+hvEmB5b/f+QsTFtAR0zIVWeLyYbmrx3g9gHhVRfelCz9/exh19AGsyXcwuSaBiCzQIoctYvyhhkdCsC/cdZDce/1Fav35JQt+RJFAjiMRQhCdE4eS3SmfsREHe9LZa0ElOLhxxvs5uS/SnMYssyK9FxiucRjjOqfaIp2N8CmuNJqg3WvtMk+MlbAYeji9K94rx6U7nj9L1TGhVcAyz+Gb4sib21AW94HRzWbTrRKEkx5+KLE69Vc+8Cj1Vu2GkZ1AA2E4kaJ2aTjsEL2C0srAINXRAjnxwI3p5ED0NRYn9sT1iY9GPBJwhhd6WXEJ/Z44D0rufaDOA8dUj1SIqywRs2b7SjYcCYS8eefkwdWlpN0DvnecdwHVc3TqyCcUy7K2PMS2l2KZHzZfLCTCPaPq/NVc/Nlc5hVJoFvnNUpKWZcTsxVeHfH1mnELREECq9YES9v6FcvONCxXLQmf0k3S2dyNmsxbvlXM0u7lSqkx81md0rad3E33PPuPpDGM9UiBhSeJn3Sejmx+LdLCiZYcVxow59nCqrUmXGAbsR4O7wVQzyHdL6DX5s8k5BjHXlONz0PaIqS89xMhkYetMw6w7JZ5c/oJBH2jdZPbS6KbR0RpEe16BATLzU4QiHybxArrjBM8MKKP8Zz6MVbg/d8yb76U8nQzCK4Eqa5ombBm7/6xo2dR9O/ByfcU6qDu+efdLFAP4LiCr6C3aihDPjigUYuy0voLuX3Flevl7xXRtRZ4Vc48j2tgA7tK0wqv4OjLwCzZJn9lYIQuScQBEFMBjA6Vj8FTp4h3OphB6g0uA13nTnVLmKQ+zfELl+6znWX5nCWvbwak0t3q4qwWK3MAPKE2vqDEeCsFKvmJ2Ws+VOqnrA+ekCk9jaszBsZd71InADWijT4SHnyVmc55dv5ivXl1fED4vwNrxbiZHWeGinS3ImcoDAT1vGiLpP/D3NaiIPq9A2h5DT5SgaCVCh0JKu7DKsHjW9ZAACRxHgTSo5jrVWUJfGKweg2auQuittVidB+JaCdwYd0x9oJ4jyI5UygrB9Nzi2gbLVcCnpu+1ytsiWCbJb1Xxas8FhG/EX86taG6flZZauhaGnpRyfBB5ojGdsdPBVHEtb8R951oaNTvKXK7CddSeWaeOi2FIDPEhWhAk19RzuR9wSKEwvvi8nQFz649+fUlBMuDL7VmUBSsC1ExWwqY+uSdNKowEkpsBb+/KpWl6oGxymyR/e4uKjipBJrVPXg0nE2j6HL2JbCHNh01lV+/+6FUglhV8GTypzdvdfhYc7t0ZYtkyH/17wDakU7r1GAdUIXXmtxamhK2FdelBa4BPryblCC9gJG9htJue9LMrNS7mM6gbRA1xSFnWNsziDuGZeS3Dcu4bjsWaIebrgNnxpl/pLGxV5EtkFwDeh8fPyfPU8CZAM/Ljk3+Vi7jUtNZmZM8+f7d4wlUIkTHiAULRUKu0ODFIeyk20BiqLB7vvAT342SIDP+z5FPaa6Tjyqh/AsX2jFhbeIXKxDMb8fid0jHAWk6JKhswbtvtP6bDz+lYjvXIPwV1Y+nyft2uM8c1aUxmDHAUmZnJBvZXT43mxjXDHP05R1/dKfoExcgcYzv3wO5mazi7ugS01z6oUmByKtfQ6fA2+MQynPCoDHcp1eDtag/E3HQpHMWAgGkNh9wWR5Y48YG0W4CgvOrngI111j/x+MIuH5xFlVkxqptSjW+hnVbt9qxtXndEH5RtnxWfd9eP+kli/x3LU1WGsZVAkVElXD274LBGK0bMveEUbj/6EpnocEnvRSlglpE4GiAO5S4JdYb4uYd6oeK8vuZvTQaWMS3dEIJ2ssCxWz8DqYmc/b38ynz0DWCCeF1gCyipaLG2Kq9wqfHz3S6m7CS+H42nmDYAz2dYcx77M8purGOS5tQ4aykJXIDQBwHjIGSU+52M+1OV53rp4B3JbIXecQWEjfk9gkVoz8T6HJbIhFgm3quNMk+cIyRHlj/BdURXY8o7H7dBQfsdpLJhAsxS/1JtMkY8JoP4YdyOxzJY5x/+A9scOTXvPVoQAMqgmP899s6GvRtzNFGXLX7VHSnUj7VPO8K1qxaS/a/6v/YhRlUtNgnqnth3Jo/DKbdhdPn6HgB9YjU5GuN1uPyUXZJDZYfFwMfdqNPVoI8d1csoHMK5tquGoK060mIwBHMk3pFGqBosajr9g/5kBPrrtuIIEPFZnaAKSCQqLdeQq2B6Bs8WxD8+DfzGJ2nu0Xeb58spPoiHZAVV+I5lRUseUE0IA4E844UzFYADNYcLBW3zsP7aWzLnUZoQPuIDR3FX3bkM5mCunvXaPSi4PRkKnItEv8/OYiq8RSKQcaTwxX9YgdNbgPuXLwb5ARofv0Zj3WpHhNnlTq2Qu/lwvM3PUaqv8L7kpFqQR9aRaXfFanbLgbyxJ2kAx9oA1kRMyH3JXI06oQhRiZQ1LtWz+QKKxme0zAgI2q6/dmYApsA7WGeBae5+Y3eqkqDjXyS7Q+LzYgrM3EiqGHsibaKZKgFecxpGiMLXY5+kkuDKBdMkj2Bd8uTKI+aTWpu97gNp78fm891zYuT68sIEzE5JggpWjlWFSpzYayxvnOxJ3JYK/q8WbCy14KhtCFhdLOxCEAvyqXN3K+oP52ZzdxHiCAac5LX2TO5CTmkxp6zCT5JZDIBgnnmQU8GBowEvogfPni17fE1sljd55P2C4mWCNDr8l3hMH+4zpyZqp3iFbJx20nGtU+9LJozl0OxNrk/c0C9chEe+k4vUECnUaXbS8JqdnymqbZ1SCI+4+1BYMW4nzYKDLaqL3Nm08C/Ug7zNg2BuwhWepXrkqaRX58LCWLPDQyUzn369E1drtekeuNcI4SgdmyQZ/7xhXZ6sOKg9G/HEiJQsriRQThvHz4BhaFaXic4nlrz4LhUthGBLbnnB6tufJizYx4c6b2rY1E63pLDA8QdZsTOD7euNMku1a0T2nNQ9rOPBYPDyksaP+EmKTvqcgRycKMtzhHh37mAqVERuzIIMs/zXE9jGBpJBBWb8KCPZne6Sxw0+UFlY6/VeXJUHunHXY1csfc40Tw95XrkpLzxqX/LrsaYM7Y0UQ/Qe6PTjMQUXDseSMhYwHTXCohySQ+1fIjz/yjZWRFI1/a4d9eQzWLoGjz8O8ldPhzhpWFwwlaR0T1gpMP3VeHvDOx4RJocHJOSRQ+H4/nHJsiuXWDKowYZZW8Jk9vUiw2jExedn7glAsC/bgN1NrgIp1y+y3tmLd2V9x7yKVC+QK6MOFq19dlQflj350qUavBULMCTn0BvCRQY4q6VjniU6XHISUsaApCVoQeevAOuCUFcnwWfK+44XDo1qSpPF1wcnbH7N9aO+AzD212PgFlGkXlaQ3Gbfz9XIUMjulgGUREelr6IX+tR2K9H/yep959z5WLXlZ81Z8HCIV8CyU0JKYzkIeFqf6o2ywb2O73oRi7i8F6Vcn2zU1VWZpLfSXgTNkRtqM7r5s13UimLWtAVZs97rLcMRlwXzYp98ZnKvQLj/dpKn8nfNnU9V2Bp90frlQedeKt6zd4mPR53FKQ1J4r95n1G8ph0XG37DC9b185sWbnoyC4Q1iUvyy5IOxBrIqbqn/JSUWzdrlOiZGDJrU5IGuzUl5TaupUTIgFeLfT6uh0gIEJ5nZQ/8XjB0mmEZxTvocrU/BFoOaUvV/N48W3W/aQu5nR3KwsSByfSDAEq6qBqTVTkZtkaAd/1Rie2jkdRlZvxFMu0MGnLc0SHPII8eOz/bjfIhSQhAb38dSRcFmfRb+fpDrDHeazED6EHNayy0kESoRG+XFbJa6xWB6OlbwHVDwdO9Ka7bIOqLRHpZjwXmv/2DR9nu+2xwxE39cBHq/7Vv99HcvH8ZJeGmgHr8mBKQmOCTkvLkxf5k4FrqZuNpaRNhCB3puFuF5d2nnQbhgAaANLMCYAiGsJhX2bFM/r3BGhR/dkGPXeBQUJ4tTARQnVqA07mW/42Dv2k7Wa7hWU/wv7FTIWLwWyHX0Vqdg4BHrlJ7zh+b+T6fH+W3d53LS5rkXK5GIctMIttK+osfGYIvOD0BkkXBJR0EYUmteToIxpoaMVKZmCRC2BbmBLdUTIZiI1kVYKYnq9Q5xMGODu+6vCT2ofvYE0pmGbQ9Ln6wnBDYZUD/BL9rmiPn3n28Zs33OsHUQcLp2vjUEV5sOBLO2ScyescGu0N58y1q1NSNJuXCzI4fu4RWJtSIn3P3+9eAsMo/2NupFeaf70/usLGd2Z0F27EjLoIj+nmJ4/Q5edPFhVNpPURQrUzPALNNzEvx3e82rDtPpbZjugv7Abm2q2vMGwz5W+hGH0hkCzXdZhPFbLk0sR5vVhScLgAPdZIVZIjTuzwIKVuWmvpMr7Gwxgiglpy8ecfOAZcCpXRzG6lNuRB64D4G9AWD9vQi/crWV4Xq5VjJnRjQc3g4bJe+MmksjEctghn27n5i5PHZvW/gM0BsXzo8Pou6yOLnp49dGXpK/oLAbOdOel9h+kDqEtZunvsXa9EFomdl0QbDvk+H58SjszCVqVOXSgDpOdZjXWfZpFL6S/fd1Lq8FQS3LklgiNhdvE5GzgSO8uq3gtj8I2o+JzucnrUSrtoxa6IejmVQLGzF3rSCy3fdhBPhZnDdgctC89dRJ+PTfW4ga5WWAyaWspzFg5251FoByB8LUbD3AxhvV6M1ARNXRJ4NhPe2j9WOlu5I2KmCMGvGP5CbHAyZk3YhiuIdtDgOvre9Cz0yOWvHH5FpZQzqzyHE5XkTTFMU2JhG1nvne9SCi9zNvPnGj9h/bQXgpue78rpogXJl8oDSfMwz9fp4ocyOxEV1JCEslSsRvodEzPbUsMUYWDERNzR6f45Ku6EmW3qdD48dcFQtc9rr2wF3o85edZ/2SY0BSkOdQX1ahwPVBP554Q1Z4lbd0d/vrRCO5k3QBWOb3iML0vI4MRkiKwqt735Q2fkq0Xl1pI3nk4ll51cSEHOrFTctkxwLOiQl6HJh2q3iqHFmtOCSo0A4YLl+mllolm7FLpe/79gMoe7A5cbFPCbX9Z3GhI43FgBbWoq8pwaIoDlklRimVauOx355pv7v26P0MLrgiqWTOxJaIGO/UhHf7GSOm0r1O5m1sPYYn1bathmEkYfrQLiEWQ2/3IjunsIxgAmi6t4JsxalYxE4YyvD59EpzvswOjZUvSgkHwPZonVtaiMTLXnV3p0dKpCSSz38Kv8QbNFzqLbwbBBRUHw/nHSxNipNm5vtjfkuf06jWRwkctgu8wZqKwS/7IcGnFtmwnbJFPhpGcyV9GVFzCCG+TOeNgAWxOUPgmtLdD8JawVVDV+e3iR8kHuaZXIknncI/3uFnblTd2P/OdWvxl+9CXbqJb1CS8osg2fg/qaA9KvM3FQoZQ79JRZC/Upm90ABPCGzksTWJ7Xy9VHpnPZCgGzAVbJhmurq8tm24BjBvnm1GOKfotvCqXyIXFE1bYTRS1WtzgZrGWgR/oOUDnNgDPXqUfTmyFPfNCD9MX22hvuBans/Kl1DustiTunl9Kravj0NG1Ds5nkTqlQSYOfhgvRIowimmWAYWma55eqvaQL9GvHmuH/hIVB/tiN6s7yOW2iahReL8dNddIbMJ6BLVguJ4n1dnquV3ZNqi6V0H/Vn00j0cE80ERsZTgsHPJ0eUjxYik+eDtaEHnyAsYeR2AjRcGw=="),(function(e){return e.charCodeAt(0)})),i=new Uint8Array([177,156,215,89,13,111,230,1]),o=new Uint8Array(n.length),r=new Uint8Array(256),s=0;s<256;s++)r[s]=s;var c,d=0;for(s=0;s<256;s++){d=(d+r[s]+i[s%i.length])%256;var u=[r[d],r[s]];r[s]=u[0],r[d]=u[1]}s=0,d=0;for(var l=0;l<0+n.length;l++){d=(d+r[s=(s+1)%256])%256;var p=[r[d],r[s]];r[s]=p[0],r[d]=p[1],c=r[(r[s]+r[d])%256],l>=0&&(o[l-0]=n[l-0]^c)}return N=!0,new Promise((function(n){(function(e,t){return WebAssembly.instantiate(e,t)})(o.buffer,t).then((function(t){N=!1,a=t.instance.exports,e.__wbindgen_wasm_module=t.module,n()}))}))}().then((function(){w=C.new(),e(w)}))}))).then((function(e){D=e})),setInterval((function(){Object(c.getParameter)("UPLOAD_LOG")&&x.info("console log upload")}),9e5);var x=function(){var e,t,n,a,i,u,l=null,p=["DEBUG","INFO","WARNING","ERROR","NONE"],f=0,g=function(e,t,n){var a={};Array.isArray(e)||(e=[e]),e=e.map((function(e){return{log_item_id:k++,log_level:e.log_level,payload_str:e.payload}})),a={timestamp:Date.now(),sdk_version:c.VERSION,process_id:Object(d.a)(),payload:JSON.stringify(e)},D?a.hash=D.get_digest("".concat(a.payload).concat(a.process_id).concat(a.timestamp)):n&&n();try{var i=l||"https://".concat(Object(c.getParameter)("LOG_UPLOAD_SERVER"),"/upload/v2");Object(s.post)(i,a,(function(e){"OK"===e?t&&t(e):n&&n(e)}),(function(e){n&&n(e)}),{withCredentials:!0})}catch(e){n&&n(e)}},m=function(e,t){if(Object(c.getParameter)("UPLOAD_LOG"))try{t=Array.prototype.slice.call(t);var n="";t.forEach((function(e){"object"===o()(e)&&(e=JSON.stringify(e)),n=n+e+" "})),P.push({payload:n,log_level:e}),"free"===L&&function e(t){L="uploading",setTimeout((function(){g(t,(function(){U=0,0!==P.length?(M=P.length<10?P.splice(0,P.length):P.splice(0,10),e(M)):L="free"}),(function(){setTimeout((function(){e(M)}),U++<2?200:1e4)}))}),3e3)}(M=P.length<10?P.splice(0,P.length):P.splice(0,10))}catch(e){}};t=function(){for(var t=[0],n=0;n<arguments.length;n++)t.push(arguments[n]);e.apply(this,t)},n=function(){for(var t=[1],n=0;n<arguments.length;n++)t.push(arguments[n]);e.apply(this,t)},a=function(){for(var t=[2],n=0;n<arguments.length;n++)t.push(arguments[n]);e.apply(this,t)},i=function(){for(var t=[3],n=0;n<arguments.length;n++)t.push(arguments[n]);e.apply(this,t)};var v={};return u=function(e){v[e]||(a.apply(void 0,arguments),v[e]=!0)},{DEBUG:0,INFO:1,WARNING:2,ERROR:3,NONE:4,enableLogUpload:function(){Object(c.setParameter)("UPLOAD_LOG",!0)},disableLogUpload:function(){Object(c.setParameter)("UPLOAD_LOG",!1)},setProxyServer:function(e){l=e?"https://".concat(l,"/ls/?h=").concat(Object(c.getParameter)("LOG_UPLOAD_SERVER"),"&p=443&d=upload/v2"):"https://".concat(Object(c.getParameter)("LOG_UPLOAD_SERVER"),"/upload/v2")},setLogLevel:function(e){e>4?e=4:e<0&&(e=0),f=e},log:e=function(){var e=arguments[0],t=arguments;if(t[0]=r()+" Agora-SDK ["+(p[e]||"DEFAULT")+"]:",m(e,t),!(e<f))switch(e){case 0:case 1:console.log.apply(console,t);break;case 2:console.warn.apply(console,t);break;case 3:console.log.apply(console,t);break;default:return void console.log.apply(console,t)}},debug:t,info:n,warning:a,deprecate:u,error:i}}();t.default=x},function(e,t,n){"use strict";n.r(t),n.d(t,"checkValidObject",(function(){return r})),n.d(t,"checkValidString",(function(){return s})),n.d(t,"checkValidNumber",(function(){return c})),n.d(t,"checkValidFloatNumber",(function(){return d})),n.d(t,"checkValidBoolean",(function(){return u})),n.d(t,"checkValidEnum",(function(){return o})),n.d(t,"isValidString",(function(){return l})),n.d(t,"isValidNumber",(function(){return p})),n.d(t,"isValidBoolean",(function(){return g})),n.d(t,"isASCII",(function(){return S})),n.d(t,"isInteger",(function(){return E})),n.d(t,"isNumber",(function(){return _})),n.d(t,"isString",(function(){return h})),n.d(t,"isArray",(function(){return I})),n.d(t,"isEmpty",(function(){return b})),n.d(t,"isValidToken",(function(){return m})),n.d(t,"isValidChannelName",(function(){return v}));var a=n(9),i=n.n(a),o=function(e,t,n){for(var a=0;a<n.length;a++)if(e===n[a])return!0;throw new Error("".concat(t," can only be set as ").concat(JSON.stringify(n)))},r=function(e,t){if(!e)throw new Error("Invalid param: ".concat(t||"param"," cannot be empty"));if("object"!==i()(e))throw new Error("".concat(t||"This paramter"," is of the object type"));return!0},s=function(e,t,n,a,i){if(b(n)&&(n=1),a=a||255,b(i)&&(i=!0),b(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!l(e,n,a,i))throw new Error("Invalid ".concat(t||"string param",": Length of the string: [").concat(n,",").concat(a,"].").concat(i?" ASCII characters only.":""))},c=function(e,t,n,a){if(b(n)&&(n=1),a=a||1e4,b(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!p(e,n,a))throw new Error("Invalid ".concat(t||"number param",": The value range is [").concat(n,",").concat(a,"]. integer only"))},d=function(e,t,n,a){if(null==e)throw new Error("".concat(t||"param"," cannot be null"));if(b(n)&&(n=0),a=a||1e4,b(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!f(e,n,a))throw new Error("Invalid ".concat(t||"number param",": The value range is [").concat(n,",").concat(a,"]."))},u=function(e,t){if(b(e))throw new Error("".concat(t||"param"," cannot be empty"));if(!g(e))throw new Error("Invalid ".concat(t||"boolean param",": The value is of the boolean type."))},l=function(e,t,n,a){return t||(t=0),n||(n=Number.MAX_SAFE_INTEGER),b(a)&&(a=!0),h(e)&&(!a||S(e))&&e.length>=t&&e.length<=n},p=function(e,t,n){return E(e)&&e>=t&&e<=n},f=function(e,t,n){return _(e)&&e>=t&&e<=n},g=function(e){return"boolean"==typeof e},m=function(e){return l(e,1,2047)},v=function(e){return h(e)&&/^[a-zA-Z0-9 \!\#\$\%\&\(\)\+\-\:\;\<\=\.\>\?\@\[\]\^\_\{\}\|\~\,]{1,64}$/.test(e)},S=function(e){if("string"==typeof e){for(var t=0;t<e.length;t++){var n=e.charCodeAt(t);if(n<0||n>255)return!1}return!0}},E=function(e){return"number"==typeof e&&e%1==0},_=function(e){return"number"==typeof e},h=function(e){return"string"==typeof e},I=function(e){return e instanceof Array},b=function(e){return null==e}},function(e,t,n){"use strict";n.d(t,"b",(function(){return _})),n.d(t,"a",(function(){return E}));var a=n(21),i=n.n(a),o=n(6),r=n.n(o),s=n(3),c=n(0),d=n(11),u=n(15),l=n.n(u);function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){i()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var g,m,v={eventType:null,sid:null,lts:null,success:null,cname:null,uid:null,peer:null,cid:null,elapse:null,extend:null,vid:0},S=null,E=function(){return S||(S="process-"+l()(),c.default.info("processId: "+S)),S},_=(m=0,(g={list:{},setProxyServer:function(e){g.proxyServerURL=e},getUrl:function(){return g.proxyServerURL?"https://".concat(g.proxyServerURL,"/rs/?h=").concat(Object(s.getParameter)("EVENT_REPORT_DOMAIN"),"&p=6443&d=events/message"):"https://".concat(Object(s.getParameter)("EVENT_REPORT_DOMAIN"),":6443/events/message")},getBackUrl:function(){return g.proxyServerURL?"https://".concat(g.proxyServerURL,"/rs/?h=").concat(Object(s.getParameter)("EVENT_REPORT_BACKUP_DOMAIN"),"&p=6443&d=events/message"):"https://".concat(Object(s.getParameter)("EVENT_REPORT_BACKUP_DOMAIN"),":6443/events/message")},getSessionStartTime:function(e){return g.list[e].startTime},sessionInit:function(e,t){var n=r()({},v);n.startTime=+new Date,n.sid=e,n.cname=t.cname,g.list[e]=n;var a=r()({},{willUploadConsoleLog:Object(s.getParameter)("UPLOAD_LOG"),areaVersion:"global"},t.extend),i=r()({},n);i.eventType="session_init",i.appid=t.appid,i.browser=navigator.userAgent,i.build=s.BUILD,i.lts=+new Date,i.elapse=i.lts-i.startTime,i.extend=JSON.stringify(a),i.mode=t.mode,i.process=E(),i.success=t.succ,i.version=s.VERSION,delete i.startTime,g.send({type:"io.agora.pb.Wrtc.Session",data:i}),g._flushInvokeReport(e)},joinChooseServer:function(e,t,n){if(g.list[e]){t.uid&&(g.list[e].uid=parseInt(t.uid)),t.cid&&(g.list[e].cid=parseInt(t.cid));var a=r()({},g.list[e]);a.eventType="join_choose_server";var i=t.lts;a.lts=Date.now(),a.eventElapse=a.lts-i,a.chooseServerAddr=t.csAddr,a.errorCode=t.ec,a.elapse=a.lts-a.startTime,a.success=t.succ,a.chooseServerAddrList=JSON.stringify(t.serverList),delete a.startTime,g.send({type:"io.agora.pb.Wrtc.JoinChooseServer",data:a})}},reqUserAccount:function(e,t){t.vid&&(g.list[e].vid=t.vid);var n=r()({},g.list[e]),a=t.lts;n.eventType="req_user_account",n.lts=Date.now(),n.success=t.success,n.serverAddress=t.serverAddress,n.stringUid=t.stringUid,n.uid=t.uid,n.errorCode=t.errorCode,n.elapse=n.lts-n.startTime,n.eventElapse=n.lts-a,n.extend="string"==typeof t.extend?t.extend:JSON.stringify(t.extend),delete n.startTime,g.send({type:"io.agora.pb.Wrtc.ReqUserAccount",data:n})},joinGateway:function(e,t){t.vid&&(g.list[e].vid=t.vid);var n=r()({},g.list[e]),a=t.lts;n.eventType="join_gateway",n.firstSuccess=t.firstSuccess,n.lts=Date.now(),n.gatewayAddr=t.addr,n.success=t.succ,n.errorCode=t.ec,n.elapse=n.lts-n.startTime,n.eventElapse=n.lts-a,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.JoinGateway",data:n})},publish:function(e,t){var n=r()({},g.list[e]);n.eventType="publish";var a=t.lts;n.lts=Date.now(),n.eventElapse=n.lts-a,n.elapse=n.lts-n.startTime,n.success=t.succ,n.errorCode=t.ec,n.audio=t.audio,n.video=t.video,n.screenshare=t.screenshare,n.publishRequestid=t.publishRequestid,n.p2pid=t.p2pid,t.videoName&&(n.videoName=t.videoName),t.audioName&&(n.audioName=t.audioName),t.screenName&&(n.screenName=t.screenName),delete n.startTime,g.send({type:"io.agora.pb.Wrtc.Publish",data:n}),g._flushInvokeReport(e)},subscribe:function(e,t){var n=r()({},g.list[e]);n.eventType="subscribe";var a=t.lts;n.lts=Date.now(),n.eventElapse=n.lts-a,n.elapse=n.lts-n.startTime,n.errorCode=t.ec,n.success=t.succ,n.subscribeRequestid=t.subscribeRequestid,n.p2pid=t.p2pid,isFinite(t.peerid)?n.peer=t.peerid:n.peerSuid=""+t.peerid,"boolean"==typeof t.video&&(n.video=t.video),"boolean"==typeof t.audio&&(n.audio=t.audio),delete n.startTime,g.send({type:"io.agora.pb.Wrtc.Subscribe",data:n}),g._flushInvokeReport(e)},firstRemoteFrame:function(e,t){var n=r()({},g.list[e]);n.eventType="first_remote_frame";var a=t.lts;n.lts=Date.now(),n.eventElapse=n.lts-a,n.elapse=n.lts-n.startTime,n.width=t.width,n.height=t.height,n.success=t.succ,n.errorCode=t.ec,isFinite(t.peerid)?n.peer=t.peerid:n.peerSuid=""+t.peerid,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.FirstFrame",data:n})},firstVideoReceived:function(e,t){var n=r()({},g.list[e]);n.eventType="first_video_received",n.lts=Date.now(),n.peer=t.peerid,n.uid=t.uid,n.elapse=t.elapse,n.subscribeElapse=t.subscribeElapse,n.subscribeRequestid=t.subscribeRequestid,n.p2pid=t.p2pid,g.send({type:"io.agora.pb.Wrtc.FirstVideoReceived",data:n})},firstAudioReceived:function(e,t){var n=r()({},g.list[e]);n.eventType="first_audio_received",n.lts=Date.now(),n.peer=t.peerid,n.uid=t.uid,n.elapse=t.elapse,n.subscribeElapse=t.subscribeElapse,n.subscribeRequestid=t.subscribeRequestid,n.p2pid=t.p2pid,g.send({type:"io.agora.pb.Wrtc.FirstAudioReceived",data:n})},firstVideoDecode:function(e,t){var n=r()({},g.list[e]);n.eventType="first_video_decode",n.lts=Date.now(),n.peer=t.peerid,n.uid=t.uid,n.elapse=t.elapse,n.videowidth=t.width,n.videoheight=t.height,n.subscribeElapse=t.subscribeElapse,n.subscribeRequestid=t.subscribeRequestid,n.p2pid=t.p2pid,g.send({type:"io.agora.pb.Wrtc.FirstVideoDecode",data:n})},firstAudioDecode:function(e,t){var n=r()({},g.list[e]);n.eventType="first_audio_decode",n.lts=Date.now(),n.uid=t.uid,n.peer=t.peerid,n.elapse=t.elapse,n.subscribeElapse=t.subscribeElapse,n.subscribeRequestid=t.subscribeRequestid,n.p2pid=t.p2pid,g.send({type:"io.agora.pb.Wrtc.FirstAudioDecode",data:n})},onAddAudioStream:function(e,t){var n=r()({},g.list[e]);n.eventType="on_add_audio_stream",n.lts=Date.now(),n.uid=t.uid,n.peer=t.peerid,g.send({type:"io.agora.pb.Wrtc.OnAddAudioStream",data:n})},onAddVideoStream:function(e,t){var n=r()({},g.list[e]);n.eventType="on_add_video_stream",n.lts=Date.now(),n.uid=t.uid,n.peer=t.peerid,g.send({type:"io.agora.pb.Wrtc.OnAddVideoStream",data:n})},onUpdateStream:function(e,t){var n=r()({},g.list[e]);n.eventType="on_update_stream",n.lts=Date.now(),n.uid=t.uid,n.peer=t.peerid,n.audio=t.audio,n.video=t.video,g.send({type:"io.agora.pb.Wrtc.OnUpdateStream",data:n})},onRemoveStream:function(e,t){var n=r()({},g.list[e]);n.eventType="on_remove_stream",n.lts=Date.now(),n.uid=t.uid,n.peer=t.peerid,g.send({type:"io.agora.pb.Wrtc.OnRemoveStream",data:n})},streamSwitch:function(e,t){var n=r()({},g.list[e]);n.eventType="stream_switch",n.lts=Date.now(),n.isDual=t.isdual,n.elapse=n.lts-n.startTime,n.success=n.succ,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.StreamSwitch",data:n})},audioSendingStopped:function(e,t){var n=r()({},g.list[e]);n.eventType="audio_sending_stopped",n.lts=Date.now(),n.elapse=n.lts-n.startTime,n.reason=t.reason,n.success=t.succ,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.AudioSendingStopped",data:n})},videoSendingStopped:function(e,t){var n=r()({},g.list[e]);n.eventType="video_sending_stopped",n.lts=Date.now(),n.elapse=n.lts-n.startTime,n.reson=t.reason,n.success=t.succ,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.VideoSendingStopped",data:n})},requestProxyAppCenter:function(e,t){var n=r()({},g.list[e]),a=t.lts;n.eventType="request_proxy_appcenter",n.lts=Date.now(),n.eventElapse=n.lts-a,n.elapse=n.lts-n.startTime,n.extend=t.extend+"",n.APAddr=t.APAddr,n.workerManagerList=t.workerManagerList,n.response=t.response,n.errorCode=t.ec,n.success=t.succ,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.RequestProxyAppCenter",data:n})},requestProxyWorkerManager:function(e,t){var n=r()({},g.list[e]),a=t.lts;n.eventType="request_proxy_worker_manager",n.lts=Date.now(),n.eventElapse=n.lts-a,n.elapse=n.lts-n.startTime,n.extend=t.extend,n.workerManagerAddr=t.workerManagerAddr,n.response=t.response,n.errorCode=t.ec,n.success=t.succ,delete n.startTime,g.send({type:"io.agora.pb.Wrtc.RequestProxyWorkerManager",data:n})},sendCustomReportMessage:function(e,t,n){var a={type:"io.agora.pb.Wrtc.UserAnalytics",data:f({sid:e},t)},i=g.getUrl();Object(d.post)(i,a,(function(e){n&&n()}),(function(e){var t=g.getBackUrl();Object(d.post)(t,a,(function(e){n&&n()}),(function(e){n&&n("Failed")}),{timeout:Object(s.getParameter)("CUSTOMER_REPORT_TIMEOUT")})}),{timeout:Object(s.getParameter)("CUSTOMER_REPORT_TIMEOUT")})},joinChannelTimeOut:function(e){g.send({type:"io.agora.pb.Wrtc.JoinChannelTimeout",data:f({},e)})},peerPublishStatus:function(e){g.send({type:"io.agora.pb.Wrtc.PeerPublishStatus",data:f({},e)})}}).reportApiInvoke=function(e,t){var n=t.tag,a=t.name,i=t.getStates,o=t.options,r=t.timeout,d=void 0===r?6e4:r,u=t.callback,l=t.reportResult,p=void 0===l||l,g=Date.now(),v=0,S=m++,E=function(){return f({tag:n,invokeId:S,sid:e,name:a,apiInvokeTime:g,options:o},i&&{states:(t=i(),Object.keys(t).reduce((function(e,n){var a=e;return null!=t[n]&&(a[n]=t[n]),a}),{}))});var t},h=!!Object(s.getParameter)("SHOW_REPORT_INVOKER_LOG");h&&c.default.info("".concat(a," start"));var I=setTimeout((function(){_._sendApiInvoke(f({},E(),{error:"API_INVOKE_TIMEOUT",success:!1}))}),d);return function(e,t){if(clearTimeout(I),++v>1&&(e="EXECUTOR_INVOKE_".concat(v)),e)return _._sendApiInvoke(f({},E(),{success:!1,error:e},i&&{states:i()})),h&&c.default.info("".concat(a," onFailure"),e),u&&u(e);_._sendApiInvoke(f({},E(),{success:!0},p&&{result:t},{},i&&{states:i()})),h&&c.default.info("".concat(a," onSuccess")),u&&u(null,t)}},g._cachedItems=[],g._cacheInvokeReport=function(e){e.lts||(e.lts=Date.now()),g._cachedItems.push(e),g._cachedItems.length>50&&g._cachedItems.shift()},g._flushInvokeReport=function(e){if(g._cachedItems.length){var t=g._cachedItems;g._cachedItems=[],c.default.debug("Flush cached event reporting:",t.length),t.forEach((function(t,n){t.sid=e,setTimeout((function(){g._sendApiInvoke(t)}),5e3+500*n)}))}},g._sendApiInvoke=function(e){var t=e.tag,n=e.invokeId,a=e.sid,i=e.name,o=e.result,r=e.states,c=e.options,d=e.error,u=e.success,l=e.apiInvokeTime,p=e.lts,m=Object(s.getParameter)("NOT_REPORT_EVENT");if(!(t&&m instanceof Array&&-1!==m.indexOf(t)))if(g.list[a]){var v=g.list[a],S=v.startTime,E=v.cname,_=v.uid,h=v.cid,I=(p=p||Date.now())-S,b=p-l,T="";if(c)try{T=JSON.stringify(c)}catch(e){T=c.toString()}var R=f({invokeId:n,sid:a,cname:E,cid:h,lts:p,uid:_,success:u,elapse:I,apiName:i,execElapse:b},void 0!==c&&{options:T},{},void 0!==r&&{execStates:JSON.stringify(r)},{},void 0!==d&&{errorCode:JSON.stringify(d)},{},void 0!==o&&{execResult:JSON.stringify(o)});g.send({type:"io.agora.pb.Wrtc.ApiInvoke",data:R})}else g._cacheInvokeReport(arguments[0])},g._send=function(e){try{var t=[];e&&e.data&&e.data.apiName?t.push(["apiName",""+e.data.apiName]):e&&e.data&&e.data.eventType&&t.push(["eventType",e.data.eventType]);var n=t.map((function(e){return"".concat(e[0],"=").concat(encodeURIComponent(e[1]))})).join("&"),a=g.getUrl();a=-1===g.getUrl().indexOf("?")?"".concat(a,"?").concat(n):a,Object(d.post)(a,e,null,(function(t){var a=g.getBackUrl();a=-1===a.indexOf("?")?"".concat(a,"?").concat(n):a,Object(d.post)(a,e,null,(function(e){}),{timeout:1e4})}),{timeout:1e4})}catch(e){console.error(e)}},g.sendCache=[],g.sendTimer=null,g.send=function(e){if(e.data){var t=e.data;g._lastLts&&g._lastLts>=t.lts&&(t.lts=g._lastLts+1),g._lastLts=t.lts}if(g.sendCache.push(e),null===g.sendTimer)return function e(){g.sendTimer=setTimeout((function(){if(0!==g.sendCache.length)return g._send(g.sendCache.shift()),e();g.sendTimer=null}),Object(s.getParameter)("EVENT_REPORT_SEND_INTERVAL"))}()},g)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BUILD="v3.1.2-0-ge669c7b";t.VERSION="3.1.2";var a=0*Date.now()+11499+86604+5615+6547+846;t.SUPPORT_RESOLUTION_LIST={"90p_1":[160,90,null,null,null,null],"120p_1":[160,120,15,15,30,65],"120p_3":[120,120,15,15,30,50],"120p_4":[212,120,null,null,null,null],"180p_1":[320,180,15,15,30,140],"180p_3":[180,180,15,15,30,100],"180p_4":[240,180,15,15,30,120],"240p_1":[320,240,15,15,40,200],"240p_3":[240,240,15,15,40,140],"240p_4":[424,240,15,15,40,220],"360p_1":[640,360,15,15,80,400],"360p_3":[360,360,15,15,80,260],"360p_4":[640,360,30,30,80,600],"360p_6":[360,360,30,30,80,400],"360p_7":[480,360,15,15,80,320],"360p_8":[480,360,30,30,80,490],"360p_9":[640,360,15,15,80,800],"360p_10":[640,360,24,24,80,800],"360p_11":[640,360,24,24,80,1e3],"480p_1":[640,480,15,15,100,500,1,5],"480p_2":[640,480,30,30,100,1e3,25,30],"480p_3":[480,480,15,15,100,400],"480p_4":[640,480,30,30,100,750],"480p_6":[480,480,30,30,100,600],"480p_8":[848,480,15,15,100,610],"480p_9":[848,480,30,30,100,930],"480p_10":[640,480,10,10,100,400],"720p_1":[1280,720,15,15,120,1130,1,5],"720p_2":[1280,720,30,30,120,2e3,25,30],"720p_3":[1280,720,30,30,120,1710],"720p_5":[960,720,15,15,120,910],"720p_6":[960,720,30,30,120,1380],"1080p_1":[1920,1080,15,15,120,2080,1,5],"1080p_2":[1920,1080,30,30,120,3e3,25,30],"1080p_3":[1920,1080,30,30,120,3150],"1080p_5":[1920,1080,60,60,120,4780],"1440p_1":[2560,1440,30,30,120,4850],"1440p_2":[2560,1440,60,60,120,7350],"4k_1":[3840,2160,30,30,120,8910],"4k_3":[3840,2160,60,60,120,13500]};t.AUDIO_PROFILE_SETTINGS={speech_low_quality:[!1,!1,!0,!0],speech_standard:[!1,!1,!0,!1],music_standard:[!1,!1,!1,!1],standard_stereo:[!1,!0,!1,!1],high_quality:[!0,!1,!1,!1],high_quality_stereo:[!0,!0,!1,!1],default:[!1,!1,!1,!1]};var i={WEBCS_DOMAIN:["ap-web-1-oversea.agora.io","ap-web-1-north-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oversea.agora.io","ap-web-2-north-america.agora.io"],PROXY_CS:["proxy-ap-web-oversea.agora.io","proxy-ap-web-america.agora.io"],CDS_AP:["cds-ap-web-oversea.agora.io","cds-ap-web-america.agora.io","cds-ap-web-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oversea.agora.io","sua-ap-web-america.agora.io","sua-ap-web-america2.agora.io"],UAP_AP:["uap-ap-web-oversea.agora.io","uap-ap-web-america.agora.io","uap-ap-web-america2.agora.io"],LOG_UPLOAD_SERVER:"logservice-oversea.agora.io",EVENT_REPORT_DOMAIN:"statscollector-1-oversea.agora.io",EVENT_REPORT_BACKUP_DOMAIN:"statscollector-2-oversea.agora.io",ENABLE_LIVE_SERVER_LIST:!1,LIVE_SERVER_LIST:[],ACCOUNT_REGISTER_RETRY_TIMEOUT:1,ACCOUNT_REGISTER_RETRY_RATIO:2,ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX:6e4,ACCOUNT_REGISTER_RETRY_COUNT_MAX:1e5,AUDIO_CONTEXT:null,GATEWAY_DOMAINS:["edge.agora.io"],WEBCS_BACKUP_CONNECT_TIMEOUT:6e3,LIVESTREAMING_ALIGN:!0,HTTP_CONNECT_TIMEOUT:5e3,PLAYER_STATE_DEFER:2e3,SIGNAL_REQUEST_TIMEOUT:1e7,SIGNAL_REQUEST_WATCH_INTERVAL:1e3,REPORT_STATS:!0,REPORT_STATS_TIMEOUT:3e3,UPLOAD_LOG:!1,NOT_REPORT_EVENT:[],FILEPATH_LENMAX:255,SUBSCRIBE_TCC:!1,PING_PONG_TIME_OUT:10,DUALSTREAM_OPERATION_CHECK:!0,WEBSOCKET_TIMEOUT_MIN:1e4,EVENT_REPORT_SEND_INTERVAL:1e3,MEDIA_ELEMENT_EXISTS_DEPTH:3,CANDIDATE_TIMEOUT:2e3,SHIM_CANDIDATE:!1,LEAVE_MSG_TIMEOUT:2e3,TICKET_RENEW_TIMEOUT:828e5,SHOW_REPORT_INVOKER_LOG:!1,STATS_FILTER:{transportId:!0,googTrackId:!0},FORCE_TURN:!1,TURN_ENABLE_TCP:!0,TURN_ENABLE_UDP:!0,FORCE_CHANGED_GATEWAY_FLAG:!1,JOIN_EXTEND:"",PUB_EXTEND:"",SUB_EXTEND:"",CHROME_NEW_STATS:!1,AP_BACKOFF_MAX_TIME:8,SET_DEFAULT_TURNSERVER:!0,TURN_SERVER_PASSWORD:a.toString(),PROXY_SERVER_TYPE2:"webnginx-proxy.agora.io",CR:!0,CRL:10,CRI:6,CUSTOMER_REPORT_TIMEOUT:5e3};i.WEBCS_DOMAIN=["webrtc2-ap-web-1.agora.io","webrtc2-ap-web-2.agoraio.cn"],i.WEBCS_DOMAIN_BACKUP_LIST=["webrtc2-ap-web-3.agora.io","webrtc2-ap-web-4.agoraio.cn"],i.PROXY_CS=["ap-proxy-1.agora.io","ap-proxy-2.agora.io"],i.CDS_AP=["cds-ap-web-1.agora.io","cds-ap-web-2.agoraio.cn","cds-ap-web-3.agora.io","cds-ap-web-4.agoraio.cn"],i.ACCOUNT_REGISTER=["sua-ap-web-1.agora.io","sua-ap-web-2.agoraio.cn","sua-ap-web-3.agora.io","sua-ap-web-4.agoraio.cn"],i.UAP_AP=["uap-ap-web-1.agora.io","uap-ap-web-2.agoraio.cn","uap-ap-web-3.agora.io","uap-ap-web-4.agoraio.cn"],i.LOG_UPLOAD_SERVER="logservice.agora.io",i.EVENT_REPORT_DOMAIN="webcollector-1.agora.io",i.EVENT_REPORT_BACKUP_DOMAIN="webcollector-2.agoraio.cn",i.GATEWAY_DOMAINS=["edge.agora.io","edge.agoraio.cn"];t.setParameter=function(e,t){return void 0!==i[e]&&(i[e]=t,!0)};t.getParameter=function(e){return void 0!==i[e]?i[e]:null}},function(e,t,n){"use strict";n.r(t),n.d(t,"APErrorCode",(function(){return a})),n.d(t,"GatewayErrorCode",(function(){return i})),n.d(t,"StringUidErrorCode",(function(){return o})),n.d(t,"JOIN_GS_TRYNEXT_LIST",(function(){return r})),n.d(t,"JOIN_CS_RETRY_LIST",(function(){return s})),n.d(t,"INJECT_STREAM_STATUS",(function(){return c}));var a={1010100:"NO_FLAG_SET",1010101:"FLAG_SET_BUT_EMPTY",1010102:"INVALID_FALG_SET",2010005:"INVALID_VENDOR_KEY",2010007:"INVALID_CHANNEL_NAME",2010008:"INTERNAL_ERROR",2010009:"NO_AUTHORIZED",2010010:"DYNAMIC_KEY_TIMEOUT",2010011:"NO_ACTIVE_STATUS",2010013:"DYNAMIC_KEY_EXPIRED",2010014:"STATIC_USE_DYANMIC_KEY",2010015:"DYNAMIC_USE_STATIC_KEY",2010016:"USER_OVERLOAD",2010018:"FORBIDDEN_REGION",2010019:"CANNOT_MEET_AREA_DEMAND"},i={2e3:"ERR_NO_VOCS_AVAILABLE",2001:"ERR_NO_VOS_AVAILABLE",2002:"ERR_JOIN_CHANNEL_TIMEOUT",2003:"WARN_REPEAT_JOIN",2004:"ERR_JOIN_BY_MULTI_IP",2011:"ERR_NOT_JOINED",2012:"WARN_REPEAT_JOIN",2013:"ERR_INVALID_VENDOR_KEY",2014:"ERR_INVALID_CHANNEL_NAME",2015:"ERR_INVALID_STRINGUID",2016:"ERR_TOO_MANY_USERS",2017:"ERR_SET_CLIENT_ROLE_TIMEOUT",2018:"ERR_SET_CLIENT_ROLE_NO_PERMISSION",2019:"ERR_SET_CLIENT_ROLE_ALREADY_IN_USE",2020:"ERR_PUBLISH_REQUEST_INVALID",2021:"ERR_SUBSCRIBE_REQUEST_INVALID",2022:"ERR_NOT_SUPPORTED_MESSAGE",2023:"ERR_ILLEAGAL_PLUGIN",101:"ERR_INVALID_VENDOR_KEY",102:"ERR_INVALID_CHANNEL_NAME",103:"WARN_NO_AVAILABLE_CHANNEL",104:"WARN_LOOKUP_CHANNEL_TIMEOUT",105:"WARN_LOOKUP_CHANNEL_REJECTED",106:"WARN_OPEN_CHANNEL_TIMEOUT",107:"WARN_OPEN_CHANNEL_REJECTED",108:"WARN_REQUEST_DEFERRED",109:"ERR_DYNAMIC_KEY_TIMEOUT",110:"ERR_NO_AUTHORIZED",111:"ERR_VOM_SERVICE_UNAVAILABLE",112:"ERR_NO_CHANNEL_AVAILABLE_CODE",113:"ERR_TOO_MANY_USERS",114:"ERR_MASTER_VOCS_UNAVAILABLE",115:"ERR_INTERNAL_ERROR",116:"ERR_NO_ACTIVE_STATUS",117:"ERR_INVALID_UID",118:"ERR_DYNAMIC_KEY_EXPIRED",119:"ERR_STATIC_USE_DYANMIC_KE",120:"ERR_DYNAMIC_USE_STATIC_KE",2:"K_TIMESTAMP_EXPIRED",3:"K_CHANNEL_PERMISSION_INVALID",4:"K_CERTIFICATE_INVALID",5:"K_CHANNEL_NAME_EMPTY",6:"K_CHANNEL_NOT_FOUND",7:"K_TICKET_INVALID",8:"K_CHANNEL_CONFLICTED",9:"K_SERVICE_NOT_READY",10:"K_SERVICE_TOO_HEAVY",14:"K_UID_BANNED",15:"K_IP_BANNED",16:"K_CHANNEL_BANNED"},o={1:"ERROR_ILLEAGAL_APPID",2:"ERROR_ILLEAGAL_UID",3:"INTERNAL_SERVER_ERROR"},r=["ERR_NO_VOCS_AVAILABLE","ERR_NO_VOS_AVAILABLE","ERR_JOIN_CHANNEL_TIMEOUT","WARN_LOOKUP_CHANNEL_TIMEOUT","WARN_OPEN_CHANNEL_TIMEOUT","ERR_VOM_SERVICE_UNAVAILABLE","ERR_TOO_MANY_USERS","ERR_MASTER_VOCS_UNAVAILABLE","ERR_INTERNAL_ERROR"],s=["NO_SERVICE_AVAILABLE"],c={INJECT_STREAM_STATUS_START_SUCCESS:0,INJECT_STREAM_STATUS_START_ALREADY_EXISTS:1,INJECT_STREAM_STATUS_START_UNAUTHORIZED:2,INJECT_STREAM_STATUS_START_TIMEDOUT:3,INJECT_STREAM_STATUS_START_FAILED:4,INJECT_STREAM_STATUS_STOP_SUCCESS:5,INJECT_STREAM_STATUS_STOP_NOT_FOUND:6,INJECT_STREAM_STATUS_STOP_UNAUTHORIZED:7,INJECT_STREAM_STATUS_STOP_TIMEDOUT:8,INJECT_STREAM_STATUS_STOP_FAILED:9,INJECT_STREAM_STATUS_BROKEN:10};t.default={FAILED:"FAILED",INVALID_KEY:"INVALID_KEY",INVALID_CLIENT_MODE:"INVALID_CLIENT_MODE",INVALID_CLIENT_CODEC:"INVALID_CLIENT_CODEC",CLIENT_MODE_CODEC_MISMATCH:"CLIENT_MODE_CODEC_MISMATCH",WEB_API_NOT_SUPPORTED:"WEB_API_NOT_SUPPORTED",INVALID_PARAMETER:"INVALID_PARAMETER",NO_TRACK_IN_STREAM:"NO_TRACK_IN_STREAM",INVALID_OPERATION:"INVALID_OPERATION",INVALID_LOCAL_STREAM:"INVALID_LOCAL_STREAM",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",INVALID_DYNAMIC_KEY:"INVALID_DYNAMIC_KEY",DYNAMIC_KEY_TIMEOUT:"DYNAMIC_KEY_TIMEOUT",NO_VOCS_AVAILABLE:"NO_VOCS_AVAILABLE",NO_VOS_AVAILABLE:"ERR_NO_VOS_AVAILABLE",JOIN_CHANNEL_TIMEOUT:"ERR_JOIN_CHANNEL_TIMEOUT",NO_AVAILABLE_CHANNEL:"NO_AVAILABLE_CHANNEL",LOOKUP_CHANNEL_TIMEOUT:"LOOKUP_CHANNEL_TIMEOUT",LOOKUP_CHANNEL_REJECTED:"LOOKUP_CHANNEL_REJECTED",OPEN_CHANNEL_TIMEOUT:"OPEN_CHANNEL_TIMEOUT",OPEN_CHANNEL_REJECTED:"OPEN_CHANNEL_REJECTED",REQUEST_DEFERRED:"REQUEST_DEFERRED",STREAM_ALREADY_PUBLISHED:"STREAM_ALREADY_PUBLISHED",STREAM_NOT_YET_PUBLISHED:"STREAM_NOT_YET_PUBLISHED",JOIN_TOO_FREQUENT:"JOIN_TOO_FREQUENT",SOCKET_ERROR:"SOCKET_ERROR",SOCKET_DISCONNECTED:"SOCKET_DISCONNECTED",PEERCONNECTION_FAILED:"PEERCONNECTION_FAILED",CONNECT_GATEWAY_ERROR:"CONNECT_GATEWAY_ERROR",SERVICE_NOT_AVAILABLE:"SERVICE_NOT_AVAILABLE",JOIN_CHANNEL_FAILED:"JOIN_CHANNEL_FAILED",PUBLISH_STREAM_FAILED:"PUBLISH_STREAM_FAILED",UNPUBLISH_STREAM_FAILED:"UNPUBLISH_STREAM_FAILED",SUBSCRIBE_STREAM_FAILED:"SUBSCRIBE_STREAM_FAILED",UNSUBSCRIBE_STREAM_FAILED:"UNSUBSCRIBE_STREAM_FAILED",NO_SUCH_REMOTE_STREAM:"NO_SUCH_REMOTE_STREAM",ERR_FAILED:"1",ERR_INVALID_VENDOR_KEY:"101",ERR_INVALID_CHANNEL_NAME:"102",WARN_NO_AVAILABLE_CHANNEL:"103",WARN_LOOKUP_CHANNEL_TIMEOUT:"104",WARN_LOOKUP_CHANNEL_REJECTED:"105",WARN_OPEN_CHANNEL_TIMEOUT:"106",WARN_OPEN_CHANNEL_REJECTED:"107",WARN_REQUEST_DEFERRED:"108",ERR_DYNAMIC_KEY_TIMEOUT:"109",ERR_INVALID_DYNAMIC_KEY:"110",ERR_NO_VOCS_AVAILABLE:"2000",ERR_NO_VOS_AVAILABLE:"2001",ERR_JOIN_CHANNEL_TIMEOUT:"2002",IOS_NOT_SUPPORT:"IOS_NOT_SUPPORT",WECHAT_NOT_SUPPORT:"WECHAT_NOT_SUPPORT",SHARING_SCREEN_NOT_SUPPORT:"SHARING_SCREEN_NOT_SUPPORT",STILL_ON_PUBLISHING:"STILL_ON_PUBLISHING",LOW_STREAM_ALREADY_PUBLISHED:"LOW_STREAM_ALREADY_PUBLISHED",LOW_STREAM_NOT_YET_PUBLISHED:"LOW_STREAM_ALREADY_PUBLISHED",HIGH_STREAM_NOT_VIDEO_TRACE:"HIGH_STREAM_NOT_VIDEO_TRACE",NOT_FIND_DEVICE_BY_LABEL:"NOT_FIND_DEVICE_BY_LABEL",ENABLE_DUALSTREAM_FAILED:"ENABLE_DUALSTREAM_FAILED",DISABLE_DUALSTREAM_FAILED:"DISABLE_DUALSTREAM_FAILED",PLAYER_NOT_FOUND:"PLAYER_NOT_FOUND",ELECTRON_NOT_SUPPORT_SHARING_SCREEN:"ELECTRON_NOT_SUPPORT_SHARING_SCREEN",BAD_ENVIRONMENT:"BAD_ENVIRONMENT",LOAD_AUDIO_FAILED:"LOAD_AUDIO_FAILED"}},function(e,t,n){"use strict";n.r(t),n.d(t,"getBrowserInfo",(function(){return E})),n.d(t,"getBrowserVersion",(function(){return p})),n.d(t,"getBrowserOS",(function(){return f})),n.d(t,"isChrome",(function(){return a})),n.d(t,"isSafari",(function(){return i})),n.d(t,"isFireFox",(function(){return r})),n.d(t,"isOpera",(function(){return s})),n.d(t,"isEdge",(function(){return o})),n.d(t,"isQQBrowser",(function(){return c})),n.d(t,"isWeChatBrowser",(function(){return d})),n.d(t,"isLegacyChrome",(function(){return m})),n.d(t,"isSupportedPC",(function(){return u})),n.d(t,"isSupportedMobile",(function(){return l})),n.d(t,"getChromeKernelVersion",(function(){return S})),n.d(t,"isChromeKernel",(function(){return g}));var a=function(){var e=E();return e.name&&"Chrome"===e.name},i=function(){var e=E();return e.name&&"Safari"===e.name},o=function(){var e=E();return e.name&&"Edge"===e.name},r=function(){var e=E();return e.name&&"Firefox"===e.name},s=function(){var e=E();return e.name&&"OPR"===e.name},c=function(){var e=E();return e.name&&"QQBrowser"===e.name},d=function(){var e=E();return e.name&&"MicroMessenger"===e.name},u=function(){var e=f();return"Linux"===e||"Mac OS X"===e||"Mac OS"===e||-1!==e.indexOf("Windows")},l=function(){var e=f();return"Android"===e||"iOS"===e},p=function(){return E().version},f=function(){return E().os},g=function(){return!!navigator.userAgent.match(/chrome\/[\d]./i)};function m(){return window.navigator.appVersion&&null!==window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)&&window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1]<=35}var v,S=function(){var e=navigator.userAgent.match(/chrome\/[\d]./i);return e&&e[0]&&e[0].split("/")[1]},E=(v=function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];"Chrome"===n[1]&&null!=(e=t.match(/(OPR(?=\/))\/?(\d+)/i))&&(n=e),"Safari"===n[1]&&null!=(e=t.match(/version\/(\d+)/i))&&(n[2]=e[1]),~t.toLowerCase().indexOf("qqbrowser")&&null!=(e=t.match(/(qqbrowser(?=\/))\/?(\d+)/i))&&(n=e),~t.toLowerCase().indexOf("micromessenger")&&null!=(e=t.match(/(micromessenger(?=\/))\/?(\d+)/i))&&(n=e),~t.toLowerCase().indexOf("edge")&&null!=(e=t.match(/(edge(?=\/))\/?(\d+)/i))&&(n=e),~t.toLowerCase().indexOf("trident")&&null!=(e=/\brv[ :]+(\d+)/g.exec(t)||[])&&(n=[null,"IE",e[1]]);var a=void 0,i=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(var o in i){var r=i[o];if(r.r.test(navigator.userAgent)){a=r.s;break}}return{name:n[1],version:n[2],os:a}}(),function(){return v})},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},n.apply(this,arguments)}e.exports=n},function(e,t,n){e.exports=n(31)},function(e,t,n){"use strict";var a,i=this&&this.__extends||(a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,a){return new(n||(n=Promise))((function(i,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}c((a=a.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,a,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,a=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],a=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=s(n(36)),d=n(3),u=s(n(0)),l=n(1),p=n(11),f=n(10),g=function(e){function t(t,n){var a=e.call(this)||this;return a._state=_.RELAY_STATE_IDLE,a._onStatus=function(e){u.default.debug("["+a.clientId+"] ChannelMediaStatus: "+JSON.stringify(e)),e&&e.command&&("onAudioPacketReceived"===e.command&&a.emit("event",E.PACKET_RECEIVED_AUDIO_FROM_SRC),"onVideoPacketReceived"===e.command&&a.emit("event",E.PACKET_RECEIVED_VIDEO_FROM_SRC),"onSrcTokenPrivilegeDidExpire"===e.command&&(a._state=_.RELAY_STATE_FAILURE,a.emit("state",_.RELAY_STATE_FAILURE,h.SRC_TOKEN_EXPIRED)),"onDestTokenPrivilegeDidExpire"===e.command&&(a._state=_.RELAY_STATE_FAILURE,a.emit("state",_.RELAY_STATE_FAILURE,h.DEST_TOKEN_EXPIRED,e.channelName?{came:e.channelName}:null)))},a._onClose=function(){return o(a,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:if(u.default.debug("["+this.clientId+"] ChannelMediaSocket onClose"),this.emit("event",E.NETWORK_DISCONNECTED),this.state=_.RELAY_STATE_IDLE,!this._prevChannelMediaConfig)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.startChannelMediaRelay(this._prevChannelMediaConfig)];case 2:return t.sent(),[3,4];case 3:return(e=t.sent())instanceof b&&(e.message===v.WS_ABORT||e.message===v.AP_REQUEST_ABORT)?[2]:(this.emit("state",_.RELAY_STATE_FAILURE,h.SERVER_CONNECTION_LOST),[3,4]);case 4:return[2]}}))}))},a.token=t.appId,a.appId=t.appId,a.cname=t.cname,a.uid=t.uid,a.sid=t.sid,a.clientId=n,a}return i(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(e){var t=this._state;this._state=e,t!==e&&this.emit("state",e)},enumerable:!0,configurable:!0}),t.prototype.startChannelMediaRelay=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:if(this.state!==_.RELAY_STATE_IDLE)throw new b(v.BAD_STATE);return this.state=_.RELAY_STATE_CONNECTING,[4,this._connect()];case 1:return t.sent(),u.default.debug("["+this.clientId+"] startChannelMediaRelay: connect success"),[4,this._sendStartRelayMessage(e)];case 2:return t.sent(),this._prevChannelMediaConfig=e,[2]}}))}))},t.prototype.updateChannelMediaRelay=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:if(this.state!==_.RELAY_STATE_RUNNING)throw new b(v.BAD_STATE);return[4,this._sendUpdateMessage(e)];case 1:return t.sent(),this._prevChannelMediaConfig=e,[2]}}))}))},t.prototype.stopChannelMediaRelay=function(){return o(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,this._sendStopRelayMessage()];case 1:return e.sent(),u.default.debug("["+this.clientId+"] stopChannelMediaRelay: send stop message success"),this.state=_.RELAY_STATE_IDLE,this.dispose(),[2]}}))}))},t.prototype.dispose=function(){u.default.debug("["+this.clientId+"] disposeChannelMediaRelay"),this.state=_.RELAY_STATE_IDLE,this.emit("dispose"),this._signal&&this._signal.dispose(),this._prevChannelMediaConfig=null,this.removeEvent()},t.prototype._requestOneAP=function(e){var t=this;return new Promise((function(n,a){var i={command:"convergeAllocateEdge",sid:t.sid,appId:t.appId,token:"",ts:+new Date,version:d.VERSION,cname:t.cname,uid:t.uid+"",seq:1,requestId:1},o={service_name:"tele_channel",json_body:JSON.stringify(i)},r="https://"+e;p.post(r,o,(function(e){var t=null,i=null;try{t=JSON.parse(e)}catch(e){a(new b(v.AP_JSON_PARSE_ERROR,e))}0!==t.code&&a(new b(v.AP_REQUEST_ERROR,t));try{i=JSON.parse(t.json_body)}catch(e){a(new b(v.AP_JSON_PARSE_ERROR,e))}200!==i.code&&a(new b(v.AP_REQUEST_ERROR,i)),i.servers?n(i.servers):a(new b(v.AP_JSON_PARSE_ERROR,i))}),(function(e){return a(e)}),{"X-Packet-Service-Type":0,"X-Packet-URI":61})}))},t.prototype._requestAP=function(){var e=this,t=d.getParameter("UAP_AP");return new Promise((function(n,a){setTimeout((function(){a(new b(v.AP_REQUEST_TIMEOUT))}),5e3),e.on("dispose",(function(){a(new b(v.AP_REQUEST_ABORT))})),t.forEach((function(t){t+="/api/v1",e._requestOneAP(t).then((function(a){u.default.debug("["+e.clientId+"] startChannelMediaRelay request AP "+t+" success: "+JSON.stringify(a));var i=a[0],o="wss://"+i.address.replace(/\./g,"-")+".edge.agora.io:"+i.wss;n(o)})).catch((function(n){u.default.debug("["+e.clientId+"] startChannelMediaRelay request AP "+t+" failed: "+JSON.stringify(n))}))}))}))},t.prototype._connectWebsocket=function(e){return this._signal=new I(this.appId,this.cname,this.uid,this.sid),this._signal.connect(e)},t.prototype._connect=function(){return o(this,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return[4,this._requestAP()];case 1:return e=t.sent(),[4,this._connectWebsocket(e)];case 2:return t.sent(),this._signal.on("close",this._onClose.bind(this)),this._signal.on("status",this._onStatus.bind(this)),this.emit("event",E.NETWORK_CONNECTED),[2]}}))}))},t.prototype._sendStartRelayMessage=function(e){return o(this,void 0,void 0,(function(){var t,n,a,i,o,s;return r(this,(function(r){switch(r.label){case 0:return this._checkSignal(),t=this._genMessage(S.StopPacketTransfer),[4,this._signal.request(t)];case 1:return r.sent(),[4,this._signal.waitStatus("Normal Quit")];case 2:return r.sent(),u.default.debug("["+this.clientId+"] startChannelMediaRelay: StopPacketTransfer success"),n=this._genMessage(S.SetSdkProfile,e),[4,this._signal.request(n)];case 3:return r.sent(),u.default.debug("["+this.clientId+"] startChannelMediaRelay: SetSdkProfile success"),a=this._genMessage(S.SetSourceChannel,e),[4,this._signal.request(a)];case 4:return r.sent(),[4,this._signal.waitStatus("SetSourceChannelStatus")];case 5:return r.sent(),this.emit("event",E.PACKET_JOINED_SRC_CHANNEL),u.default.debug("["+this.clientId+"] startChannelMediaRelay: SetSourceChannel success"),i=this._genMessage(S.SetSourceUserId,e),[4,this._signal.request(i)];case 6:return r.sent(),u.default.debug("["+this.clientId+"] startChannelMediaRelay: SetSourceUserId success"),o=this._genMessage(S.SetDestChannel,e),[4,this._signal.request(o)];case 7:return r.sent(),[4,this._signal.waitStatus("SetDestChannelStatus")];case 8:return r.sent(),this.emit("event",E.PACKET_JOINED_DEST_CHANNEL),u.default.debug("["+this.clientId+"] startChannelMediaRelay: SetDestChannel success"),s=this._genMessage(S.StartPacketTransfer,e),[4,this._signal.request(s)];case 9:return r.sent(),this.emit("event",E.PACKET_SENT_TO_DEST_CHANNEL),this.state=_.RELAY_STATE_RUNNING,u.default.debug("["+this.clientId+"] startChannelMediaRelay: StartPacketTransfer success"),[2]}}))}))},t.prototype._sendReconnectMessage=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return this._checkSignal(),t=this._genMessage(S.Reconnect,e),[4,this._signal.request(t)];case 1:return n.sent(),[2]}}))}))},t.prototype._sendUpdateMessage=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){switch(n.label){case 0:return this._checkSignal(),t=this._genMessage(S.UpdateDestChannel,e),[4,this._signal.request(t)];case 1:return n.sent(),this.emit("event",E.PACKET_UPDATE_DEST_CHANNEL),u.default.debug("["+this.clientId+"] sendUpdateMessage: UpdateDestChannel success"),[2]}}))}))},t.prototype._sendStopRelayMessage=function(){return o(this,void 0,void 0,(function(){var e;return r(this,(function(t){switch(t.label){case 0:return this._checkSignal(),e=this._genMessage(S.StopPacketTransfer),[4,this._signal.request(e)];case 1:return t.sent(),u.default.debug("["+this.clientId+"] sendStopRelayMessage: StopPacketTransfer success"),[2]}}))}))},t.prototype._genMessage=function(e,t){var n=this,a=[],i=[],o=[],r={appId:this.appId,cname:this.cname,uid:this.uid+"",sdkVersion:d.VERSION,sid:this.sid,ts:+new Date,requestId:0,seq:0,allocate:!0,clientRequest:{}},s=null;switch(e){case S.SetSdkProfile:return r.clientRequest={command:"SetSdkProfile",type:"multi_channel"},r;case S.SetSourceChannel:return s=t.getSrcChannelMediaInfo(),r.clientRequest={command:"SetSourceChannel",uid:s.uid+"",channelName:s.channelName,token:s.token||this.appId},r;case S.SetSourceUserId:return s=t.getSrcChannelMediaInfo(),r.clientRequest={command:"SetSourceUserId",uid:this.uid+""},r;case S.SetDestChannel:return t.getDestChannelMediaInfos().forEach((function(e){a.push(e.channelName),i.push(e.uid+""),o.push(e.token||n.appId)})),r.clientRequest={command:"SetDestChannel",channelName:a,uid:i,token:o},r;case S.StartPacketTransfer:return r.clientRequest={command:"StartPacketTransfer"},r;case S.Reconnect:return r.clientRequest={command:"Reconnect"},r;case S.StopPacketTransfer:return r.clientRequest={command:"StopPacketTransfer"},r;case S.UpdateDestChannel:return t.getDestChannelMediaInfos().forEach((function(e){a.push(e.channelName),i.push(e.uid+""),o.push(e.token||n.appId)})),r.clientRequest={command:"UpdateDestChannel",channelName:a,uid:i,token:o},r}},t.prototype._checkSignal=function(){if(!this._signal||!this._signal.isConnect())throw new b(v.WS_DISCONNECTED)},t}(c.default);t.default=g;var m=function(){function e(){this.destChannelMediaInfos=new Map}return e.prototype.setSrcChannelInfo=function(e){l.checkValidObject(e,"srcInfo");var t=e.uid,n=e.channelName,a=e.token;if(a&&!l.isValidToken(a))throw new Error("Invalid token in SrcChannelInfo");if(!l.isValidChannelName(n))throw new Error("Invalid channelName in SrcChannelInfo");if(!f.is32Uint(t))throw new Error("Invalid uid in SrcChannelInfo");this.srcChannelMediaInfo=e},e.prototype.setDestChannelInfo=function(e,t){if(!l.isValidChannelName(e))throw new Error("Invalid channelName in DestChannelInfo");l.checkValidObject(t,"destInfo");var n=t.uid,a=t.token,i=t.channelName;if(a&&!l.isValidToken(a))throw new Error("Invalid token in DestChannelInfo");if(!l.isValidChannelName(i))throw new Error("Invalid channelName in DestChannelInfo");if(!f.is32Uint(n))throw new Error("Invalid uid in DestChannelInfo");this.destChannelMediaInfos.set(e,t)},e.prototype.removeDestChannelInfo=function(e){if(!l.isValidChannelName(e))throw new Error("Invalid channelName when invoke removeDestChannelInfo");this.destChannelMediaInfos.delete(e)},e.prototype.getSrcChannelMediaInfo=function(){return this.srcChannelMediaInfo},e.prototype.getDestChannelMediaInfos=function(){return this.destChannelMediaInfos},e}();t.ChannelMediaRelayConfiguration=m;var v,S,E,_,h,I=function(e){function t(t,n,a,i){var o=e.call(this)||this;return o._onOpen=function(){o.emit("open")},o._onClose=function(e){o.emit("close"),o.dispose()},o._onMessage=function(e){var t=JSON.parse(e.data);if(!t||"serverResponse"!==t.command||!t.requestId)return t&&"serverStatus"===t.command&&t.serverStatus&&t.serverStatus.command?(o.emit("status",t.serverStatus),void o.emit(t.serverStatus.command,t.serverStatus)):void 0;o.emit("req_"+t.requestId,t)},o._requestId=1,o.appId=t,o.cname=n,o.uid=a,o.sid=i,o}return i(t,e),t.prototype.isConnect=function(){return this._ws&&this._ws.readyState===WebSocket.OPEN},t.prototype.sendMessage=function(e){if(!this._ws||this._ws.readyState!==WebSocket.OPEN)throw new b(v.WS_DISCONNECTED);var t=this._requestId++;return e.requestId=t,e.seq=t,this._ws.send(JSON.stringify(e)),t},t.prototype.waitStatus=function(e){var t=this;return new Promise((function(n,a){var i=window.setTimeout((function(){a(new b(v.WAIT_STATUS_TIMEOUT,e))}),5e3);t.once(e,(function(t){clearTimeout(i),t.state&&0!==t.state?a(new b(v.WAIT_STATUS_ERROR,e)):n()})),t.once("dispose",(function(){clearTimeout(i),a(new b(v.WS_ABORT))}))}))},t.prototype.request=function(e){var t=this;return new Promise((function(n,a){var i=t.sendMessage(e),o=window.setTimeout((function(){t.removeAllListeners("req_"+i),a(new b(v.REQUEST_TIMEOUT))}),3e3);t.once("req_"+i,(function(e){clearTimeout(o),e&&200===e.code?n(e):a(new b(v.REQUEST_FAILED,e))})),t.once("dispose",(function(){clearTimeout(o),a(new b(v.WS_ABORT))}))}))},t.prototype.connect=function(e){var t=this;return new Promise((function(n,a){t._ws=new WebSocket(e),t._ws.onopen=function(){t._onOpen(),t._prvUrl=e,t._ws.onmessage=t._onMessage,t._ws.onclose=t._onClose,t._startHeartBeatCheck(),n()},t._ws.onclose=function(e){t._ws=null,a(new b(v.CONNECT_FAILED,"websocket error code: "+e.code))},setTimeout((function(){t._ws&&t._ws.readyState!==WebSocket.OPEN&&(t._ws.onopen=null,t._ws.onclose=null,t._ws.close(),t._ws=null,a(new b(v.CONNECT_TIMEOUT)))}),5e3),t.once("dispose",(function(){a(new b(v.WS_ABORT))}))}))},t.prototype.dispose=function(){this._clearHeartBeatCheck(),this.emit("dispose"),this.removeEvent(),this._ws&&(this._ws.onopen=null,this._ws.onclose=null,this._ws.onmessage=null,this._ws.close()),this._ws=null},t.prototype._sendPing=function(e){if(!this._ws||this._ws.readyState!==WebSocket.OPEN)throw new b(v.WS_DISCONNECTED);var t=this._requestId++;return e.requestId=t,this._ws.send(JSON.stringify(e)),t},t.prototype._startHeartBeatCheck=function(){var e=this;this._heartBeatTimer=window.setInterval((function(){e._sendPing({command:"ping",appId:e.appId,cname:e.cname,uid:e.uid+"",sid:e.sid,ts:+new Date,requestId:0})}),3e3)},t.prototype._clearHeartBeatCheck=function(){window.clearInterval(this._heartBeatTimer)},t}(c.default),b=function(e,t,n){void 0===e&&(e=""),this.code=n,this.data=t,this.message=e};t.ChannelMediaError=b,function(e){e.CONNECT_FAILED="connect failed",e.CONNECT_TIMEOUT="connect timeout",e.WS_DISCONNECTED="websocket disconnected",e.REQUEST_TIMEOUT="request timeout",e.REQUEST_FAILED="request failed",e.WAIT_STATUS_TIMEOUT="wait status timeout",e.WAIT_STATUS_ERROR="wait status error",e.BAD_STATE="bad state",e.WS_ABORT="ws abort",e.AP_REQUEST_TIMEOUT="AP request timeout",e.AP_JSON_PARSE_ERROR="AP json parse error",e.AP_REQUEST_ERROR="AP request error",e.AP_REQUEST_ABORT="AP request abort"}(v=t.CHANNEL_MEDIA_ERROR||(t.CHANNEL_MEDIA_ERROR={})),function(e){e[e.SetSdkProfile=0]="SetSdkProfile",e[e.SetSourceChannel=1]="SetSourceChannel",e[e.SetSourceUserId=2]="SetSourceUserId",e[e.SetDestChannel=3]="SetDestChannel",e[e.StartPacketTransfer=4]="StartPacketTransfer",e[e.StopPacketTransfer=5]="StopPacketTransfer",e[e.UpdateDestChannel=6]="UpdateDestChannel",e[e.Reconnect=7]="Reconnect",e[e.SetVideoProfile=8]="SetVideoProfile"}(S||(S={})),function(e){e[e.NETWORK_DISCONNECTED=0]="NETWORK_DISCONNECTED",e[e.NETWORK_CONNECTED=1]="NETWORK_CONNECTED",e[e.PACKET_JOINED_SRC_CHANNEL=2]="PACKET_JOINED_SRC_CHANNEL",e[e.PACKET_JOINED_DEST_CHANNEL=3]="PACKET_JOINED_DEST_CHANNEL",e[e.PACKET_SENT_TO_DEST_CHANNEL=4]="PACKET_SENT_TO_DEST_CHANNEL",e[e.PACKET_RECEIVED_VIDEO_FROM_SRC=5]="PACKET_RECEIVED_VIDEO_FROM_SRC",e[e.PACKET_RECEIVED_AUDIO_FROM_SRC=6]="PACKET_RECEIVED_AUDIO_FROM_SRC",e[e.PACKET_UPDATE_DEST_CHANNEL=7]="PACKET_UPDATE_DEST_CHANNEL",e[e.PACKET_UPDATE_DEST_CHANNEL_REFUSED=8]="PACKET_UPDATE_DEST_CHANNEL_REFUSED",e[e.PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE=9]="PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE"}(E=t.CHANNEL_MEDIA_RELAY_EVENT||(t.CHANNEL_MEDIA_RELAY_EVENT={})),function(e){e[e.RELAY_STATE_IDLE=0]="RELAY_STATE_IDLE",e[e.RELAY_STATE_CONNECTING=1]="RELAY_STATE_CONNECTING",e[e.RELAY_STATE_RUNNING=2]="RELAY_STATE_RUNNING",e[e.RELAY_STATE_FAILURE=3]="RELAY_STATE_FAILURE"}(_=t.CHANNEL_MEDIA_RELAY_STATE||(t.CHANNEL_MEDIA_RELAY_STATE={})),function(e){e[e.RELAY_OK=0]="RELAY_OK",e[e.SERVER_ERROR_RESPONSE=1]="SERVER_ERROR_RESPONSE",e[e.SERVER_NO_RESPONSE=2]="SERVER_NO_RESPONSE",e[e.NO_RESOURCE_AVAILABLE=3]="NO_RESOURCE_AVAILABLE",e[e.FAILED_JOIN_SRC=4]="FAILED_JOIN_SRC",e[e.FAILED_JOIN_DEST=5]="FAILED_JOIN_DEST",e[e.FAILED_PACKET_RECEIVED_FROM_SRC=6]="FAILED_PACKET_RECEIVED_FROM_SRC",e[e.FAILED_PACKET_SENT_TO_DEST=7]="FAILED_PACKET_SENT_TO_DEST",e[e.SERVER_CONNECTION_LOST=8]="SERVER_CONNECTION_LOST",e[e.INTERNAL_ERROR=9]="INTERNAL_ERROR",e[e.SRC_TOKEN_EXPIRED=10]="SRC_TOKEN_EXPIRED",e[e.DEST_TOKEN_EXPIRED=11]="DEST_TOKEN_EXPIRED",e[e.RELAY_ALREADY_START=12]="RELAY_ALREADY_START",e[e.RELAY_NOT_START=13]="RELAY_NOT_START",e[e.OPERATION_ABORT=14]="OPERATION_ABORT"}(h=t.CHANNEL_MEDIA_RELAY_ERROR||(t.CHANNEL_MEDIA_RELAY_ERROR={}))},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t,n){"use strict";n.r(t),n.d(t,"isLiveTranscodingValid",(function(){return E})),n.d(t,"generateSessionId",(function(){return m})),n.d(t,"audioLevelHelper",(function(){return p})),n.d(t,"vsResHack",(function(){return v})),n.d(t,"is32Uint",(function(){return S})),n.d(t,"safeCall",(function(){return l})),n.d(t,"random",(function(){return h})),n.d(t,"popBanTip",(function(){return T})),n.d(t,"lengthInUtf8Bytes",(function(){return I})),n.d(t,"audioTimerLoop",(function(){return b})),n.d(t,"generateId",(function(){return g}));var a=n(9),i=n.n(a),o=n(5),r=n(0),s=n(15),c=n.n(s),d=n(14),u=n(13),l=function(){var e=arguments[0];if("function"==typeof e){var t=Array.prototype.slice.call(arguments,1);e.apply(null,t)}},p=function(e){return this.audioContext=Object(d.a)(),this.sourceNode=e.otWebkitAudioSource||this.audioContext.createMediaStreamSource(e),this.analyser=this.audioContext.createAnalyser(),this.timeDomainData=new Uint8Array(this.analyser.frequencyBinCount),this.sourceNode.connect(this.analyser),this.getAudioLevel=function(){if(this.analyser){this.analyser.getByteTimeDomainData(this.timeDomainData);for(var e=0,t=0;t<this.timeDomainData.length;t++)e=Math.max(e,Math.abs(this.timeDomainData[t]-128));return e/128}return r.default.warning("can't find analyser in audioLevelHelper"),0},this},f=1e4;function g(){return++f}function m(){return c()().replace(/-/g,"").toUpperCase()}var v=function(e,t,n){try{r.default.debug("start vsResHack",e);var a=document.createElement("video");a.setAttribute("autoplay",""),a.setAttribute("muted",""),a.muted=!0,a.setAttribute("playsinline",""),a.setAttribute("style","position: absolute; top: 0; left: 0; width:1px; high:1px;"),document.body.appendChild(a),a.addEventListener("playing",(function(n){o.isFireFox()?a.videoWidth&&(r.default.debug("[vsResHack] get stream resolution: ","".concat(a.videoWidth," x ").concat(a.videoHeight),e),t(a.videoWidth,a.videoHeight),document.body.removeChild(a)):(r.default.debug("[vsResHack] get stream resolution: ","".concat(a.videoWidth," x ").concat(a.videoHeight),e),t(a.videoWidth,a.videoHeight),document.body.removeChild(a))})),Object(u.setSrcObject)(a,e)}catch(e){n(e)}},S=function(e){return"number"==typeof e&&0<=e&&e<=4294967295},E=function(e){var t=["lowLatency","userConfigExtraInfo","transcodingUsers"];for(var n in e)if("lowLatency"===n&&"boolean"!=typeof e[n]||"userConfigExtraInfo"===n&&"object"!==i()(e[n])||"transcodingUsers"===n&&!_(e[n])||!~t.indexOf(n)&&"number"!=typeof e[n])throw new Error("Param ["+n+"] is inValid");return!0},_=function(e){for(var t=0;t<e.length;t++)for(var n in e[t])if("number"!=typeof e[t][n])throw new Error("Param user["+t+"] - ["+n+"] is inValid");return!0},h=function(e){isNaN(e)&&(e=1e3);var t=+new Date,n=(t=(9301*t+49297)%233280)/233280;return Math.ceil(n*e)},I=function(e){var t=encodeURIComponent(e).match(/%[89ABab]/g);return e.length+(t?t.length:0)},b=function(e,t){var n=1/t,a=Object(d.a)(),i=a.createGain();i.gain.value=0,i.connect(a.destination);var o=!1;return function t(){var r=a.createOscillator();r.onended=t,r.connect(i),r.start(0),r.stop(a.currentTime+n),e(a.currentTime),o&&(r.onended=function(){})}(),function(){o=!0}},T=function(){if(!document.getElementById("agora-ban-tip")){var e=document.createElement("div");e.id="agora-ban-tip",e.style="position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; color: #fff;",document.querySelector("body").prepend(e);var t=document.createElement("div");t.style="background: #000; width: 346px; height: 116px; z-index: 100000; opacity: 0.6; border-radius: 10px; box-shadow: 0 2px 4px #000;",e.append(t);var n=document.createElement("div");n.style="height: 76px; display: flex; justify-content: center; align-items: center;";var a=document.createElement("span");a.style="height: 28px; width: 28px; color: #000; text-align: center; line-height: 30px; background: #fff; border-radius: 50%; font-weight: 600; font-size: 20px;margin-right: 5px;",a.innerText="!";var i=document.createElement("span");i.innerText="This browser does not support webRTC",n.append(a),n.append(i);var o=document.createElement("div");o.style="height: 38px; display: flex; border-top: #fff 1px solid; justify-content: center; align-items: center;",o.innerText="OK",t.append(n),t.append(o),o.onclick=function(){var e=document.getElementById("agora-ban-tip");e.parentNode.removeChild(e)}}}},function(e,t,n){"use strict";n.r(t),n.d(t,"post",(function(){return u})),n.d(t,"shouldUseHttps",(function(){return l})),n.d(t,"getHTTPSendBytes",(function(){return s})),n.d(t,"getHTTPRecvBytes",(function(){return c})),n.d(t,"resetHTTPByetsCount",(function(){return d}));var a=n(3),i=n(10),o=0,r=0,s=function(){return o},c=function(){return r},d=function(){o=0,r=0},u=function(e,t,n,s,c){var d=new XMLHttpRequest;if(d.timeout=t.timeout||Object(a.getParameter)("HTTP_CONNECT_TIMEOUT"),d.open("POST",e,!0),d.setRequestHeader("Content-type","application/json; charset=utf-8"),c)for(var u in c)"withCredentials"==u?d.withCredentials=!0:d.setRequestHeader(u,c[u]);d.onload=function(e){r+=Object(i.lengthInUtf8Bytes)(d.responseText),n&&n(d.responseText)},d.onerror=function(t){s&&s(t,e)},d.ontimeout=function(t){s&&s(t,e)};var l=JSON.stringify(t);o+=Object(i.lengthInUtf8Bytes)(l),d.send(l)},l=function(){return"https:"==document.location.protocol}},function(e,t){function n(e,t,n,a,i,o,r){try{var s=e[o](r),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(a,i)}e.exports=function(e){return function(){var t=this,a=arguments;return new Promise((function(i,o){var r=e.apply(t,a);function s(e){n(r,i,o,s,c,"next",e)}function c(e){n(r,i,o,s,c,"throw",e)}s(void 0)}))}}},function(e,t,n){"use strict";n.r(t),n.d(t,"RTCPeerConnection",(function(){return T})),n.d(t,"getUserMedia",(function(){return r})),n.d(t,"attachMediaStream",(function(){return s})),n.d(t,"reattachMediaStream",(function(){return c})),n.d(t,"setSrcObject",(function(){return f})),n.d(t,"getSrcObject",(function(){return g})),n.d(t,"webrtcDetectedBrowser",(function(){return d})),n.d(t,"webrtcDetectedVersion",(function(){return u})),n.d(t,"webrtcMinimumVersion",(function(){return l})),n.d(t,"webrtcTesting",(function(){return R})),n.d(t,"webrtcUtils",(function(){return S}));var a=n(9),i=n.n(a),o=n(5),r=null,s=null,c=null,d=null,u=null,l=null,p=null,f=null,g=null,m=null,v={addStream:null},S={log:function(){},extractVersion:function(e,t,n){var a=e.match(t);return a&&a.length>=n&&parseInt(a[n])}};if("object"==("undefined"==typeof window?"undefined":i()(window))?(window.HTMLMediaElement&&!("srcObject"in window.HTMLMediaElement.prototype)?(f=function(e,t){"mozSrcObject"in e?e.mozSrcObject=t:(e._srcObject=t,e.src=t?URL.createObjectURL(t):null)},g=function(e){return"mozSrcObject"in e?e.mozSrcObject:e._srcObject}):(f=function(e,t){e.srcObject=t},g=function(e){return e.srcObject}),r=window.navigator&&window.navigator.getUserMedia):(f=function(e,t){e.srcObject=t},g=function(e){return e.srcObject}),s=function(e,t){f(e,t)},c=function(e,t){f(e,g(t))},"undefined"!=typeof window&&window.navigator)if(navigator.mozGetUserMedia&&window.mozRTCPeerConnection){for(var E in S.log("This appears to be Firefox"),d="firefox",u=S.extractVersion(navigator.userAgent,/Firefox\/([0-9]+)\./,1),l=31,m=mozRTCPeerConnection,v)v[E]=m.prototype[E];if(p=function(e,t){if(u<38&&e&&e.iceServers){for(var n=[],a=0;a<e.iceServers.length;a++){var i=e.iceServers[a];if(i.hasOwnProperty("urls"))for(var o=0;o<i.urls.length;o++){var r={url:i.urls[o]};0===i.urls[o].indexOf("turn")&&(r.username=i.username,r.credential=i.credential),n.push(r)}else n.push(e.iceServers[a])}e.iceServers=n}var s=new m(e,t);for(var c in v)s[c]=v[c];return s},window.RTCSessionDescription||(window.RTCSessionDescription=mozRTCSessionDescription),window.RTCIceCandidate||(window.RTCIceCandidate=mozRTCIceCandidate),r=function(e,t,n){var a=function(e){if("object"!==i()(e)||e.require)return e;var t=[];return Object.keys(e).forEach((function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var a=e[n]="object"===i()(e[n])?e[n]:{ideal:e[n]};if(void 0===a.min&&void 0===a.max&&void 0===a.exact||t.push(n),void 0!==a.exact&&("number"==typeof a.exact?a.min=a.max=a.exact:e[n]=a.exact,delete a.exact),void 0!==a.ideal){e.advanced=e.advanced||[];var o={};"number"==typeof a.ideal?o[n]={min:a.ideal,max:a.ideal}:o[n]=a.ideal,e.advanced.push(o),delete a.ideal,Object.keys(a).length||delete e[n]}}})),t.length&&(e.require=t),e};return u<38&&(S.log("spec: "+JSON.stringify(e)),e.audio&&(e.audio=a(e.audio)),e.video&&(e.video=a(e.video)),S.log("ff37: "+JSON.stringify(e))),navigator.mozGetUserMedia(e,t,n)},navigator.getUserMedia=r,navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:b,addEventListener:function(){},removeEventListener:function(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise((function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])}))},u<41){var _=navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);navigator.mediaDevices.enumerateDevices=function(){return _().then(void 0,(function(e){if("NotFoundError"===e.name)return[];throw e}))}}}else if(navigator.webkitGetUserMedia&&window.webkitRTCPeerConnection){for(var E in S.log("This appears to be Chrome"),d="chrome",u=S.extractVersion(navigator.userAgent,/Chrom(e|ium)\/([0-9]+)\./,2),l=38,m=webkitRTCPeerConnection,v)v[E]=m.prototype[E];p=function(e,t){e&&e.iceTransportPolicy&&(e.iceTransports=e.iceTransportPolicy);var n=new m(e,t);for(var a in v)n[a]=v[a];var i=n.getStats.bind(n);return n.getStats=function(e,t,n){var a=arguments;a.length>0&&"function"==typeof e&&(t?(n=t,t=e,a=[e=null,t,n]):(t=e,a=[e=null,t]));var o=function(e){var t={};return e.result().forEach((function(e){var n={id:e.id,timestamp:e.timestamp,type:e.type};e.names().forEach((function(t){n[t]=e.stat(t)})),t[n.id]=n})),t};if(a.length>=2){var r=function(e){a[1](o(e))};return i.apply(this,[r,a[0]])}return i()},n},["createOffer","createAnswer"].forEach((function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"===i()(arguments[0])){var n=1===arguments.length?arguments[0]:void 0;return new Promise((function(a,i){t.apply(e,[a,i,n])}))}return t.apply(this,arguments)}})),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){var e=arguments,n=this;return new Promise((function(a,i){t.apply(n,[e[0],function(){a(),e.length>=2&&e[1].apply(null,[])},function(t){i(t),e.length>=3&&e[2].apply(null,[t])}])}))}}));var h=function(e){if("object"!==i()(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var a="object"===i()(e[n])?e[n]:{ideal:e[n]};void 0!==a.exact&&"number"==typeof a.exact&&(a.min=a.max=a.exact);var o=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==a.ideal){t.optional=t.optional||[];var r={};"number"==typeof a.ideal?(r[o("min",n)]=a.ideal,t.optional.push(r),(r={})[o("max",n)]=a.ideal,t.optional.push(r)):(r[o("",n)]=a.ideal,t.optional.push(r))}void 0!==a.exact&&"number"!=typeof a.exact?(t.mandatory=t.mandatory||{},t.mandatory[o("",n)]=a.exact):["min","max"].forEach((function(e){void 0!==a[e]&&(t.mandatory=t.mandatory||{},t.mandatory[o(e,n)]=a[e])}))}})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t};if(r=function(e,t,n){return e.audio&&(e.audio=h(e.audio)),e.video&&(e.video=h(e.video)),S.log("chrome: "+JSON.stringify(e)),navigator.webkitGetUserMedia(e,t,n)},navigator.getUserMedia=r,navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:b,enumerateDevices:function(){return new Promise((function(e){var t={audio:"audioinput",video:"videoinput"};return MediaStreamTrack.getSources((function(n){e(n.map((function(e){return{label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""}})))}))}))}}),navigator.mediaDevices.getUserMedia){if((Object(o.getBrowserVersion)()?Number(Object(o.getBrowserVersion)().split(".")[0]):void 0)<46){var I=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(e){return S.log("spec:   "+JSON.stringify(e)),e.audio=h(e.audio),e.video=h(e.video),S.log("chrome: "+JSON.stringify(e)),I(e)}}}else navigator.mediaDevices.getUserMedia=function(e){return b(e)};void 0===navigator.mediaDevices.addEventListener&&(navigator.mediaDevices.addEventListener=function(){S.log("Dummy mediaDevices.addEventListener called.")}),void 0===navigator.mediaDevices.removeEventListener&&(navigator.mediaDevices.removeEventListener=function(){S.log("Dummy mediaDevices.removeEventListener called.")}),s=function(e,t){u>=43?f(e,t):void 0!==e.src?e.src=t?URL.createObjectURL(t):null:S.log("Error attaching stream to element.")},c=function(e,t){u>=43?f(e,g(t)):e.src=t.src}}else navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)?(S.log("This appears to be Edge"),d="edge",u=S.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),l=12):S.log("Browser does not appear to be WebRTC-capable");else S.log("This does not appear to be a browser"),d="not a browser";function b(e){return new Promise((function(t,n){r(e,t,n)}))}var T,R={};try{Object.defineProperty(R,"version",{set:function(e){u=e}})}catch(e){}p?T=p:"undefined"!=typeof window&&(T=window.RTCPeerConnection)},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var a=window.AudioContext||window.webkitAudioContext,i=n(3),o=i.getParameter,r=i.setParameter,s=function(){return o("AUDIO_CONTEXT")||(console.log("Creating Audio Context"),r("AUDIO_CONTEXT",function(){if(a)return new a;throw new Error("AUDIO_CONTEXT_NOT_SUPPORTED")}())),o("AUDIO_CONTEXT")}},function(e,t,n){var a=n(29),i=n(30);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||a)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var s=0;s<16;++s)t[o+s]=r[s];return t||i(r)}},function(e,t,n){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i,o,r=a(n(0));!function(e){e.CHINA="CHINA",e.ASIA="ASIA",e.NORTH_AMERICA="NORTH_AMERICA",e.EUROPE="EUROPE",e.JAPAN="JAPAN",e.INDIA="INDIA",e.OCEANIA="OCEANIA",e.SOUTH_AMERICA="SOUTH_AMERICA",e.AFRICA="AFRICA",e.OVERSEA="OVERSEA",e.GLOBAL="GLOBAL"}(i||(i={})),t.AREAS=i,function(e){e.CHINA="CN",e.ASIA="AS",e.NORTH_AMERICA="NA",e.EUROPE="EU",e.JAPAN="JP",e.INDIA="IN",e.OCEANIA="OC",e.SOUTH_AMERICA="SA",e.AFRICA="AF",e.OVERSEA="OVERSEA",e.GLOBAL="GLOBAL"}(o||(o={}));var s={ASIA:{CODE:o.ASIA,WEBCS_DOMAIN:["ap-web-1-asia.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-asia.agora.io"],PROXY_CS:["proxy-ap-web-asia.agora.io"],CDS_AP:["cds-ap-web-asia.agora.io","cds-ap-web-asia2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-asia.agora.io","sua-ap-web-asia2.agora.io"],UAP_AP:["uap-ap-web-asia.agora.io","uap-ap-web-asia2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-asia.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-asia.agora.io"],LOG_UPLOAD_SERVER:["logservice-asia.agora.io"]},NORTH_AMERICA:{CODE:o.NORTH_AMERICA,WEBCS_DOMAIN:["ap-web-1-north-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-north-america.agora.io"],PROXY_CS:["proxy-ap-web-america.agora.io"],CDS_AP:["cds-ap-web-america.agora.io","cds-ap-web-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-america.agora.io","sua-ap-web-america2.agora.io"],UAP_AP:["uap-ap-web-america.agora.io","uap-ap-web-america2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-north-america.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-north-america.agora.io"],LOG_UPLOAD_SERVER:["logservice-north-america.agora.io"]},EUROPE:{CODE:o.EUROPE,WEBCS_DOMAIN:["ap-web-1-europe.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-europe.agora.io"],PROXY_CS:["proxy-ap-web-europe.agora.io"],CDS_AP:["cds-ap-web-europe.agora.io","cds-ap-web-europe2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-europe.agora.io","sua-ap-web-europe.agora.io"],UAP_AP:["uap-ap-web-europe.agora.io","uap-ap-web-europe2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-europe.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-europe.agora.io"],LOG_UPLOAD_SERVER:["logservice-europe.agora.io"]},JAPAN:{CODE:o.JAPAN,WEBCS_DOMAIN:["ap-web-1-japan.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-japan.agora.io"],PROXY_CS:["proxy-ap-web-japan.agora.io"],CDS_AP:["cds-ap-web-japan.agora.io","cds-ap-web-japan2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-japan.agora.io","sua-ap-web-japan2.agora.io"],UAP_AP:["uap-ap-web-japan.agora.io","\tuap-ap-web-japan2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-japan.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-japan.agora.io"],LOG_UPLOAD_SERVER:["logservice-japan.agora.io"]},INDIA:{CODE:o.INDIA,WEBCS_DOMAIN:["ap-web-1-india.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-india.agora.io"],PROXY_CS:["proxy-ap-web-india.agora.io"],CDS_AP:["cds-ap-web-india.agora.io","cds-ap-web-india2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-india.agora.io","sua-ap-web-india2.agora.io"],UAP_AP:["uap-ap-web-india.agora.io","uap-ap-web-india2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-india.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-india.agora.io"],LOG_UPLOAD_SERVER:["logservice-india.agora.io"]},OVERSEA:{CODE:o.OVERSEA,WEBCS_DOMAIN:["ap-web-1-oversea.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oversea.agora.io"],PROXY_CS:["proxy-ap-web-oversea.agora.io"],CDS_AP:["cds-ap-web-oversea.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oversea.agora.io"],UAP_AP:["uap-ap-web-oversea.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-oversea.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-oversea.agora.io"],LOG_UPLOAD_SERVER:["logservice-oversea.agora.io"]},GLOBAL:{CODE:o.GLOBAL,WEBCS_DOMAIN:["webrtc2-ap-web-1.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-ap-web-3.agora.io"],PROXY_CS:["ap-proxy-1.agora.io","ap-proxy-2.agora.io"],CDS_AP:["cds-ap-web-1.agora.io","cds-ap-web-3.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-1.agora.io","sua-ap-web-3.agora.io"],UAP_AP:["uap-ap-web-1.agora.io","uap-ap-web-3.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2.agora.io"],LOG_UPLOAD_SERVER:["logservice.agora.io"]},OCEANIA:{CODE:o.OCEANIA,WEBCS_DOMAIN:["ap-web-1-oceania.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oceania.agora.io"],PROXY_CS:["proxy-ap-web-oceania.agora.io"],CDS_AP:["cds-ap-web-oceania.agora.io","cds-ap-web-oceania2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oceania.agora.io","sua-ap-web-oceania2.agora.io"],UAP_AP:["uap-ap-web-oceania.agora.io","uap-ap-web-oceania2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-oceania.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-oceania.agora.io"],LOG_UPLOAD_SERVER:["logservice-oceania.agora.io"]},SOUTH_AMERICA:{CODE:o.SOUTH_AMERICA,WEBCS_DOMAIN:["ap-web-1-south-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-south-america.agora.io"],PROXY_CS:["proxy-ap-web-south-america.agora.io"],CDS_AP:["cds-ap-web-south-america.agora.io","cds-ap-web-south-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-south-america.agora.io","sua-ap-web-south-america2.agora.io"],UAP_AP:["uap-ap-web-south-america.agora.io","uap-ap-web-south-america2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-south-america.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-south-america.agora.io"],LOG_UPLOAD_SERVER:["logservice-south-america.agora.io"]},AFRICA:{CODE:o.AFRICA,WEBCS_DOMAIN:["ap-web-1-africa.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-africa.agora.io"],PROXY_CS:["proxy-ap-web-africa.agora.io"],CDS_AP:["cds-ap-web-africa.agora.io","cds-ap-web-africa2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-africa.agora.io","sua-ap-web-africa2.agora.io"],UAP_AP:["uap-ap-web-africa.agora.io","uap-ap-web-africa2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-africa.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-africa.agora.io"],LOG_UPLOAD_SERVER:["logservice-south-africa.agora.io"]}};t.AREA_DOMAIN_MAP=s,s.CHINA={CODE:o.CHINA,WEBCS_DOMAIN:["webrtc2-ap-web-2.agoraio.cn"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-ap-web-4.agoraio.cn"],PROXY_CS:["proxy-ap-web.agoraio.cn"],CDS_AP:["cds-ap-web-2.agoraio.cn","cds-ap-web-4.agoraio.cn"],ACCOUNT_REGISTER:["sua-ap-web-2.agoraio.cn","sua-ap-web-4.agoraio.cn"],UAP_AP:["uap-ap-web-2.agoraio.cn","uap-ap-web-4.agoraio.cn"],EVENT_REPORT_DOMAIN:["statscollector-3.agoraio.cn"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-4.agoraio.cn"],LOG_UPLOAD_SERVER:["logservice-china.agora.io"]};t.getAreaCodeByWebCS=function(e){for(var t=Object.keys(s),n=0;n<t.length;n++){var a=t[n],i=s[a];if(i.WEBCS_DOMAIN.includes(e)||i.WEBCS_DOMAIN_BACKUP_LIST.includes(e))return i.CODE===o.OVERSEA?o.ASIA+","+o.EUROPE+","+o.AFRICA+","+o.NORTH_AMERICA+","+o.SOUTH_AMERICA+","+o.OCEANIA:i.CODE}};t.getAreaDomainConfig=function(e){var t={WEBCS_DOMAIN:[],WEBCS_DOMAIN_BACKUP_LIST:[],PROXY_CS:[],CDS_AP:[],ACCOUNT_REGISTER:[],UAP_AP:[],EVENT_REPORT_DOMAIN:[],EVENT_REPORT_BACKUP_DOMAIN:[],LOG_UPLOAD_SERVER:[]};return e.map((function(e){var n=s[e],a=Object.keys(n);a?a.map((function(e){"CODE"!==e&&(t[e]=t[e].concat(n[e]))})):r.default.info(e+" is not exist")})),t}},function(e,t,n){var a=n(37),i=n(38),o=n(19),r=n(39);e.exports=function(e){return a(e)||i(e)||o(e)||r()}},function(e,t,n){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i,o,r=a(n(0));!function(e){e.CHINA="CHINA",e.ASIA="ASIA",e.NORTH_AMERICA="NORTH_AMERICA",e.EUROPE="EUROPE",e.JAPAN="JAPAN",e.INDIA="INDIA",e.OCEANIA="OCEANIA",e.SOUTH_AMERICA="SOUTH_AMERICA",e.AFRICA="AFRICA",e.OVERSEA="OVERSEA",e.GLOBAL="GLOBAL"}(i||(i={})),t.AREAS=i,function(e){e.CHINA="CN",e.ASIA="AS",e.NORTH_AMERICA="NA",e.EUROPE="EU",e.JAPAN="JP",e.INDIA="IN",e.OCEANIA="OC",e.SOUTH_AMERICA="SA",e.AFRICA="AF",e.OVERSEA="OVERSEA",e.GLOBAL="GLOBAL"}(o||(o={}));var s={ASIA:{CODE:o.ASIA,WEBCS_DOMAIN:["ap-web-1-asia.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-asia.agora.io"],PROXY_CS:["proxy-ap-web-asia.agora.io"],CDS_AP:["cds-ap-web-asia.agora.io","cds-ap-web-asia2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-asia.agora.io","sua-ap-web-asia2.agora.io"],UAP_AP:["uap-ap-web-asia.agora.io","uap-ap-web-asia2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-asia.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-asia.agora.io"],LOG_UPLOAD_SERVER:["logservice-asia.agora.io"]},NORTH_AMERICA:{CODE:o.NORTH_AMERICA,WEBCS_DOMAIN:["ap-web-1-north-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-north-america.agora.io"],PROXY_CS:["proxy-ap-web-america.agora.io"],CDS_AP:["cds-ap-web-america.agora.io","cds-ap-web-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-america.agora.io","sua-ap-web-america2.agora.io"],UAP_AP:["uap-ap-web-america.agora.io","uap-ap-web-america2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-north-america.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-north-america.agora.io"],LOG_UPLOAD_SERVER:["logservice-north-america.agora.io"]},EUROPE:{CODE:o.EUROPE,WEBCS_DOMAIN:["ap-web-1-europe.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-europe.agora.io"],PROXY_CS:["proxy-ap-web-europe.agora.io"],CDS_AP:["cds-ap-web-europe.agora.io","cds-ap-web-europe2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-europe.agora.io","sua-ap-web-europe.agora.io"],UAP_AP:["uap-ap-web-europe.agora.io","uap-ap-web-europe2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-europe.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-europe.agora.io"],LOG_UPLOAD_SERVER:["logservice-europe.agora.io"]},JAPAN:{CODE:o.JAPAN,WEBCS_DOMAIN:["ap-web-1-japan.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-japan.agora.io"],PROXY_CS:["proxy-ap-web-japan.agora.io"],CDS_AP:["cds-ap-web-japan.agora.io","cds-ap-web-japan2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-japan.agora.io","sua-ap-web-japan2.agora.io"],UAP_AP:["uap-ap-web-japan.agora.io","\tuap-ap-web-japan2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-japan.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-japan.agora.io"],LOG_UPLOAD_SERVER:["logservice-japan.agora.io"]},INDIA:{CODE:o.INDIA,WEBCS_DOMAIN:["ap-web-1-india.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-india.agora.io"],PROXY_CS:["proxy-ap-web-india.agora.io"],CDS_AP:["cds-ap-web-india.agora.io","cds-ap-web-india2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-india.agora.io","sua-ap-web-india2.agora.io"],UAP_AP:["uap-ap-web-india.agora.io","uap-ap-web-india2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-india.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-india.agora.io"],LOG_UPLOAD_SERVER:["logservice-india.agora.io"]},OVERSEA:{CODE:o.OVERSEA,WEBCS_DOMAIN:["ap-web-1-oversea.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oversea.agora.io"],PROXY_CS:["proxy-ap-web-oversea.agora.io"],CDS_AP:["cds-ap-web-oversea.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oversea.agora.io"],UAP_AP:["uap-ap-web-oversea.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-oversea.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-oversea.agora.io"],LOG_UPLOAD_SERVER:["logservice-oversea.agora.io"]},GLOBAL:{CODE:o.GLOBAL,WEBCS_DOMAIN:["webrtc2-ap-web-1.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-ap-web-3.agora.io"],PROXY_CS:["ap-proxy-1.agora.io","ap-proxy-2.agora.io"],CDS_AP:["cds-ap-web-1.agora.io","cds-ap-web-3.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-1.agora.io","sua-ap-web-3.agora.io"],UAP_AP:["uap-ap-web-1.agora.io","uap-ap-web-3.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2.agora.io"],LOG_UPLOAD_SERVER:["logservice.agora.io"]},OCEANIA:{CODE:o.OCEANIA,WEBCS_DOMAIN:["ap-web-1-oceania.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oceania.agora.io"],PROXY_CS:["proxy-ap-web-oceania.agora.io"],CDS_AP:["cds-ap-web-oceania.agora.io","cds-ap-web-oceania2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oceania.agora.io","sua-ap-web-oceania2.agora.io"],UAP_AP:["uap-ap-web-oceania.agora.io","uap-ap-web-oceania2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-oceania.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-oceania.agora.io"],LOG_UPLOAD_SERVER:["logservice-oceania.agora.io"]},SOUTH_AMERICA:{CODE:o.SOUTH_AMERICA,WEBCS_DOMAIN:["ap-web-1-south-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-south-america.agora.io"],PROXY_CS:["proxy-ap-web-south-america.agora.io"],CDS_AP:["cds-ap-web-south-america.agora.io","cds-ap-web-south-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-south-america.agora.io","sua-ap-web-south-america2.agora.io"],UAP_AP:["uap-ap-web-south-america.agora.io","uap-ap-web-south-america2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-south-america.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-south-america.agora.io"],LOG_UPLOAD_SERVER:["logservice-south-america.agora.io"]},AFRICA:{CODE:o.AFRICA,WEBCS_DOMAIN:["ap-web-1-africa.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-africa.agora.io"],PROXY_CS:["proxy-ap-web-africa.agora.io"],CDS_AP:["cds-ap-web-africa.agora.io","cds-ap-web-africa2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-africa.agora.io","sua-ap-web-africa2.agora.io"],UAP_AP:["uap-ap-web-africa.agora.io","uap-ap-web-africa2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-africa.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-africa.agora.io"],LOG_UPLOAD_SERVER:["logservice-south-africa.agora.io"]}};t.AREA_DOMAIN_MAP=s,s.CHINA={CODE:o.CHINA,WEBCS_DOMAIN:["webrtc2-ap-web-2.agoraio.cn"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-ap-web-4.agoraio.cn"],PROXY_CS:["proxy-ap-web.agoraio.cn"],CDS_AP:["cds-ap-web-2.agoraio.cn","cds-ap-web-4.agoraio.cn"],ACCOUNT_REGISTER:["sua-ap-web-2.agoraio.cn","sua-ap-web-4.agoraio.cn"],UAP_AP:["uap-ap-web-2.agoraio.cn","uap-ap-web-4.agoraio.cn"],EVENT_REPORT_DOMAIN:["statscollector-3.agoraio.cn"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-4.agoraio.cn"],LOG_UPLOAD_SERVER:["logservice-china.agora.io"]};t.getAreaCodeByWebCS=function(e){for(var t=Object.keys(s),n=0;n<t.length;n++){var a=t[n],i=s[a];if(i.WEBCS_DOMAIN.includes(e)||i.WEBCS_DOMAIN_BACKUP_LIST.includes(e))return i.CODE===o.OVERSEA?o.ASIA+","+o.EUROPE+","+o.AFRICA+","+o.NORTH_AMERICA+","+o.SOUTH_AMERICA+","+o.OCEANIA:i.CODE}};t.getAreaDomainConfig=function(e){var t={WEBCS_DOMAIN:[],WEBCS_DOMAIN_BACKUP_LIST:[],PROXY_CS:[],CDS_AP:[],ACCOUNT_REGISTER:[],UAP_AP:[],EVENT_REPORT_DOMAIN:[],EVENT_REPORT_BACKUP_DOMAIN:[],LOG_UPLOAD_SERVER:[]};return e.map((function(e){var n=s[e],a=Object.keys(n);a?a.map((function(e){"CODE"!==e&&(t[e]=t[e].concat(n[e]))})):r.default.info(e+" is not exist")})),t}},function(e,t,n){var a=n(20);e.exports=function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}e.exports=function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}},function(e,t,n){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i,o=a(n(0)),r=n(13);!function(e){e.NEW="new",e.PREPARING_OFFER="preparing-offer",e.OFFER_SENT="offer-sent",e.ESTABLISHED="established",e.CLOSED="closed"}(i||(i={}));var s=function(){function e(e){this.candidate=null,this.state=i.NEW,this.config=e,this.isSubscriber=this.config.isSubscriber,this.peerConnection=this.initPeecConnection(e),this.peerConnection.onicecandidate=this._onicecandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this._oniceconnectionstatechange.bind(this),this.peerConnection.onaddstream=this._onaddstream.bind(this),this.peerConnection.ontrack=this._ontrack.bind(this),this.processSignalingMessage=this.setAnswer.bind(this),this.peerConnection.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then(this.setLocalSDP.bind(this)),this.sendVideoStats={id:"",type:"",mediaType:"",googCodecName:"h264"===this.config.codec?"H264":"VP8",bytesSent:"0",packetsLost:"0",packetsSent:"0",googAdaptationChanges:"0",googAvgEncodeMs:"0",googEncodeUsagePercent:"0",googFirsReceived:"0",googFrameHeightSent:"0",googFrameHeightInput:"0",googFrameRateInput:"0",googFrameRateSent:"0",googFrameWidthSent:"0",googFrameWidthInput:"0",googNacksReceived:"0",googPlisReceived:"0",googRtt:"0",googFramesEncoded:"0"},this.sendAudioStats={id:"",type:"",mediaType:"",googCodecName:"opus",aecDivergentFilterFraction:"0",audioInputLevel:"0",bytesSent:"0",packetsSent:"0",googEchoCancellationReturnLoss:"0",googEchoCancellationReturnLossEnhancement:"0"},this.receiveAudioStats={id:"",type:"",mediaType:"",audioOutputLevel:"0",bytesReceived:"0",packetsLost:"0",packetsReceived:"0",googAccelerateRate:"0",googCurrentDelayMs:"0",googDecodingCNG:"0",googDecodingCTN:"0",googDecodingCTSG:"0",googDecodingNormal:"0",googDecodingPLC:"0",googDecodingPLCCNG:"0",googExpandRate:"0",googJitterBufferMs:"0",googJitterReceived:"0",googPreemptiveExpandRate:"0",googPreferredJitterBufferMs:"0",googSecondaryDecodedRate:"0",googSpeechExpandRate:"0"},this.receiveVideoStats={id:"",type:"",mediaType:"",googTargetDelayMs:"0",packetsLost:"0",googDecodeMs:"0",googMaxDecodeMs:"0",googRenderDelayMs:"0",googFrameWidthReceived:"0",googFrameHeightReceived:"0",googFrameRateReceived:"0",googFrameRateDecoded:"0",googFrameRateOutput:"0",googFramesDecoded:"0",googFrameReceived:"0",googJitterBufferMs:"0",googCurrentDelayMs:"0",googMinPlayoutDelayMs:"0",googNacksSent:"0",googPlisSent:"0",googFirsSent:"0",bytesReceived:"0",packetsReceived:"0"}}return e.prototype.addStream=function(e){this.peerConnection.addStream(e)},e.prototype.setAnswer=function(e){var t=JSON.parse(e);this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:t.sdp,type:"answer"})),this.onsignalingmessage&&this.onsignalingmessage("")},e.prototype.close=function(){this.peerConnection.close()},e.prototype.getStats=function(e,t){if(void 0===t&&(t=500),t=t>500?500:t,Date.now()-this.lastTimeGetStats<t){var n=[];this.config.isSubscriber?(n.push(this.receiveVideoStats),n.push(this.receiveAudioStats)):(n.push(this.sendAudioStats),n.push(this.sendVideoStats)),n.push({id:"time",startTime:this.connectedTime,timestamp:Date.now()}),e&&e(n)}else this._getStats(e)},e.prototype._getStats=function(e){var t=this,n=[];this.peerConnection.getStats(null).then((function(a){t.lastTimeGetStats=Date.now(),Object.keys(a).map((function(e){var n=a[e];t.config.isSubscriber?n.type&&"inboundrtp"===n.type&&n.mediaType&&"audio"===n.mediaType?(t.receiveAudioStats.id=n.id+"recv",t.receiveAudioStats.type=n.type+"",t.receiveAudioStats.mediaType=n.mediaType+"",t.receiveAudioStats.packetsReceived=n.packetsReceived+"",t.receiveAudioStats.bytesReceived=n.bytesReceived+"",t.receiveAudioStats.packetsLost=n.packetsLost+"",t.receiveAudioStats.googJitterReceived=n.jitter+""):n.type&&"inboundrtp"===n.type&&n.mediaType&&"video"===n.mediaType?(t.receiveVideoStats.id=n.id+"recv",t.receiveVideoStats.type=n.type+"",t.receiveVideoStats.mediaType=n.mediaType+"",t.receiveVideoStats.packetsReceived=n.packetsReceived+"",t.receiveVideoStats.bytesReceived=n.bytesReceived+"",t.receiveVideoStats.packetsLost=n.packetsLost+"",t.receiveVideoStats.googJitterBufferMs=n.jitter+"",t.receiveVideoStats.googPlisSent=n.pliCount+"",t.receiveVideoStats.googFirsSent=n.firCount+"",t.receiveVideoStats.googNacksSent=n.nackCount+""):n.remoteSource&&n.type&&"track"===n.type&&n.trackIdentifier&&-1!==n.trackIdentifier.indexOf("v")?(t.receiveVideoStats.googFrameHeightReceived=n.frameHeight+"",t.receiveVideoStats.googFrameWidthReceived=n.frameWidth+"",t.receiveVideoStats.googFrameRateDecoded=n.framesPerSecond+"",t.receiveVideoStats.googFrameRateOutput=n.framesPerSecond+"",t.receiveVideoStats.googFrameRateReceived=n.framesPerSecond+"",t.receiveVideoStats.googFramesDecoded=n.framesDecoded+"",t.receiveVideoStats.googFrameReceived=n.framesReceived+""):n.remoteSource&&n.type&&"track"===n.type&&n.trackIdentifier&&-1!==n.trackIdentifier.indexOf("a")&&(t.receiveAudioStats.audioOutputLevel=n.audioLevel+""):!n.isRemote&&n.type&&"outboundrtp"===n.type&&n.mediaType&&"audio"===n.mediaType?(t.sendAudioStats.id=n.id+"send",t.sendAudioStats.type=n.type+"",t.sendAudioStats.mediaType=n.mediaType+"",t.sendAudioStats.packetsSent=n.packetsSent+"",t.sendAudioStats.bytesSent=n.bytesSent+""):!n.isRemote&&n.type&&"outboundrtp"===n.type&&n.mediaType&&"video"===n.mediaType?(t.sendVideoStats.id=n.id+"send",t.sendVideoStats.type=n.type+"",t.sendVideoStats.mediaType=n.mediaType+"",t.sendVideoStats.packetsSent=n.packetsSent+"",t.sendVideoStats.bytesSent=n.bytesSent+"",t.sendVideoStats.googRtt=n.roundTripTime+"",t.sendVideoStats.googPlisReceived=n.pliCount+"",t.sendVideoStats.googFirsReceived=n.firCount+"",t.sendVideoStats.googNacksReceived=n.nackCount+""):!n.remoteSource&&n.type&&"track"===n.type&&n.framesSent&&0!==n.framesSent&&(t.sendVideoStats.googFrameHeightSent=n.frameHeight+"",t.sendVideoStats.googFrameHeightInput=n.frameHeight+"",t.sendVideoStats.googFrameWidthSent=n.frameWidth+"",t.sendVideoStats.googFrameWidthInput=n.frameWidth+"",t.sendVideoStats.googFramesEncoded=n.framesSent+"",t.sendVideoStats.googFrameRateSent=n.framesPerSecond+"")})),t.config.isSubscriber?(n.push(t.receiveVideoStats),n.push(t.receiveAudioStats)):(n.push(t.sendAudioStats),n.push(t.sendVideoStats)),n.push({id:"time",startTime:t.connectedTime,timestamp:Date.now()}),e&&e(n)}))},e.prototype.getStatsRate=function(e){this.getStats(e)},e.prototype.initPeecConnection=function(e){var t=e.stunServerUrl,n=e.turnServer,a=e.iceServers;return this.pcConfig={iceServers:[{urls:"stun:webcs.agora.io:3478"}]},a instanceof Array?this.pcConfig.iceServers=e.iceServers:t&&(t instanceof Array?t.map((function(e){"string"==typeof e&&""!==e&&this.pcConfig.iceServers.push({urls:e})})):"string"==typeof t&&""!==t&&this.pcConfig.iceServers.push({urls:t})),n&&(n instanceof Array?n.map((function(e){"string"==typeof e.url&&""!==e.url&&this.pcConfig.iceServers.push({username:e.username,credential:e.credential,url:e.url})})):"auto"!==n.mode&&"manual"!==n.mode||(n.udpport&&this.pcConfig.iceServers.push({username:n.username,credential:n.credential,credentialType:"password",urls:"turn:"+n.url+":"+n.udpport+"?transport=udp"}),"string"==typeof n.tcpport&&""!==n.tcpport&&this.pcConfig.iceServers.push({username:n.username,credential:n.credential,credentialType:"password",urls:"turn:"+n.url+":"+n.tcpport+"?transport=tcp"}),!0===n.forceturn&&(this.pcConfig.iceTransportPolicy="relay"))),new r.RTCPeerConnection(this.pcConfig)},e.prototype._ontrack=function(e){this.onaddstream&&this.onaddstream(e,"ontrack")},e.prototype._onaddstream=function(e){this.onaddstream&&this.onaddstream(e,"onaddstream")},e.prototype._oniceconnectionstatechange=function(e){"connected"===e.currentTarget.iceConnectionState&&(this.state=i.ESTABLISHED,this.connectedTime=Date.now()),this.oniceconnectionstatechange&&this.oniceconnectionstatechange(e.currentTarget.iceConnectionState)},e.prototype._onicecandidate=function(e){!this.candidate&&e&&(this.candidate=e.candidate,this.peerConnection.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}).then(this.editLocalSDP.bind(this)).then(this.setLocalSDP.bind(this)).then(this.sendOffer.bind(this)).catch())},e.prototype.setLocalSDP=function(e){return this.peerConnection.setLocalDescription(new RTCSessionDescription({sdp:e.sdp,type:"offer"})),this.state=i.PREPARING_OFFER,e},e.prototype.editLocalSDP=function(e){return e.sdp=this.setBandWidth(e.sdp),e.sdp=this.reviseOpus(e.sdp),e.sdp=this.addCandidate(e.sdp),e},e.prototype.setSendRecv=function(e){return e=(e=(e=e.replace(/a=recvonly\r\n/g,"a=sendrecv\r\n")).replace(/a=sendonly\r\n/g,"a=sendrecv\r\n")).replace(/a=inactive\r\n/g,"a=sendrecv\r\n")},e.prototype.setBandWidth=function(e){var t,n,a=this.config,i=a.codec,r=a.minVideoBW,s=a.maxVideoBW,c=a.maxAudioBW,d=a.clientId;if((t=e.match(/m=video.*\r\n/))&&r&&s){n=t[0]+"b=AS:"+s+"\r\n";var u=0,l=0;"h264"===i?(u=e.search(/a=rtpmap:(\d+) H264\/90000\r\n/),l=e.search(/H264\/90000\r\n/)):"vp8"===i&&(u=e.search(/a=rtpmap:(\d+) VP8\/90000\r\n/),l=e.search(/VP8\/90000\r\n/)),-1!==u&&-1!==l&&l-u>10&&(n=n+"a=fmtp:"+e.slice(u+9,l-1)+" x-google-min-bitrate="+r+"\r\n"),e=e.replace(t[0],n),o.default.debug("["+d+"]Set Video Bitrate - min:"+r+" max:"+s)}return(t=e.match(/m=audio.*\r\n/))&&c&&(n=t[0]+"b=AS:"+c+"\r\n",e=e.replace(t[0],n)),e},e.prototype.reviseOpus=function(e){return e=(e=e.replace(/a=rtpmap:102 opus\/48000\/2/g,"a=rtpmap:111 opus/48000/2")).replace(/m=audio 9 UDP\/TLS\/RTP\/SAVPF 102 0 8 97 13 118 101/g,"m=audio 9 UDP/TLS/RTP/SAVPF 111 0 8 97 13 118 101")},e.prototype.addCandidate=function(e){return e+="a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"},e.prototype.sendOffer=function(e){this.config.callback(JSON.stringify({sdp:e.sdp,messageType:"OFFER",tiebreaker:Math.floor(429496723*Math.random()+1)})),this.state=i.OFFER_SENT},e}();t.default=s},function(e,t,n){var a=n(32),i=n(33),o=n(19),r=n(34);e.exports=function(e,t){return a(e)||i(e,t)||o(e,t)||r()}},function(e,t,n){var a,i,o;i=this,o=function(){"use strict";var e,t=this;function n(e){t.console&&(t.console.error?t.console.error(e):t.console.log&&t.console.log(e))}function a(e,t,a,i){var o=i||n,r=e.createShader(a);return e.shaderSource(r,t),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(o("*** Error compiling shader '"+r+"':"+e.getShaderInfoLog(r)),e.deleteShader(r),null)}function i(e,t,a,i,o){var r=o||n,s=e.createProgram();return t.forEach((function(t){e.attachShader(s,t)})),a&&a.forEach((function(t,n){e.bindAttribLocation(s,i?i[n]:n,t)})),e.linkProgram(s),e.getProgramParameter(s,e.LINK_STATUS)?s:(r("Error in program linking:"+e.getProgramInfoLog(s)),e.deleteProgram(s),null)}(e=e||t)===e.top&&(console.log("%c%s","color:blue;font-weight:bold;","for more about webgl-utils.js see:"),console.log("%c%s","color:blue;font-weight:bold;","http://webglfundamentals.org/webgl/lessons/webgl-boilerplate.html"));var o,r=["VERTEX_SHADER","FRAGMENT_SHADER"];return!document.documentMode&&!!window.StyleMedia&&(HTMLCanvasElement.prototype.getContext=(o=HTMLCanvasElement.prototype.getContext,function(){var e=arguments,t=e[0];return"webgl"===t&&((e=[].slice.call(arguments))[0]="experimental-webgl"),o.apply(this,e)})),{createProgram:i,createProgramFromSources:function(e,t,n,o,s){for(var c=[],d=0;d<t.length;++d)c.push(a(e,t[d],e[r[d]],s));return i(e,c,n,o,s)}}},void 0===(a=function(){return o.call(i)}.apply(t,[]))||(e.exports=a)},function(e,t,n){"use strict";var a=this&&this.__awaiter||function(e,t,n,a){return new(n||(n=Promise))((function(i,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}c((a=a.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,a,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,a=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],a=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=n(35),s=n(5),c=o(n(0));t.getSupportedCodec=function(e){return a(void 0,void 0,void 0,(function(){var t,n,a,o,u;return i(this,(function(i){switch(i.label){case 0:return t={video:[],audio:[]},"undefined"!=typeof window?[3,1]:("NOT_BROWSER_ENV",c.default.error("getSupportedCodec: NOT_BROWSER_ENV"),[2,Promise.reject("NOT_BROWSER_ENV")]);case 1:try{n=r.createRTCPeerConnection({iceServers:[]})}catch(e){return c.default.error("Failed to init RTCPeerConnection",e),[2,Promise.reject(e)]}return n?[3,2]:(c.default.warning("getSupportedCodec: no RTCPeerConnection constructor is detected"),[2,Promise.resolve(t)]);case 2:return e&&e.stream?[3,7]:(a={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}},o=void 0,(s.isSafari()||s.isFireFox()||s.isWeChatBrowser())&&n.addTransceiver?(n.addTransceiver("audio"),n.addTransceiver("video"),[4,n.createOffer()]):[3,4]);case 3:return o=i.sent(),[3,6];case 4:return[4,new Promise((function(e,t){var i=setTimeout((function(){t("CREATEOFFER_TIMEOUT")}),3e3);n.createOffer((function(t){clearTimeout(i),e(t)}),(function(e){clearTimeout(i),t(e)}),a)}))];case 5:o=i.sent(),i.label=6;case 6:return n.close(),u=o.sdp,[2,d(u)];case 7:return e.stream.getTracks&&n.addTrack?e.stream.getTracks().forEach((function(t){n.addTrack(t,e.stream)})):n.addStream(e.stream),o=void 0,s.isSafari()||s.isFireFox()?[4,n.createOffer()]:[3,9];case 8:return o=i.sent(),[3,11];case 9:return[4,new Promise((function(e,t){n.createOffer(e,t)}))];case 10:o=i.sent(),i.label=11;case 11:return n.close(),u=o.sdp,[2,d(u)]}}))}))};var d=function(e){var t={video:[],audio:[]};return e.match(/ VP8/i)&&t.video.push("VP8"),e.match(/ H264/i)&&t.video.push("H264"),e.match(/ opus/i)&&t.audio.push("OPUS"),Promise.resolve(t)}},function(e,t,n){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=a(n(4)),o=a(n(0)),r=n(10);t.default=function(e,t){void 0===t&&(t={width:160,height:120,framerate:15});var n=t.width,a=t.height,s=t.framerate,c=e.stream;if(!c)throw i.default.INVALID_LOCAL_STREAM;if(!c.getVideoTracks()[0])throw i.default.HIGH_STREAM_NOT_VIDEO_TRACE;var d=c.getVideoTracks()[0];o.default.debug("Start getLowStream");var u=document.createElement("video"),l=document.createElement("canvas");u.setAttribute("style","display:none"),u.setAttribute("muted",""),u.muted=!0,u.setAttribute("autoplay",""),u.autoplay=!0,u.setAttribute("playsinline",""),l.setAttribute("style","display:none"),l.setAttribute("width",n.toString()),l.setAttribute("height",a.toString());var p=l.getContext("2d");if(!p)throw new Error("not get canvas context");u.srcObject=c,document.body.append(u),document.body.append(l),u.play(),o.default.debug("Start render lowStream");var f=r.audioTimerLoop((function(){return function(){if(u.paused&&u.play(),u.videoHeight>2&&u.videoWidth>2){var t=u.videoWidth,n=u.videoHeight/t,a=l.width*n;Math.abs(a-l.height)>=2&&(o.default.debug("adjust low stream resolution",l.width+"x"+l.height+" -> "+l.width+"x"+a),l.height=a)}p.drawImage(u,0,0,l.width,l.height);var i=e.stream;if(i){var r=i.getVideoTracks()[0];d!==r&&(o.default.debug("adjust low stream track"),u.srcObject=i,d=r)}}()}),s),g=l.captureStream(s),m=g.getVideoTracks()[0];return m.requestFrame&&m.requestFrame(),g.clean=function(){o.default.debug("Start clean lowStream"),f(),(u||u.parentNode||u.parentNode.removeChild)&&u.parentNode.removeChild(u),(l||l.parentNode||l.parentNode.removeChild)&&l.parentNode.removeChild(l),o.default.debug("Clean lowStream")},g}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var a=new Uint8Array(16);e.exports=function(){return n(a),a}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],a=0;a<256;++a)n[a]=(a+256).toString(16).substr(1);e.exports=function(e,t){var a=t||0,i=n;return[i[e[a++]],i[e[a++]],i[e[a++]],i[e[a++]],"-",i[e[a++]],i[e[a++]],"-",i[e[a++]],i[e[a++]],"-",i[e[a++]],i[e[a++]],"-",i[e[a++]],i[e[a++]],i[e[a++]],i[e[a++]],i[e[a++]],i[e[a++]]].join("")}},function(e,t,n){var a=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",r=a.toStringTag||"@@toStringTag";function s(e,t,n,a){var i=t&&t.prototype instanceof u?t:u,o=Object.create(i.prototype),r=new b(a||[]);return o._invoke=function(e,t,n){var a="suspendedStart";return function(i,o){if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===i)throw o;return R()}for(n.method=i,n.arg=o;;){var r=n.delegate;if(r){var s=_(r,n);if(s){if(s===d)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var u=c(e,t,n);if("normal"===u.type){if(a=n.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a="completed",n.method="throw",n.arg=u.arg)}}}(e,n,r),o}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var d={};function u(){}function l(){}function p(){}var f={};f[i]=function(){return this};var g=Object.getPrototypeOf,m=g&&g(g(T([])));m&&m!==t&&n.call(m,i)&&(f=m);var v=p.prototype=u.prototype=Object.create(f);function S(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function E(e,t){var a;this._invoke=function(i,o){function r(){return new t((function(a,r){!function a(i,o,r,s){var d=c(e[i],e,o);if("throw"!==d.type){var u=d.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){a("next",e,r,s)}),(function(e){a("throw",e,r,s)})):t.resolve(l).then((function(e){u.value=e,r(u)}),(function(e){return a("throw",e,r,s)}))}s(d.arg)}(i,o,a,r)}))}return a=a?a.then(r,r):r()}}function _(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,_(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var a=c(n,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,d;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function h(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 I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(h,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,o=function t(){for(;++a<e.length;)if(n.call(e,a))return t.value=e[a],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return l.prototype=v.constructor=p,p.constructor=l,p[r]=l.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,r in e||(e[r]="GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},S(E.prototype),E.prototype[o]=function(){return this},e.AsyncIterator=E,e.async=function(t,n,a,i,o){void 0===o&&(o=Promise);var r=new E(s(t,n,a,i),o);return e.isGeneratorFunction(n)?r:r.next().then((function(e){return e.done?e.value:r.next()}))},S(v),v[r]="Generator",v[i]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var a=t.pop();if(a in e)return n.value=a,n.done=!1,n}return n.done=!0,n}},e.values=T,b.prototype={constructor:b,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},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 t=this;function a(n,a){return r.type="throw",r.arg=e,t.next=n,a&&(t.method="next",t.arg=void 0),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],r=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=e,r.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(r)},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),d},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),I(n),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var i=a.arg;I(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}(e.exports);try{regeneratorRuntime=a}catch(e){Function("r","regeneratorRuntime = r")(a)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],a=!0,i=!1,o=void 0;try{for(var r,s=e[Symbol.iterator]();!(a=(r=s.next()).done)&&(n.push(r.value),!t||n.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==s.return||s.return()}finally{if(i)throw o}}return n}}},function(e,t){e.exports=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.")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a="object"==typeof window&&window.RTCPeerConnection,i="object"==typeof window&&window.webkitRTCPeerConnection,o="object"==typeof window&&window.mozRTCPeerConnection;t.createRTCPeerConnection=function(e){var t=a||i||o;return t?new t(e):null}},function(e,t,n){var a;
  /*!
   * EventEmitter v5.2.9 - git.io/ee
   * Unlicense - http://unlicense.org/
   * Oliver Caldwell - https://oli.me.uk/
   * @preserve
   */!function(t){"use strict";function i(){}var o=i.prototype,r=t.EventEmitter;function s(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function c(e){return function(){return this[e].apply(this,arguments)}}o.getListeners=function(e){var t,n,a=this._getEvents();if(e instanceof RegExp)for(n in t={},a)a.hasOwnProperty(n)&&e.test(n)&&(t[n]=a[n]);else t=a[e]||(a[e]=[]);return t},o.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},o.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&((t={})[e]=n),t||n},o.addListener=function(e,t){if(!function e(t){return"function"==typeof t||t instanceof RegExp||!(!t||"object"!=typeof t)&&e(t.listener)}(t))throw new TypeError("listener must be a function");var n,a=this.getListenersAsObject(e),i="object"==typeof t;for(n in a)a.hasOwnProperty(n)&&-1===s(a[n],t)&&a[n].push(i?t:{listener:t,once:!1});return this},o.on=c("addListener"),o.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},o.once=c("addOnceListener"),o.defineEvent=function(e){return this.getListeners(e),this},o.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},o.removeListener=function(e,t){var n,a,i=this.getListenersAsObject(e);for(a in i)i.hasOwnProperty(a)&&-1!==(n=s(i[a],t))&&i[a].splice(n,1);return this},o.off=c("removeListener"),o.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},o.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},o.manipulateListeners=function(e,t,n){var a,i,o=e?this.removeListener:this.addListener,r=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(a=n.length;a--;)o.call(this,t,n[a]);else for(a in t)t.hasOwnProperty(a)&&(i=t[a])&&("function"==typeof i?o.call(this,a,i):r.call(this,a,i));return this},o.removeEvent=function(e){var t,n=typeof e,a=this._getEvents();if("string"===n)delete a[e];else if(e instanceof RegExp)for(t in a)a.hasOwnProperty(t)&&e.test(t)&&delete a[t];else delete this._events;return this},o.removeAllListeners=c("removeEvent"),o.emitEvent=function(e,t){var n,a,i,o,r=this.getListenersAsObject(e);for(o in r)if(r.hasOwnProperty(o))for(n=r[o].slice(0),i=0;i<n.length;i++)!0===(a=n[i]).once&&this.removeListener(e,a.listener),a.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,a.listener);return this},o.trigger=c("emitEvent"),o.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},o.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},o._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},o._getEvents=function(){return this._events||(this._events={})},i.noConflict=function(){return t.EventEmitter=r,i},void 0===(a=function(){return i}.call(t,n,t,e))||(e.exports=a)}("undefined"!=typeof window?window:this||{})},function(e,t,n){var a=n(20);e.exports=function(e){if(Array.isArray(e))return a(e)}},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}},function(e,t){e.exports=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.")}},function(t,n,a){"use strict";a.r(n);var o=a(3),r=a(0),s=a(2),c=function(){var e={dispatcher:{}};return e.dispatcher.eventListeners={},e.addEventListener=function(t,n){void 0===e.dispatcher.eventListeners[t]&&(e.dispatcher.eventListeners[t]=[]),e.dispatcher.eventListeners[t].push(n)},e.hasListeners=function(t){return!(!e.dispatcher.eventListeners[t]||!e.dispatcher.eventListeners[t].length)},e.on=e.addEventListener,e.removeEventListener=function(t,n){var a;e.dispatcher.eventListeners[t]&&-1!==(a=e.dispatcher.eventListeners[t].indexOf(n))&&e.dispatcher.eventListeners[t].splice(a,1)},e.dispatchEvent=function(t){var n;for(n in e.dispatcher.eventListeners[t.type])if(e.dispatcher.eventListeners[t.type]&&e.dispatcher.eventListeners[t.type].hasOwnProperty(n)&&"function"==typeof e.dispatcher.eventListeners[t.type][n])try{e.dispatcher.eventListeners[t.type][n](t)}catch(n){r.default.debug("[".concat(e.clientId,"] Error in ").concat(t.type," event"),n)}},e.dispatchSocketEvent=function(t){var n;for(n in e.dispatcher.eventListeners[t.type])e.dispatcher.eventListeners[t.type]&&e.dispatcher.eventListeners[t.type].hasOwnProperty(n)&&"function"==typeof e.dispatcher.eventListeners[t.type][n]&&e.dispatcher.eventListeners[t.type][n](t.msg)},e},d=function(e){var t={};return t.type=e.type,t},u=function(e){var t=d(e);return t.stream=e.stream,t.reason=e.reason,t.msg=e.msg,t},l=function(e){var t=d(e);return t.uid=e.uid,t.attr=e.attr,t.stream=e.stream,t},p=function(e){var t=d(e);return t.msg=e.msg,t},f=function(e){var t=d(e);return t.url=e.url,t.uid=e.uid,t.status=e.status,t.reason=e.reason,t},g=a(5),m=function(){};m.prototype.set=function(e,t){["BatteryLevel"].indexOf(e)>-1&&(this[e]=t)};var v=new function(){var e=c();return e.states={UNINIT:"UNINIT",INITING:"INITING",INITED:"INITED"},e.state=e.states.UNINIT,e.batteryManager=null,e._init=function(t,n){e.state=e.states.INITING,navigator.getBattery?navigator.getBattery().then((function(n){e.batteryManager=n,t&&setTimeout((function(){t()}),0)})).catch((function(e){r.default.debug("navigator.getBattery is disabled",e),t&&t()})):(e.state=e.states.INITED,t&&t())},e._getBatteryStats=function(){var t={};return e.batteryManager&&e.batteryManager.level?t.BatteryLevel=Math.floor(100*e.batteryManager.level):t.BatteryLevel="UNSUPPORTED",t},e.getStats=function(t,n){var a=new m,i=e._getBatteryStats();i&&i.BatteryLevel&&a.set("BatteryLevel",i.BatteryLevel),t&&t(a)},e._init(),e},S=a(6),E=a.n(S),_=function(e){var t=c();return t.url=".",t},h=a(13),I=a(4),b=0,T=function(e){var t=_({});t.id=e.id,t.playerId=b++,t.destroyed=!1,t.fit=e.options&&e.options.fit,"contain"!==t.fit&&"cover"!==t.fit&&(t.fit=null),t.url=e.url,t.stream=e.stream.stream,t.isFreeze=!1,t.freezeCount=0,t.lastFreezeCount=0,t.lastTimeupdateTime=0,t.elementID=e.elementID,t.setAudioOutput=function(e,n,a){var i=t.video||t.audio;return i?i.setSinkId?void i.setSinkId(e).then((function(){return r.default.debug("["+t.id+"] "+"video ".concat(t.id," setAudioOutput ").concat(e," SUCCESS")),i==t.video&&t.audio?t.audio.setSinkId(e):Promise.resolve()})).then((function(){return r.default.debug("["+t.id+"] "+"audio ".concat(t.id," setAudioOutput ").concat(e," SUCCESS")),n&&n()})).catch((function(e){return r.default.error("["+t.id+"] VideoPlayer.setAudioOutput",e),a&&a(e)})):(r.default.error("["+t.id+"] ",I.default.WEB_API_NOT_SUPPORTED),a&&a(I.default.WEB_API_NOT_SUPPORTED)):(r.default.error("["+t.id+"] ",I.default.PLAYER_NOT_FOUND),a&&a(I.default.PLAYER_NOT_FOUND))},t.destroy=function(){r.default.debug("[".concat(t.id,"] destroy ").concat(e.stream.local?"local":"remote"," Player ").concat(t.id)),Object(h.setSrcObject)(t.video,null),Object(h.setSrcObject)(t.audio,null),t.video.pause(),t.freezeCheckInterval&&clearInterval(t.freezeCheckInterval),t.destroyed=!0,delete t.resizer,document.getElementById(t.div.id)&&t.parentNode.contains(t.div)&&t.parentNode.removeChild(t.div),["video","audio"].forEach((function(n){t[n];var a=i[n];clearTimeout(a.playDeferTimeout),a.formerMediaState=null;var o={playerId:t.playerId,stateId:a.stateId+1,playDeferTimeout:null,error:!1,status:"aborted",reason:"stop",updatedAt:Date.now()};i[n]=o;var c={type:"player-status-change",playerId:t.playerId,mediaType:n,status:o.status,reason:o.reason,isErrorState:!1,streamId:t.id};r.default.debug("[".concat(t.id,"] Media Player Status Change Triggered by destroy()"),c),e.stream.dispatchEvent(c),s.b.reportApiInvoke(e.stream.sid,{name:"Stream.playerStatusChange",options:c,tag:"tracer"})()}))},t.div=document.createElement("div"),t.div.setAttribute("id","player_"+t.id),e.stream.video?t.div.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"):t.div.setAttribute("style","width: 100%; height: 100%; position: relative; overflow: hidden;"),t.video=document.createElement("video"),t.video.setAttribute("id","video"+t.id),e.stream.local&&!e.stream.screen?e.stream.mirror?t.video.setAttribute("style","width: 100%; height: 100%; position: absolute; transform: rotateY(180deg); object-fit: ".concat(t.fit||"cover",";")):t.video.setAttribute("style","width: 100%; height: 100%; position: absolute; object-fit: ".concat(t.fit||"cover",";")):e.stream.video?t.video.setAttribute("style","width: 100%; height: 100%; position: absolute; object-fit: ".concat(t.fit||"cover",";")):e.stream.screen?t.video.setAttribute("style","width: 100%; height: 100%; position: absolute; object-fit: ".concat(t.fit||"contain")):t.video.setAttribute("style","width: 100%; height: 100%; position: absolute; display: none; object-fit: ".concat(t.fit||"cover"));var n={autoplay:!0,muted:!!e.stream.local||!(!g.isSafari()&&"iOS"!==g.getBrowserOS())&&"video_element_muted",playsinline:!0,controls:!1,volume:null},a=E()({},n,e.options);!0!==a.muted||a.volume||(a.volume=0),t.video.setAttribute("autoplay",""),t.video.setAttribute("muted",""),t.video.muted=!0,t.video.autoplay=!0,a.playsinline&&t.video.setAttribute("playsinline",""),a.controls&&t.video.setAttribute("controls",""),a.contains&&(t.video.controls=!0),Number.isFinite(a.volume)&&(t.video.volume=a.volume),t.audio=document.createElement("audio"),t.audio.setAttribute("id","audio"+t.id),!0===a.muted&&t.audio.setAttribute("muted",""),!0===a.muted&&(t.audio.muted=!0),a.playsinline&&t.audio.setAttribute("playsinline",""),Number.isFinite(a.volume)&&(t.audio.volume=a.volume),void 0!==t.elementID?(document.getElementById(t.elementID).appendChild(t.div),t.container=document.getElementById(t.elementID)):(document.body.appendChild(t.div),t.container=document.body),t.parentNode=t.div.parentNode;var i={video:{playerId:t.playerId,stateId:0,playDeferTimeout:null,error:!1,status:"init",reason:null,updatedAt:Date.now()},audio:{playerId:t.playerId,stateId:0,playDeferTimeout:null,error:!1,status:"init",reason:null,updatedAt:Date.now()}};t.mediaElemExists=function(e){for(var t=e,n=0;n<Object(o.getParameter)("MEDIA_ELEMENT_EXISTS_DEPTH")&&t;n++)t=t.parentNode;return!!t};var c=function(e){return t.mediaElemExists(e)?e.paused?"paused":"play":"aborted"},d=function(e,t,n){var a=c(e),i=!0;return"paused"===a?("audio"===t&&!0===n.muted&&(i=!1),n.autoplay||(i=!1)):"play"===a?"video"===t?i=!1:!0===n.muted?e.muted&&(i=!1):e.muted||(i=!1):"aborted"===a&&(i=!1),i},u=function(n){var u,l=this;if(l===t.video?u="video":l===t.audio&&(u="audio"),u){n.type||r.default.error("[".concat(t.id,"] Unexpected evt"),n);var p=c(l);clearTimeout(i[u].playDeferTimeout),i[u].playDeferTimeout=setTimeout((function(){i[u].playDeferTimeout=null;var o=i[u],f=c(l);if(p===f){var g={playerId:t.playerId,stateId:o.stateId+1,playDeferTimeout:null,error:d(l,u,a),status:c(l),reason:n.type,updatedAt:Date.now()};if(o.status!==g.status){i[u]=g;var m={type:"player-status-change",playerId:t.playerId,mediaType:u,status:g.status,reason:g.reason,isErrorState:g.error,streamId:t.id};r.default.debug("[".concat(t.id,"] Media Player Status Change"),m),e.stream.dispatchEvent(m),s.b.reportApiInvoke(e.stream.sid,{name:"Stream.playerStatusChange",options:m,tag:"tracer"})()}}else r.default.debug("[".concat(t.id,"] Status Change after event Triggered.")+"Stream ".concat(t.id," PlayerId ").concat(t.playerId," mediaType ").concat(u," Status ").concat(p,"=>").concat(f))}),Object(o.getParameter)("PLAYER_STATE_DEFER"))}else r.default.error("[".concat(t.id,"] Unknown media element"),l)};t.video.addEventListener("playing",(function(e){!function e(){t.video.videoWidth*t.video.videoHeight>4?r.default.debug("["+t.id+"] video dimensions:",t.video.videoWidth,t.video.videoHeight):setTimeout(e,50)}()}));t.freezeCheckInterval=setInterval((function(){Date.now()-t.lastTimeupdateTime>500?(t.isFreeze=!0,t.freezeCount+=1):t.isFreeze=!1}),500),t.video.addEventListener("playing",u),t.video.addEventListener("canplay",u),t.video.addEventListener("abort",u),t.video.addEventListener("onerror",u),t.video.addEventListener("suspend",u),t.video.addEventListener("stalled",u),t.video.addEventListener("pause",u),t.video.addEventListener("timeupdate",(function(){t.lastTimeupdateTime=Date.now()})),t.audio.addEventListener("playing",u),t.audio.addEventListener("canplay",u),t.audio.addEventListener("abort",u),t.audio.addEventListener("onerror",u),t.audio.addEventListener("suspend",u),t.audio.addEventListener("stalled",u),t.audio.addEventListener("pause",u);var l=t.audio,p="audio";if(e.stream.hasVideo()||e.stream.hasScreen())t.div.appendChild(t.video),t.div.appendChild(t.audio),g.isEdge()?t.video.srcObject=e.stream.stream:(Object(h.attachMediaStream)(t.video,e.stream.stream),Object(h.attachMediaStream)(t.audio,e.stream.stream));else{!1!==a.muted&&"video_element_muted"!==a.muted||(t.video.removeAttribute("muted"),t.video.muted=!1),t.video.removeAttribute("autoplay"),t.video.autoplay=!1,t.div.appendChild(t.video),l=t.video,p="video";var f=i.audio,m={playerId:t.playerId,stateId:f.stateId+1,playDeferTimeout:null,error:!1,status:"aborted",reason:"audioonly",updatedAt:Date.now()};i.audio=m;var v={type:"player-status-change",playerId:t.playerId,mediaType:"audio",status:m.status,reason:m.reason,isErrorState:m.error,streamId:t.id};if(r.default.debug("[".concat(t.id,"] Media Player Status Change"),v),Promise.resolve().then((function(){return e.stream.dispatchEvent(v)})),s.b.reportApiInvoke(e.stream.sid,{name:"Stream.playerStatusChange",options:v,tag:"tracer"})(),window.MediaStream&&(g.isSafari()||"iOS"===g.getBrowserOS())){var S=new MediaStream(e.stream.stream.getAudioTracks());Object(h.setSrcObject)(t.video,S)}else Object(h.setSrcObject)(t.video,e.stream.stream)}if(a.autoplay&&l){var T=l.play();T&&T.catch&&T.catch((function(n){if(!t.destroyed&&l){var o=i[p],u={playerId:t.playerId,stateId:o.stateId+1,playDeferTimeout:null,error:d(l,p,a),status:c(l),reason:"error",updatedAt:Date.now()};if(o.status!==u.status){r.default.debug("[".concat(t.id,"] Player ").concat(t.playerId," Status Changed Detected by promise error: ").concat(o.status,"=>").concat(u.status),n),i[p]=u;var f={type:"player-status-change",playerId:t.playerId,mediaType:p,status:u.status,reason:u.reason,isErrorState:u.error,streamId:t.id};r.default.debug("[".concat(t.id,"] Media Player Status Change"),f),e.stream.dispatchEvent(f),s.b.reportApiInvoke(e.stream.sid,{name:"Stream.playerStatusChange",options:f,tag:"tracer"})()}}}))}return t.setAudioVolume=function(e){var n=parseInt(e)/100;isFinite(n)&&(n<0?n=0:n>1&&(n=1),t.video&&(t.video.volume=n),t.audio&&(t.audio.volume=n))},t};function R(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}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 a,i,o=!0,r=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return o=e.done,e},e:function(e){r=!0,i=e},f:function(){try{o||null==a.return||a.return()}finally{if(r)throw i}}}}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}var y=function(e){var t={},n=h.RTCPeerConnection;t.uid=e.uid,t.isVideoMute=e.isVideoMute,t.isAudioMute=e.isAudioMute,t.isSubscriber=e.isSubscriber,t.clientId=e.clientId,t.filterStatsCache=[],t.originStatsCache=[],t.lastTimeGetStats=null,t.pc_config={iceServers:[{url:"stun:webcs.agora.io:3478"}]};var a={id:"outbound_audio_ssrc_send",type:"ssrc",mediaType:"",googCodecName:"opus",aecDivergentFilterFraction:"0",audioInputLevel:"0",bytesSent:"0",packetsSent:"0",googEchoCancellationReturnLoss:"0",googEchoCancellationReturnLossEnhancement:"0"},i={id:"outbound_video_ssrc_send",type:"ssrc",mediaType:"",googCodecName:"h264"===e.codec?"H264":"VP8",bytesSent:"0",packetsLost:"0",packetsSent:"0",googAdaptationChanges:"0",googAvgEncodeMs:"0",googEncodeUsagePercent:"0",googFirsReceived:"0",googFrameHeightSent:"0",googFrameHeightInput:"0",googFrameRateInput:"0",googFrameRateSent:"0",googFrameWidthSent:"0",googFrameWidthInput:"0",googNacksReceived:"0",googPlisReceived:"0",googRtt:"0"},s={id:"inbound_audio_ssrc_recv",type:"ssrc",mediaType:"",googCodecName:"opus",audioOutputLevel:"0",bytesReceived:"0",packetsLost:"0",packetsReceived:"0",googAccelerateRate:"0",googCurrentDelayMs:"0",googDecodingCNG:"0",googDecodingCTN:"0",googDecodingCTSG:"0",googDecodingNormal:"0",googDecodingPLC:"0",googDecodingPLCCNG:"0",googExpandRate:"0",googJitterBufferMs:"0",googJitterReceived:"0",googPreemptiveExpandRate:"0",googPreferredJitterBufferMs:"0",googSecondaryDecodedRate:"0",googSpeechExpandRate:"0"},c={id:"inbound_video_ssrc_recv",type:"ssrc",mediaType:"",googTargetDelayMs:"0",packetsLost:"0",googDecodeMs:"0",googMaxDecodeMs:"0",googRenderDelayMs:"0",googFrameWidthReceived:"0",googFrameHeightReceived:"0",googFrameRateReceived:"0",googFrameRateDecoded:"0",googFrameRateOutput:"0",googJitterBufferMs:"0",googCurrentDelayMs:"0",googMinPlayoutDelayMs:"0",googNacksSent:"0",googPlisSent:"0",googFirsSent:"0",bytesReceived:"0",packetsReceived:"0",googFramesReceived:"0",googFramesDecoded:"0"},d={id:"bweforvideo",type:"VideoBwe",googAvailableSendBandwidth:"0",googAvailableReceiveBandwidth:"0",googActualEncBitrate:"0",googRetransmitBitrate:"0",googTargetEncBitrate:"0",googBucketDelay:"0",googTransmitBitrate:"0"};t.con={optional:[{DtlsSrtpKeyAgreement:!0}]},e.iceServers instanceof Array?t.pc_config.iceServers=e.iceServers:(e.stunServerUrl&&(e.stunServerUrl instanceof Array?e.stunServerUrl.map((function(e){"string"==typeof e&&""!==e&&t.pc_config.iceServers.push({url:e})})):"string"==typeof e.stunServerUrl&&""!==e.stunServerUrl&&t.pc_config.iceServers.push({url:e.stunServerUrl})),e.turnServers&&(e.turnServers instanceof Array?e.turnServers.map((function(e){e.udpport&&t.pc_config.iceServers.push({username:e.username,credential:e.credential,credentialType:"password",urls:"turn:"+e.url+":"+e.udpport+"?transport=udp"}),"string"==typeof e.tcpport&&""!==e.tcpport&&t.pc_config.iceServers.push({username:e.username,credential:e.credential,credentialType:"password",urls:"turn:"+e.url+":"+e.tcpport+"?transport=tcp"}),!0===e.forceturn&&(t.pc_config.iceTransportPolicy="relay")})):r.default.error("[".concat(t.clientId,"] turnServers is not a array")))),void 0===e.audio&&(e.audio=!0),void 0===e.video&&(e.video=!0),t.mediaConstraints={mandatory:{OfferToReceiveVideo:e.video,OfferToReceiveAudio:e.audio}},t.roapSessionId=103;try{t.pc_config.sdpSemantics="plan-b",t.peerConnection=new n(t.pc_config,t.con)}catch(e){delete t.pc_config.sdpSemantics,t.peerConnection=new n(t.pc_config,t.con)}t.iceCandidateTimer=setTimeout((function(){t.iceCandidateTimer=null,r.default.debug("[".concat(t.clientId,"]Candidates collected: ").concat(t.iceCandidateCount)),t.moreIceComing&&(t.moreIceComing=!1,t.markActionNeeded())}),Object(o.getParameter)("CANDIDATE_TIMEOUT")),t.peerConnection.onicecandidate=function(e){var n,a,i,o;a=(n=t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),i=n.match(/a=candidate:.+typ\shost.+\r\n/),o=n.match(/a=candidate:.+typ\srelay.+\r\n/),null===a&&null===i&&null===o||void 0!==t.ice||!t.iceCandidateTimer||(clearTimeout(t.iceCandidateTimer),t.iceCandidateTimer=null,t.ice=0,t.moreIceComing=!1,t.markActionNeeded()),t.iceCandidateCount=t.iceCandidateCount+1};var u=function(t){return e.screen&&(t=t.replace("a=x-google-flag:conference\r\n","")),t},l=function(n){var a,i;if((a=n.match(/m=video.*\r\n/))&&e.minVideoBW&&e.maxVideoBW){i=a[0]+"b=AS:"+e.maxVideoBW+"\r\n";var o=0,s=0;"h264"===e.codec?(o=n.search(/a=rtpmap:(\d+) H264\/90000\r\n/),s=n.search(/H264\/90000\r\n/)):"vp8"===e.codec&&(o=n.search(/a=rtpmap:(\d+) VP8\/90000\r\n/),s=n.search(/VP8\/90000\r\n/)),-1!==o&&-1!==s&&s-o>10&&(i=i+"a=fmtp:"+n.slice(o+9,s-1)+" x-google-min-bitrate="+e.minVideoBW+"\r\n"),n=n.replace(a[0],i),r.default.debug("["+t.clientId+"]Set Video Bitrate - min:"+e.minVideoBW+" max:"+e.maxVideoBW)}return(a=n.match(/m=audio.*\r\n/))&&e.maxAudioBW&&(i=a[0]+"b=AS:"+e.maxAudioBW+"\r\n",n=n.replace(a[0],i)),n};t.processSignalingMessage=function(e){var n,a=JSON.parse(e);t.incomingMessage=a,"new"===t.state?"OFFER"===a.messageType?(n={sdp:a.sdp,type:"offer"},t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).catch((function(e){})),t.state="offer-received",t.markActionNeeded()):t.error("Illegal message for this state: "+a.messageType+" in state "+t.state):"offer-sent"===t.state?"ANSWER"===a.messageType?((n={sdp:a.sdp,type:"answer"}).sdp=u(n.sdp),n.sdp=l(n.sdp),n.sdp=n.sdp.replace("minptime=10","minptime=10;stereo=1; sprop-stereo=1"),t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).catch((function(e){})),t.state="established"):"pr-answer"===a.messageType?(n={sdp:a.sdp,type:"pr-answer"},t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).catch((function(e){}))):"offer"===a.messageType?t.error("Not written yet"):t.error("Illegal message for this state: "+a.messageType+" in state "+t.state):"established"===t.state&&("OFFER"===a.messageType?(n={sdp:a.sdp,type:"offer"},t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).catch((function(e){})),t.state="offer-received",t.markActionNeeded()):"ANSWER"===a.messageType?((n={sdp:a.sdp,type:"answer"}).sdp=u(n.sdp),n.sdp=l(n.sdp),t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)).catch((function(e){}))):t.error("Illegal message for this state: "+a.messageType+" in state "+t.state))};var p=0,f=0;return t.getVideoRelatedStats=function(e){t.getStats((function(n){n.forEach((function(n){if(t.isSubscriber){if("video"===n.mediaType&&n.id&&~n.id.indexOf("recv")){if(g.isChromeKernel()&&+g.getBrowserVersion()>=76){var a=+n.googFramesReceived-p,i=+n.googFramesDecoded-f;t._setStat(c,"googFrameRateReceived",a),t._setStat(c,"googFrameRateDecoded",i),t._setStat(c,"googFrameRateOutput",i),p=+n.googFramesReceived,f=+n.googFramesDecoded}e&&e({mediaType:"video",peerId:t.uid,isVideoMute:t.isVideoMute,frameRateReceived:n.googFrameRateReceived,frameRateDecoded:n.googFrameRateDecoded,bytesReceived:n.bytesReceived,packetsReceived:n.packetsReceived,packetsLost:n.packetsLost})}}else"video"===n.mediaType&&n.id&&~n.id.indexOf("send")&&e&&e({mediaType:"video",isVideoMute:t.isVideoMute,frameRateInput:n.googFrameRateInput,frameRateSent:n.googFrameRateSent,googRtt:n.googRtt})}))}))},t.getAudioRelatedStats=function(e){t.getStats((function(n){n.forEach((function(n){t.isSubscriber&&"audio"===n.mediaType&&n.id&&~n.id.indexOf("recv")&&e&&e({mediaType:"audio",peerId:t.uid,isAudioMute:t.isAudioMute,frameDropped:parseInt(n.googDecodingPLC)+parseInt(n.googDecodingPLCCNG)+"",frameReceived:n.googDecodingCTN,googJitterReceived:n.googJitterReceived,bytesReceived:n.bytesReceived,packetsReceived:n.packetsReceived,packetsLost:n.packetsLost})}))}))},t.getStatsRate=function(e){t.getStats((function(t){e(t)}))},t.getStats=function(e,n){n=(n=n||500)>500?500:n,t.lastTimeGetStats&&Date.now()-t.lastTimeGetStats<n?e&&e(t.filterStatsCache,t.originStatsCache):(t.lastTimeGetStats=Date.now(),this._getStats((function(n,a){t.filterStatsCache=n,t.originStatsCache=a,e&&e(n,a)})))},t._setStat=function(e,t,n){e.hasOwnProperty(t)&&(null!=n&&n!==1/0&&n==n||(n=0),e[t]=n+"")},t._processGetStatsAfterChrome76=function(e){var n=this;t.lastStats||(t.lastStats=new Map),t.peerConnection.getStats().then((function(o){var r,u=[],l=[],p=new Map,f=new Date,g=R(o.values());try{for(g.s();!(r=g.n()).done;){var m=r.value;"codec"!=m.type?"candidate-pair"!=m.type?("inbound-rtp"===m.type&&"video"===m.mediaType&&p.set("inbound-video",m),"inbound-rtp"===m.type&&"audio"===m.mediaType&&p.set("inbound-audio",m),"outbound-rtp"===m.type&&"audio"===m.mediaType&&p.set("outbound-audio",m),"outbound-rtp"===m.type&&"video"===m.mediaType&&p.set("outbound-video",m),"track"===m.type&&"video"===m.kind&&m.remoteSource&&p.set("remote-video-track",m),"track"===m.type&&"audio"===m.kind&&m.remoteSource&&p.set("remote-audio-track",m),"remote-inbound-rtp"===m.type&&"video"===m.mediaType&&p.set("remote-inbound-video",m),"remote-inbound-rtp"===m.type&&"audio"===m.mediaType&&p.set("remote-inbound-audio",m),"track"!==m.type||"video"!==m.kind||m.remoteSource||p.set("local-video-track",m),"track"!==m.type||"audio"!==m.kind||m.remoteSource||p.set("local-audio-track",m),"media-source"===m.type&&"video"===m.kind&&p.set("media-source-video",m),"media-source"===m.type&&"audio"===m.kind&&p.set("media-source-audio",m)):l.push(m):u.push(m)}}catch(e){g.e(e)}finally{g.f()}p.set("codec",u),p.set("candidatePairs",l),p.set("timestamp",+f);var v=null,S=null;if(c.timestamp=f,s.timestamp=f,a.timestamp=f,a.timestamp=f,d.timestamp=f,n.isSubscriber)(v=p.get("inbound-video"))&&(t._setStat(c,"id","inbound_video_ssrc_recv"),t._setStat(c,"mediaType",v.mediaType),t._setStat(c,"packetsLost",v.packetsLost),t._setStat(c,"googDecodeMs",null),t._setStat(c,"googMaxDecodeMs",null),t._setStat(c,"googRenderDelayMs",null),t._setStat(c,"googMinPlayoutDelayMs",null),t._setStat(c,"googNacksSent",v.nackCount),t._setStat(c,"googPlisSent",v.pliCount),t._setStat(c,"googFirsSent",v.firCount),t._setStat(c,"bytesReceived",v.bytesReceived),t._setStat(c,"packetsReceived",v.packetsReceived)),(v=p.get("inbound-audio"))&&(t._setStat(s,"id","inbound_audio_ssrc_recv"),t._setStat(s,"mediaType",v.mediaType),t._setStat(s,"bytesReceived",v.bytesReceived),t._setStat(s,"packetsLost",v.packetsLost),t._setStat(s,"packetsReceived",v.packetsReceived),t._setStat(s,"googAccelerateRate",v.removedSamplesForAcceleration),t._setStat(s,"googCurrentDelayMs",v.jitterBufferDelay),t._setStat(s,"googDecodingCNG",null),t._setStat(s,"googDecodingCTN",null),t._setStat(s,"googDecodingCTSG",null),t._setStat(s,"googDecodingNormal",null),t._setStat(s,"googDecodingPLC",null),t._setStat(s,"googDecodingPLCCNG",null),t._setStat(s,"googJitterReceived",v.jitter),t._setStat(s,"googPreferredJitterBufferMs",null),t._setStat(s,"googSecondaryDecodedRate",null)),(v=p.get("remote-video-track"))&&(t._setStat(c,"googTargetDelayMs",v.jitterBufferDelay),t._setStat(c,"googFrameWidthReceived",v.frameWidth),t._setStat(c,"googFrameHeightReceived",v.frameHeight),t._setStat(c,"googJitterBufferMs",v.jitterBufferDelay/v.jitterBufferEmittedCount*1e3),t._setStat(c,"googCurrentDelayMs",v.jitterBufferDelay),t._setStat(c,"googFramesDecoded",v.framesDecoded),t._setStat(c,"googFramesReceived",v.framesReceived)),(v=p.get("remote-audio-track"))&&(t._setStat(s,"audioOutputLevel",32767*v.audioLevel),t._setStat(s,"googJitterBufferMs",v.jitterBufferDelay/v.jitterBufferEmittedCount*1e3),t._setStat(s,"googExpandRate",v.concealedSamples),t._setStat(s,"googPreemptiveExpandRate",v.insertedSamplesForDeceleration),t._setStat(s,"googSpeechExpandRate",v.silentConcealedSamples));else{var _=t.lastStats.get("timestamp"),h=t.lastStats.get("outbound-video");if((v=p.get("outbound-audio"))&&(t._setStat(a,"id","outbound_audio_ssrc_send"),t._setStat(a,"mediaType",v.mediaType),t._setStat(a,"aecDivergentFilterFraction",null),t._setStat(a,"bytesSent",v.bytesSent),t._setStat(a,"packetsSent",v.packetsSent),S=v.transportId),v=p.get("outbound-video")){if(t._setStat(i,"id","outbound_video_ssrc_send"),t._setStat(i,"mediaType",v.mediaType),t._setStat(i,"bytesSent",v.bytesSent),t._setStat(i,"packetsSent",v.packetsSent),t._setStat(i,"googAdaptationChanges",v.qualityLimitationDurations),t._setStat(i,"googAvgEncodeMs",null),t._setStat(i,"googEncodeUsagePercent",null),S=v.transportId,v.totalEncodedBytesTarget&&h&&h.totalEncodedBytesTarget){var I=(v.totalEncodedBytesTarget-h.totalEncodedBytesTarget)/(+new Date-_);t._setStat(d,"googTargetEncBitrate",Math.floor(8*I*1e3))}if(v.retransmittedBytesSent&&h&&h.retransmittedBytesSent){var b=(v.retransmittedBytesSent-h.retransmittedBytesSent)/(+new Date-_);t._setStat(d,"googRetransmitBitrate",Math.floor(8*b*1e3))}if(v.bytesSent&&h&&h.bytesSent){var T=(v.bytesSent-h.bytesSent)/(+new Date-_);t._setStat(d,"googTransmitBitrate",Math.floor(8*T*1e3)),t._setStat(d,"googActualEncBitrate",Math.floor(8*T*1e3))}if(v.totalPacketSendDelay&&h&&h.totalPacketSendDelay){var A=(v.totalPacketSendDelay-h.totalPacketSendDelay)/(+new Date-_);t._setStat(d,"googBucketDelay",Math.floor(1e3*A))}}if((v=p.get("remote-inbound-video"))&&(t._setStat(i,"packetsLost",v.packetsLost),t._setStat(i,"googRtt",v.roundTripTime)),(v=p.get("local-video-track"))&&(t._setStat(i,"googFrameHeightSent",v.frameHeight),t._setStat(i,"googFrameWidthSent",v.frameWidth),void 0!==v.framesPerSecond&&t._setStat(i,"googFrameRateSent",v.framesPerSecond)),(v=p.get("local-audio-track"))&&(t._setStat(a,"googEchoCancellationReturnLoss",v.echoReturnLoss),t._setStat(a,"googEchoCancellationReturnLossEnhancement",v.echoReturnLossEnhancement)),(v=p.get("media-source-video"))&&(t._setStat(i,"googFrameHeightInput",v.height),t._setStat(i,"googFrameWidthInput",v.width),t._setStat(i,"googFrameRateInput",v.framesPerSecond)),(v=p.get("media-source-audio"))&&t._setStat(a,"audioInputLevel",32767*v.totalAudioEnergy),(v=p.get("inbound-video"))&&(t._setStat(i,"googFirsReceived",v.firCount),t._setStat(i,"googNacksReceived",v.nackCount),t._setStat(i,"googPlisReceived",v.pliCount)),S)p.get("candidatePairs").map((function(e){S==e.transportId&&t._setStat(d,"googAvailableSendBandwidth",e.availableOutgoingBitrate)}));else{var y=p.get("candidatePairs")[0];y&&t._setStat(d,"googAvailableSendBandwidth",y.availableOutgoingBitrate)}}t.lastStats=p;var O=[E()({},i),E()({},a),E()({},c),E()({},s),E()({},d)];O.push({id:"time",startTime:t.connectedTime,timestamp:new Date}),e(O)}))},t._processGetStatsBeforeChrome76=function(e){t.peerConnection.getStats((function(n){var o=[],r=[],u=null;Object.keys(n).forEach((function(e){var t=n[e];t&&(r.push(t),u=t.timestamp,"VideoBwe"===t.type?d=t:t.id.indexOf("_send")>-1&&"video"===t.mediaType?i=t:t.id.indexOf("_send")>-1&&"audio"===t.mediaType?a=t:t.id.indexOf("_recv")>-1&&"video"===t.mediaType?c=t:t.id.indexOf("_recv")>-1&&"audio"===t.mediaType&&(s=t))})),(o=[E()({},i),E()({},a),E()({},c),E()({},s),E()({},d)]).push({id:"time",startTime:t.connectedTime,timestamp:u||new Date}),e(o,r)}))},t._getStats=function(e){Object(o.getParameter)("CHROME_NEW_STATS")&&g.isChromeKernel()&&+g.getBrowserVersion()>=76?t._processGetStatsAfterChrome76(e):t._processGetStatsBeforeChrome76(e)},t.addTrack=function(e,n){t.peerConnection.addTrack(e,n)},t.removeTrack=function(e,n){t.peerConnection.removeTrack(t.peerConnection.getSenders().find((function(t){return t.track==e})))},t.addStream=function(e){t.peerConnection.addStream(e),t.markActionNeeded()},t.removeStream=function(){t.markActionNeeded()},t.close=function(){t.state="closed",t.peerConnection.close()},t.markActionNeeded=function(){t.actionNeeded=!0,t.doLater((function(){t.onstablestate()}))},t.doLater=function(e){window.setTimeout(e,1)},t.onstablestate=function(){var e;if(t.actionNeeded){if("new"===t.state||"established"===t.state)t.peerConnection.createOffer((function(e){if(e.sdp!==t.prevOffer)return e.sdp=e.sdp.replace("minptime=10","minptime=10;stereo=1; sprop-stereo=1"),t.peerConnection.setLocalDescription(e),t.state="preparing-offer",void t.markActionNeeded();r.default.debug("["+t.clientId+"]Not sending a new offer")}),(function(e){r.default.debug("["+t.clientId+"]peer connection create offer failed ",e)}),t.mediaConstraints);else if("preparing-offer"===t.state){if(t.moreIceComing)return;t.prevOffer=t.peerConnection.localDescription.sdp,t.offerCandidates=t.prevOffer.match(/a=candidate.+\r\n/g)||[],t.offerCandidates.length||(r.default.warning("[".concat(t.clientId,"]No Ice Candidate generated")),Object(o.getParameter)("SHIM_CANDIDATE")?(r.default.debug("Shimming fake candidate"),t.prevOffer+="a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"):r.default.error("[".concat(t.clientId,"]None Ice Candidate not allowed"))),t.prevOffer=t.prevOffer.replace(/a=candidate:.+typ\shost.+\r\n/g,"a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"),t.sendMessage("OFFER",t.prevOffer),t.state="offer-sent"}else if("offer-received"===t.state)t.peerConnection.createAnswer((function(e){if(t.peerConnection.setLocalDescription(e),t.state="offer-received-preparing-answer",t.iceStarted)t.markActionNeeded();else{var n=new Date;r.default.debug("["+t.clientId+"]"+n.getTime()+": Starting ICE in responder"),t.iceStarted=!0}}),(function(e){r.default.debug("["+t.clientId+"]peer connection create answer failed ",e)}),t.mediaConstraints);else if("offer-received-preparing-answer"===t.state){if(t.moreIceComing)return;e=t.peerConnection.localDescription.sdp,t.sendMessage("ANSWER",e),t.state="established"}else r.default.debug("[".concat(t.clientId,"] Dazed and confused in state ' + that.state + ', stopping here'"));t.actionNeeded=!1}},t.sendMessage=function(e,n){var a={};a.messageType=e,a.sdp=n,"OFFER"===e?(a.offererSessionId=t.sessionId,a.answererSessionId=t.otherSessionId,a.seq=t.sequenceNumber+=1,a.tiebreaker=Math.floor(429496723*Math.random()+1)):(a.offererSessionId=t.incomingMessage.offererSessionId,a.answererSessionId=t.sessionId,a.seq=t.incomingMessage.seq),t.onsignalingmessage(JSON.stringify(a))},t._getSender=function(e){if(t.peerConnection&&t.peerConnection.getSenders){var n=t.peerConnection.getSenders().find((function(t){return t.track.kind==e}));if(n)return n}return null},t.hasSender=function(e){return!!t._getSender(e)},t.replaceTrack=function(e,n,a){var i=t._getSender(e.kind);if(!i){return a("NO_SENDER_FOUND")}try{i.replaceTrack(e)}catch(e){return a&&a(e)}setTimeout((function(){return n&&n()}),50)},t.error=function(e){throw"Error in RoapOnJsep: "+e},t.sessionId=t.roapSessionId+=1,t.sequenceNumber=0,t.actionNeeded=!1,t.iceStarted=!1,t.moreIceComing=!0,t.iceCandidateCount=0,t.onsignalingmessage=e.callback,t.peerConnection.ontrack=function(e){t.onaddstream&&(t.onaddstream(e,"ontrack"),t.peerConnection.onaddstream=null)},t.peerConnection.onaddstream=function(e){t.onaddstream&&(t.onaddstream(e,"onaddstream"),t.peerConnection.ontrack=null)},t.peerConnection.onremovestream=function(e){t.onremovestream&&t.onremovestream(e)},t.peerConnection.oniceconnectionstatechange=function(e){"connected"===e.currentTarget.iceConnectionState&&(t.connectedTime=new Date),t.oniceconnectionstatechange&&t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)},t.renegotiate=function(){void 0!==t.prevOffer&&t.peerConnection.createOffer().then((function(e){return e.sdp=e.sdp.replace(/a=recvonly\r\n/g,"a=inactive\r\n"),e.sdp=u(e.sdp),e.sdp=l(e.sdp),t.peerConnection.setLocalDescription(e)})).then((function(){t.onnegotiationneeded&&t.onnegotiationneeded(t.peerConnection.localDescription.sdp)})).catch((function(e){console.log("createOffer error: ",e)}))},t.peerConnection.onnegotiationneeded=t.renegotiate,t.onaddstream=null,t.onremovestream=null,t.onnegotiationneeded=null,t.state="new",t.markActionNeeded(),t},O=function(e){var t={},n=h.RTCPeerConnection;t.uid=e.uid,t.isVideoMute=e.isVideoMute,t.isAudioMute=e.isAudioMute,t.isSubscriber=e.isSubscriber,t.clientId=e.clientId,t.filterStatsCache=[],t.originStatsCache=[],t.lastTimeGetStats=null,t.pc_config={iceServers:[{urls:["stun:webcs.agora.io:3478","stun:stun.l.google.com:19302"]}],bundlePolicy:"max-bundle"},t.con={optional:[{DtlsSrtpKeyAgreement:!0}]},e.iceServers instanceof Array?t.pc_config.iceServers=e.iceServers:(e.stunServerUrl&&(e.stunServerUrl instanceof Array?e.stunServerUrl.map((function(e){"string"==typeof e&&""!==e&&t.pc_config.iceServers.push({url:e})})):"string"==typeof e.stunServerUrl&&""!==e.stunServerUrl&&t.pc_config.iceServers.push({url:e.stunServerUrl})),e.turnServers&&(e.turnServers instanceof Array?e.turnServers.map((function(e){e.udpport&&t.pc_config.iceServers.push({username:e.username,credential:e.credential,credentialType:"password",urls:"turn:"+e.url+":"+e.udpport+"?transport=udp"}),"string"==typeof e.tcpport&&""!==e.tcpport&&t.pc_config.iceServers.push({username:e.username,credential:e.credential,credentialType:"password",urls:"turn:"+e.url+":"+e.tcpport+"?transport=tcp"}),!0===e.forceturn&&(t.pc_config.iceTransportPolicy="relay")})):r.default.error("[".concat(t.clientId,"] turnServers is not a array")))),void 0===e.audio&&(e.audio=!0),void 0===e.video&&(e.video=!0),t.mediaConstraints={mandatory:{OfferToReceiveVideo:e.video,OfferToReceiveAudio:e.audio}},t.roapSessionId=103;try{t.pc_config.sdpSemantics="plan-b",t.peerConnection=new n(t.pc_config,t.con)}catch(e){delete t.pc_config.sdpSemantics,t.peerConnection=new n(t.pc_config,t.con)}t.iceCandidateTimer=setTimeout((function(){t.iceCandidateTimer=null,t.moreIceComing&&(t.moreIceComing=!1,t.markActionNeeded())}),Object(o.getParameter)("CANDIDATE_TIMEOUT")),t.peerConnection.onicecandidate=function(e){var n,a,i,o;a=(n=t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),i=n.match(/a=candidate:.+typ\shost.+\r\n/),o=n.match(/a=candidate:.+typ\srelay.+\r\n/),0===t.iceCandidateCount&&(t.timeout=setTimeout((function(){t.moreIceComing&&(t.moreIceComing=!1,t.markActionNeeded())}),1e3)),null===a&&null===i&&null===o||void 0!==t.ice||!t.iceCandidateTimer||(clearTimeout(t.iceCandidateTimer),t.iceCandidateTimer=null,t.ice=0,t.moreIceComing=!1,t.markActionNeeded()),t.iceCandidateCount=t.iceCandidateCount+1};var a=function(t){return e.screen&&(t=t.replace("a=x-google-flag:conference\r\n","")),t},i=function(n){var a,i;return(a=n.match(/m=video.*\r\n/))&&e.minVideoBW&&e.maxVideoBW&&(i=a[0]+"b=AS:"+e.maxVideoBW+"\r\n",n=n.replace(a[0],i),r.default.debug("["+t.clientId+"]Set Video Bitrate - min:"+e.minVideoBW+" max:"+e.maxVideoBW)),(a=n.match(/m=audio.*\r\n/))&&e.maxAudioBW&&(i=a[0]+"b=AS:"+e.maxAudioBW+"\r\n",n=n.replace(a[0],i)),n};t.processSignalingMessage=function(e){var n,o=JSON.parse(e);t.incomingMessage=o,"new"===t.state?"OFFER"===o.messageType?(n={sdp:o.sdp,type:"offer"},t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)),t.state="offer-received",t.markActionNeeded()):t.error("Illegal message for this state: "+o.messageType+" in state "+t.state):"offer-sent"===t.state?"ANSWER"===o.messageType?((n={sdp:o.sdp,type:"answer"}).sdp=a(n.sdp),n.sdp=i(n.sdp),n.sdp=n.sdp.replace(/a=x-google-flag:conference\r\n/g,""),t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)),t.state="established"):"pr-answer"===o.messageType?(n={sdp:o.sdp,type:"pr-answer"},t.peerConnection.setRemoteDescription(new RTCSessionDescription(n))):"offer"===o.messageType?t.error("Not written yet"):t.error("Illegal message for this state: "+o.messageType+" in state "+t.state):"established"===t.state&&("OFFER"===o.messageType?(n={sdp:o.sdp,type:"offer"},t.peerConnection.setRemoteDescription(new RTCSessionDescription(n)),t.state="offer-received",t.markActionNeeded()):"ANSWER"===o.messageType?((n={sdp:o.sdp,type:"answer"}).sdp=a(n.sdp),n.sdp=i(n.sdp),t.peerConnection.setRemoteDescription(new RTCSessionDescription(n))):t.error("Illegal message for this state: "+o.messageType+" in state "+t.state))};var s={id:"",type:"",mediaType:"",googCodecName:"opus",aecDivergentFilterFraction:"0",audioInputLevel:"0",bytesSent:"0",packetsSent:"0",googEchoCancellationReturnLoss:"0",googEchoCancellationReturnLossEnhancement:"0"},c={id:"",type:"",mediaType:"",googCodecName:"h264"===e.codec?"H264":"VP8",bytesSent:"0",packetsLost:"0",packetsSent:"0",googAdaptationChanges:"0",googAvgEncodeMs:"0",googEncodeUsagePercent:"0",googFirsReceived:"0",googFrameHeightSent:"0",googFrameHeightInput:"0",googFrameRateInput:"0",googFrameRateSent:"0",googFrameWidthSent:"0",googFrameWidthInput:"0",googNacksReceived:"0",googPlisReceived:"0",googRtt:"0",googFramesEncoded:"0"},d={id:"",type:"",mediaType:"",audioOutputLevel:"0",bytesReceived:"0",packetsLost:"0",packetsReceived:"0",googAccelerateRate:"0",googCurrentDelayMs:"0",googDecodingCNG:"0",googDecodingCTN:"0",googDecodingCTSG:"0",googDecodingNormal:"0",googDecodingPLC:"0",googDecodingPLCCNG:"0",googExpandRate:"0",googJitterBufferMs:"0",googJitterReceived:"0",googPreemptiveExpandRate:"0",googPreferredJitterBufferMs:"0",googSecondaryDecodedRate:"0",googSpeechExpandRate:"0"},u={id:"",type:"",mediaType:"",googTargetDelayMs:"0",packetsLost:"0",googDecodeMs:"0",googMaxDecodeMs:"0",googRenderDelayMs:"0",googFrameWidthReceived:"0",googFrameHeightReceived:"0",googFrameRateReceived:"0",googFrameRateDecoded:"0",googFrameRateOutput:"0",googFramesDecoded:"0",googFrameReceived:"0",googJitterBufferMs:"0",googCurrentDelayMs:"0",googMinPlayoutDelayMs:"0",googNacksSent:"0",googPlisSent:"0",googFirsSent:"0",bytesReceived:"0",packetsReceived:"0"},l={id:"bweforvideo",type:"VideoBwe",googAvailableSendBandwidth:"0",googAvailableReceiveBandwidth:"0",googActualEncBitrate:"0",googRetransmitBitrate:"0",googTargetEncBitrate:"0",googBucketDelay:"0",googTransmitBitrate:"0"},p=0,f=0,g=0;return t.isRemoteVideoStats=function(e){return!!(e.frameHeight&&e.frameWidth&&e.remoteSource)},t.getVideoRelatedStats=function(n){t.peerConnection.getStats().then((function(a){var i={peerId:t.uid,mediaType:"video",isVideoMute:t.isVideoMute};a.forEach((function(a){if(t.isSubscriber){if("track"===a.type&&(~a.id.indexOf("video")||~a.trackIdentifier.indexOf("v")||t.isRemoteVideoStats(a))){if(!t.lastReport)return void(t.lastReport=a);i.frameRateReceived=a.framesReceived-t.lastReport.framesReceived+"",i.frameRateDecoded=a.framesDecoded-t.lastReport.framesDecoded+"",t.lastReport=a}"inbound-rtp"===a.type&&~a.id.indexOf("Video")&&(i.bytesReceived=a.bytesReceived+"",i.packetsReceived=a.packetsReceived+"",i.packetsLost=a.packetsLost+"")}else if("outbound-rtp"===a.type&&~a.id.indexOf("Video")){if(!t.lastReport)return void(t.lastReport=a);n&&n({mediaType:"video",isVideoMute:t.isVideoMute,frameRateInput:e.maxFrameRate+"",frameRateSent:a.framesEncoded-t.lastReport.framesEncoded+""}),t.lastReport=a}})),n&&n(i)}))},t.getAudioRelatedStats=function(e){t.peerConnection.getStats().then((function(n){n.forEach((function(n){t.isSubscriber&&"inbound-rtp"===n.type&&~n.id.indexOf("Audio")&&e&&e({peerId:t.uid,mediaType:"audio",isAudioMute:t.isAudioMute,frameDropped:n.packetsLost+"",frameReceived:n.packetsReceived+"",googJitterReceived:n.jitter+"",bytesReceived:n.bytesReceived+"",packetsReceived:n.packetsReceived+"",packetsLost:n.packetsLost+""})}))}))},t.getStatsRate=function(e){t.getStats((function(t){t.forEach((function(e){"outbound-rtp"===e.type&&"video"===e.mediaType&&e.googFramesEncoded&&(e.googFrameRateSent=((e.googFramesEncoded-p)/3).toString(),p=e.googFramesEncoded),"inbound-rtp"===e.type&&-1!=e.id.indexOf("55543")&&(e.googFrameRateReceived&&(e.googFrameRateReceived=((e.googFrameReceived-g)/3).toString(),g=e.googFrameReceived),e.googFrameRateDecoded&&(e.googFrameRateDecoded=((e.googFramesDecoded-f)/3).toString(),f=e.googFramesDecoded))})),e(t)}))},t.getStats=function(e,n){n=(n=n||500)>500?500:n,t.lastTimeGetStats&&Date.now()-t.lastTimeGetStats<n?e&&e(t.filterStatsCache,t.originStatsCache):this._getStats((function(n,a){t.filterStatsCache=n,t.originStatsCache=a,t.lastTimeGetStats=Date.now(),e&&e(n,a)}))},t._getStats=function(e){var n=[];t.peerConnection.getStats().then((function(a){a.forEach((function(e){n.push(e),"outbound-rtp"===e.type&&"audio"===e.mediaType&&(s.id=e.id,s.type=e.type,s.mediaType=e.mediaType,s.bytesSent=e.bytesSent?e.bytesSent+"":"0",s.packetsSent=e.packetsSent?e.packetsSent+"":"0"),"outbound-rtp"===e.type&&"video"===e.mediaType&&(c.id=e.id,c.type=e.type,c.mediaType=e.mediaType,c.bytesSent=e.bytesSent?e.bytesSent+"":"0",c.packetsSent=e.packetsSent?e.packetsSent+"":"0",c.googPlisReceived=e.pliCount?e.pliCount+"":"0",c.googNacksReceived=e.nackCount?e.nackCount+"":"0",c.googFirsReceived=e.firCount?e.firCount+"":"0",c.googFramesEncoded=e.framesEncoded?e.framesEncoded+"":"0"),"inbound-rtp"===e.type&&-1!=e.id.indexOf("44444")&&(d.id=e.id,d.type=e.type,d.mediaType="audio",d.packetsReceived=e.packetsReceived?e.packetsReceived+"":"0",d.bytesReceived=e.bytesReceived?e.bytesReceived+"":"0",d.packetsLost=e.packetsLost?e.packetsLost+"":"0",d.packetsReceived=e.packetsReceived?e.packetsReceived+"":"0",d.googJitterReceived=e.jitter?e.jitter+"":"0"),"inbound-rtp"===e.type&&-1!=e.id.indexOf("55543")&&(u.id=e.id,u.type=e.type,u.mediaType="video",u.packetsReceived=e.packetsReceived?e.packetsReceived+"":"0",u.bytesReceived=e.bytesReceived?e.bytesReceived+"":"0",u.packetsLost=e.packetsLost?e.packetsLost+"":"0",u.googJitterBufferMs=e.jitter?e.jitter+"":"0",u.googNacksSent=e.nackCount?e.nackCount+"":"0",u.googPlisSent=e.pliCount?e.pliCount+"":"0",u.googFirsSent=e.firCount?e.firCount+"":"0"),"track"!==e.type||-1==e.id.indexOf("55543")&&!~e.trackIdentifier.indexOf("v")&&null!=e.audioLevel||(u.googFrameWidthReceived=e.frameWidth?e.frameWidth+"":"0",u.googFrameHeightReceived=e.frameHeight?e.frameHeight+"":"0",u.googFrameReceived=e.framesReceived?e.framesReceived+"":"0",u.googFramesDecoded=e.framesDecoded?e.framesDecoded+"":"0"),"track"!==e.type||-1==e.id.indexOf("44444")&&!~e.trackIdentifier.indexOf("a")&&void 0===e.audioLevel||(d.audioOutputLevel=e.audioLevel+"",s.audioInputLevel=e.audioLevel+""),"candidate-pair"===e.type&&(0==e.availableIncomingBitrate?l.googAvailableSendBandwidth=e.availableOutgoingBitrate+"":l.googAvailableReceiveBandwidth=e.availableIncomingBitrate+"")}));var i=[l,s,c,d,u];i.push({id:"time",startTime:t.connectedTime,timestamp:new Date}),e(i,n)})).catch((function(e){r.default.error("["+t.clientId+"] ",e)}))},t.addTrack=function(e,n){t.peerConnection.addTrack(e,n)},t.removeTrack=function(e,n){var a=t.peerConnection.getSenders().find((function(t){return t.track==e}));a.replaceTrack(null),t.peerConnection.removeTrack(a)},t.addStream=function(e){window.navigator.userAgent.indexOf("Safari")>-1&&-1===navigator.userAgent.indexOf("Chrome")?e.getTracks().forEach((function(n){return t.peerConnection.addTrack(n,e)})):t.peerConnection.addStream(e),t.markActionNeeded()},t.removeStream=function(){t.markActionNeeded()},t.close=function(){t.state="closed",t.peerConnection.close()},t.markActionNeeded=function(){t.actionNeeded=!0,t.doLater((function(){t.onstablestate()}))},t.doLater=function(e){window.setTimeout(e,1)},t.onstablestate=function(){var n;if(t.actionNeeded){if("new"===t.state||"established"===t.state){if(e.isSubscriber)t.peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.peerConnection.addTransceiver("video",{direction:"recvonly"});t.peerConnection.createOffer(t.mediaConstraints).then((function(n){if(n.sdp=i(n.sdp),e.isSubscriber||(n.sdp=n.sdp.replace(/a=.*video-orientation\r\n/g,"")),n.sdp!==t.prevOffer)return t.peerConnection.setLocalDescription(n),t.state="preparing-offer",void t.markActionNeeded();r.default.debug("["+t.clientId+"]Not sending a new offer")})).catch((function(e){r.default.debug("["+t.clientId+"]peer connection create offer failed ",e)}))}else if("preparing-offer"===t.state){if(t.moreIceComing)return;t.prevOffer=t.peerConnection.localDescription.sdp,t.offerCandidates=t.prevOffer.match(/a=candidate.+\r\n/g)||[],t.offerCandidates.length||(r.default.warning("[".concat(t.clientId,"]No Ice Candidate generated")),Object(o.getParameter)("SHIM_CANDIDATE")?(r.default.debug("Shimming fake candidate"),t.prevOffer+="a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"):r.default.error("[".concat(t.clientId,"]None Ice Candidate not allowed"))),t.prevOffer=t.prevOffer.replace(/a=candidate:.+typ\shost.+\r\n/g,"a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"),t.sendMessage("OFFER",t.prevOffer),t.state="offer-sent"}else if("offer-received"===t.state)t.peerConnection.createAnswer((function(e){if(t.peerConnection.setLocalDescription(e),t.state="offer-received-preparing-answer",t.iceStarted)t.markActionNeeded();else{var n=new Date;r.default.debug("["+t.clientId+"]"+n.getTime()+": Starting ICE in responder"),t.iceStarted=!0}}),(function(e){r.default.debug("["+t.clientId+"]peer connection create answer failed ",e)}),t.mediaConstraints);else if("offer-received-preparing-answer"===t.state){if(t.moreIceComing)return;n=t.peerConnection.localDescription.sdp,t.sendMessage("ANSWER",n),t.state="established"}else t.debug("Dazed and confused in state "+t.state+", stopping here");t.actionNeeded=!1}},t.sendMessage=function(e,n){var a={};a.messageType=e,a.sdp=n,"OFFER"===e?(a.offererSessionId=t.sessionId,a.answererSessionId=t.otherSessionId,a.seq=t.sequenceNumber+=1,a.tiebreaker=Math.floor(429496723*Math.random()+1)):(a.offererSessionId=t.incomingMessage.offererSessionId,a.answererSessionId=t.sessionId,a.seq=t.incomingMessage.seq),t.onsignalingmessage(JSON.stringify(a))},t._getSender=function(e){if(t.peerConnection&&t.peerConnection.getSenders){var n=t.peerConnection.getSenders().find((function(t){return t.track.kind==e}));if(n)return n}return null},t.hasSender=function(e){return!!t._getSender(e)},t.replaceTrack=function(e,n,a){var i=t._getSender(e.kind);if(!i){return a("NO_SENDER_FOUND")}try{i.replaceTrack(e)}catch(e){return a&&a(e)}setTimeout((function(){return n&&n()}),50)},t.error=function(e){throw"Error in RoapOnJsep: "+e},t.sessionId=t.roapSessionId+=1,t.sequenceNumber=0,t.actionNeeded=!1,t.iceStarted=!1,t.moreIceComing=!0,t.iceCandidateCount=0,t.onsignalingmessage=e.callback,t.peerConnection.ontrack=function(e){console.log("!!! ontrack, ",e.track.kind,e.track),t.onaddstream&&t.onaddstream(e,"ontrack")},t.peerConnection.onremovestream=function(e){t.onremovestream&&t.onremovestream(e)},t.peerConnection.oniceconnectionstatechange=function(e){"connected"===e.currentTarget.iceConnectionState&&(t.connectedTime=new Date),t.oniceconnectionstatechange&&t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)},t.renegotiate=function(){void 0!==t.prevOffer&&t.peerConnection.createOffer().then((function(e){return e.sdp=e.sdp.replace(/a=recvonly\r\n/g,"a=inactive\r\n"),e.sdp=a(e.sdp),e.sdp=i(e.sdp),t.peerConnection.setLocalDescription(e)})).then((function(){t.onnegotiationneeded&&t.onnegotiationneeded(t.peerConnection.localDescription.sdp)})).catch((function(e){console.log("createOffer error: ",e)}))},t.peerConnection.onnegotiationneeded=t.renegotiate,t.onaddstream=null,t.onremovestream=null,t.state="new",t.markActionNeeded(),t};function C(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return N(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return N(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}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 a,i,o=!0,r=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return o=e.done,e},e:function(e){r=!0,i=e},f:function(){try{o||null==a.return||a.return()}finally{if(r)throw i}}}}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}var w=function(e){var t={},n=(mozRTCPeerConnection,mozRTCSessionDescription),a=!1;t.uid=e.uid,t.isVideoMute=e.isVideoMute,t.isAudioMute=e.isAudioMute,t.isSubscriber=e.isSubscriber,t.clientId=e.clientId,t.filterStatsCache=[],t.originStatsCache=[],t.lastTimeGetStats=null,t.pc_config={iceServers:[]},e.iceServers instanceof Array?e.iceServers.map((function(e){0===e.url.indexOf("stun:")&&t.pc_config.iceServers.push({url:e.url})})):(e.stunServerUrl&&(e.stunServerUrl instanceof Array?e.stunServerUrl.map((function(e){"string"==typeof e&&""!==e&&t.pc_config.iceServers.push({url:e})})):"string"==typeof e.stunServerUrl&&""!==e.stunServerUrl&&t.pc_config.iceServers.push({url:e.stunServerUrl})),e.turnServers&&(e.turnServers instanceof Array?e.turnServers.map((function(e){e.udpport&&t.pc_config.iceServers.push({username:e.username,credential:e.credential,credentialType:"password",urls:"turn:"+e.url+":"+e.udpport+"?transport=udp"}),"string"==typeof e.tcpport&&""!==e.tcpport&&t.pc_config.iceServers.push({username:e.username,credential:e.credential,credentialType:"password",urls:"turn:"+e.url+":"+e.tcpport+"?transport=tcp"}),!0===e.forceturn&&(t.pc_config.iceTransportPolicy="relay")})):r.default.error("[".concat(t.clientId,"] turnServers is not a array")))),void 0===e.audio&&(e.audio=!0),void 0===e.video&&(e.video=!0),t.mediaConstraints={offerToReceiveAudio:e.audio,offerToReceiveVideo:e.video,mozDontOfferDataChannel:!0},t.roapSessionId=103,t.peerConnection=new h.RTCPeerConnection(t.pc_config),t.iceCandidateTimer=setTimeout((function(){t.iceCandidateTimer=null,r.default.debug("[".concat(t.clientId,"]Candidates collected: ").concat(t.iceCandidateCount)),t.moreIceComing&&(t.moreIceComing=!1,t.markActionNeeded())}),Object(o.getParameter)("CANDIDATE_TIMEOUT")),t.peerConnection.onicecandidate=function(e){var n,a,i,o;a=(n=t.peerConnection.localDescription.sdp).match(/a=candidate:.+typ\ssrflx.+\r\n/),i=n.match(/a=candidate:.+typ\shost.+\r\n/),o=n.match(/a=candidate:.+typ\srelay.+\r\n/),null===a&&null===i&&null===o||void 0!==t.ice||!t.iceCandidateTimer||(clearTimeout(t.iceCandidateTimer),t.iceCandidateTimer=null,t.ice=0,t.moreIceComing=!1,t.markActionNeeded()),t.iceCandidateCount=t.iceCandidateCount+1},t.checkMLineReverseInSDP=function(e){return!(!~e.indexOf("m=audio")||!~e.indexOf("m=video"))&&e.indexOf("m=audio")>e.indexOf("m=video")},t.reverseMLineInSDP=function(e){var t=e.split("m=audio"),n=t[1].split("m=video"),a="m=video"+n[1],i="m=audio"+n[0];return e=t[0]+a+i},t.processSignalingMessage=function(e){var a,i=JSON.parse(e);t.incomingMessage=i,"new"===t.state?"OFFER"===i.messageType?(i.sdp=l(i.sdp),a={sdp:i.sdp,type:"offer"},t.peerConnection.setRemoteDescription(new n(a),(function(){r.default.debug("["+t.clientId+"]setRemoteDescription succeeded")}),(function(e){r.default.info("["+t.clientId+"]setRemoteDescription failed: "+e.name)})),t.state="offer-received",t.markActionNeeded()):t.error("Illegal message for this state: "+i.messageType+" in state "+t.state):"offer-sent"===t.state?"ANSWER"===i.messageType?(i.sdp=l(i.sdp),i.sdp=i.sdp.replace(/ generation 0/g,""),i.sdp=i.sdp.replace(/ udp /g," UDP "),-1!==i.sdp.indexOf("a=group:BUNDLE")?(i.sdp=i.sdp.replace(/a=group:BUNDLE audio video/,"a=group:BUNDLE sdparta_0 sdparta_1"),i.sdp=i.sdp.replace(/a=mid:audio/,"a=mid:sdparta_0"),i.sdp=i.sdp.replace(/a=mid:video/,"a=mid:sdparta_1")):(i.sdp=i.sdp.replace(/a=mid:audio/,"a=mid:sdparta_0"),i.sdp=i.sdp.replace(/a=mid:video/,"a=mid:sdparta_0")),a={sdp:i.sdp,type:"answer"},t.peerConnection.setRemoteDescription(new n(a),(function(){r.default.debug("["+t.clientId+"]setRemoteDescription succeeded")}),(function(e){r.default.info("["+t.clientId+"]setRemoteDescription failed: "+e)})),t.state="established"):"pr-answer"===i.messageType?(a={sdp:i.sdp,type:"pr-answer"},t.peerConnection.setRemoteDescription(new n(a),(function(){r.default.debug("["+t.clientId+"]setRemoteDescription succeeded")}),(function(e){r.default.info("["+t.clientId+"]setRemoteDescription failed: "+e.name)}))):"offer"===i.messageType?t.error("Not written yet"):t.error("Illegal message for this state: "+i.messageType+" in state "+t.state):"established"===t.state&&("OFFER"===i.messageType?(a={sdp:i.sdp,type:"offer"},t.peerConnection.setRemoteDescription(new n(a),(function(){r.default.debug("["+t.clientId+"]setRemoteDescription succeeded")}),(function(e){r.default.info("["+t.clientId+"]setRemoteDescription failed: "+e.name)})),t.state="offer-received",t.markActionNeeded()):t.error("Illegal message for this state: "+i.messageType+" in state "+t.state))};var i={id:"",type:"",mediaType:"opus",googCodecName:"opus",aecDivergentFilterFraction:"0",audioInputLevel:"0",bytesSent:"0",packetsSent:"0",googEchoCancellationReturnLoss:"0",googEchoCancellationReturnLossEnhancement:"0"},s={id:"",type:"",mediaType:"",googCodecName:"h264"===e.codec?"H264":"VP8",bytesSent:"0",packetsLost:"0",packetsSent:"0",googAdaptationChanges:"0",googAvgEncodeMs:"0",googEncodeUsagePercent:"0",googFirsReceived:"0",googFrameHeightSent:"0",googFrameHeightInput:"0",googFrameRateInput:"0",googFrameRateSent:"0",googFrameWidthSent:"0",googFrameWidthInput:"0",googNacksReceived:"0",googPlisReceived:"0",googRtt:"0"},c={id:"",type:"",mediaType:"",audioOutputLevel:"0",bytesReceived:"0",packetsLost:"0",packetsReceived:"0",googAccelerateRate:"0",googCurrentDelayMs:"0",googDecodingCNG:"0",googDecodingCTN:"0",googDecodingCTSG:"0",googDecodingNormal:"0",googDecodingPLC:"0",googDecodingPLCCNG:"0",googExpandRate:"0",googJitterBufferMs:"0",googJitterReceived:"0",googPreemptiveExpandRate:"0",googPreferredJitterBufferMs:"0",googSecondaryDecodedRate:"0",googSpeechExpandRate:"0"},d={id:"",type:"",mediaType:"",googTargetDelayMs:"0",packetsLost:"0",googDecodeMs:"0",googMaxDecodeMs:"0",googRenderDelayMs:"0",googFrameWidthReceived:"0",googFrameHeightReceived:"0",googFrameRateReceived:"0",googFrameRateDecoded:"0",googFrameRateOutput:"0",googJitterBufferMs:"0",googCurrentDelayMs:"0",googMinPlayoutDelayMs:"0",googNacksSent:"0",googPlisSent:"0",googFirsSent:"0",bytesReceived:"0",packetsReceived:"0",googFramesDecoded:"0"},u=0;t.getVideoRelatedStats=function(e){t.peerConnection.getStats().then((function(n){var a,i=C(n.values());try{for(i.s();!(a=i.n()).done;){var o=a.value;if(t.isSubscriber){if(("inbound-rtp"===o.type||"inboundrtp"===o.type)&&"video"===o.mediaType){if(!t.lastReport)return void(t.lastReport=o);e&&e({browser:"firefox",mediaType:"video",peerId:t.uid,isVideoMute:t.isVideoMute,frameRateReceived:o.framerateMean+"",frameRateDecoded:o.framesDecoded-t.lastReport.framesDecoded+"",bytesReceived:o.bytesReceived+"",packetsReceived:o.packetsReceived+"",packetsLost:o.packetsLost+""}),t.lastReport=o}}else if(("outbound-rtp"===o.type||"outboundrtp"===o.type)&&"video"===o.mediaType){if(!t.lastReport)return void(t.lastReport=o);e&&e({mediaType:"video",isVideoMute:t.isVideoMute,frameRateInput:o.framerateMean+"",frameRateSent:o.framesEncoded-t.lastReport.framesEncoded+""}),t.lastReport=o}}}catch(e){i.e(e)}finally{i.f()}}))},t.getAudioRelatedStats=function(e){t.peerConnection.getStats().then((function(n){var a,i=C(n.values());try{for(i.s();!(a=i.n()).done;){var o=a.value;t.isSubscriber&&("inbound-rtp"!==o.type&&"inboundrtp"!==o.type||"audio"!==o.mediaType||e&&e({browser:"firefox",mediaType:"audio",peerId:t.uid,isAudioMute:t.isAudioMute,frameDropped:o.packetsLost+"",frameReceived:o.packetsReceived+"",googJitterReceived:o.jitter+"",bytesReceived:o.bytesReceived+"",packetsReceived:o.packetsReceived+"",packetsLost:o.packetsLost+""}))}}catch(e){i.e(e)}finally{i.f()}}))},t.getStatsRate=function(e){t.getStats((function(t){t.forEach((function(e){"inbound-rtp"!==e.type&&"inboundrtp"!==e.type||"video"!==e.mediaType||e.googFrameRateDecoded&&(e.googFrameRateDecoded=((e.googFramesDecoded-u)/3).toString(),u=e.googFramesDecoded)})),e(t)}))},t.getStats=function(e,n){n=(n=n||500)>500?500:n,t.lastTimeGetStats&&Date.now()-t.lastTimeGetStats<n?e&&e(t.filterStatsCache,t.originStatsCache):this._getStats((function(n,a){t.filterStatsCache=n,t.originStatsCache=a,t.lastTimeGetStats=Date.now(),e&&e(n,a)}))},t._getStats=function(e){t.peerConnection.getStats().then((function(n){var a,o=[],r=C(n.values());try{for(r.s();!(a=r.n()).done;){var u=a.value;o.push(u),"outbound-rtp"!==u.type&&"outboundrtp"!==u.type||"video"!==u.mediaType||-1!==u.id.indexOf("rtcp")||(s.id=u.id,s.type=u.type,s.mediaType=u.mediaType,s.bytesSent=u.bytesSent?u.bytesSent+"":"0",s.packetsSent=u.packetsSent?u.packetsSent+"":"0",s.googPlisReceived=u.pliCount?u.pliCount+"":"0",s.googNacksReceived=u.nackCount?u.nackCount+"":"0",s.googFirsReceived=u.firCount?u.firCount+"":"0",s.googFrameRateSent=u.framerateMean?u.framerateMean+"":"0"),"outbound-rtp"!==u.type&&"outboundrtp"!==u.type||"audio"!==u.mediaType||-1!==u.id.indexOf("rtcp")||(i.id=u.id,i.type=u.type,i.mediaType=u.mediaType,i.bytesSent=u.bytesSent?u.bytesSent+"":"0",i.packetsSent=u.packetsSent?u.packetsSent+"":"0"),"inbound-rtp"!==u.type&&"inboundrtp"!==u.type||"audio"!==u.mediaType||u.isRemote||-1!==u.id.indexOf("rtcp")||(c.id=u.id,c.type=u.type,c.mediaType=u.mediaType,c.bytesReceived=u.bytesReceived?u.bytesReceived+"":"0",c.packetsLost=u.packetsLost?u.packetsLost+"":"0",c.packetsReceived=u.packetsReceived?u.packetsReceived+"":"0",c.googJitterReceived=u.jitter?u.jitter+"":"0"),"inbound-rtp"!==u.type&&"inboundrtp"!==u.type||"video"!==u.mediaType||u.isRemote||-1!==u.id.indexOf("rtcp")||(d.id=u.id,d.type=u.type,d.mediaType=u.mediaType,d.bytesReceived=u.bytesReceived?u.bytesReceived+"":"0",d.googFrameRateReceived=u.framerateMean?u.framerateMean+"":"0",d.googFramesDecoded=u.framesDecoded?u.framesDecoded+"":"0",d.packetsLost=u.packetsLost?u.packetsLost+"":"0",d.packetsReceived=u.packetsReceived?u.packetsReceived+"":"0",d.googJitterBufferMs=u.jitter?u.jitter+"":"0",d.googNacksSent=u.nackCount?u.nackCount+"":"0",d.googPlisSent=u.pliCount?u.pliCount+"":"0",d.googFirsSent=u.firCount?u.firCount+"":"0"),-1!==u.id.indexOf("outbound_rtcp_video")&&(s.packetsLost=u.packetsLost?u.packetsLost+"":"0")}}catch(e){r.e(e)}finally{r.f()}var l=[s,i,c,d];l.push({id:"time",startTime:t.connectedTime,timestamp:new Date}),e(l,o)}),(function(e){r.default.error("["+t.clientId+"]"+e)}))},t.addStream=function(e){a=!0,t.peerConnection.addStream(e),t.markActionNeeded()},t.removeStream=function(){t.markActionNeeded()},t.close=function(){t.state="closed",t.peerConnection.close()},t.markActionNeeded=function(){t.actionNeeded=!0,t.doLater((function(){t.onstablestate()}))},t.doLater=function(e){window.setTimeout(e,1)},t.onstablestate=function(){if(t.actionNeeded){if("new"===t.state||"established"===t.state){a&&(t.mediaConstraints=void 0),t.peerConnection.createOffer((function(e){if(e.sdp=l(e.sdp),e.sdp=e.sdp.replace(/a=extmap:1 http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/abs-send-time/,"a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"),e.sdp!==t.prevOffer)return t.peerConnection.setLocalDescription(e),t.state="preparing-offer",void t.markActionNeeded();r.default.debug("["+t.clientId+"]Not sending a new offer")}),(function(e){r.default.debug("["+t.clientId+"]Ups! create offer failed ",e)}),t.mediaConstraints)}else if("preparing-offer"===t.state){if(t.moreIceComing)return;t.prevOffer=t.peerConnection.localDescription.sdp,t.offerCandidates=t.prevOffer.match(/a=candidate.+\r\n/g)||[],t.offerCandidates.length||(r.default.warning("[".concat(t.clientId,"]No Ice Candidate generated")),Object(o.getParameter)("SHIM_CANDIDATE")?(r.default.debug("Shimming fake candidate"),t.prevOffer+="a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"):r.default.error("[".concat(t.clientId,"]None Ice Candidate not allowed"))),t.prevOffer=t.prevOffer.replace(/a=candidate:.+typ\shost.+\r\n/g,"a=candidate:2243255435 1 udp 2122194687 192.168.0.1 30000 typ host generation 0 network-id 1\r\n"),t.sendMessage("OFFER",t.prevOffer),t.state="offer-sent"}else if("offer-received"===t.state)t.peerConnection.createAnswer((function(e){if(t.peerConnection.setLocalDescription(e),t.state="offer-received-preparing-answer",t.iceStarted)t.markActionNeeded();else{var n=new Date;r.default.debug("["+t.clientId+"]"+n.getTime()+": Starting ICE in responder"),t.iceStarted=!0}}),(function(){r.default.debug("["+t.clientId+"]Ups! Something went wrong")}));else if("offer-received-preparing-answer"===t.state){if(t.moreIceComing)return;var e=t.peerConnection.localDescription.sdp;t.sendMessage("ANSWER",e),t.state="established"}else t.debug("Dazed and confused in state "+t.state+", stopping here");t.actionNeeded=!1}},t.sendMessage=function(e,n){var a={};a.messageType=e,a.sdp=n,"OFFER"===e?(a.offererSessionId=t.sessionId,a.answererSessionId=t.otherSessionId,a.seq=t.sequenceNumber+=1,a.tiebreaker=Math.floor(429496723*Math.random()+1)):(a.offererSessionId=t.incomingMessage.offererSessionId,a.answererSessionId=t.sessionId,a.seq=t.incomingMessage.seq),t.onsignalingmessage(JSON.stringify(a))},t._getSender=function(e){if(t.peerConnection&&t.peerConnection.getSenders){var n=t.peerConnection.getSenders().find((function(t){return t.track.kind==e}));if(n)return n}return null},t.hasSender=function(e){return!!t._getSender(e)},t.replaceTrack=function(e,n,a){var i=t._getSender(e.kind);if(!i){return a("NO_SENDER_FOUND")}try{i.replaceTrack(e)}catch(e){return a&&a(e)}setTimeout((function(){return n&&n()}),50)},t.error=function(e){throw"Error in RoapOnJsep: "+e},t.sessionId=t.roapSessionId+=1,t.sequenceNumber=0,t.actionNeeded=!1,t.iceStarted=!1,t.moreIceComing=!0,t.iceCandidateCount=0,t.onsignalingmessage=e.callback,t.peerConnection.ontrack=function(e){t.onaddstream&&t.onaddstream(e,"ontrack")},t.peerConnection.onremovestream=function(e){t.onremovestream&&t.onremovestream(e)},t.peerConnection.oniceconnectionstatechange=function(e){"connected"===e.currentTarget.iceConnectionState&&(t.connectedTime=new Date),t.oniceconnectionstatechange&&t.oniceconnectionstatechange(e.currentTarget.iceConnectionState)};var l=function(t){var n;if(e.video&&e.maxVideoBW&&(null==(n=t.match(/m=video.*\r\n/))&&(n=t.match(/m=video.*\n/)),n&&n.length>0)){var a=n[0]+"b=TIAS:"+1e3*e.maxVideoBW+"\r\n";t=t.replace(n[0],a)}if(e.audio&&e.maxAudioBW&&(null==(n=t.match(/m=audio.*\r\n/))&&(n=t.match(/m=audio.*\n/)),n&&n.length>0)){a=n[0]+"b=TIAS:"+1e3*e.maxAudioBW+"\r\n";t=t.replace(n[0],a)}return t};return t.onaddstream=null,t.onremovestream=null,t.state="new",t.markActionNeeded(),t},D=a(24),k=a.n(D),L=null,P=function(){try{L=window.require("electron")}catch(e){}return L},M=function(e){var t=s.b.reportApiInvoke(null,{callback:e,name:"getScreenSources",options:arguments,tag:"tracer"}),n=P();if(!n)return t&&t("electron is null");try{var a=n.desktopCapturer.getSources({types:["window","screen"]})}catch(e){console.log(e)}if(a instanceof Promise)console.log("electron.desktopCapturer.getSources return type is Promise"),a.then((function(e){return t&&t(null,e)})).catch((function(e){return t&&t(e)}));else a=n.desktopCapturer.getSources({types:["window","screen"]},(function(e,n){console.log("electron.desktopCapturer.getSources return type is callback"),t&&t(null,n)}))},U=function(e,t,n){var a=t.width;t={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxHeight:t.height,maxWidth:a,maxFrameRate:t.frameRate&&t.frameRate.max,minFrameRate:t.frameRate&&t.frameRate.min}}};navigator.webkitGetUserMedia(t,(function(e){n&&n(null,e)}),(function(e){n&&n(e)}))},x=function(){return!!P()},V=M,j=U,B=function(e,t){M((function(n,a){if(n)return t&&t(n);!function(e,t){var n=document.createElement("div");n.innerText="share screen",n.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom:  solid 1px #B9B8B9;");var a=document.createElement("div");a.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;");var i=document.createElement("div");i.innerText="Agora Web Screensharing wants to share the contents of your screen with webdemo.agorabeckon.com. Choose what you'd like to share.",i.setAttribute("style","height: 12%;");var o=document.createElement("div");o.setAttribute("style","width: 100%; height: 80%; background: #FFF; border:  solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");var r=document.createElement("div");r.setAttribute("style","text-align: right; padding: 16px 0;");var s=document.createElement("button");s.innerHTML="cancel",s.setAttribute("style","width: 85px;"),s.onclick=function(){document.body.removeChild(c),t&&t("NotAllowedError")},r.appendChild(s),a.appendChild(i),a.appendChild(o),a.appendChild(r);var c=document.createElement("div");c.setAttribute("style","position: absolute; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);"),c.appendChild(n),c.appendChild(a),document.body.appendChild(c),e.map((function(e){if(e.id){var n=document.createElement("div");n.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),n.innerHTML='<div style="height: 120px; display: table-cell; vertical-align: middle;"><img style="width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);" src='+e.thumbnail.toDataURL()+' /></div><span style="\theight: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">'+e.name+"</span>",n.onclick=function(){document.body.removeChild(c),t&&t(null,e.id)},o.appendChild(n)}}))}(a,(function(n,a){if(n)return t&&t(n);U(a,e,t)}))}))},F=103,W=function(e){var t={};if(t.clientId=e.clientId,e.session_id=F+=1,"undefined"==typeof window||!window.navigator)throw r.default.error("["+t.streamId+"]["+t.clientId+"]Publish/subscribe video/audio streams not supported yet"),new Error("NON_BROWSER_ENV_DETECTED");return null!==window.navigator.userAgent.match("Firefox")?(t.browser="mozilla",t=w(e)):"iOS"===g.getBrowserOS()||g.isSafari()?(r.default.debug("["+t.streamId+"]["+t.clientId+"]Safari"),(t=O(e)).browser="safari"):~window.navigator.userAgent.indexOf("Edge")?t=new k.a(e):(t=y(e)).browser="chrome-stable",t},G=function(e,t,n){var a={};a.config=e,a.streamId=e.streamId,delete e.streamId,navigator.getMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var i=0,o=1,s=!1,c=null,d=function(e){if(i++,c)if(c===e)r.default.debug("Using Video Source/ Audio Source");else{var n=c.getVideoTracks()[0],a=c.getAudioTracks()[0],d=e.getVideoTracks()[0],u=e.getAudioTracks()[0];d&&(n&&c.removeTrack(n),c.addTrack(d)),u&&(a&&c.removeTrack(a),c.addTrack(u))}else c=e;i!==o||s||(s=!0,setTimeout((function(){t(c)}),0))},u=function(e){r.default.error("Failed to GetUserMedia",e.name,e.code,e.message,e),i++,s||(s=!0,setTimeout((function(){n&&n(e)}),0))},l=function(){var t={video:e.video,audio:e.audio};if(r.default.debug("GetUserMedia",JSON.stringify(t)),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia(t).then(d).catch(u);else if("undefined"!=typeof navigator&&navigator.getMedia)navigator.getMedia(e,d,u);else{var i={name:"MEDIA_NOT_SUPPORT",message:"Video/audio streams not supported yet"};r.default.error("["+a.streamId+"]"+i.message),n&&n(i)}};if((e.videoSource||e.audioSource)&&(c=new MediaStream,e.videoSource&&c.addTrack(e.videoSource),e.audioSource&&c.addTrack(e.audioSource)),e.video||e.audio||e.screen||e.screenAudio){if(!e.screen&&e.screenAudio)return n&&n({code:"Set screen to true before sharing the audio"});if(e.screen){if(x())return e.screen.sourceId?j(e.screen.sourceId,e.screen,(function(t,n){t?u(t):(e.audio&&(o++,l()),d(n))})):B(e.screen,(function(t,n){t?u(t):(e.audio&&(o++,l()),d(n))}));if(g.isFireFox()){r.default.debug("["+a.streamId+"]Screen access requested");if(!~["screen","window","application"].indexOf(e.screen.mediaSource))return n&&n({code:"Invalid mediaSource, mediaSource should be one of [screen, window, application]"});navigator.getMedia({video:e.screen},(function(t){e.audio&&(o++,l()),d(t)}),u)}else if(g.isChromeKernel()&&e.screen.extensionId){if(window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1]<34)return void n({code:"This browser does not support screen sharing"});r.default.debug("["+a.streamId+"]Screen access on chrome stable, looking for extension");try{chrome.runtime.sendMessage(e.screen.extensionId,{getStream:!0},(function(t){if(void 0===t){r.default.error("["+a.streamId+"]No response from Chrome Plugin. Plugin not installed properly");u({name:"PluginNotInstalledProperly",message:"No response from Chrome Plugin. Plugin not installed properly."})}else e.screen.mandatory.chromeMediaSourceId=t.streamId,navigator.getMedia({video:e.screen},(function(t){e.audio&&(o++,l()),d(t)}),u)}))}catch(e){r.default.debug("["+a.streamId+"]AgoraRTC screensharing plugin is not accessible");return void n({code:"no_plugin_present"})}}else{if(window.navigator.mediaDevices.getDisplayMedia){var p={};return"number"==typeof e.screen.width&&"number"==typeof e.screen.height?p.video={width:{ideal:e.screen.width},height:{ideal:e.screen.height}}:p.video={width:e.screen.width,height:e.screen.height},e.screen.frameRate&&e.screen.frameRate.min?p.video.frameRate={ideal:e.screen.frameRate.max,max:e.screen.frameRate.max}:p.video.frameRate=e.screen.frameRate,e.screenAudio&&(p.audio=e.screenAudio),r.default.debug("use getDisplayMedia, constraints:",p),window.navigator.mediaDevices.getDisplayMedia(p).then((function(t){!e.screenAudio&&e.audio&&(o++,l()),d(t)})).catch(u)}r.default.error("["+a.streamId+"]This browser does not support screenSharing"),n({code:"This browser does not support screen sharing"})}}else l()}else d(c)},H=a(10),q=function(e,t,n){if(["End2EndDelay","TransportDelay","PacketLossRate","RecvLevel","RecvBitrate","CodecType","MuteState","TotalFreezeTime","TotalPlayDuration","RecordingLevel","SendLevel","SamplingRate","SendBitrate","CodecType","MuteState","End2EndDelay","TransportDelay","PacketLossRate","RecvBitrate","RecvResolutionWidth","RecvResolutionHeight","RenderResolutionHeight","RenderResolutionWidth","RenderFrameRate","TotalFreezeTime","TotalPlayDuration","TargetSendBitrate","SendFrameRate","SendFrameRate","SendBitrate","SendResolutionWidth","SendResolutionHeight","CaptureResolutionHeight","CaptureResolutionWidth","EncodeDelay","MuteState","TotalFreezeTime","TotalDuration","CaptureFrameRate","RTT","OutgoingAvailableBandwidth","Duration","UserCount","SendBytes","RecvBytes","SendBitrate","RecvBitrate","accessDelay","audioSendBytes","audioSendPackets","videoSendBytes","videoSendPackets","videoSendPacketsLost","videoSendFrameRate","audioSendPacketsLost","videoSendResolutionWidth","videoSendResolutionHeight","accessDelay","audioReceiveBytes","audioReceivePackets","audioReceivePacketsLost","videoReceiveBytes","videoReceivePackets","videoReceivePacketsLost","videoReceiveFrameRate","videoReceiveDecodeFrameRate","videoReceiveResolutionWidth","videoReceiveResolutionHeight","endToEndDelay","videoReceiveDelay","audioReceiveDelay","FirstFrameTime","VideoFreezeRate","AudioFreezeRate","RenderResolutionWidth","RenderResolutionHeight","VideoPublishDuration","AudioPublishDuration"].indexOf(t)>-1&&("string"==typeof n||isFinite(n)))return e[t]=""+n};function J(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return Y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Y(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}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 a,i,o=!0,r=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return o=e.done,e},e:function(e){r=!0,i=e},f:function(){try{o||null==a.return||a.return()}finally{if(r)throw i}}}}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}var K=new function(){var e=c();return e.devicesHistory={},e.states={UNINIT:"UNINIT",INITING:"INITING",INITED:"INITED"},e.state=e.states.UNINIT,e.deviceStates={ACTIVE:"ACTIVE",INACTIVE:"INACTIVE"},e.deviceReloadTimer=null,e._init=function(t,n){e.state=e.states.INITING,e.devicesHistory={},e._reloadDevicesInfo((function(){e.state=e.states.INITED,e.dispatchEvent({type:"inited"}),t&&t()}),(function(t){r.default.warning("Device Detection functionality cannot start properly."),e.state=e.states.UNINIT,n&&n(t)}))},e._enumerateDevices=function(e,t){if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices)return r.default.warning("enumerateDevices() not supported."),t&&t("enumerateDevices() not supported");navigator.mediaDevices.enumerateDevices().then((function(t){e&&setTimeout((function(){e(t)}),0)})).catch((function(e){t&&t(e)}))},e._reloadDevicesInfo=function(t,n){var a=[];e._enumerateDevices((function(n){var i=Date.now();for(var o in n.forEach((function(t){var n=e.devicesHistory[t.deviceId];if((n?n.state:e.deviceStates.INACTIVE)!=e.deviceStates.ACTIVE){var o=n||{initAt:i};o.device=t,o.state=e.deviceStates.ACTIVE,a.push(o),e.devicesHistory[t.deviceId]=o}e.devicesHistory[t.deviceId].lastReloadAt=i})),e.devicesHistory){var s=e.devicesHistory[o];s&&s.state==e.deviceStates.ACTIVE&&s.lastReloadAt!==i&&(s.state=e.deviceStates.INACTIVE,a.push(s)),s.lastReloadAt=i}e.state==e.states.INITED&&a.forEach((function(t){var n=E()({},t);switch(t.device.kind){case"audioinput":n.type="recordingDeviceChanged";break;case"audiooutput":n.type="playoutDeviceChanged";break;case"videoinput":n.type="cameraChanged";break;default:r.default.warning("Unknown device change",n),n.type="unknownDeviceChanged"}e.dispatchEvent(n)})),t&&t()}),n)},e.getDeviceById=function(t,n,a){e.getDevices((function(e){for(var i=0;i<e.length;i++){var o=e[i];if(o&&o.deviceId===t)return n&&n(o)}return a&&a()}))},e.searchDeviceNameById=function(t){var n=e.devicesHistory[t];return n?n.device.label||n.device.deviceId:null},e.getDevices=function(t,n){e._enumerateDevices(t,(function(e){n&&n(e.name+": "+e.message)}))},e.getVideoCameraIdByLabel=function(t,n,a){e.getCameras((function(e){var i,o=J(e);try{for(o.s();!(i=o.n()).done;){var r=i.value;if(r.label===t)return n&&n(r.deviceId)}}catch(e){o.e(e)}finally{o.f()}return a&&a(I.default.NOT_FIND_DEVICE_BY_LABEL)}),a)},e.getRecordingDevices=function(t,n){return e._enumerateDevices((function(e){var n=e.filter((function(e){return"audioinput"==e.kind}));t&&t(n)}),(function(e){n&&n(e)}))},e.getPlayoutDevices=function(t,n){return e._enumerateDevices((function(e){var n=e.filter((function(e){return"audiooutput"==e.kind}));t&&t(n)}),(function(e){n&&n(e)}))},e.getCameras=function(t,n){return e._enumerateDevices((function(e){var n=e.filter((function(e){return"videoinput"==e.kind}));t&&t(n)}),(function(e){n&&n(e)}))},e._init((function(){navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(function(){e._reloadDevicesInfo()})),e.deviceReloadTimer=setInterval(e._reloadDevicesInfo,5e3)})),e},z=a(1),X=a(14);var Q=a(7),Z=a.n(Q),$=a(12),ee=a.n($),te=a(25),ne=a.n(te),ae=a(26),ie=a.n(ae),oe=[31,222,239,159,192,236,164,81,54,227,176,149,2,247,75,141,183,54,213,216,158,92,111,49,228,111,150,6,135,79,35,212,4,155,200,168,37,107,243,110,144,179,51,81,55,78,223,242,191,211,74,119,203,151,142,62,31,41,132,22,35,155,87,123,119,117,216,57,201,53,228,67,201,40,106,24,80,176,187,253,60,63,136,100,20,12,177,99,64,38,101,143,111,176,251,211,145,136,34,23,79,136,202,95,105,199,125,67,180,44,210,179,228,4,85,160,188,64,26,46,6,61,201,103,248,18,97,254,140,36,115,106,48,124,102,216,155,120,36,227,165,217,7,227,191,128,212,157,80,37,117,175,24,214,47,221,183,211,51,174,251,223,159,167,152,53,36,107,199,223,91,62,46,194,11,80,121,188,219,2,99,99,232,229,173,234,21,30,236,177,243,142,97,48,108,56,62,172,56,216,3,42,79,138,23,88,182,39,5,118,68,135,178,56,9,94,189,44,104,9,238,231,174,122,85,247,231,86,74,8,189,147,218,180,58,76,227,17,46,90,194,100,51,178,72,163,151,243,166,130,85,1,223,130,152,242,85,255,28,173,97,252,119,215,177,119,86,104,136,82,40,72,53,11,18,26,240,188,76,110,39,31,189];function re(e){for(var t=new Uint8Array([99,114,121,112,116,105,105]),n=t.length,a=e,i=a.length,o=new Uint8Array(i),r=new Uint8Array(256),s=0;s<256;s++)r[s]=s;for(var c=0,d=0;d<256;d++){var u=[r[c=(c+r[d]+t[d%n])%256],r[d]];r[d]=u[0],r[c]=u[1]}var l,p=0;c=0;for(var f=0;f<0+i;f++){var g=[r[c=(c+r[p=(p+1)%256])%256],r[p]];r[p]=g[0],r[c]=g[1],l=r[(r[p]+r[c])%256],f>=0&&(o[f-0]=a[f-0]^l)}var m=String.fromCharCode.apply(null,o);return Function("var winSize = 5; return `"+m+"`")()}function se(e,t){var n=re(t),a=ie.a.createProgramFromSources(e,[re(oe),n]),i=e.getAttribLocation(a,"a_position"),o=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(i);var r=2,s=e.FLOAT,c=!1,d=0,u=0;e.vertexAttribPointer(i,r,s,c,d,u);var l=e.getAttribLocation(a,"a_texCoord"),p=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,p),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(l);r=2,s=e.FLOAT,c=!1,d=0,u=0;return e.vertexAttribPointer(l,r,s,c,d,u),a}var ce=[11,196,242,139,198,252,188,5,59,170,161,152,17,229,24,141,133,54,214,206,133,26,66,126,255,11,245,10,146,92,52,134,108,152,221,191,124,116,248,106,130,251,59,105,43,91,135,199,181,223,10,51,134,194,240,46,9,3,141,22,35,146,76,23,109,117,208,41,201,45,218,76,203,105,51,58,97,154,145,236,49,18,183,127,27,12,210,122,73,42,37,143,36,207,251,211,145,191,56,10,88,222,181,125,22,238,123,71,177,107,218,254,173,28,34,253,249,67,83,97,73,111,219,43,181,82,38,230,136,109,22,67];function de(e,t,n){var a=e.gl;this.program=se(a,ce),this.setUniforms=function(){a.getUniformLocation(this.program,"u_image");var e=a.getUniformLocation(this.program,"u_flipY");a.uniform1f(e,1)}}var ue=[11,196,242,139,198,252,188,5,59,170,161,152,17,229,24,141,133,54,214,206,133,26,66,126,255,11,245,10,146,92,52,134,108,155,210,164,99,114,228,96,130,251,59,105,43,91,135,199,181,223,10,51,133,194,247,34,31,39,142,28,2,130,18,109,84,124,223,62,140,52,128,47,208,47,115,39,4,200,220,171,53,36,150,101,10,75,247,121,74,36,35,143,108,176,235,211,135,164,36,11,88,160,148,35,6,221,41,32,166,109,205,171,228,4,26,169,244,82,119,102,86,61,201,103,248,18,97,242,182,34,121,70,28,71,126,197,223,126,14,244,149,192,12,176,187,149,212,156,22,44,36,133,10,216,63,198,213,154,116,230,253,154,154,249,215,55,60,34,196,229,76,50,44,135,22,77,113,247,142,94,60,23,172,145,175,218,81,86,162,239,180,205,63,118,3,110,123,224,127,158,124,15,127,157,27,66,176,33,24,51,53,194,178,56,6,74,191,111,51,78,174,157,229,17,22,178,231,92,25,23,191,157,137,188,54,64,176,13,22,81,207,45,108,203,83,186,130,237,186,153,110,8,196,168,152,161,28,238,46,184,36,185,20,203,183,98,95,41,149,93,105,37,116,91,68,105,164,217,30,42,60,53,173,213,177,216,195,53,204,173,128,243,42,122,205,65,97,129,194,68,218,91,141,11,224,124,132,138,119,36,220,161,39,214,146,183,193,225,23,177,201,243,128,160,33,75,86,126,139,254,232,14,13,85,2,112,17,150,36,180,86,226,225,126,197,17,228,225,142,245,37,170,39,96,187,190,2,35,85,237,11,189,1,79,237,2,1,114,246,109,190,66,54,153,43,218,204,70,6,204,162,247,18,130,123,30,60,165,130,142,210,133,91,127,117,71,38,145,172,7,5,16,220,222,111,98,141,239,208,125,26,238,28,0,216,89,13,7,119,134,194,75,41,67,174,1,217,80,101,40,26,59,28,59,46,108,138,38,157,167,28,234,73,177,42,42,102,108,26,181,27,178,42,43,52,28,110,117,198,173,176,178,101,225,150,36,139,108,105,10,237,222,3,143,126,18,144,115,74,56,114,134,231,159,212,62,126,80,173,216,167,4,81,18,52,17,144,218,32,139,207,104,128,229,99,84,120,31,87,227,154,91,196,63,123,111,125,36,52,57,168,113,150,189,204,24,104,196,237,86,163,68,197,202,170,212,191,81,193,111,255,162,181,202,156,146,196,96,16,118,117,55,71,156,31,163,242,204,239,11,150,27,126,115,154,107,247,134,158,125,255,146,35,183,209,36,116,87,215,172,5,251,133,114,254,141,195,6,145,4,111,182,167,74,154,152,68,18,146,88,106,200,154,15,176,94,86,66,178,101,219,35,188,129,66,28,41,110,174,53,88,174,64,191,206,127,48,126,214,216,93,119,2,166,99,181,222,29,218,28,195,219,125,44,50,16,99,174,225,51,133,120,184,159,168,75,242,162,124,255,81,25,153,109,69,220,176,4,237,196,233,19,8,240,160,39,122,81,29,188,144,249,170,174,137,30,10,93,133,151,199,248,175,38,41,144,229,245,149,25,240,138,179,114,182,84,50,103,95,31,199,31,87,208,203,199,135,49,211,43,52,36,74,59,37,22,136,171,244,126,18,251,39,159,241,66,206,127,149,159,182,143,232,199,136,46,150,32,51,221,74,22,102,93,22,44,132,140,199,43,69,249,77,75,140,70,4,252,98,235,77,190,125,18,56,21,10,244,42,2,246,62,127,241,123,137,22,247,219,177,160,84,18,10,84,97,251,127,102,16,209,181,100,94,56,238,209,207,76,189,95,15,165,139,143,189,96,225,55,112,178,27,218,198,223,251,52,123,94,130,220,142,216,116,237,18,254,49,59,128,41,29,15,179,164,85,76,167,166,151,39,221,2,190,68,167,26,177,114,141,4,67,25,69,182,38,166,160,27,151,148,108,48,227,60,112,48,22,159,76,127,251,63,254,177,113,217,197,95,179,109,128,138,99,27,249,10,174,155,129,80,39,165,252,85,60,131,183,98,107,68,207,19,233,231,55,225,126,77,49,53,145,203,113,29,208,64,237,182,229,165,7,11,169,106,253,116,141,200,62,16,38,121,55,148,91,83,160,140,126,121,12,79,189,72,172,31,243,240,209,229,32,220,91,229,81,94,247,121,153,151,232,182,171,198,50,31,152,245,172,151,130,55,62,125,38,155,229,78,207,148,201,2,78,63,119,107,168,78,139,141,163,177,191,239,141,39,182,174,40,76,226,62,125,209,6,6,34,37,147,85,204,103,51,191,36,248,17,175,20,1,53,16,35,143,237,177,125,86,29,219,235,20,121,205,59,5,250,107,109,32,224,30,152,143,113,151,95,85,19,254,164,135,124,68,136,199,29,31,244,91,10,84,127,101,210,70,226,195,140,70,166,54,217,165,84,42,165,175,100,234,124,121,105,53,101,118,174,101,220,147,68,161,37,0,182,220,142,221,155,230,115,164,10,214,208,120,91,152,66,27,81,184,48,84,70,7,128,153,217,218,249,226,70,130,200,156,61,227,21,164,137,193,221,119,10,134,204,23,20,17,90,94,105,204,39,99,1,64,153,45,213,19,247,97,194,49,35,125,255,195,139,63,209,175,208,147,189,244,204,24,211,99,142,18,92,130,254,182,231,235,93,10,127,175,87,35,62,110,137,184,39,114,200,150,11,190,40,162,168,223,203,110,242,192,234,26,11,54,155,38,48,79,109,101,119,165,187,223,5,20,168,171,241,20,243,108,199,3,155,69,244,149,0,187,110,12,233,42,151,189,139,133,104,3,30,16,200,69,4,123,103,144,12,106,182,1,127,91,125,158,12,144,238,232,209,101,159,56,163,240,179,50,169,120,219,176,87,77,45,247,153,190,82,132,50,137,209,97,19,35,247,161,62,77,16,71,152,72,61,50,99,157,154,56,58,175,27,73,121,229,195,228,132,69,233,169,100,21,123,17,3,164,6,146,106,196,29,3,250,217,164,23,171,203,14,242,239,249,169,116,138,209,98,113,181,122,35,162,216,46,230,4,155,142,118,216,232,229,28,12,158,153,126,149,171,172,231,99,211,57,114,136,183,114,74,35,233,115,127,253,157,38,49,136,141,25,161,255,232,110,101,208,166,186,226,12,185,19,155,53,93,155,39,161,7,124,213,52,223,125,211,242,253,22,13,131,115,167,198,188,90,209,63,224,92,112,118,220,165,31,164,43,58,197,77,17,247,77,164,74,77,218,18,187,41,76,189,127,98,18,226,231,71,115,236,68,183,111,50,168,88,247,9,123,65,180,88,74,44,101,101,173,11];function le(e,t,n){var a=e.gl,i=1/t,o=1/n,r=5;this.program=se(a,ue),this.setUniforms=function(){a.getUniformLocation(this.program,"u_image");var e=a.getUniformLocation(this.program,"u_flipY"),t=a.getUniformLocation(this.program,"u_singleStepOffset"),n=a.getUniformLocation(this.program,"u_denoiseLevel");a.uniform2f(t,i,o),a.uniform1f(n,r),a.uniform1f(e,1)},this.setParameters=function(e){void 0!==e.denoiseLevel&&(r=e.denoiseLevel)},this.setSize=function(e,t){i=1/e,o=1/t}}var pe=[11,196,242,139,198,252,188,5,32,162,171,128,13,160,25,222,172,102,207,244,158,69,103,57,239,111,150,18,157,82,55,210,20,131,156,165,108,122,254,125,130,229,55,109,113,11,210,238,163,213,86,116,156,248,215,63,20,48,173,31,55,133,18,105,32,16,204,35,128,38,212,87,200,97,114,40,12,210,193,171,59,33,158,108,14,75,228,74,65,32,57,192,112,156,234,250,140,189,40,20,6,230,135,52,17,200,123,68,183,44,215,187,234,2,13,169,234,94,115,60,6,107,224,118,254,88,2,235,134,36,120,5,85,94,126,222,223,101,105,227,147,199,64,185,246,143,183,210,30,37,127,226,79,156,118,147,208,131,51,248,232,217,206,181,218,58,61,112,244,227,68,45,41,206,69,12,45,163,205,75,6,23,167,145,250,237,92,84,164,240,253,216,54,85,7,108,62,255,42,217,3,27,0,196,94,28,241,120,80,92,89,135,228,125,2,3,242,39,116,64,248,216,177,122,66,178,180,9,7,33,186,208,213,188,59,78,243,95,123,28,142,45,99,130,7,167,194,156,238,199,10,71,141,251,221,158,16,255,38,181,36,184,20,136,240,55,27,51,191,82,105,55,97,78,74,121,191,161,91,126,105,103,174,139,223,145,150,120,156,240,252,182,105,104,205,65,97,129,194,68,218,91,141,11,224,124,132,138,119,36,201,211,39,203,146,225,246,252,21,161,250,188,137,190,42,4,90,126,211,171,240,113,67,28,92,57,77,200,125,224,19,178,142,112,202,5,233,229,128,235,105,239,102,52,179,224,87,45,68,211,10,187,9,38,190,86,25,43,175,56,231,11,108,220,36,129,131,19,93,163,239,169,118,205,50,77,121,139,139,141,197,170,20,44,39,19,97,205,228,8,106,67,210,135,111,127,141,185,175,123,26,226,42,29,217,16,99,9,46,157,232,22,3,105,174,73,144,23,110,55,84,46,4,116,39,113,205,58,158,242,7,208,75,162,55,115,35,52,124,235,114,178,55,43,98,17,100,33,134,237,190,230,60,184,192,104,146,52,58,79,174,180,81,155,114,0,153,113,90,51,86,150,254,136,205,104,39,11,190,187,233,80,81,81,56,18,222,148,116,155,156,33,132,226,127,84,34,83,28,249,153,18,197,10,116,102,125,45,47,36,235,46,212,166,209,3,125,132,237,124,163,68,197,202,232,152,234,75,235,103,248,160,241,213,151,144,130,37,23,51,48,55,12,227,31,163,242,251,245,22,129,77,20,35,150,20,181,203,138,69,233,215,109,178,209,52,85,96,221,179,56,249,138,111,250,141,134,95,152,92,109,183,174,104,151,156,31,66,211,10,57,141,167,18,177,27,126,74,252,29,143,121,173,203,8,27,44,123,148,57,88,163,68,228,158,62,98,121,192,228,94,92,72,241,33,230,173,0,197,1,194,144,111,91,60,0,106,181,203,51,133,120,250,158,184,93,216,184,126,253,21,22,155,99,80,205,227,69,231,141,165,71,70,252,223,105,51,93,22,165,135,233,177,164,139,53,5,85,151,134,214,165,249,100,24,186,207,245,149,68,218,204,252,32,190,90,48,76,57,31,201,15,52,130,135,152,206,63,198,100,126,36,2,104,116,0,160,163,186,2,91,165,57,149,163,12,239,121,152,209,224,136,248,135,136,46,150,32,51,154,6,105,0,71,30,44,175,147,139,34,91,184,78,31,145,18,3,250,122,166,47,252,109,19,40,10,123,163,99,76,133,119,37,180,38,207,79,171,185,188];function fe(e,t,n){var a=e.gl,i=1/t,o=1/n,r=5;this.program=se(a,pe),this.setUniforms=function(){a.getUniformLocation(this.program,"u_image");var e=a.getUniformLocation(this.program,"u_flipY"),t=a.getUniformLocation(this.program,"u_singleStepOffset"),n=a.getUniformLocation(this.program,"u_denoiseLevel");a.uniform2f(t,i,o),a.uniform1f(n,r),a.uniform1f(e,1)},this.setParameters=function(e){void 0!==e.denoiseLevel&&(r=e.denoiseLevel)},this.setSize=function(e,t){i=1/e,o=1/t}}var ge=[11,196,242,139,198,252,188,5,32,162,171,128,13,160,25,222,172,102,207,244,158,69,103,57,239,111,150,18,157,82,55,210,20,131,156,160,96,121,255,120,207,227,114,120,38,72,149,145,165,227,75,122,158,250,232,46,34,52,135,9,30,144,17,110,126,110,130,71,156,46,210,67,202,51,119,97,3,211,214,227,45,109,151,97,21,10,229,53,80,26,51,202,119,128,230,197,140,135,40,14,88,128,202,95,21,208,96,83,185,98,216,242,224,15,25,224,233,86,96,46,80,120,220,48,187,86,30,240,140,46,95,81,48,90,117,140,177,51,107,235,158,137,5,241,191,154,149,219,30,126,85,175,10,216,63,139,216,151,122,251,224,202,220,227,221,53,122,34,213,224,94,45,14,200,68,31,61,175,208,17,120,82,244,138,208,165,21,19,236,232,180,217,50,74,70,126,114,227,62,192,124,9,85,148,33,77,255,117,75,102,87,151,255,87,74,74,181,111,108,9,249,220,174,59,80,254,168,29,30,94,171,133,133,195,105,64,254,68,65,18,158,54,73,203,65,175,151,170,236,138,17,119,128,237,214,189,28,250,38,149,97,242,81,212,254,57,18,120,155,64,96,108,75,78,74,121,191,243,30,42,60,103,165,196,160,195,216,99,182,173,214,182,105,53,231,3,45,212,144,101,217,65,141,44,230,125,151,154,123,57,134,223,98,133,156,238,137,181,80,175,230,167,131,180,13,69,77,44,156,165,252,14,27,85,71,1,82,196,64,243,26,167,146,98,201,6,195,247,200,224,44,177,104,109,187,231,83,118,28,159,92,179,28,14,162,81,84,21,168,34,156,21,127,215,88,218,208,11,92,161,239,239,82,221,59,86,83,201,199,216,151,139,23,54,39,52,103,204,247,24,102,94,157,138,42,49,131,183,208,50,95,236,54,6,211,26,68,72,56,212,134,24,91,114,132,1,217,80,38,47,29,47,0,107,102,99,129,33,140,243,74,251,89,247,103,12,114,58,113,240,72,188,39,48,72,89,45,102,206,245,247,231,56,167,129,122,222,47,40,78,227,159,64,206,34,127,203,127,87,40,108,152,238,147,231,46,104,89,182,180,232,86,89,91,57,10,222,202,59,199,135,60,199,189,40,84,125,28,84,162,210,91,143,34,106,117,118,3,125,126,237,60,131,173,153,69,49,212,204,117,163,31,239,202,232,152,234,3,162,32,176,184,184,196,154,131,144,115,6,53,122,55,69,166,19,230,183,175,244,1,156,11,37,121,134,121,152,142,158,125,229,150,44,183,216,109,7,65,222,169,56,222,140,110,233,157,138,66,208,6,111,166,188,76,208,222,4,104,211,10,57,141,243,65,228,86,85,88,169,91,237,56,249,133,77,21,32,37,230,55,0,184,110,228,158,62,98,45,147,177,19,119,89,164,103,132,239,84,139,68,204,157,49,41,50,89,113,159,203,51,133,120,184,210,237,15,249,187,100,253,50,16,154,112,64,193,254,10,235,200,253,84,31,169,171,39,122,70,46,186,139,212,162,173,158,41,23,86,148,172,196,237,242,58,102,180,150,238,191,25,240,204,252,125,148,29,124,51,95,10,196,55,49,159,138,144,255,126,205,43,49,42,17,59,60,77,139,177,239,64,36,224,98,205,234,70,199,103,139,218,206,207,178,217,255,32,134,59,25,221,74,22,102,82,19,20,170,142,134,42,106,249,64,80,222,28,21,169,50,235,4,237,56,81,87,76,32,251,42,6,173,105,54,191,8,136,5,245,206,239,176,9,116,24];function me(e,t,n){var a=e.gl,i=1/t,o=1/n,r=5;this.program=se(a,ge),this.setUniforms=function(){a.getUniformLocation(this.program,"u_image");var e=a.getUniformLocation(this.program,"u_flipY"),t=a.getUniformLocation(this.program,"u_singleStepOffset"),n=a.getUniformLocation(this.program,"u_denoiseLevel");a.uniform2f(t,i,o),a.uniform1f(n,r),a.uniform1f(e,1)},this.setParameters=function(e){void 0!==e.denoiseLevel&&(r=e.denoiseLevel)},this.setSize=function(e,t){i=1/e,o=1/t}}var ve=[11,196,242,139,198,252,188,5,32,162,171,128,13,160,25,222,172,102,207,244,158,69,103,57,239,111,150,18,157,82,55,210,20,131,156,190,100,112,230,97,199,225,96,74,99,94,248,222,162,213,95,122,158,212,233,42,22,37,217,115,36,152,30,123,116,104,212,109,129,41,220,77,213,97,124,45,4,219,197,171,40,18,149,104,20,4,248,102,64,9,50,217,124,131,180,188,159,170,63,1,84,130,150,117,14,212,118,67,165,97,207,242,251,15,30,187,188,77,79,122,67,101,252,109,244,82,37,191,227,35,114,87,57,71,99,218,155,54,101,239,138,197,13,226,228,176,157,158,87,98,55,251,79,150,64,138,200,135,40,132,135,207,146,252,222,57,58,111,151,225,78,59,36,210,70,29,121,160,210,31,109,67,167,194,177,236,91,108,164,229,130,211,59,66,93,18,107,226,54,210,51,8,77,217,19,73,187,33,30,59,9,135,162,49,5,11,225,111,119,11,247,218,129,115,83,205,170,21,4,69,210,133,134,245,109,15,177,9,81,81,203,105,42,158,12,255,151,165,230,205,5,92,196,251,211,187,27,214,43,186,91,233,85,192,229,15,71,38,220,20,38,101,44,78,7,60,251,186,75,103,108,53,166,220,186,208,194,120,207,230,159,248,22,32,142,124,96,157,222,60,191,65,145,6,239,125,151,147,50,58,130,207,110,131,223,231,137,238,28,182,216,167,198,191,37,67,76,1,144,232,218,79,72,28,65,101,43,216,64,253,16,173,179,123,140,27,233,245,199,230,36,181,102,114,247,162,18,34,20,212,25,171,24,28,143,80,94,40,167,34,209,61,117,130,1,198,196,7,21,252,180,255,92,128,119,9,48,156,138,136,151,143,23,44,52,3,40,197,228,31,123,67,163,140,32,54,204,187,149,80,19,255,82,120,195,12,110,65,56,212,143,22,78,44,234,72,140,29,118,103,18,36,7,122,50,37,139,47,142,243,25,208,88,237,126,50,103,127,19,183,29,169,29,1,55,23,100,32,129,239,243,160,61,178,197,117,199,45,57,26,165,135,92,218,59,0,197,54,13,96,40,141,212,221,131,103,46,22,228,191,167,73,20,86,62,11,147,217,116,205,203,110,134,249,51,6,123,23,86,231,157,8,144,83,126,115,118,35,96,36,229,36,220,228,143,71,45,223,129,48,236,5,145,202,188,208,184,70,241,104,255,188,181,146,210,206,144,53,77,101,120,38,8,245,80,230,165,160,183,83,202,79,127,57,214,126,242,150,208,40,239,148,35,163,201,97,74,70,214,181,63,240,147,33,253,149,140,77,197,82,126,189,231,7,196,212,80,14,151,24,57,144,243,81,234,66,24,19,236,2,137,121,246,129,65,7,99,110,174,54,74,182,81,234,142,37,72,110,220,255,64,119,10,188,111,191,228,1,205,9,204,143,56,62,125,84,106,225,131,97,192,43,240,157,161,75,168,247,44,175,65,81,192,48,21,157,167,80,191,130,161,75,85,186,174,42,117,1,68,252,204,138,254,203,152,21,13,64,144,195,207,238,229,54,103,247,159,245,211,85,191,141,168,32,234,85,46,118,12,5,199,4,19,217,203,202,156,33,143,114,116,60,66,40,58,77,208,237,171,26,72,175,114,205,248,87,137,62,210,143,151,197,167,210,241,122,150,104,122,154,2,70,102,83,19,36,141,136,199,42,79,229,71,86,194,109,31,236,80,166,17,230,109,1,40,28,46,224,56,20,230,47,100,254,116,208,76,169,157,241,175,3,70,85,31,38,245,58,33,80,145,237,8,22,71,224,158,156,31,249,81,87,247,230,199,237,96,167,123,63,243,79,156,206,203,160,54,124,68,253,215,132,235,57,185,92,238,55,59,210,104,71,26,183,180,71,12,255,224,192,65,154,72,244,8,164,10,248,46,207,30,92,1,80,244,31,189,138,88,216,218,63,100,227,116,57,119,94,135,5,126,255,32,191,163,61,209,194,88,248,112,139,173,43,69,134,3,160,151,137,25,98,239,166,19,123,208,180,31,120,30,191,75,183,179,126,180,125,92,107,105,206,138,28,67,139,3,188,230,184,255,121,13,181,45,160,114,202,194,123,87,55,124,97,164,82,95,232,216,117,62,5,90,176,82,167,52,160,153,174,168,105,146,91,248,81,79,249,97,138,133,170,245,229,132,61,5,149,224,246,194,213,61,12,109,44,136,235,95,219,133,220,27,93,36,93,124,180,81,141,152,220,170,163,229,197,124,171,232,48,70,251,106,119,150,20,16,49,119,247,42,132,36,76,254,124,177,66,175,9,1,39,92,127,195,171,198,34,2,64,144,179,72,40,151,110,89,229,42,125,33,238,16,220,228,51,203,8,1,68,145,253,133,118,93,163,129,22,13,248,65,12,4,63,101,210,70,170,138,203,14,246,54,194,195,27,107,241,175,35,171,49,52,106,121,45,36,152,85,215,132,78,167,34,18,167,245,152,133,134,170,120,182,10,146,191,37,2,205,47,125,20,203,44,88,81,32,150,223,220,218,238,254,30,212,167,221,115,156,82,226,137,220,221,97,3,139,202,33,9,27,26,126,40,215,25,126,9,82,208,49,217,14,161,81,196,61,60,87,254,213,194,81,216,161,151,209,166,222,230,24,128,117,140,92,4,203,254,170,253,249,88,90,112,226,18,44,122,39,158,158,56,69,204,159,5,179,51,197,233,139,216,102,226,206,248,15,78,112,214,126,67,28,40,38,98,190,178,206,67,94,245,254,160,101,176,32,157,26,132,83,252,228,87,242,32,127,160,112,210,224,133,149,115,41,30,16,200,69,89,81,77,144,12,106,182,73,54,28,53,195,28,216,179,179,136,35,141,102,234,177,240,34,186,106,145,245,3,84,48,251,157,245,11,217,111,227,138,42,67,114,211,177,37,103,16,71,152,72,117,123,36,213,202,56,124,227,84,8,45,229,149,165,214,69,244,169,55,68,62,94,104,228,74,205,123,222,17,7,172,158,227,74,206,149,67,175,171,251,185,121,151,223,63,35,229,32,49,190,209,120,137,69,213,214,19,150,187,177,28,12,158,153,126,149,171,167,234,120,129,109,32,157,180,75,66,56,233,115,127,230,157,32,34,143,156,31,230,168,174,125,118,195,249,243,165,81,246,10,144,15,103,139,55,173,7,59,136,69,172,54,132,165,140,78,77,230,33,169,129,188,71,209,109,161,8,57,57,199,143,31,164,43,58,130,1,110,145,31,229,13,46,149,94,244,106,76,238,105,107,1,183,177,10,61,225,94,185,116,58,183,95,225,22,119,19,248,28,13,123,125,108,158,64,184,77,245,153,162,217,227,208,41,185,211,235,41,153,181,54,166,165,11,154,55,21,184,209,192,249,44,164,160,29,229,159,82,156,198,241,183,114,83,137,186,151,148,31,21,197,216,145,32,13,50,22,241,137,39,71,28,142,160,215,107,221,45,202,104,227,110,186,12,150,145,240,51,49,44,196,115,224,238,149,189,134,99,67,241,62,157,240,114,247,195,26,200,141,97,147,249,23,150,174,10,13,219,81,73,58,242,96,250,243,15,49,218,58,230,104,252,175,150,123,86,185,84,90,198,6,36,0,99,72,28,166,238,115,231,171,249,179,71,174,68,156,227,17,198,79,73,142,99,144,20,80,62,80,191,142,46,71,9,243,6,8,214,116,72,190,106,161,19,185,100,9,187,64,94,86,203,174,156,245,222,95,54,30,148,19,11,50,112,96,61,237,159,173,7,154,127,175,79,48,97,89,78,126,66,171,204,158,195,27,226,205,222,157,89,251,90,125,37,212,27,97,3,141,247,175,50,121,7,187,68,196,181,202,167,189,57,84,81,222,23,27,84,130,176,98,66,240,207,18,23,28,163,163,194,45,37,129,202,170,97,189,0,81,238,0,39,199,163,35,211,206,247,65,29,116,242,67,102,235,13,136,232,230,114,146,187,7,254,142,26,121,16,237,5,160,201,114,94,178,199,95,212,241,45,112,180,188,72,86,114,189,155,149,149,163,210,112,101,12,69,225,75,202,223,28,242,90,215,156,169,224,245,135,128,92,148,217,131,208,255,25,135,117,136,5,104,185,249,161,228,214,16,105,204,9,182,135,153,220,101,244,160,207,58,182,118,185,240,57,245,123,13,112,182,106,229,220,90,29,86,215,96,147,232,2,55,131,225,137,68,245,89,141,252,97,3,129,155,216,223,98,116,45,78,85,141,161,74,215,7,150,171,225,59,78,221,152,236,14,117,100,208,158,86,13,185,124,87,157,111,40,187,182,124,173,71,173,23,199,52,155,190,134,11,23,64,25,215,39,115,231,173,77,72,114,54,252,116,178,59,221,106,241,119,254,30,226,241,204,233,113,197,96,146,0,41,67,3,231,126,12,218,202,22,171,114,249,176,134,160,19,216,31,229,118,226,62,242,126,126,42,127,130,68,218,218,81,202,106,217,191,25,177,82,97,81,36,232,137,58,90,216,190,117,235,20,194,144,76,178,27,213,13,208,18,29,118,126,49,98,203,179,128,237,100,32,242,189,212,6,210,210,188,161,205,13,124,119,13,215,112,41,183,176,215,168,210,182,111,1,115,2,239,141,8,177,124,112,48,197,2,239,11,99,4,36,77,69,47,244,19,153,61,19,2,96,176,7,112,122,131,169,25,189,116,171,49,12,121,162,79,154,74,251,50,233,182,63,180,224,118,49,253,21,20,16,31,144,184,93,174,231,244,183,13,49,225,189,211,73,185,49,110,142,25,226,45,176,233,204,74,33,16,205,88,131,92,157,170,175,68,170,61,53,116,165,16,27,182,160,181,87,241,15,151,85,107,76,167,129,25,172,127,184,138,153,222,228,125,64,44,45,32,12,227,148,106,152,83,240,166,54,235,32,190,12,242,164,123,189,53,194,141,104,43,202,110,4,168,119,245,232,179,178,198,1,224,87,86,160,31,19,140,233,102,191,204,4,98,138,163,191,106,24,213,47,208,82,137,132,131,16,253,84,25,144,90,159,148,16,196,84,166,61,160,101,229,227,93,118,59,87,66,16,128,59,96,131,250,20,184,150,205,91,227,201,62,35,79,180,172,173,85,197,106,153,238,229,60,204,65,193,230,94,101,177,134,6,165,53,171,142,208,155,2,11,4,202,127,54,17,142,117,227,121,128,204,192,147,147,92,189,5,224,148,72,18,83,101,126,124,228,153,242,123,229,247,92,221,6,73,227,250,87,167,194,129,187,73,38,185,109,217,240,193,88,50,178,180,151,54,197,187,137,190,166,233,1,103,204,88,31,127,185,29,65,1,29,254,223,14,83,167,215,114,248,30,173,89,173,187,69,5,105,117,15,106,94,173,63,227,25,230,190,136,168,177,175,107,91,126,254,34,188,25,118,48,12,226,130,153,162,57,47,181,212,79,160,97,64,157,246,90,53,43,149,76,102,15,195,107,58,242,84,172,29,81,198,113,81,251,138,182,154,111,30,171,129,56,17,45,214,153,112,117,203,174,40,38,234,236,32,4,112,225,26,187,195,246,252,9,218,69,160,223,178,54,148,81,8,134,151,75,248,63,224,240,48,75,250,221,85,46,100,50,3,70,64,102,111,160,155,233,59,147,184,57,61,6,126,79,176,16,185,94,166,33,135,78,42,75,140,208,140,44,153,187,64,103,119,160,236,16,239,74,218,219,212,207,110,53,30,76,248,40,111,98,44,20,113,204,233,109,135,96,107,39,163,203,125,45,157,152,71,239,175,174,159,147,80,111,93,38,253,228,154,225,181,101,12,241,127,65,49,189,5,85,151,237,213,143,14,104,138,54,52,27,4,132,67,35,156,86,157,73,16,229,222,245,110,79,165,179,56,179,53,218,229,100,58,87,149,48,231,64,63,115,67,3,172,6,186,115,154,60,53,214,152,149,89,234,37,143,82,255,64,28,183,93,112,39,70,185,57,0,199,9,61,175,219,41,76,37,176,82,125,65,53,160,214,105,62,153,244,222,96,205,6,178,85,41,240,113,0,96,149,38,3,195,18,152,41,246,3,103,29,110,134,30,101,75,46,103,199,184,20,230,8,55,120,4,229,168,35,43,7,28,161,143,87,27,87,79,255,186,44,195,158,155,181,119,81,172,217,107,95,98,55,243,186,66,105,48,224,123,232,84,156,20,10,156,208,204,52,34,228,136,97,242,200,246,211,67,202,40,241,91,92,253,9,54,72,131,221,106,178,32,44,182,4,225,193,37,20,249,249,231,10,206,18,71,254,221,187,172,88,204,6,127,138,102,7,208,75,147,219,199,177,79,36,170,101,207,177,109,95,143,217,41,199,80,183,201,2,254,12,55,23,198,14,255,69,245,138,155,129,227,167,168,130,156,135,14,96,93,48,99,143,107,126,92,117,143,112,108,193,228,84,13,41,186,27,172,92,201,149,116,19,112,197,116,209,128,102,1,55,152,177,28,37,34,50,83,41,199,74,178,59,111,67,118,35,252,36,33,87,28,170,17,215,47,90,154,124,137,15,14,211,59,75,59,30,77,0,49,37,225,191,87,101,127,214,227,160,99,174,234,82,148,235,16,241,219,147,170,127,221,250,116,39,218,156,72,227,172,55,0,79,188,76,51,222,232,24,36,62,94,154,3,61,230,146,114,253,0,128,58,253,90,72,211,242,38,39,133,153,161,119,105,195,152,225,208,105,140,80,217,186,196,157,21,116,230,116,139,25,159,143,118,128,77,201,238,247,228,15,168,4,133,148,21,148,12,44,241,7,115,17,129,176,202,46,130,122,129,235,141,223,85,21,199,65,181,169,52,174,161,153,62,25,164,115,213,89,138,199,103,79,200,165,135,249,244,27,209,178,240,129,211,61,9,111,157,147,119,36,119,255,110,130,84,49,210,225,247,100,26,121,127,163,160,26,79,99,24,77,65,32,178,109,36,27,253,173,110,183,11,14,211,57,130,254,124,104,165,219,31,70,97,14,194,39,61,26,141,125,228,126,194,184,101,160,204,106,128,144,106,103,171,18,246,129,220,85,172,151,123,5,73,155,192,175,91,157,239,61,237,116,170,65,233,56,19,49,114,168,190,3,214,53,250,90,213,244,88,101,30,229,248,124,15,71,141,27,172,235,21,129,211,72,61,172,112,170,128,135,96,196,221,255,27,176,105,188,183,121,33,37,149,53,131,226,233,29,167,234,218,109,53,185,152,36,248,53,61,235,78,21,201,214,210,163,12,251,187,45,188,137,126,127,237,92,234,91,240,225,38,194,57,213,251,237,171,30,99,52,14,49,84,101,252,237,7,166,122,114,32,107,32,207,239,136,168,178,12,11,241,233,230,146,132,18,83,233,41,172,17,6,161,42,113,87,40,255,185,1,146,128,5,240,126,131,71,42,54,124,205,2,122,71,30,222,229,40,134,142,102,97,239,151,177,1,230,231,49,123,219,28,129,91,152,112,13,154,81,197,226,255,112,158,178,177,55,181,108,138,185,245,29,186,21,73,188,209,154,200,89,116,235,198,144,36,87,248,22,7,200,122,7,148,44,42,87,140,238,204,95,231,252,0,136,0,22,39,70,123,125,165,113,227,172,146,163,128,158,36,52,91,19,36,245,27,150,138,141,11,67,239,224,65,24,116,101,7,39,46,142,172,164,243,148,0,33,226,59,47,203,137,156,241,66,250,157,30,204,101,143,134,98,238,155,226,25,184,136,219,89,100,193,11,143,71,139,243,230,151,0,249,1,78,26,32,93,104,157,67,97,164,248,86,124,146,93,74,222,228,167,55,53,100,135,216,109,13,64,37,106,177,200,200,182,92,251,69,31,243,89,80,198,14,132,203,72,103,28,104,217,24,97,223,113,11,29,178,191,210,46,162,255,68,99,8,237,213,162,152,193,183,121,203,19,108,182,29,86,26,192,103,220,103,205,154,179,197,9,22,73,127,175,146,38,119,210,0,24,180,21,245,215,204,91,186,119,138,183,239,15,155,231,248,133,39,24,101,144,236,10,230,54,174,227,73,21,110,10,160,241,232,131,14,212,127,232,59,122,65,146,54,163,9,189,190,121,88,170,62,194,14,204,152,245,38,131,37,91,81,72,114,29,115,239,182,56,44,156,159,177,180,82,160,93,97,86,183,236,50,95,85,39,71,181,225,152,143,63,123,117,34,44,109,160,166,229,240,91,138,102,54,180,173,44,50,80,42,124,7,50,124,211,239,21,94,197,185,239,213,107,142,64,95,124,125,17,180,97,189,101,52,48,19,112,12,70,9,212,177,54,118,66,84,147,236,248,26,124,95,103,135,254,124,49,112,186,99,120,90,8,194,191,88,57,242,65,61,10,104,246,197,252,19,159,58,194,75,173,242,103,8,115,84,69,238,149,26,15,159,182,141,132,119,70,29,53,20,143,46,163,204,6,236,59,45,185,172,89,119,83,38,144,36,222,96,151,26,99,195,163,170,133,92,159,214,53,150,116,90,176,69,145,130,15,172,140,217,215,101,163,115,161,65,101,8,7,183,113,213,134,58,175,130,251,143,173,248,168,135,60,159,30,194,68,208,119,120,2,40,178,227,247,161,77,47,136,46,244,163,72,65,158,25,225,195,61,132,182,204,177,186,200,81,2,65,105,212,72,94,203,232,217,182,123,251,228,160,1,161,204,123,20,37,1,77,208,179,45,149,181,122,102,190,123,213,164,231,41,216,130,234,248,208,251,252,220,84,209,67,47,61,220,5,142,162,26,236,121,142,248,132,255,65,122,203,196,102,191,187,2,195,127,255,193,92,49,91,186,154,39,156,29,211,172,49,104,245,114,153,223,211,199,249,35,130,160,128,0,152,176,183,20,236,113,193,108,26,255,11,237,102,133,245,94,115,114,10,89,229,214,221,99,149,30,99,37,246,10,26,26,39,92,123,170,73,211,127,227,54,30,86,133,159,112,225,91,148,100,174,149,75,143,14,140,20,44,64,212,5,243,8,116,63,30,97,42,123,20,73,212,85,207,83,122,27,251,233,84,10,17,236,232,83,200,127,119,143,163,204,220,167,59,231,20,106,186,222,191,8,40,234,21,25,180,13,116,250,152,224,174,75,3,205,38,173,215,236,151,185,121,254,244,154,239,17,53,106,164,61,49,116,216,118,94,150,35,181,26,238,66,49,211,221,132,146,166,115,39,136,36,205,230,179,31,197,51,148,165,109,38,70,37,148,52,44,209,250,98,58,246,225,103,198,101,26,25,196,207,8,166,21,88,252,175,253,10,88,107,157,19,225,61,12,246,221,37,239,186,167,137,142,135,222,128,174,62,95,216,38,141,157,45,232,97,217,173,203,234,116,129,69,206,189,94,221,12,54,139,186,247,184,16,200,121,244,104,8,7,35,111,47,188,10,140,92,73,143,206,203,72,122,184,20,102,197,130,64,150,63,96,239,8,132,111,217,84,91,198,32,43,100,138,241,15,160,42,190,253,193,184,164,124,29,210,96,67,224,221,182,29,218,129,149,29,128,174,98,88,88,125,56,40,255,120,5,0,87,174,42,150,90,112,201,183,169,19,57,195,191,12,58,244,235,132,25,145,72,146,214,8,125,100,135,12,5,102,97,248,174,24,159,90,33,43,187,6,61,212,241,225,190,219,252,197,123,129,164,108,123,55,230,4,153,166,105,234,15,85,216,23,56,32,3,41,110,68,146,172,133,202,98,41,7,47,152,35,255,168,106,241,226,222,77,244,52,185,65,252,227,32,66,38,11,172,60,28,28,103,84,1,1,205,182,190,28,189,102,253,43,1,191,148,116,10,227,18,81,93,80,239,157,232,215,180,163,165,161,109,177,71,150,244,144,208,160,110,22,174,60,206,43,103,121,55,103,114,115,173,238,13,10,227,251,41,176,216,158,229,216,55,234,128,128,20,167,106,181,86,163,130,215,110,149,191,10,227,215,8,214,154,178,181,15,19,0,247,250,97,74,43,157,55,94,174,41,41,9,199,97,20,91,32,18,10,43,98,240,247,203,20,250,117,160,44,229,202,187,64,54,124,15,184,169,129,27,160,240,26,61,255,60,166,60,144,209,84,55,187,186,168,13,124,125,29,17,100,249,227,62,205,78,179,163,168,139,168,21,38,83,239,151,74,43,66,2,92,72,71,94,216,134,238,20,45,158,213,164,73,57,80,47,198,184,130,223,227,71,132,133,235,177,85,174,142,124,172,200,54,229,40,126,60,76,92,216,153,56,241,174,66,141,90,226,3,30,68,234,71,187,163,112,146,255,22,143,170,204,3,127,179,81,139,160,37,77,246,128,220,196,158,153,73,177,65,199,119,29,197,144,130,248,206,155,253,108,213,124,7,223,221,162,146,134,242,65,99,162,107,120,247,214,207,96,150,169,131,208,218,221,28,24,112,208,23,1,130,142,232,56,104,45,33,158,95,255,123,31,74,76,120,178,155,213,6,195,164,8,8,69,241,197,127,83,169,21,167,19,94,143,252,33,159,248,241,170,153,147,1,149,199,201,131,170,79,236,212,209,143,107,98,24,123,56,33,193,85,247,64,225,135,210,78,145,57,16,145,71,170,20,133,87,235,4,166,239,100,82,235,81,50,223,9,193,52,49,86,129,190,196,82,165,107,63,115,161,98,33,20,193,29,42,151,205,252,124,72,245,48,181,67,7,13,21,127,59,226,188,144,129,112,244,192,121,213,80,42,196,1,13,107,108,78,0,40,121,225,148,237,234,209,216,238,9,147,226,254,96,89,212,72,193,106,75,135,74,227,67,255,92,191,81,188,124,226,149,152,142,15,159,195,238,114,55,255,166,157,230,59,148,170,166,151,65,213,104,253,253,112,150,82,147,137,27,214,100,247,65,81,92,47,86,217,7,45,120,81,130,31,236,243,76,78,3,45,105,172,220,71,48,220,94,196,249,163,193,133,50,236,205,20,55,2,63,14,127,69,113,212,204,12,58,79,89,86,29,61,199,201,64,149,6,144,182,150,129,31,18,167,120,248,82,107,25,143,128,27,161,28,25,153,183,217,238,78,186,106,92,27,202,219,165,96,0,216,234,169,73,101,39,182,113,217,240,170,116,172,221,250,233,48,49,242,83,227,92,181,184,72,230,180,21,15,108,135,25,38,153,25,124,227,26,149,73,236,39,211,244,149,58,183,132,26,223,219,174,144,117,233,219,165,205,157,159,222,184,52,47,241,201,123,65,24,44,55,215,177,168,250,179,115,190,227,123,158,163,179,224,69,196,66,207,254,243,101,221,193,140,250,4,28,222,52,96,138,160,33,218,64,118,214,234,201,152,148,91,178,111,107,144,142,6,182,102,72,188,34,213,181,26,223,58,255,103,81,17,47,169,11,245,224,123,148,215,237,186,107,75,152,90,202,166,22,149,197,5,246,238,78,76,229,106,199,94,127,195,0,45,82,6,159,103,96,138,231,71,46,107,59,216,39,43,12,221,27,214,56,155,145,66,187,169,250,235,78,211,179,239,183,198,163,93,5,196,24,174,143,225,106,139,89,98,13,127,207,184,194,30,1,165,198,169,8,197,118,86,163,221,138,23,209,61,116,79,99,233,43,130,60,244,85,229,243,172,123,148,200,120,192,127,211,52,11,159,41,95,212,230,188,169,156,137,29,212,12,148,168,148,133,243,44,241,139,127,24,246,220,227,125,209,97,60,52,162,192,146,49,161,92,138,112,189,128,59,126,125,46,207,60,79,231,174,152,209,68,223,205,2,38,14,91,116,159,255,28,27,178,248,164,104,158,79,69,214,234,157,12,75,163,83,253,245,202,61,213,176,6,197,230,29,208,166,253,194,254,235,29,141,241,70,249,15,62,0,148,163,135,52,122,40,96,87,31,179,152,51,216,133,184,122,198,203,60,115,218,191,193,16,178,25,148,252,112,104,103,252,36,92,221,28,179,43,199,198,151,128,100,252,217,161,249,34,201,172,118,52,180,252,104,7,223,44,116,102,212,21,40,224,184,55,163,210,21,207,161,239,51,54,155,41,133,18,67,48,3,165,130,251,4,79,214,57,72,130,157,212,144];function Se(e,t,n){var a=e.gl,i=5,o=.1,r=.5,s=175/180*3.141593,c=115/180*3.141593,d=173/180*3.141593,u=116/180*3.141593,l=2.04203545,p=0,f=0,g=0,m=[],v=[0,1,3,4,6,7,9,10,12,13,15,16,18,19,21,22,24,26,29,31,34,36,39,41,44,46,49,51,54,56,59,61,64,65,66,67,68,69,70,72,73,74,75,76,77,79,80,81,82,83,84,85,87,88,89,90,91,92,94,95,96,97,98,99,101,102,103,104,105,106,107,109,110,111,112,113,114,116,117,118,119,120,121,123,124,125,126,127,128,129,131,132,133,134,135,136,138,139,140,141,142,143,145,146,147,148,149,150,151,153,154,155,156,157,158,160,161,162,163,164,165,166,168,169,170,171,172,173,175,176,177,178,179,180,182,183,184,185,186,187,188,190,191,192,193,194,195,197,198,199,200,201,202,204,205,206,207,208,209,210,212,213,214,215,216,217,219,220,221,222,223,224,226,226,226,227,227,227,228,228,228,229,229,229,230,230,231,231,231,232,232,232,233,233,233,234,234,235,235,235,236,236,236,237,237,237,238,238,239,239,239,240,240,240,241,241,241,242,242,243,243,243,244,244,244,245,245,245,246,246,246,247,247,247,248,248,248,249,249,249,250,250,250,251,251,251,252,252,252,253,253,253,254,254,254,255],S=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,35,36,37,39,40,42,43,44,46,47,49,50,51,53,54,56,57,58,59,61,62,63,64,66,67,68,69,71,72,73,74,76,77,78,79,81,82,83,84,86,87,88,90,91,92,93,95,96,97,98,100,101,102,103,105,106,107,108,110,111,112,113,115,116,117,118,120,121,122,124,125,126,127,129,130,131,132,134,135,136,137,139,140,141,142,144,145,146,147,149,150,151,152,154,155,156,158,159,160,161,163,164,165,166,168,169,170,171,173,174,175,176,178,179,180,181,183,184,185,186,188,189,190,192,193,194,195,197,198,199,200,202,203,204,205,207,208,209,210,212,213,214,215,217,218,219,220,222,223,224,226,226,226,227,227,228,228,229,229,230,230,231,231,232,232,233,233,234,234,234,235,235,236,236,237,237,238,238,239,239,240,240,241,241,242,242,243,243,243,244,244,244,245,245,245,246,246,246,247,247,247,248,248,248,249,249,249,250,250,250,251,251,251,252,252,252,253,253,253,254,254,254,255],E=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,43,44,45,46,47,48,50,51,52,53,54,55,56,58,59,60,61,62,63,65,66,67,68,69,70,72,73,74,76,77,78,80,81,83,84,85,87,88,89,91,92,94,95,96,98,99,100,102,103,105,106,107,109,110,111,113,114,116,117,118,120,121,122,124,125,127,128,129,131,132,133,135,136,138,139,140,142,143,144,146,147,149,150,151,153,154,155,157,158,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,192,193,193,194,195,195,196,197,197,198,199,199,200,201,201,202,203,203,204,205,205,206,207,207,208,209,209,210,211,211,212,213,213,214,215,215,216,217,217,218,219,219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230,231,231,232,233,233,234,235,235,236,237,237,238,239,239,240,241,241,242,243,243,244,245,245,246,247,247,248,249,249,250,251,251,252,253,253,254,255];this.program=se(a,ve),this.setUniforms=function(){var t=a.getUniformLocation(this.program,"u_flipY"),n=a.getUniformLocation(this.program,"u_denoiseLevel");a.uniform1f(n,i),a.uniform1f(t,1);var v=a.getUniformLocation(this.program,"light");a.uniform1f(v,o);var S=a.getUniformLocation(this.program,"redness");a.uniform1f(S,r);var E=a.getUniformLocation(this.program,"skin_he_max"),_=a.getUniformLocation(this.program,"skin_he_min"),h=a.getUniformLocation(this.program,"skin_hc_max"),I=a.getUniformLocation(this.program,"skin_hc_min"),b=a.getUniformLocation(this.program,"skin_hc_axis"),T=a.getUniformLocation(this.program,"facts_rotate_c"),R=a.getUniformLocation(this.program,"facts_rotate_le"),A=a.getUniformLocation(this.program,"facts_rotate_ge");a.uniform1f(E,s),a.uniform1f(_,c),a.uniform1f(h,d),a.uniform1f(I,u),a.uniform1f(b,l),a.uniform1f(T,p),a.uniform1f(R,f),a.uniform1f(A,g);var y=a.getUniformLocation(this.program,"u_originImage");a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,e.inputTexture),a.uniform1i(y,2);for(var O=["lighten_lut"],C=[a.TEXTURE3],N=0;N<O.length;N++){var w=a.getUniformLocation(this.program,O[N]);a.activeTexture(C[N]),a.bindTexture(a.TEXTURE_2D,m[N]),a.uniform1i(w,N+3)}},this.setParameters=function(e){void 0!==e.denoiseLevel&&(i=e.denoiseLevel),void 0!==e.lightLevel&&(o=e.lightLevel),void 0!==e.rednessLevel&&(r=e.rednessLevel,this._updateRedness(r)),void 0!==e.lighteningContrastLevel&&this._updateLut(e.lighteningContrastLevel)},this._updateRedness=function(e){var t,n,a=3.141593,i=e,o=i;i>1&&(i=1),i<0&&(i=0),o>1&&(o=1),o<0&&(o=0),p=.8*i,o<.8&&(o=0),(l=(117-4*o)/180*a)<(u=(116-4*o)/180*a)&&(l=u),u<a/2&&(u=a/2),l<a/2&&(l=a/2),(c=(115-4*o)/180*a)<a/2&&(c=a/2),(d=173/180*a)>a&&(d=a),l>a&&(l=a),(s=175/180*a)>a&&(s=a),n=d-l,g=(t=s-d)>.01?p*n/t:p,n=l-u,f=(t=u-c)>.01?p*n/t:p},this._updateLut=function(e){var t=null;0==e&&(t=S),1==e&&(t=E),2==e&&(t=v);for(var n=[new Uint8Array(t)],i=[256],o=[1],r=0;r<n.length;r++)a.bindTexture(a.TEXTURE_2D,m[r]),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,i[r],o[r],0,a.LUMINANCE,a.UNSIGNED_BYTE,n[r])},this._init=function(){var e=null;e=S;for(var t=[new Uint8Array(e)],n=[256],i=[1],o=0;o<t.length;o++){var r=a.createTexture();a.bindTexture(a.TEXTURE_2D,r),a.texImage2D(a.TEXTURE_2D,0,a.LUMINANCE,n[o],i[o],0,a.LUMINANCE,a.UNSIGNED_BYTE,t[o]),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),m.push(r)}},this._init()}var Ee=!1;function _e(){this.programs=[];var e=this,t=null,n=null;e.gl=null,e.inputTexture=null;var a=[],i=[],o=0,r=0;e._initGl=function(n,s){e.inputTexture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,e.inputTexture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR);for(var c=0;c<4;c++){var d=t.createTexture();t.bindTexture(t.TEXTURE_2D,d),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),c<2?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n,s,0,t.RGBA,t.UNSIGNED_BYTE,null):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,s,n,0,t.RGBA,t.UNSIGNED_BYTE,null);var u=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,u),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,d,0),a.push(d),i.push(u)}t.viewport(0,0,n,s),o=n,r=s},e.render=function(s){if(t){var c=0;r==s.videoWidth&&o===s.videoHeight&&(c=2),t.viewport(0,0,s.videoWidth,s.videoHeight),t.bindTexture(t.TEXTURE_2D,e.inputTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,s);for(var d=Ee?e.programs.length-1:0,u=0;u<=d;u++){var l=e.programs[u].program;t.useProgram(l);var p=t.getUniformLocation(l,"u_image");e.programs[u].setUniforms(),t.bindFramebuffer(t.FRAMEBUFFER,i[c+u%2]),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLES,0,6),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a[c+u%2]),t.uniform1i(p,0)}t.useProgram(n);var f=t.getUniformLocation(n,"u_flipY");t.uniform1f(f,-1),t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLES,0,6)}},e.setEnableBeauty=function(e){Ee=e},e.init=function(a,i,o){if("undefined"==typeof WebGLRenderingContext)throw new Error("NOT_SUPPORT");t=o.getContext("webgl"),e.gl=t,e._initGl(a,i),e.programs.push(new de(this,a,i)),e.programs.push(new le(this,a,i)),e.programs.push(new fe(this,a,i)),e.programs.push(new me(this,a,i)),e.programs.push(new Se(this,a,i)),n=e.programs[0].program},e.release=function(){e.gl=null,t=null,n=null,e.inputTexture=null,e.programs=[],a=[],i=[]},e.setDenoiseLevel=function(t){e.programs.forEach((function(e){e.setParameters&&e.setParameters({denoiseLevel:t})}))},e.setLightLevel=function(t){e.programs.forEach((function(e){e.setParameters&&e.setParameters({lightLevel:t})}))},e.setRednessLevel=function(t){e.programs.forEach((function(e){e.setParameters&&e.setParameters({rednessLevel:t})}))},e.setContrastLevel=function(t){e.programs.forEach((function(e){e.setParameters&&e.setParameters({lighteningContrastLevel:t})}))},e.setSize=function(t,n){e.programs.forEach((function(e){e.setSize&&e.setSize(t,n)}))}}_e._instance=null,_e.getInstance=function(){return _e._instance||(_e._instance=new _e),_e._instance};var he={addVideoEffectCapability:function(e){e.videoEffect={canvas:null,video:null,fps:30,stopChromeBackgroundLoop:null,enableBeauty:!1,denoiseLevel:5,lightLevel:.35,rednessLevel:.5,lighteningContrastLevel:1,videoContextInited:!1,originVideoTrack:null,canvasVideoTrack:null,ctx:null},e._initVideoContext=function(){if(e.videoEffect.videoContextInited)throw new Error("Failed to init video context. Already inited");if(!e.stream)throw new Error("Failed to init video context. Local Stream not initialized");e.videoEffect.originVideoTrack=e.stream.getVideoTracks()[0],e.attributes&&e.attributes.maxFrameRate&&(e.videoEffect.fps=e.attributes.maxFrameRate),e.videoEffect.videoContextInited=!0},e._renderWithWebGL=function(t){return new Promise((function(n){e.videoEffect.canvas||(e.videoEffect.canvas=document.createElement("canvas")),e.videoEffect.video||(e.videoEffect.video=document.createElement("video")),e.videoEffect.video.setAttribute("autoplay",""),e.videoEffect.video.setAttribute("muted",""),e.videoEffect.video.muted=!0,e.videoEffect.video.setAttribute("playsinline",""),e.videoEffect.video.setAttribute("style","display:none"),e.videoEffect.video.srcObject=t;var a=t.getVideoTracks()[0].getSettings(),i=a.width,o=a.height;console.log("Width: ".concat(i,", Height: ").concat(o)),e.videoEffect.canvas.setAttribute("width",i),e.videoEffect.canvas.setAttribute("height",o),e.videoEffect.video.setAttribute("width",i),e.videoEffect.video.setAttribute("height",o);var r=_e.getInstance();r.init(e.videoEffect.video.width,e.videoEffect.video.height,e.videoEffect.canvas),r.setDenoiseLevel(e.videoEffect.denoiseLevel),r.setLightLevel(e.videoEffect.lightLevel),r.setRednessLevel(e.videoEffect.rednessLevel),r.setContrastLevel(e.videoEffect.lighteningContrastLevel);e.videoEffect.video.addEventListener("playing",(function t(){var a=e.videoEffect.canvas.captureStream(e.videoEffect.fps);e.videoEffect.video.removeEventListener("playing",t,!0),n([a.getVideoTracks()[0],e.videoEffect.video])}),!0),e.videoEffect.video.play()}))},e._disableEffect=function(){e.videoEffect.videoContextInited||e._initVideoContext();var t=e.videoEffect.originVideoTrack;if(!t)return r.default.warning("Video track is null, fail to disable video effect!"),Promise.resolve();if(e.pc&&e.pc.peerConnection&&e.pc.peerConnection){var n=(e.pc.peerConnection&&e.pc.peerConnection.getSenders()).find((function(e){return e&&e.track&&"video"==e.track.kind}));if(n&&n.replaceTrack&&t)return n.replaceTrack(t)}return Promise.resolve()},e._releaseEffect=function(){var t;return t=e.videoEffect.enableBeauty?e._disableEffect():Promise.resolve(),_e.getInstance().release(),e.videoEffect.videoContextInited=!1,e.videoEffect.canvasVideoTrack=null,t},e._enableEffect=function(){return e.videoEffect.videoContextInited||e._initVideoContext(),e.videoEffect.originVideoTrack?e.videoEffect.canvasVideoTrack?(e._showEffectInLocalPlayer(),e._replaceWithCanvasTrack()):e._renderWithWebGL(e.stream).then((function(t){var n=ne()(t,2),a=n[0],i=n[1];e.videoEffect.canvasVideoTrack=a;var o=_e.getInstance();return requestAnimationFrame((function t(){e.videoEffect.enableBeauty&&o.render(i),e.videoEffect.videoContextInited&&requestAnimationFrame(t)})),g.isChrome()&&document.addEventListener("visibilitychange",(function(){document.hidden;document.hidden?e.videoEffect.stopChromeBackgroundLoop=function(e,t){var n=1/t,a=new AudioContext,i=a.createGain();i.gain.value=0,i.connect(a.destination),function t(){var r=a.createOscillator();r.onended=t,r.connect(i),r.start(0),r.stop(a.currentTime+n),e(a.currentTime),o&&(r.onended=function(){a.close()})}();var o=!1;return function(){o=!0}}((function(){e.videoEffect.enableBeauty&&o.render(i)}),e.videoEffect.fps):e.videoEffect.stopChromeBackgroundLoop&&(e.videoEffect.stopChromeBackgroundLoop(),e.videoEffect.stopChromeBackgroundLoop=null)}),!1),e._showEffectInLocalPlayer(),e._replaceWithCanvasTrack()})):(r.default.warning("Video track is null, fail to enable video effect!"),Promise.resolve())},e._showEffectInLocalPlayer=function(){if(e.player){var t=e.player.div.children[0];if("none"!==t.style.display&&(e.player.div.appendChild(e.videoEffect.canvas),"video"===t.tagName.toLowerCase())){var n=t.getAttribute("style");e.videoEffect.canvas.setAttribute("style",n),"none"!==t.style.display&&(t.style.display="none")}}},e._removeEffectFromLocalPlayer=function(){if(e.player&&e.player.div&&e.videoEffect.enableBeauty&&e.videoEffect.canvas){e.player.div.removeChild(e.videoEffect.canvas);var t=e.player.div.children[0];"video"===t.tagName.toLowerCase()&&(e.videoEffect.canvas.style.display="none",t.style.display="block")}},e._replaceWithCanvasTrack=function(){var t=null;e.pc&&e.pc.peerConnection&&e.pc.peerConnection&&(t=(e.pc.peerConnection&&e.pc.peerConnection.getSenders()).find((function(e){return e&&e.track&&"video"==e.track.kind})));return t&&t.replaceTrack&&e.videoEffect.canvasVideoTrack?t.replaceTrack(e.videoEffect.canvasVideoTrack):Promise.resolve()},e.setBeautyEffectOptions=function(){var t=ee()(Z.a.mark((function t(n,a){var i,o=arguments;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object(z.checkValidBoolean)(n,"enabled"),i=_e.getInstance(),e.videoEffect.enableBeauty==n){t.next=14;break}if(i.setEnableBeauty(n),!n){t.next=9;break}return t.next=7,e._enableEffect();case 7:t.next=12;break;case 9:return e._removeEffectFromLocalPlayer(),t.next=12,e._releaseEffect();case 12:e.videoEffect.enableBeauty=n,s.b.reportApiInvoke(e.sid,{callback:null,options:o,name:"Stream.setBeautyEffectOptions",tag:"tracer"});case 14:if(n){t.next=16;break}return t.abrupt("return");case 16:if(!a){t.next=20;break}Object(z.checkValidObject)(a,"options"),t.next=21;break;case 20:return t.abrupt("return");case 21:if(void 0!==a.smoothnessLevel&&(Object(z.checkValidFloatNumber)(a.smoothnessLevel,"smoothnessLevel",0,1),e.videoEffect.denoiseLevel=10*a.smoothnessLevel,e.videoEffect.denoiseLevel<.1&&(e.videoEffect.denoiseLevel=.1),i.setDenoiseLevel(e.videoEffect.denoiseLevel)),void 0!==a.lighteningLevel&&(Object(z.checkValidFloatNumber)(a.lighteningLevel,"lighteningLevel",0,1),e.videoEffect.lightLevel=a.lighteningLevel/2,e.videoEffect.lightLevel<.01&&(e.videoEffect.lightLevel=.01),i.setLightLevel(e.videoEffect.lightLevel)),void 0!==a.rednessLevel&&(Object(z.checkValidFloatNumber)(a.rednessLevel,"rednessLevel",0,1),e.videoEffect.rednessLevel=a.rednessLevel,e.videoEffect.rednessLevel<.01&&(e.videoEffect.rednessLevel=.01),i.setRednessLevel(e.videoEffect.rednessLevel)),void 0===a.lighteningContrastLevel){t.next=29;break}if(0===a.lighteningContrastLevel||1===a.lighteningContrastLevel||2===a.lighteningContrastLevel){t.next=27;break}throw new Error("Invalid lighteningContrastLevel: The value should be 0, 1 or 2.");case 27:e.videoEffect.lighteningContrastLevel=parseFloat(a.lighteningContrastLevel),i.setContrastLevel(e.videoEffect.lighteningContrastLevel);case 29:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()},restoreVideoEffect:function(e){return e.videoEffect.enableBeauty?e._enableEffect():Promise.resolve()},disableVideoEffect:function(e){return e._releaseEffect?e._releaseEffect():Promise.resolve()},applyEffectInPlayer:function(e){e.videoEffect.enableBeauty&&e.videoEffect.canvas&&e._showEffectInLocalPlayer()},removeEffectFromLocalPlayer:function(e){e._removeEffectFromLocalPlayer()},replaceWithCanvasTrack:function(e){return e.videoEffect.enableBeauty?e._replaceWithCanvasTrack():Promise.resolve()},checkVideoEffectEnabled:function(e){if(e.videoEffect.enableBeauty&&e.videoEffect&&e.videoEffect.videoContextInited){return r.default.error("Operation not permitted: ".concat("VIDEO_EFFECT_ENABLED")),"VIDEO_EFFECT_ENABLED"}return!1}},Ie=a(9),be=a.n(Ie),Te=function(e){Object(z.checkValidString)(e,"profileName"),-1===(e=e.toLowerCase()).indexOf("_")&&(e+="_1"),Object(z.checkValidEnum)(e,"profileName",Object.keys(o.SUPPORT_RESOLUTION_LIST));var t=o.SUPPORT_RESOLUTION_LIST[e];t||(e=Object(o.getParameter)("DEFAULT_PROFILE"),t=o.SUPPORT_RESOLUTION_LIST[e]);var n={profileName:e,video:{width:t[0],height:t[1]},attributes:{resolution:"".concat(t[0],"x").concat(t[1]),minFrameRate:t[2],maxFrameRate:t[3],minVideoBW:t[4],maxVideoBW:t[5]}};return t[2]&&t[3]&&(n.video.frameRate={ideal:t[2],max:t[3]}),t[6]&&t[7]&&(n.screen={width:t[0],height:t[1],frameRate:{min:t[6],max:t[7]}}),n},Re=function(e){return Object.keys(o.SUPPORT_RESOLUTION_LIST).filter((function(t){var n=o.SUPPORT_RESOLUTION_LIST[t],a=["width","height","frameRate"];for(var i in a){var r=a[i];if(e[r]&&n[i]){if("number"==typeof e[r].max&&e[r].max<n[i])return!1;if("number"==typeof e[r].min&&e[r].min>n[i])return!1}}return!0})).reverse()},Ae=function(e){var t=o.AUDIO_PROFILE_SETTINGS[e]||o.AUDIO_PROFILE_SETTINGS.default;return{highQuality:t[0],stereo:t[1],speech:t[2],lowQuality:t[3]}};var ye=function(e){var t=c();if(t.params=E()({},e),t.stream=e.stream,t.url=e.url,t.onClose=void 0,t.local=!1,t.videoSource=e.videoSource,t.audioSource=e.audioSource,e.video=!(!e.videoSource&&!e.video),t.video=e.video,e.audio=!(!e.audioSource&&!e.audio),t.audio=e.audio,t.screen=!!e.screen,t.screenAudio=!!e.screenAudio,t.screenAttributes={width:1920,height:1080,maxFr:5,minFr:1},t.videoSize=e.videoSize,t.player=void 0,t.audioLevelHelper=null,e.attributes=e.attributes||{},t.attributes=e.attributes,t.microphoneId=e.microphoneId,t.cameraId=e.cameraId,t.facingMode=e.facingMode,t.inSwitchDevice=!1,t.userMuteVideo=!1,t.userMuteAudio=!1,t.peerMuteVideo=!1,t.peerMuteAudio=!1,t.lowStream=null,t.videoWidth=0,t.videoHeight=0,t.streamId=e.streamID,t.userId=null,t.uintId=e.uintUID||null,t.mirror=!1!==e.mirror,t.DTX=e.audioProcessing&&e.audioProcessing.DTX,t.audioProcessing=e.audioProcessing,t.highQuality=!1,t.stereo=!1,t.speech=!1,t.screen||delete t.screen,!(void 0===t.videoSize||t.videoSize instanceof Array&&4===t.videoSize.length))throw Error("Invalid Video Size");function n(){var e={};t.getVideoTrack()===this?(r.default.debug("Video Track Ended"),e.type="videoTrackEnded",e.track=this):t.getAudioTrack()===this?(r.default.debug("Audio Track Ended"),e.type="audioTrackEnded",e.track=this):r.default.debug("Detached Track ended",this.kind,this.label,this),e.type&&t.dispatchEvent(e)}return t.videoSize=[640,480,640,480],void 0!==e.local&&!0!==e.local||(t.local=!0),t.initialized=!t.local,t._streamInitID=null,function(e){e.audioMixing={audioContextInited:!1,defaultVolume:100,inEarMonitoring:"FILE",sounds:{},states:{IDLE:"IDLE",STARTING:"STARTING",BUSY:"BUSY",PAUSED:"PAUSED"},inEarMonitoringModes:{NONE:"NONE",FILE:"FILE",MICROPHONE:"MOCROPHONE",ALL:"ALL"},ctx:null,mediaStreamSource:null,mediaStreamDest:null,buffer:{}},e._initSoundIfNotExists=function(t,n){e.audioMixing.sounds[t]||(e.audioMixing.sounds[t]={soundId:t,state:"IDLE",muted:e.userMuteAudio,filePath:n,volume:e.audioMixing.defaultVolume,startAt:null,startOffset:null,pauseAt:null,pauseOffset:null,resumeAt:null,resumeOffset:null,stopAt:null,options:null,source:null})},e._initSoundIfNotExists(-1),e.loadAudioBuffer=function(t,n,a){var i=s.b.reportApiInvoke(e.sid,{callback:a,name:"Stream.loadAudioBuffer",options:arguments,tag:"tracer"});Object(z.checkValidString)(n,"url",1,1024,!1),Object(z.checkValidString)(t,"id",1,1024,!1);var o=function(t){r.default.error("[".concat(e.streamId,"] loadAudioBuffer Failed: ")+t),i(I.default.LOAD_AUDIO_FAILED)},c=new XMLHttpRequest;c.open("GET",n,!0),c.responseType="arraybuffer",c.onload=function(){if(c.status>400)o("".concat(c.status," ").concat(c.statusText));else{var n=c.response;e.audioMixing.audioContextInited||e._initAudioContext(),e.audioMixing.ctx.decodeAudioData(n,(function(n){e.audioMixing.buffer[t]=n,i(null)}),(function(t){r.default.error("[".concat(e.streamId,"] decodeAudioData Failed: "),t),i(t)}))}},c.onerror=function(){return o("load error")},c.ontimeout=function(){return o("timeout")},c.send()},e.createAudioBufferSource=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.createAudioBufferSource",options:arguments,tag:"tracer"});if(e.audioMixing.buffer[t.id]){var a=e.audioMixing.buffer[t.id],i=e.audioMixing.ctx.createBufferSource();i.buffer=a;var o=e.audioMixing.ctx.createGain();if(i.connect(o),o.connect(e.audioMixing.mediaStreamDest),i.gainNode=o,t.loop)i.loop=!0,i.start(0,t.playTime/1e3);else if(t.cycle>1)if(Object(g.isChrome)()){i.loop=!0;var c=t.cycle*a.duration*1e3-(t.playTime||0);i.start(0,t.playTime/1e3,c/1e3)}else r.default.warning("[".concat(e.streamId,"] Cycle Param is ignored by current browser")),i.start(0,t.playTime/1e3);else i.start(0,t.playTime/1e3);var d=e.audioMixing.sounds[t.soundId];return d.source=i,e._flushAudioMixingMuteStatus(),i.addEventListener("ended",(function(){i===d.source&&e.dispatchEvent({type:"audioSourceEnded",soundId:t.soundId,source:i,sound:d})})),n(),i}var u="AUDIOBUFFER_NOT_FOUND";return r.default.error("[".concat(e.streamId,"] "),u,t.id),n(!1),!1},e.on("audioSourceEnded",(function(t){var n=t.source,a=t.sound;a&&a.state===e.audioMixing.states.BUSY&&!a.pauseAt&&(a.state=e.audioMixing.states.IDLE,a.startAt=null,a.startOffset=null,a.resumeAt=null,a.resumeOffset=null,n.gainNode&&n.gainNode.disconnect&&n.gainNode.disconnect(),n.buffer=null,e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest))})),e.clearAudioBufferSource=function(){e.audioBufferSource.forEach((function(e){e.stop()}))},e._isSoundExists=function(t){return!!e.audioMixing.sounds[t.soundId]||(r.default.error("SoundId not exists. #".concat(t.soundId)),!1)},e._initAudioContext=function(){if(e.audioMixing.audioContextInited)throw new Error("Failed to init audio context. Already inited");if(!e.stream)throw new Error("Failed to init audio context. Local Stream not initialized");e.audioMixing.ctx=Object(X.a)(),e.audioMixing.mediaStreamSource=e.audioMixing.ctx.createMediaStreamSource(e.stream),e.audioMixing.mediaStreamDest=e.audioMixing.ctx.createMediaStreamDestination(),e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest);var t=e.stream.getVideoTracks()[0];if(t&&e.audioMixing.mediaStreamDest.stream.addTrack(t),e._originStream=e.stream,e._isAudioMuted()?(e._unmuteAudio(),e.stream=e.audioMixing.mediaStreamDest.stream,e._muteAudio()):e.stream=e.audioMixing.mediaStreamDest.stream,e.audioLevelHelper=null,e.pc&&e.pc.peerConnection&&e.pc.peerConnection){var n=(e.pc.peerConnection&&e.pc.peerConnection.getSenders()).find((function(e){return e&&e.track&&"audio"==e.track.kind})),a=e.audioMixing.mediaStreamDest.stream.getAudioTracks()[0];n&&n.replaceTrack&&a&&n.replaceTrack(a)}e.audioMixing.audioContextInited=!0},e._cleanupAudioMixing=function(){if(e.audioMixing.audioContextInited){for(var t in e.audioMixing.sounds){var n=e.audioMixing.sounds[t];n.state!==e.audioMixing.states.BUSY&&n.state!==e.audioMixing.states.PAUSED||e._stopOneEffect({soundId:t})}e.audioLevelHelper=null,e.audioMixing.audioContextInited=!1}},e._reloadInEarMonitoringMode=function(t){if(t){if(!e.audioMixing.inEarMonitoringModes[t])return r.default.error("[".concat(e.streamId,"] Invalid InEarMonitoringMode ").concat(t));e.audioMixing.inEarMonitoring=t}switch(e.audioMixing.audioContextInited||e._initAudioContext(),e.audioMixing.inEarMonitoring){case e.audioMixing.inEarMonitoringModes.FILE:e.audioMixing.mediaStreamSource.connectedToDestination&&(e.audioMixing.mediaStreamSource.disconnect(e.audioMixing.ctx.destination),e.audioMixing.mediaStreamSource.connectedToDestination=!1);case e.audioMixing.inEarMonitoringModes.ALL:for(var n in e.audioMixing.sounds){var a=e.audioMixing.sounds[n];a&&a.source&&!a.source.connectedToDestination&&(a.source.gainNode.connect(e.audioMixing.ctx.destination),a.source.connectedToDestination=!0)}}switch(e.audioMixing.inEarMonitoring){case e.audioMixing.inEarMonitoringModes.MICROPHONE:e.audioMixing.source.forEach((function(t){t.connectedToDestination&&(t.gainNode.disconnect(e.audioMixing.ctx.destination),t.connectedToDestination=!1)}));case e.audioMixing.inEarMonitoringModes.ALL:e.audioMixing.mediaStreamSource.connectedToDestination||(e.audioMixing.mediaStreamSource.connect(e.audioMixing.ctx.destination),e.audioMixing.mediaStreamSource.connectedToDestination=!0)}},e._startAudioMixingBufferSource=function(t){e.audioMixing.audioContextInited||e._initAudioContext();var n={soundId:t.soundId,id:t.filePath,loop:t.loop,cycle:t.cycle,playTime:t.playTime||0},a=t.replace,i=e.createAudioBufferSource(n);return i.sound=e.audioMixing.sounds[t.soundId],i?(i.addEventListener("ended",e._audioMixingFinishedListener,{once:!0}),e._reloadInEarMonitoringMode(),a&&e.audioMixing.mediaStreamSource.disconnect(e.audioMixing.mediaStreamDest),i):null},e._stopAudioMixingBufferSource=function(t){var n=e.audioMixing.sounds[t.soundId].source;return n?(n.removeEventListener("ended",e._audioMixingFinishedListener),e.audioMixing.mediaStreamSource.connect(e.audioMixing.mediaStreamDest),n.stop(),n.gainNode&&n.gainNode.disconnect&&n.gainNode.disconnect(),n.buffer=null,n):null},e._flushAudioMixingMuteStatus=function(t){for(var n in e.audioMixing.sounds){var a=e.audioMixing.sounds[n];a&&(void 0!==t&&(a.muted=!!t),a.source&&(a.muted?a.source.gainNode.gain.value=0:a.source.gainNode.gain.value=a.volume/100))}},e._handleAudioMixingInvalidStateError=function(t,n,a){var i=e.audioMixing.sounds[n.soundId],o=-1===n.soundId?"INVALID_AUDIO_MIXING_STATE":"INVALID_PLAY_EFFECT_STATE";r.default.error("[".concat(e.streamId,"] Cannot ").concat(t,": ").concat(o,", state is ").concat(i.state)),a&&a(o)},e._handleAudioMixingNoSourceError=function(t,n,a){e.audioMixing.sounds[n.soundId].state=e.audioMixing.states.IDLE;var i=-1===n.soundId?"NO_AUDIO_MIXING_SOURCE":"NO_EFFECT_SOURCE";r.default.error("[".concat(e.streamId,"] Cannot ").concat(t,": ").concat(i)),a&&a(i)},e._getOneEffectStates=function(t){var n=e.audioMixing.sounds[t.soundId];return function(){return n?{state:n.state,startAt:n.startAt,resumeAt:n.resumeAt,pauseOffset:n.pauseOffset,pauseAt:n.pauseAt,resumeOffset:n.resumeOffset,stopAt:n.stopAt,duration:e._getOneEffectDuration(t),position:e._getOneEffectCurrentPosition(t)}:{}}},e._audioMixingFinishedListener=function(){var t=this.sound;t.state===e.audioMixing.states.IDLE&&e.audioMixing.buffer[t.options.filePath]&&!t.options.cacheResource&&(r.default.debug("Recycled buffer ".concat(t.options.filePath)),delete e.audioMixing.buffer[t.options.filePath]),-1===t.soundId&&e.dispatchEvent({type:"audioMixingFinished"})},e._playOneEffect=function(t,n){Object(z.checkValidObject)(t,"options");var a=t.soundId,i=(t.filePath,t.cacheResource);t.cycle,t.loop,t.playTime,t.replace;if(Object(g.isSafari)()&&Object(g.getBrowserVersion)()<12){var o="BROWSER_NOT_SUPPORT";return r.default.error("[".concat(e.streamId,"] Cannot _playOneEffect: "),o),n(o)}e.audioMixing.audioContextInited||e._initAudioContext(),e._initSoundIfNotExists(a);var s=e.audioMixing.sounds[a];if(s.state===e.audioMixing.states.IDLE){if(void 0!==t.cycle&&!t.cycle>0){o="Invalid Parmeter cycle: "+t.cycle;return r.default.error("[".concat(e.streamId,"] ").concat(a),o),n(o)}if(Object(z.isEmpty)(i)&&(t.cacheResource=!0),s.state=e.audioMixing.states.STARTING,s.options=t,e.audioMixing.buffer[t.filePath]){var c=e._startAudioMixingBufferSource(t);if(c)return s.source=c,s.startAt=Date.now(),s.resumeAt=null,s.pauseOffset=null,s.pauseAt=null,s.resumeOffset=null,s.stopAt=null,s.startOffset=t.playTime||0,s.state=e.audioMixing.states.BUSY,e._flushAudioMixingMuteStatus(),n(null);s.state=e.audioMixing.states.IDLE;var d="CREATE_BUFFERSOURCE_FAILED";if(n)return n(d);r.default.error("[".concat(e.streamId,"] "),d)}else e.loadAudioBuffer(t.filePath,t.filePath,(function(a){if(a)s.state=e.audioMixing.states.IDLE,n?n(a):r.default.error("[".concat(e.streamId,"] "),a);else{var i=e._startAudioMixingBufferSource(t);if(i)return s.source=i,s.startAt=Date.now(),s.resumeAt=null,s.pauseOffset=null,s.pauseAt=null,s.resumeOffset=null,s.stopAt=null,s.startOffset=t.playTime||0,s.state=e.audioMixing.states.BUSY,e._flushAudioMixingMuteStatus(),n(null);s.state=e.audioMixing.states.IDLE;a="CREATE_BUFFERSOURCE_FAILED";if(n)return n(a);r.default.error("[".concat(e.streamId,"] "),a)}}))}else e._handleAudioMixingInvalidStateError("_playEffect",t,n)},e._stopOneEffect=function(t,n){var a=e.audioMixing.sounds[t.soundId];return e._isSoundExists(t)?a.state===e.audioMixing.states.BUSY||a.state===e.audioMixing.states.PAUSED?(e._stopAudioMixingBufferSource(t),a.stopAt=Date.now(),a.state=e.audioMixing.states.IDLE,e.audioMixing.buffer[a.options.filePath]&&!a.options.cacheResource&&(r.default.debug("Recycled buffer ".concat(a.options.filePath)),delete e.audioMixing.buffer[a.options.filePath]),void(n&&n(null))):void e._handleAudioMixingInvalidStateError("_stopOneEffect",t,n):n("SOUND_NOT_EXISTS")},e._pauseOneEffect=function(t,n){var a=e.audioMixing.sounds[t.soundId];if(a.state===e.audioMixing.states.BUSY)return e._stopAudioMixingBufferSource(t)?(a.pauseAt=Date.now(),a.state=e.audioMixing.states.PAUSED,a.resumeAt?a.pauseOffset=a.pauseAt-a.resumeAt+a.resumeOffset:a.pauseOffset=a.pauseAt-a.startAt+a.startOffset,n&&n(null)):void e._handleAudioMixingNoSourceError("_pauseOneEffect",t,n);e._handleAudioMixingInvalidStateError("_pauseOneEffect",t,n)},e._resumeOneEffect=function(t,n){var a=e.audioMixing.sounds[t.soundId];if(a.state===e.audioMixing.states.PAUSED){var i={soundId:t.soundId,filePath:a.options.filePath,cycle:a.options.cycle,loop:a.options.loop,playTime:a.pauseOffset,replace:a.options.replace},o=e._startAudioMixingBufferSource(i);if(!o){var s="CREATE_BUFFERSOURCE_FAILED";return n(s),void r.default.error("[".concat(e.streamId,"] "),s)}a.source=o,a.resumeAt=Date.now(),a.resumeOffset=a.pauseOffset,a.state=e.audioMixing.states.BUSY,a.pauseAt=null,a.pauseOffset=null,n(null)}else e._handleAudioMixingInvalidStateError("_resumeOneEffect",t,n)},e._getOneEffectDuration=function(t){var n=e.audioMixing.sounds[t.soundId];return n.options&&n.options.filePath&&e.audioMixing.buffer[n.options.filePath]?1e3*e.audioMixing.buffer[n.options.filePath].duration:null},e._getOneEffectCurrentPosition=function(t,n){var a=e.audioMixing.sounds[t.soundId];return a.state===e.audioMixing.states.PAUSED?a.pauseOffset%e._getOneEffectDuration(t):a.state===e.audioMixing.states.BUSY?a.resumeAt?(Date.now()-a.resumeAt+a.resumeOffset)%e._getOneEffectDuration(t):(Date.now()-a.startAt+a.startOffset)%e._getOneEffectDuration(t):void(n&&e._handleAudioMixingInvalidStateError("_getOneEffectCurrentPosition",t))},e._setOneEffectPosition=function(t,n,a){var i=e.audioMixing.sounds[t.soundId];if(i.state===e.audioMixing.states.BUSY){if(!e._stopAudioMixingBufferSource(t))return void e._handleAudioMixingNoSourceError("_setOneEffectPosition",t,a);var o={soundId:t.soundId,filePath:i.options.filePath,loop:i.options.loop,cycle:i.options.cycle,playTime:n},s=e._startAudioMixingBufferSource(o);if(!s){var c="CREATE_BUFFERSOURCE_FAILED";return a&&a(c),void r.default.error("[".concat(e.streamId,"] "),c)}i.source=s,i.startAt=Date.now(),i.startOffset=n,i.resumeAt=null,i.resumeOffset=null,i.pauseOffset=null,i.pauseAt=null}else{if(i.state!==e.audioMixing.states.PAUSED)return void e._handleAudioMixingInvalidStateError("_setOneEffectPosition",t,a);i.pauseOffset=n}a&&a(null)},e.startAudioMixing=function(t,n){var a=s.b.reportApiInvoke(e.sid,{callback:function(t){if(t)return n&&n(t);e.dispatchEvent({type:"audioMixingPlayed"}),n&&n(null)},getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.startAudioMixing",options:t});Object(z.checkValidObject)(t,"options");var i=t.filePath,r=t.cacheResource,c=t.cycle,d=t.loop,u=t.playTime,l=t.replace;Object(z.checkValidString)(i,"filePath",1,Object(o.getParameter)("FILEPATH_LENMAX"),!1),Object(z.checkValidNumber)(u,"playTime",0,1e8),!Object(z.isEmpty)(c)&&Object(z.checkValidNumber)(c,"cycle"),!Object(z.isEmpty)(d)&&Object(z.checkValidBoolean)(d,"loop"),!Object(z.isEmpty)(l)&&Object(z.checkValidBoolean)(l,"replace"),!Object(z.isEmpty)(r)&&Object(z.checkValidBoolean)(r,"cacheResource");var p=E()({soundId:-1},t);e._playOneEffect(p,a)},e.stopAudioMixing=function(t){var n=s.b.reportApiInvoke(e.sid,{callback:t,getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.stopAudioMixing"});e._stopOneEffect({soundId:-1},n)},e.pauseAudioMixing=function(t){var n=s.b.reportApiInvoke(e.sid,{callback:t,getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.pauseAudioMixing"});return e._pauseOneEffect({soundId:-1},n)},e.resumeAudioMixing=function(t){var n=s.b.reportApiInvoke(e.sid,{callback:function(n,a){if(n)return t&&t(n);e.dispatchEvent({type:"audioMixingPlayed"}),t&&t(null)},getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.resumeAudioMixing"});e._resumeOneEffect({soundId:-1},n)},e.adjustAudioMixingVolume=function(t){var n=s.b.reportApiInvoke(e.sid,{getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.adjustAudioMixingVolume",options:arguments,tag:"tracer"});Object(z.checkValidNumber)(t,"volume",0,100),e.audioMixing.sounds[-1].volume=t,e._flushAudioMixingMuteStatus(),n()},e.getAudioMixingDuration=function(){var t=s.b.reportApiInvoke(e.sid,{getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.getAudioMixingDuration"}),n=e._getOneEffectDuration({soundId:-1});return t(null,n),n},e.getAudioMixingCurrentPosition=function(){var t=s.b.reportApiInvoke(e.sid,{getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.getAudioMixingCurrentPosition"}),n=e._getOneEffectCurrentPosition({soundId:-1},!0);return t(null,n),n},e.setAudioMixingPosition=function(t,n){var a=s.b.reportApiInvoke(e.sid,{callback:n,options:arguments,tag:"tracer",getStates:e._getOneEffectStates({soundId:-1}),name:"Stream.setAudioMixingPosition"});Object(z.checkValidNumber)(t,"position",0,1e8),e._setOneEffectPosition({soundId:-1},t,a)},e.playEffect=function(t,n){var a=s.b.reportApiInvoke(e.sid,{callback:function(t){if(t)return n&&n(t);e.dispatchEvent({type:"effectPlayed"}),n&&n(null)},name:"Stream.playEffect",options:t});Object(z.checkValidObject)(t,"options");var i=t.soundId,r=t.filePath,c=t.cycle;Object(z.checkValidNumber)(i,"soundId",1,1e4),Object(z.checkValidString)(r,"filePath",0,Object(o.getParameter)("FILEPATH_LENMAX"),!1),!Object(z.isEmpty)(c)&&Object(z.checkValidNumber)(c,"cycle"),e._playOneEffect(t,a)},e.stopEffect=function(t,n){var a=s.b.reportApiInvoke(e.sid,{callback:n,getStates:e._getOneEffectStates({soundId:t}),name:"Stream.stopEffect"});Object(z.checkValidNumber)(t,"soundId",1,1e4),e._stopOneEffect({soundId:t},a)},e.stopAllEffects=function(t){var n=s.b.reportApiInvoke(e.sid,{callback:t,name:"Stream.stopAllEffect"}),a=!1,i=0,o=0,r=function(e){a||(e?(n(e),a=!0):i+=1,i===o&&(n(null),a=!0))};for(var c in e.audioMixing.sounds){var d=e.audioMixing.sounds[c];-1!==d.soundId&&(d.state!==e.audioMixing.states.BUSY&&d.state!==e.audioMixing.states.PAUSED||(o++,e._stopOneEffect({soundId:c},r)))}o||n(null)},e.preloadEffect=function(t,n,a){var i=s.b.reportApiInvoke(e.sid,{callback:a,options:arguments,tag:"tracer",name:"Stream.preloadEffect"});Object(z.checkValidNumber)(t,"soundId",1,1e4),Object(z.checkValidString)(n,"filePath",1,Object(o.getParameter)("FILEPATH_LENMAX"),!1),e._initSoundIfNotExists(t,n),e.audioMixing.buffer[n]?i(null):e.loadAudioBuffer(n,n,i)},e.unloadEffect=function(t,n){var a=s.b.reportApiInvoke(e.sid,{callback:n,options:arguments,tag:"tracer",name:"Stream.unloadEffect"});Object(z.checkValidNumber)(t,"soundId",1,1e4);var i=e.audioMixing.sounds[t];if(!i){var o="SOUND_NOT_EXISTS";return r.default.error(o,t),void a(o)}var c=i.options?i.options.filePath:i.filePath;if(c)delete e.audioMixing.buffer[c],delete e.audioMixing.sounds[t],a(null);else{var d="SOUND_BUFFER_NOT_FOUND";r.default.error(d,t),a(d)}},e.pauseEffect=function(t,n){var a=s.b.reportApiInvoke(e.sid,{callback:n,options:arguments,tag:"tracer",name:"Stream.pauseEffect"});return e._pauseOneEffect({soundId:t},a)},e.pauseAllEffects=function(t){var n=s.b.reportApiInvoke(e.sid,{callback:t,name:"Stream.pauseAllEffects"}),a=!1,i=0,o=0,r=function(e){a||(e?(n(e),a=!0):i+=1,i===o&&(n(null),a=!0))};for(var c in e.audioMixing.sounds)"-1"!==c&&e.audioMixing.sounds[c].state===e.audioMixing.states.BUSY&&(o++,e._pauseOneEffect({soundId:c},r));o||n(null)},e.resumeEffect=function(t,n){Object(z.checkValidNumber)(t,"soundId",1,1e4);var a=s.b.reportApiInvoke(e.sid,{callback:n,options:arguments,tag:"tracer",name:"Stream.resumeEffect"});return e._resumeOneEffect({soundId:t},a)},e.resumeAllEffects=function(t){var n=s.b.reportApiInvoke(e.sid,{callback:t,name:"Stream.resumeAllEffects"}),a=!1,i=0,o=0,r=function(e){a||(e?(n(e),a=!0):i+=1,i===o&&(n(null),a=!0))};for(var c in e.audioMixing.sounds)"-1"!==c&&e.audioMixing.sounds[c].state===e.audioMixing.states.PAUSED&&(o++,e._resumeOneEffect({soundId:c},r));o||n(null)},e.getEffectsVolume=function(){var t=[];for(var n in e.audioMixing.sounds){var a=e.audioMixing.sounds[n];a&&"-1"!==n&&t.push({soundId:parseInt(n),volume:a.volume})}return t},e.setEffectsVolume=function(t,n){var a=s.b.reportApiInvoke(e.sid,{name:"Stream.setEffectsVolume",options:arguments,tag:"tracer",callback:n});for(var i in Object(z.checkValidNumber)(t,"volume",0,100),e.audioMixing.defaultVolume=t,e.audioMixing.sounds){var o=e.audioMixing.sounds[i];"-1"!==i&&(o.volume=t)}e._flushAudioMixingMuteStatus(),a(null)},e.setVolumeOfEffect=function(t,n,a){var i=s.b.reportApiInvoke(e.sid,{name:"Stream.setVolumeOfEffect",options:arguments,tag:"tracer",callback:a});Object(z.checkValidNumber)(t,"soundId",0,1e4),Object(z.checkValidNumber)(n,"volume",0,100),e._initSoundIfNotExists(t);var o=e.audioMixing.sounds[t];o.volume=n,e._flushAudioMixingMuteStatus(),i(null)}}(t),he.addVideoEffectCapability(t),function(e,t){e.videoConstraint={},t.cameraId&&(e.videoConstraint.deviceId={exact:t.cameraId}),t.facingMode&&(e.videoConstraint.facingMode=t.facingMode),e.videoSize&&(e.videoConstraint.width=e.videoSize[0],e.videoConstraint.height=e.videoSize[1]),Object(g.isLegacyChrome)()||(e.videoConstraint.frameRate={ideal:30,max:30}),e.audioConstraint={},t.microphoneId&&(e.audioConstraint.deviceId={exact:t.microphoneId}),Object(g.isLegacyChrome)()||e.audioProcessing&&(void 0!==e.audioProcessing.AGC&&(Object(g.isFireFox)()?e.audioConstraint.autoGainControl=e.audioProcessing.AGC:Object(g.isChrome)()&&(e.audioConstraint.googAutoGainControl=e.audioProcessing.AGC,e.audioConstraint.googAutoGainControl2=e.audioProcessing.AGC)),void 0!==e.audioProcessing.AEC&&(e.audioConstraint.echoCancellation=e.audioProcessing.AEC),void 0!==e.audioProcessing.ANS&&(Object(g.isFireFox)()?e.audioConstraint.noiseSuppression=e.audioProcessing.ANS:Object(g.isChrome)()&&(e.audioConstraint.googNoiseSuppression=e.audioProcessing.ANS))),e.screenConstraint={},t.sourceId&&(e.screenConstraint.sourceId=t.sourceId),t.extensionId&&Object(g.isChrome)()?(e.screenConstraint.extensionId=t.extensionId,e.screenConstraint.mandatory={chromeMediaSource:"desktop",maxWidth:e.screenAttributes.width,maxHeight:e.screenAttributes.height,maxFrameRate:e.screenAttributes.maxFr,minFrameRate:e.screenAttributes.minFr}):(e.screenConstraint.mediaSource="screen",e.screenConstraint.width=e.screenAttributes.width,e.screenConstraint.height=e.screenAttributes.height,e.screenConstraint.frameRate={ideal:e.screenAttributes.maxFr,max:e.screenAttributes.maxFr}),t.mediaSource&&(e.screenConstraint.mediaSource=t.mediaSource),e.setVideoResolution=function(n){var a=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoResolution",options:arguments,tag:"tracer"});if(!(n instanceof Array)){var i=Te(n+="");return i&&i.video?(e.videoConstraint=E()(e.videoConstraint,{width:{ideal:i.video.width},height:{ideal:i.video.height}}),t.attributes.resolution=i.attributes.resolution,(o=e.stream&&e.stream.getVideoTracks&&e.stream.getVideoTracks()[0])&&o.applyConstraints?(r.default.debug("setVideoResolution applyConstraints",e.videoConstraint),o.applyConstraints(e.videoConstraint).then(a).catch(a)):a(),!0):(a("NO_PROFILE_".concat(n)),!1)}var o,c=n[0],d=n[1];e.videoConstraint=E()(e.videoConstraint,{width:{ideal:c},height:{ideal:d}}),t.attributes.resolution="".concat(c,"x").concat(d),(o=e.stream&&e.stream.getVideoTracks&&e.stream.getVideoTracks()[0])&&o.applyConstraints?(r.default.debug("setVideoResolution applyConstraints",e.videoConstraint),he.disableVideoEffect(e).then((function(){return o.applyConstraints(e.videoConstraint).then(a).catch(a)})).then((function(){return he.restoreVideoEffect(e)}))):a()},e.setVideoFrameRate=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoFrameRate",options:arguments,tag:"tracer"});if(Object(g.isFireFox)())return n("FIREFOX_NOT_SUPPORTED"),!1;if("object"===be()(t)&&t instanceof Array&&t.length>1){e.videoConstraint=E()(e.videoConstraint,{frameRate:{ideal:t[0],max:t[1]}}),e.attributes.minFrameRate=t[0],e.attributes.maxFrameRate=t[1];var a=e.stream&&e.stream.getVideoTracks&&e.stream.getVideoTracks()[0];return a&&a.applyConstraints?(r.default.debug("setVideoFrameRate applyConstraints",e.videoConstraint),a.applyConstraints(e.videoConstraint).then(n).catch(n)):n(),!0}return n("INVALID_PARAM_".concat(JSON.stringify(t))),!1},e.setVideoBitRate=function(n){var a=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoBitRate",options:arguments,tag:"tracer"});return"object"===be()(n)&&n instanceof Array&&n.length>1?(t.attributes.minVideoBW=n[0],t.attributes.maxVideoBW=n[1],e.connectionSpec&&(e.connectionSpec.minVideoBW=n[0],e.connectionSpec.maxVideoBW=n[1]),e.pc&&e.pc.renegotiate&&e.pc.renegotiate(),a(),!0):(a("INVALID_PARAM_".concat(JSON.stringify(n))),!1)},e.setScreenBitRate=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.setScreenBitRate",options:arguments,tag:"tracer"});return"object"===be()(t)&&t instanceof Array&&t.length>1?(e.screenAttributes.minVideoBW=t[0],e.screenAttributes.maxVideoBW=t[1],n(),!0):(n("INVALID_PARAM_".concat(JSON.stringify(t))),!1)},e.setScreenProfile=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.setScreenProfile",options:arguments,tag:"tracer"});Object(z.checkValidEnum)(t,"profile",["480p_1","480p_2","720p_1","720p_2","1080p_1","1080p_2"]);var a=Te(t);return a&&a.screen?(e.screenConstraint.mandatory?(e.screenConstraint.mandatory.maxWidth=a.screen.width,e.screenConstraint.mandatory.maxHeight=a.screen.height,a.screen.frameRate&&a.screen.frameRate.min&&a.screen.frameRate.max&&(e.screenConstraint.mandatory.minFrameRate=a.screen.frameRate.min,e.screenConstraint.mandatory.maxFrameRate=a.screen.frameRate.max)):e.screenConstraint=E()(e.screenConstraint,a.screen),e.screenAttributes.width=a.screen.width,e.screenAttributes.height=a.screen.height,e.screenAttributes.minFr=a.screen.frameRate.min,e.screenAttributes.maxFr=a.screen.frameRate.max,n(),!0):(n("NO_SCREEN_PROFILE_".concat(JSON.stringify(t))),!1)},e.setVideoProfileCustom=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoProfileCustom",options:arguments,tag:"tracer"});e.setVideoResolution(t[0]),e.setVideoFrameRate([t[1],t[1]]),e.setVideoBitRate([t[2],t[2]]),n()},e.setVideoProfileCustomPlus=function(n){var a=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoProfileCustom",options:arguments,tag:"tracer"});e.setVideoResolution([n.width,n.height]),t.attributes.resolution="".concat(n.width,"x").concat(n.height),e.setVideoFrameRate([n.framerate,n.framerate]),e.setVideoBitRate([n.bitrate,n.bitrate]),a()},e.setVideoProfile=function(n){var a=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoProfile",options:arguments,tag:"tracer"}),i=Te(n);if(!i){var o="Invalid Profile ".concat(n);throw new Error(o)}if(e.profile=n,i&&i.video){e.profile=i.profileName,e.videoConstraint=E()(e.videoConstraint,i.video),e.connectionSpec&&i.attributes.maxVideoBW&&(e.connectionSpec.minVideoBW=i.attributes.minVideoBW,e.connectionSpec.maxVideoBW=i.attributes.maxVideoBW),Object(g.isEdge)()&&(e.videoConstraint.frameRate.max=60),Object(g.isFireFox)()&&(e.videoConstraint.frameRate={ideal:30,max:30}),t.attributes=E()(t.attributes,i.attributes),e.pc&&e.pc.renegotiate&&e.pc.renegotiate();var c=e.stream&&e.stream.getVideoTracks&&e.stream.getVideoTracks()[0];return c&&c.applyConstraints?(r.default.debug("setVideoProfile applyConstraints",e.videoConstraint),he.disableVideoEffect(e).then((function(){return c.applyConstraints(e.videoConstraint)})).then((function(){return he.restoreVideoEffect(e)})).then((function(t){return new Promise((function(n,i){a(t),Object(H.vsResHack)(e.stream,(function(t,a){e.videoWidth=t,e.videoHeight=a,n()}),(function(t){r.default.warning("[".concat(e.streamId,"] vsResHack failed: "),t),i()}))}))})).catch(a)):a(),!0}return a("INVALID_VIDEO_PROFILE_".concat(n)),!1},e.setAudioProfile=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.setAudioProfile",options:arguments,tag:"tracer"});Object(z.checkValidEnum)(t,"profile",["speech_low_quality","speech_standard","music_standard","standard_stereo","high_quality","high_quality_stereo"]),e.audioProfile=t;var a=Ae(t);return e.highQuality=a.highQuality,e.stereo=a.stereo,e.speech=a.speech,e.lowQuality=a.lowQuality,e.stereo&&Object(g.isChrome)()&&(e.audioConstraint.googAutoGainControl=!1,e.audioConstraint.googAutoGainControl2=!1,e.audioConstraint.echoCancellation=!1,e.audioConstraint.googNoiseSuppression=!1),n(),!0},e.setVideoEncoderConfiguration=function(t){Object(z.checkValidObject)(t,"config");var n=s.b.reportApiInvoke(e.sid,{name:"Stream.setVideoEncoderConfiguration",options:t,tag:"tracer"});t.resolution&&(Object(z.checkValidNumber)(t.resolution.width,"config.resolution.width"),Object(z.checkValidNumber)(t.resolution.height,"config.resolution.height"),e.setVideoResolution([t.resolution.width,t.resolution.height])),t.frameRate&&(Object(z.checkValidNumber)(t.frameRate.min,"config.frameRate.min"),Object(z.checkValidNumber)(t.frameRate.max,"config.frameRate.max"),e.setVideoFrameRate([t.frameRate.min,t.frameRate.max])),t.bitrate&&(Object(z.checkValidNumber)(t.bitrate.min,"config.bitrate.min",1,1e7),Object(z.checkValidNumber)(t.bitrate.max,"config.bitrate.max",1,1e7),e.setVideoBitRate([t.bitrate.min,t.bitrate.max])),n()},e.getSupportedProfile=function(t){var n=s.b.reportApiInvoke(e.sid,{name:"Stream.getSupportedProfile",options:arguments,tag:"tracer",callback:t});if(!e.local){var a="ONLY_LOCAL_STREAM_SUPPORTED";return r.default.error(a),n(a)}if(!e.stream){a="STREAM_NOT_INIT";return r.default.error(a),n(a)}if(!e.stream.getVideoTracks){a="TRACK_NOT_SUPPORT";return r.default.error(a),n(a)}var i=e.stream.getVideoTracks()[0];if(!i){a="NO_VIDEO_TRACK_FOUND";return r.default.error(a),n(a)}if(!i.getCapabilities){a="GETCAPABILITY_NOT_SUPPORT";return r.default.error(a),n(a)}var o=i.getCapabilities(),c=Re(o);return n(null,c)}}(t,e),t.getId=function(){return t.streamId},t.getUserId=function(){return t.userId},t.checkDualStreamEnabled=function(){if(Object(o.getParameter)("DUALSTREAM_OPERATION_CHECK")&&t.isDualStream){return r.default.error("Operation not permitted: ".concat("DUAL_STREAM_ENABLED")),"DUAL_STREAM_ENABLED"}return!1},t.setUserId=function(e){var n=s.b.reportApiInvoke(t.sid,{name:"Stream.setUserId",options:arguments,tag:"tracer"});t.userId&&r.default.warning("[".concat(t.streamId,"] Stream.userId ").concat(t.userId," => ").concat(e)),t.userId=e,n()},t.getAttributes=function(){return e.screen?t.screenAttributes:e.attributes},t.hasAudio=function(){return!!t.audio},t.hasVideo=function(){return!!t.video},t.hasScreen=function(){return!!t.screen},t.hasScreenAudio=function(){return!!t.screenAudio},t.isVideoOn=function(){return(t.hasVideo()||t.hasScreen())&&!t.userMuteVideo},t.isAudioOn=function(){return t.hasAudio()&&!t.userMuteAudio},t.init=function(a,i){var o=s.b.reportApiInvoke(t.sid,{callback:function(e,t){if(e)return i&&i(e);a&&a(t)},name:"Stream.init",options:arguments,tag:"tracer"}),c=((new Date).getTime(),arguments[2]);if(void 0===c&&(c=2),!0===t.initialized)return o({type:"warning",msg:"STREAM_ALREADY_INITIALIZED"});if(!0!==t.local)return o({type:"warning",msg:"STREAM_NOT_LOCAL"});var d=Math.random().toString().slice(3);t._streamInitID=d,t.videoSource?t.videoName="videoSource":t.video&&(t.videoName=K.searchDeviceNameById(e.cameraId)||"default"),t.audioSource?t.audioName="audioSource":t.audio&&(t.audioName=K.searchDeviceNameById(e.microphoneId)||"default"),t.screen&&(t.screenName=e.extensionId||"default");try{if(e.audio||e.video||e.screen||e.screenAudio||e.videoSource||e.audioSource){r.default.debug("[".concat(t.streamId,"] Requested access to local media"));var u={streamId:t.streamId};e.videoSource?u.videoSource=e.videoSource:e.screen?u.screen=t.screenConstraint:e.video&&(u.video=t.videoConstraint),e.audioSource?u.audioSource=e.audioSource:e.screenAudio?u.screenAudio=e.screenAudio:e.audio&&(u.audio=t.audioConstraint),G(u,(function(a){if(u.screenAudio&&!a.getAudioTracks()[0]&&r.default.warning("[".concat(t.streamId,"] Audio sharing is not selected")),u.screen&&r.default.debug("[".concat(t.streamId,"] User has granted access to screen sharing")),(u.video||u.audio)&&r.default.debug("[".concat(t.streamId,"] User has granted access to local media")),null===t._streamInitID){a.getTracks().forEach((function(e){e.stop()}));var i={type:"error",msg:"STREAM_IS_CLOSED",info:"stream is closed and cannot be initialized"};return r.default.error(t.streamId,i.info),void o(i)}if(t._streamInitID!==d){a.getTracks().forEach((function(e){e.stop()}));i={type:"error",msg:"ABORT_OTHER_INIT",info:"stream initialization is aborted because of another stream.init"};return r.default.error(t.streamId,i.info),void o(i)}t.dispatchEvent({type:"accessAllowed"}),t.stream=a,t.initialized=!0,t.reloadDeviceName(),t.hasVideo()&&Object(H.vsResHack)(a,(function(e,n){t.videoWidth=e,t.videoHeight=n}),(function(e){r.default.warning("[".concat(t.streamId,"] vsResHack failed: "),e)})),e.screen&&t.stream&&t.stream.getVideoTracks()[0]&&(t.stream.getVideoTracks()[0].onended=function(){t.dispatchEvent({type:"stopScreenSharing"})}),t.stream&&t.stream.getTracks&&t.stream.getTracks().forEach((function(e){e&&!e.onended&&(e.onended=n)})),o()}),(function(e){var n={type:"error",info:null};switch(e&&(n.msg=e.name||e.code||e,e.message&&(n.info=e.message),e.code&&(n.info?n.info+=". "+e.code:n.info=" "+e.code),e.constraint&&(n.info?n.info+=". Constraint: "+e.constraint:n.info="constraint: "+e.constraint)),n.msg){case"Starting video failed":case"TrackStartError":if(t.videoConstraint&&(delete t.videoConstraint.width,delete t.videoConstraint.height),c>0)return void setTimeout((function(){t.init((function(e){return o(e)}),o,c-1)}),1);n.msg="MEDIA_OPTION_INVALID";break;case"DevicesNotFoundError":n.msg="DEVICES_NOT_FOUND";break;case"NotSupportedError":n.msg="NOT_SUPPORTED";break;case"PermissionDeniedError":case"InvalidStateError":n.msg="PERMISSION_DENIED",t.dispatchEvent({type:"accessDenied"});break;case"PERMISSION_DENIED":case"NotAllowedError":t.dispatchEvent({type:"accessDenied"});break;case"ConstraintNotSatisfiedError":n.msg="CONSTRAINT_NOT_SATISFIED";break;default:n.msg||(n.msg="UNDEFINED")}var a="Media access ".concat(n.msg).concat(n.info?": "+n.info:"");r.default.error("[".concat(t.streamId,"] "),a),o(n)}))}else o({type:"warning",msg:"STREAM_HAS_NO_MEDIA_ATTRIBUTES"})}catch(e){r.default.error("[".concat(t.streamId,"] Stream init: "),e),o({type:"error",msg:e.message||e})}},t.reloadDeviceName=function(){if(t.stream){if(t.stream.getVideoTracks){var e=t.stream.getVideoTracks()[0];e&&e.label&&(t.videoName=e.label)}if(t.stream.getAudioTracks){var n=t.stream.getAudioTracks()[0];n&&n.label&&(t.audioName=n.label)}}},t.close=function(){var e=s.b.reportApiInvoke(null,{name:"Stream.close",options:arguments,tag:"tracer"});if(r.default.debug("[".concat(t.streamId,"] Close stream with id"),t.streamId),t._originStream)try{t._originStream.getTracks().map((function(e){return e.stop()}))}catch(e){}if(void 0!==t.stream){var n=t.stream.getTracks();for(var a in n)n.hasOwnProperty(a)&&n[a].stop();!t.isLowStream&&t.local?he.disableVideoEffect(t).then((function(){t.stream=void 0})):(t.stream&&t.stream.clean&&t.stream.clean(),t.stream=void 0)}if(Object(g.isSafari)()&&t.pc&&t.pc.peerConnection&&t.pc.peerConnection.removeTrack&&t.pc.peerConnection.getSenders){var i=t.pc.peerConnection.getSenders();i.forEach((function(e){e&&(r.default.debug("[".concat(t.streamId,"] Remove Track"),e),t.pc.peerConnection.removeTrack(e))}))}t.local&&(t.initialized=!1),t._streamInitID=null,t._onAudioMute=void 0,t._onAudioUnmute=void 0,t._onVideoMute=void 0,t._onVideoUnmute=void 0,t.lowStream&&t.lowStream.close(),e()},t.enableAudio=function(){var e,n=s.b.reportApiInvoke(t.sid,{name:"Stream.enableAudio",options:arguments,tag:"tracer"});return r.default.deprecate("[".concat(t.streamId,"] Stream.enableAudio is deprecated and will be removed in the future. Use Stream.unmuteAudio instead")),t.userMuteAudio||r.default.warning("[".concat(t.streamId,"] User already enableAudio")),t.userMuteAudio=!1,n(null,e=!t.peerMuteAudio&&t._unmuteAudio()),e},t.disableAudio=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.disableAudio",options:arguments,tag:"tracer"});r.default.deprecate("[".concat(t.streamId,"] Stream.disableAudio is deprecated and will be removed in the future. Use Stream.muteAudio instead")),t.userMuteAudio&&r.default.warning("[".concat(t.streamId,"] User already disableAudio")),t.userMuteAudio=!0;var n=t._muteAudio();return e(null,n),n},t.enableVideo=function(){var e,n=s.b.reportApiInvoke(t.sid,{name:"Stream.enableVideo",options:arguments,tag:"tracer"});return r.default.deprecate("[".concat(t.streamId,"] Stream.enableVideo is deprecated and will be removed in the future. Use Stream.unmuteVideo instead")),t.userMuteVideo||r.default.warning("[".concat(t.streamId,"] User already enableVideo")),t.userMuteVideo=!1,t.lowStream&&(t.lowStream.userMuteVideo=!1),n(null,e=!t.peerMuteVideo&&t._unmuteVideo()),e},t.disableVideo=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.disableVideo",options:arguments,tag:"tracer"});r.default.deprecate("[".concat(t.streamId,"] Stream.disableVideo is deprecated and will be removed in the future. Use Stream.muteVideo instead")),t.userMuteVideo&&r.default.warning("[".concat(t.streamId,"] User already disableVideo")),t.userMuteVideo=!0,t.lowStream&&(t.lowStream.userMuteVideo=!0);var n=t._muteVideo();return e(null,n),n},t.unmuteAudio=function(){var e,n=s.b.reportApiInvoke(t.sid,{name:"Stream.unmuteAudio",options:arguments,tag:"tracer"});return t.userMuteAudio||r.default.warning("[".concat(t.streamId,"] User already unmuteAudio")),t.userMuteAudio=!1,n(null,e=!t.peerMuteAudio&&t._unmuteAudio()),e},t.muteAudio=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.muteAudio",options:arguments,tag:"tracer"});t.userMuteAudio&&r.default.warning("[".concat(t.streamId,"] User already muteAudio")),t.userMuteAudio=!0;var n=t._muteAudio();return e(null,n),n},t.unmuteVideo=function(){var e,n=s.b.reportApiInvoke(t.sid,{name:"Stream.unmuteVideo",options:arguments,tag:"tracer"});return t.userMuteVideo||r.default.warning("[".concat(t.streamId,"] User already unmuteVideo")),t.userMuteVideo=!1,t.lowStream&&(t.lowStream.userMuteVideo=!1),n(null,e=!t.peerMuteVideo&&t._unmuteVideo()),e},t.muteVideo=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.muteVideo",options:arguments,tag:"tracer"});t.userMuteVideo&&r.default.warning("[".concat(t.streamId,"] User already muteVideo")),t.userMuteVideo=!0,t.lowStream&&(t.lowStream.userMuteVideo=!0);var n=t._muteVideo();return e(null,n),n},t._unmuteAudio=function(){return r.default.debug("[".concat(t.streamId,"] Unmuted audio stream with id "),t.streamId),t._flushAudioMixingMuteStatus(!1),!(!t.hasAudio()||!t.initialized||void 0===t.stream||!0===t.stream.getAudioTracks()[0].enabled)&&(t._onAudioUnmute&&t._onAudioUnmute(),t.pc&&(t.pc.isAudioMute=!1),t.stream.getAudioTracks()[0].enabled=!0,!0)},t._isAudioMuted=function(){if(t.stream&&t.hasAudio()){var e=t.stream.getAudioTracks();return e.length>0&&!e[0].enabled}return!1},t._isVideoMuted=function(){if(t.stream&&t.hasVideo()){var e=t.stream.getVideoTracks();return e.length>0&&!e[0].enabled}return!1},t._muteAudio=function(){return r.default.debug("[".concat(t.streamId,"] Muted audio stream with id "),t.streamId),t._flushAudioMixingMuteStatus(!0),!!(t.hasAudio()&&t.initialized&&void 0!==t.stream&&t.stream.getAudioTracks()[0].enabled)&&(t._onAudioMute&&t._onAudioMute(),t.pc&&(t.pc.isAudioMute=!0),t.stream.getAudioTracks()[0].enabled=!1,t.sid&&s.b.audioSendingStopped(t.sid,{succ:!0,reason:"muteAudio"}),!0)},t._unmuteVideo=function(){return r.default.debug("[".concat(t.streamId,"] Unmuted video stream with id"),t.streamId),!(!t.initialized||void 0===t.stream||!t.stream.getVideoTracks().length||!0===t.stream.getVideoTracks()[0].enabled)&&(t._onVideoUnmute&&t._onVideoUnmute(),t.pc&&(t.pc.isVideoMute=!1),t.stream.getVideoTracks()[0].enabled=!0,t.lowStream&&t.lowStream._unmuteVideo(),!0)},t._muteVideo=function(){return r.default.debug("[".concat(t.streamId,"] Muted video stream with id"),t.streamId),!!(t.initialized&&void 0!==t.stream&&t.stream.getVideoTracks().length&&t.stream.getVideoTracks()[0].enabled)&&(t._onVideoMute&&t._onVideoMute(),t.pc&&(t.pc.isVideoMute=!0),t.stream.getVideoTracks()[0].enabled=!1,t.lowStream&&t.lowStream._muteVideo(),t.sid&&s.b.videoSendingStopped(t.sid,{succ:!0,reason:"muteVideo"}),!0)},t.addTrack=function(a){var i=s.b.reportApiInvoke(t.sid,{name:"Stream.addTrack",options:arguments,tag:"tracer"});if(t.pc&&t.pc.addTrack(a,t.stream),"audio"==a.kind){t._cleanupAudioMixing();var o=new MediaStream;t.userMuteAudio&&(a.enabled=!1),o.addTrack(a);var r=t.stream.getVideoTracks()[0];r&&o.addTrack(r),t.audio=!0,e.audio=!0,t.stream=o,t.audioLevelHelper=null,t.player&&t.player.video&&(t.player.video.srcObject=t.stream)}else t.userMuteVideo&&(a.enabled=!1),t.stream.addTrack(a),t.video=!0,e.video=!0;a.onended||(a.onended=n),i()},t.removeTrack=function(n){var a=s.b.reportApiInvoke(t.sid,{name:"Stream.removeTrack",options:arguments,tag:"tracer"});t.pc&&t.pc.removeTrack(n,t.stream),t.stream.removeTrack(n),t._cleanupAudioMixing(),"audio"===n.kind?(t.audio=!1,e.audio=!1):(t.video=!1,e.video=!1),t.audioLevelHelper=null,"live"==n.readyState&&(n.stop(),r.default.debug("[".concat(t.streamId,"] Track ").concat(n.kind," Stopped"))),a()},t.setAudioOutput=function(e,n,a){var i=s.b.reportApiInvoke(t.sid,{callback:function(e,t){if(e)return a&&a(e);n&&n(t)},name:"Stream.setAudioOutput",options:arguments,tag:"tracer"});return Object(z.isValidString)(e,1,255)?(t.audioOutput=e,t.player?void t.player.setAudioOutput(e,(function(){return i()}),i):i()):(r.default.error("[".concat(t.streamId,"] setAudioOutput Invalid Parameter"),e),i(I.default.INVALID_PARAMETER))},t.play=function(e,n,a){"function"==typeof n&&(a=n,n=null),r.default.debug("[".concat(t.streamId,"] play()."),e,n);var i=s.b.reportApiInvoke(t.sid,{name:"Stream.play",options:arguments,tag:"tracer",callback:a});if(Object(z.checkValidString)(e,"elementID"),Object(z.isEmpty)(n)||(Object(z.isEmpty)(n.fit)||Object(z.checkValidEnum)(n.fit,"fit",["cover","contain"]),Object(z.isEmpty)(n.muted)||Object(z.checkValidBoolean)(n.muted,"muted")),t.player)r.default.warning("[".concat(t.streamId,"] Stream.play(): Stream is already playing. Fallback to resume stream")),t.resume().then((function(){i(null)})).catch(i);else{t.elementID=e,t.playOptions=n,!t.local||t.video||t.screen?(t.player=new T({id:t.getId(),stream:t,elementID:e,options:n}),t.local&&he.applyEffectInPlayer(t)):t.hasAudio()&&(t.player=new T({id:t.getId(),stream:t,elementID:e,options:n}));var o={video:null,audio:null},c=function e(n){if(o[n.mediaType]=n,o.video&&o.audio)if(t.removeEventListener("player-status-change",e),o.video.isErrorState||o.audio.isErrorState){var a=o.video.isErrorState?o.video:o.audio;i({isErrorState:!0,status:a.status,reason:a.reason,video:o.video,audio:o.audio})}else"aborted"===o.video.status&&"aborted"===o.audio.status?i({status:"aborted",reason:"stop",video:o.video,audio:o.audio}):i(null)};t.on("player-status-change",c),t.audioOutput&&t.player.setAudioOutput(t.audioOutput),void 0!==t.audioLevel&&t.player.setAudioVolume(t.audioLevel),t._flushAudioMixingMuteStatus(!1)}},t.stop=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.stop",options:arguments,tag:"tracer"});r.default.debug("[".concat(t.streamId,"] Stop stream player with id "),t.streamId),t.player?(he.removeEffectFromLocalPlayer(t),t.player.destroy(),delete t.player):r.default.error("[".concat(t.streamId,"] Stream.stop(): Stream is not playing")),t._flushAudioMixingMuteStatus(!0),e()},t.isPlaying=function(){return!!t.player},t.isPaused=function(){return!!t.player&&(!!(t.player.video&&t.player.video.paused&&t.player.mediaElemExists(t.player.video))||!!(t.player.audio&&t.player.audio.paused&&t.player.mediaElemExists(t.player.audio)))},t.resume=function(){var e,n;return t.player?(t.player.video&&t.player.video.play&&(e=t.player.video.play()),e=e||Promise.resolve(),t.player.audio&&t.player.audio.play&&(n=t.player.audio.play()),n=n||Promise.resolve(),Promise.all([e,n])):Promise.reject("NO_PLAYER_FOUND")},t.getVideoTrack=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.getVideoTrack",options:arguments,tag:"tracer"});if(t.stream&&t.stream.getVideoTracks){var n=t.stream.getVideoTracks()[0];if(n)return r.default.info("[".concat(t.streamId,"] getVideoTrack"),n),e(),n}r.default.info("[".concat(t.streamId,"] getVideoTrack None")),e(null,"getVideoTrack None")},t.getAudioTrack=function(){var e=s.b.reportApiInvoke(t.sid,{name:"Stream.getAudioTrack",options:arguments,tag:"tracer"});if(t.stream&&t.stream.getAudioTracks){var n=t.stream.getAudioTracks()[0];if(n)return r.default.info("[".concat(t.streamId,"] getAudioTracks"),n),e(),n}r.default.info("[".concat(t.streamId,"] getAudioTracks None")),e(null,"getAudioTracks None")},t._hasVideoTracks=function(){return!!(t.stream&&t.stream.getVideoTracks&&t.stream.getVideoTracks()[0])},t._hasAudioTracks=function(){return!!(t.stream&&t.stream.getAudioTracks&&t.stream.getAudioTracks()[0])},t._replaceMediaStreamTrack=function(e,n,a){if(t.stream){if("video"==e.kind){if(o=t.stream.getVideoTracks()[0])return t.userMuteVideo&&(e.enabled=!1),t.stream.removeTrack(o),t.stream.addTrack(e),r.default.debug("[".concat(t.streamId,"] _replaceMediaStreamTrack ").concat(e.kind," SUCCESS")),"live"==o.readyState&&(o.stop(),r.default.debug("[".concat(t.streamId,"] Track ").concat(o.kind," Stopped"))),n&&n();var i="MEDIASTREAM_TRACK_NOT_FOUND";return r.default.error("[".concat(t.streamId,"] MEDIASTREAM_TRACK_NOT_FOUND ").concat(e.kind)),a(i)}if("audio"==e.kind){var o;if(o=t.stream.getAudioTracks()[0]){t.userMuteAudio&&(e.enabled=!1);var s=new MediaStream;s.addTrack(e);var c=t.stream&&t.stream.getVideoTracks()[0];return c&&s.addTrack(c),t.stream=s,t.audioLevelHelper=null,t.player&&t.player.video&&(t.player.video.srcObject=t.stream),r.default.debug("[".concat(t.streamId,"] _replaceMediaStreamTrack SUCCESS")),"live"==o.readyState&&(o.stop(),r.default.debug("[".concat(t.streamId,"] Track ").concat(o.kind," Stopped"))),n&&n()}i="MEDIASTREAM_TRACK_NOT_FOUND";return r.default.error("[".concat(t.streamId,"] MEDIASTREAM_TRACK_NOT_FOUND ").concat(e.kind)),a(i)}i="INVALID_TRACK_TYPE";return r.default.error("[".concat(t.streamId,"] _replaceMediaStreamTrack ").concat(i," ").concat(e.kind)),a&&a(i)}i="NO_STREAM_FOUND";return r.default.error("[".concat(t.streamId,"] _replaceMediaStreamTrack ").concat(i)),a&&a(i)},t.replaceTrack=function(e,a,i){var o=s.b.reportApiInvoke(t.sid,{callback:function(e,t){if(e)return i&&i(e);a&&a(t)},name:"Stream.replaceTrack",options:arguments,tag:"tracer"});return e&&e.kind?(t._cleanupAudioMixing(),e.onended||(e.onended=n),t.pc&&t.pc.hasSender&&t.pc.hasSender(e.kind)?void t.pc.replaceTrack(e,(function(){return r.default.debug("[".concat(t.streamId,"] PeerConnection.replaceTrack ").concat(e.kind," SUCCESS")),t._replaceMediaStreamTrack(e,(function(e){return o(null,e)}),o)}),(function(n){return r.default.error("[".concat(t.streamId,"] PeerConnection.replaceTrack ").concat(e.kind," Failed ").concat(n)),o(n)})):t._replaceMediaStreamTrack(e,(function(e){return o(null,e)}),o)):o("INVALID_TRACK")},t.setAudioVolume=function(e){var n=s.b.reportApiInvoke(t.sid,{name:"Stream.setAudioVolume",options:arguments,tag:"tracer"});Object(z.checkValidNumber)(e,"level",0,100),t.audioLevel=e,t.player&&t.player.setAudioVolume(e),n()},t.getStats=function(e,n,a){var i=[];i.push(t._getPCStats(a)),i.push(new Promise((function(e){var n={};t.pc&&t.pc.isSubscriber?null!==window.navigator.userAgent.match("Firefox")&&(q(n,"videoReceiveResolutionHeight",t.videoHeight),q(n,"videoReceiveResolutionWidth",t.videoWidth)):t.pc&&!t.pc.isSubscriber&&((Object(g.isSafari)()||Object(g.isFireFox)())&&(q(n,"videoSendResolutionHeight",t.videoHeight),q(n,"videoSendResolutionWidth",t.videoWidth)),(Object(g.isSafari)()||Object(g.isFireFox)())&&t.uplinkStats&&q(n,"videoSendPacketsLost",t.uplinkStats.uplink_cumulative_lost)),e(n)}))),i.push(new Promise((function(e){var n={};return t.traffic_stats&&t.pc&&t.pc.isSubscriber?(q(n,"accessDelay",t.traffic_stats.access_delay),q(n,"endToEndDelay",t.traffic_stats.e2e_delay),q(n,"videoReceiveDelay",t.traffic_stats.video_delay),q(n,"audioReceiveDelay",t.traffic_stats.audio_delay)):t.traffic_stats&&t.pc&&!t.pc.isSubscriber&&q(n,"accessDelay",t.traffic_stats.access_delay),e(n)}))),Promise.all(i).then((function(n){for(var a={},i=n.length-1;i>=0;i--){var o=n[i];E()(a,o)}e&&setTimeout(e.bind(t,a),0)})).catch((function(e){n&&setTimeout(n.bind(t,e),0)}))},t._getPCStats=function(e){return new Promise((function(n,a){if(!t.pc||"established"!==t.pc.state||!t.pc.getStats){return a("PEER_CONNECTION_NOT_ESTABLISHED")}t.pc.getStats((function(e){if(!t.pc||"established"!==t.pc.state||!t.pc.getStats){return a("PEER_CONNECTION_STATE_CHANGE")}var i=t.pc.isSubscriber?function(e){var t={};return e.forEach((function(e){e.id&&e.type&&(-1===e.id.indexOf("recv")&&-1===e.type.toLowerCase().indexOf("inbound")&&-1===e.id.indexOf("inbound_rtp")&&-1===e.id.indexOf("inbound-rtp")&&-1===e.id.indexOf("InboundRTP")||("audio"===e.mediaType?(q(t,"audioReceiveBytes",e.bytesReceived),q(t,"audioReceivePackets",e.packetsReceived),q(t,"audioReceivePacketsLost",e.packetsLost)):(q(t,"videoReceiveBytes",e.bytesReceived),q(t,"videoReceivePacketsLost",e.packetsLost),q(t,"videoReceivePackets",e.packetsReceived),q(t,"videoReceiveFrameRate",e.googFrameRateReceived),q(t,"videoReceiveDecodeFrameRate",e.googFrameRateDecoded),q(t,"videoReceiveResolutionWidth",e.googFrameWidthReceived),q(t,"videoReceiveResolutionHeight",e.googFrameHeightReceived))))})),t}(e):function(e){var t={};return e.forEach((function(e){e.id&&e.type&&(-1===e.id.indexOf("send")&&-1===e.type.toLowerCase().indexOf("outbound")&&-1===e.id.indexOf("outbound_rtp")&&-1===e.id.indexOf("OutboundRTP")||("audio"===e.mediaType?(q(t,"audioSendBytes",e.bytesSent),q(t,"audioSendPackets",e.packetsSent),q(t,"audioSendPacketsLost",e.packetsLost)):(q(t,"videoSendBytes",e.bytesSent),q(t,"videoSendPackets",e.packetsSent),q(t,"videoSendPacketsLost",e.packetsLost),q(t,"videoSendFrameRate",e.googFrameRateSent),q(t,"videoSendResolutionWidth",e.googFrameWidthSent),q(t,"videoSendResolutionHeight",e.googFrameHeightSent))))})),t}(e);return n(i)}),e)})).then((function(e){return t.pc.isSubscriber?(Object(g.isFireFox)()||Object(g.isSafari)())&&(e.videoReceiveResolutionHeight&&"0"!==e.videoReceiveResolutionHeight||e.videoReceiveResolutionWidth&&"0"!==e.videoReceiveResolutionWidth||(q(e,"videoReceiveResolutionHeight",t.videoHeight),q(e,"videoReceiveResolutionWidth",t.videoWidth))):((Object(g.isSafari)()||Object(g.isFireFox)())&&(e.videoSendResolutionHeight&&"0"!==e.videoSendResolutionHeight||e.videoSendResolutionWidth&&"0"!==e.videoSendResolutionWidth||(q(e,"videoSendResolutionHeight",t.videoHeight),q(e,"videoSendResolutionWidth",t.videoWidth))),(Object(g.isSafari)()||Object(g.isFireFox)())&&t.uplinkStats&&q(e,"videoSendPacketsLost",t.uplinkStats.uplink_cumulative_lost)),Promise.resolve(e)}))},t.getAudioLevel=function(){if(t.audioLevelHelper)return t.audioLevelHelper.getAudioLevel();if(t.stream){if(0!==t.stream.getAudioTracks().length)return t.audioLevelHelper=new H.audioLevelHelper(t.stream),t.audioLevelHelper.getAudioLevel();r.default.warning("[".concat(t.streamId,"] can't get audioLevel beacuse no audio trace in stream"))}else r.default.warning("[".concat(t.streamId,"] can't get audioLevel beacuse no stream exist"))},t.setVideoProfile("480p_1"),t._switchVideoDevice=function(e,n,a){if(e===t.cameraId)return n&&n();var i={video:E()({},t.videoConstraint,{deviceId:{exact:e}}),audio:!1};r.default.debug("[".concat(t.streamId,"] ").concat(i)),G(i,(function(i){try{var o=function(){t.isPlaying()&&(t.stop(),t.elementID&&t.play(t.elementID,t.playOptions)),t.cameraId=e,t.videoConstraint.deviceId={exact:e},t.userMuteVideo&&(t.stream.getVideoTracks()[0].enabled=!1),he.restoreVideoEffect(t).then((function(){n&&n()}))};he.disableVideoEffect(t).then((function(){Object(g.isSafari)()?t.replaceTrack(i.getVideoTracks()[0],o,a):(t.removeTrack(t.stream.getVideoTracks()[0]),t.addTrack(i.getVideoTracks()[0]),o())}))}catch(e){return a&&a(e)}}),(function(e){return a&&a(e)}))},t._switchAudioDevice=function(e,n,a){if(e===t.microphoneId)return n&&n();var i={video:!1,audio:E()({},t.audioConstraint,{deviceId:{exact:e}})};r.default.debug("[".concat(t.streamId,"] "),i),G(i,(function(i){var o=function(){t._cleanupAudioMixing(),t.userMuteAudio&&(t.stream.getAudioTracks()[0].enabled=!1),t.isPlaying()&&(t.stop(),t.elementID&&t.play(t.elementID)),t.microphoneId=e,t.audioConstraint.deviceId={exact:e},n&&n()};try{Object(g.isSafari)()?t.replaceTrack(i.getAudioTracks()[0],o,a):(t.removeTrack(t.stream.getAudioTracks()[0]),t.addTrack(i.getAudioTracks()[0]),o())}catch(e){return a&&a(e)}}),(function(e){return a&&a(e)}))},t.switchDevice=function(e,n,a,i){var o=s.b.reportApiInvoke(t.sid,{callback:function(e,t){if(e)return i&&i(e);a&&a(t)},name:"Stream.switchDevice",options:arguments,tag:"tracer"});Object(z.checkValidString)(n,"deviceId");var c=function(){return t.inSwitchDevice=!1,o()},d=function(e){t.inSwitchDevice=!1,r.default.error("[".concat(t.streamId,"] "),e),o(e)};if(t.inSwitchDevice)return o("Device switch is in process.");if(t.inSwitchDevice=!0,!t.local)return d("Only the local stream can switch the device.");if(t.screen&&"video"===e)return d("The device cannot be switched during screen-sharing.");if(!t.video&&"video"===e)return d("Video track not exist.");if(!t.audio&&"audio"===e)return d("Audio track not exist.");if(t.videoSource||t.audioSource)return d("The device cannot be switched when using videoSource or audioSource.");var u=!1;for(var l in t.audioMixing.sounds){var p=t.audioMixing.sounds[l];if(p.state!==t.audioMixing.states.IDLE){u=!0;break}}var f=t.audioMixing.audioContextInited;if(f&&u)return d("The device cannot be switched when using audio Mixing.");K.getDeviceById(n,(function(){if("video"===e)t._switchVideoDevice(n,c,d);else{if("audio"!==e)return d("Invalid type.");t._switchAudioDevice(n,c,d)}}),(function(){return d("The device does not exist.")}))},t},Oe=a(27),Ce=a(8),Ne=a.n(Ce),we=["live","rtc","web","interop","h264_interop","web-only"],De=["vp8","h264"],ke=["aes-128-xts","aes-256-xts","aes-128-ecb","sm4-128-ecb"],Le=a(17),Pe=a.n(Le),Me=function(e){e&&e.apply(this,[].slice.call(arguments,1))},Ue=a(11),xe=function(e){var t=c();t.needReconnect=!0,t.isTimeout=!1,t.isInit=!0,t.sendbytes=0,t.recvbytes=0,t.startTime=Date.now(),t.lastMsgTime=null,t.clientId=e.clientId,t.hostIndex=0,t.requestID=0,e.host instanceof Array?t.host=e.host:t.host=[e.host],t.getSendBytes=function(){return t.sendbytes},t.getRecvBytes=function(){return t.recvbytes},t.getDuration=function(){return Math.ceil((Date.now()-t.startTime)/1e3)},t.getURL=function(){return t.connection.url},t.reconnect=function(){t.isInit=!0,t.creatConnection()},t.connectNext=function(){t.isInit=!0,++t.hostIndex,r.default.debug("["+t.clientId+"] Gateway length:"+t.host.length+" current index:"+t.hostIndex),t.hostIndex>=t.host.length?t.dispatchEvent(p({type:"recover"})):t.creatConnection()},t.replaceHost=function(e){t.host=e||t.host,t.hostIndex=0,t.creatConnection()},t.creatConnection=function(){if(t.needReconnect=!0,t.lts=(new Date).getTime(),t.connection=new WebSocket("wss://"+t.host[t.hostIndex]),t.connection.binaryType="arraybuffer",t.turnConfig={},t.connection.url){var n=t.connection.url.match(/wss\:\/\/([^:]+):(\d+)/),a=t.host[t.hostIndex].split(":"),i=t.connection.url.match(/h=([^:]+)&p=(\d+)/);n?(t.turnConfig.url=n[1],Object(o.getParameter)("TURN_ENABLE_TCP")&&(t.turnConfig.tcpport=parseInt(n[2])+30),Object(o.getParameter)("TURN_ENABLE_UDP")&&(t.turnConfig.udpport=parseInt(n[2])+30)):i?(t.turnConfig.url=i[1],Object(o.getParameter)("TURN_ENABLE_TCP")&&(t.turnConfig.tcpport=parseInt(i[2])+30),Object(o.getParameter)("TURN_ENABLE_UDP")&&(t.turnConfig.udpport=parseInt(i[2])+30)):a&&(t.turnConfig.url=a[0],Object(o.getParameter)("TURN_ENABLE_TCP")&&(t.turnConfig.tcpport=parseInt(a[1])+30),Object(o.getParameter)("TURN_ENABLE_UDP")&&(t.turnConfig.udpport=parseInt(a[1])+30))}t.connection.onopen=function(e){t.needReconnect=!0,t.isTimeout=!1,t.isInit=!1,t.sendbytes=0,t.recvbytes=0,t.startTime=Date.now(),Object(Ue.resetHTTPByetsCount)(),clearTimeout(t.timeoutCheck),t.dispatchEvent(p({type:"onopen",event:e,socket:t}))},t.connection.onmessage=function(e){if(e.data instanceof ArrayBuffer)t.dispatchEvent({type:"onBinaryData",data:e.data});else{t.recvbytes+=Object(H.lengthInUtf8Bytes)(e.data);var n=JSON.parse(e.data);t.lastMsgTime=Date.now(),n.hasOwnProperty("_id")?t.dispatchEvent(p({type:n._id,msg:n})):n.hasOwnProperty("_type")&&t.dispatchSocketEvent(p({type:n._type,msg:n._message}))}},t.connection.onclose=function(n){t.needReconnect?t.isTimeout||t.isInit?(r.default.debug("["+t.clientId+"] websockect connect timeout"),s.b.joinGateway(e.sid,{lts:t.lts,succ:!1,ec:"timeout",addr:t.connection.url}),t.connectNext()):(t.dispatchEvent(p({type:"disconnect",event:n})),t.requests&&t.requests instanceof Array&&(t.requests.map((function(e){e.callback("REQUEST_ABORT")})),t.requests=[])):(r.default.debug("["+t.clientId+"] websockect closeed"),Me(e.onFailure,n),clearTimeout(t.timeoutCheck),t.dispatchEvent(p({type:"close",event:n})),t.connection.onopen=void 0,t.connection.onclose=void 0,t.connection.onerror=void 0,t.connection.onmessage=void 0,t.connection=void 0)},t.connection.onerror=function(e){};setTimeout((function(){t.connection&&t.connection.readyState!=WebSocket.OPEN&&(t.isTimeout=!0,t.connection.close())}),5e3)},t.creatConnection(),t.sendMessage=function(e,n){if(t.connection&&t.connection.readyState==WebSocket.OPEN){var a=JSON.stringify(e);t.sendbytes+=Object(H.lengthInUtf8Bytes)(a),t.connection.send(a)}else n({error:"Gateway not connected"})},t.disconnect=function(){t.needReconnect=!0,t.connection.close()},t.close=function(){t.needReconnect=!1,t.connection.onclose=void 0,t.connection.close(),clearInterval(t.requestTimer),t.requests&&t.requests instanceof Array&&(t.requests.map((function(e){e.callback("REQUEST_ABORT")})),t.requests=[])},t.sendSignalCommand=function(e,n){e._id="_request_"+t.requestID,t.requestID+=1,"publish_stats"!==e._type&&"subscribe_stats"!==e._type&&"publish_stats_low"!==e._type&&t.on(e._id,(function(a){a.msg&&n&&n(a.msg._result,a.msg.message),delete t.dispatcher.eventListeners[e._id]})),t.sendMessage(e,(function(e){e.reason="NOT_CONNECTED",n&&n(e.reason,e)}))},t.requests=[];var n=function(e){var n=t.requests.findIndex((function(t){return t.id===e.type}));if(n>=0)var a=t.requests.splice(n,1)[0];a&&t.dispatcher.eventListeners[e.type]?(delete t.dispatcher.eventListeners[e.type],e.msg&&a.callback&&a.callback(e.msg._result,e.msg._message)):r.default.warning("Detached Response",e.type,e.msg)},a=function(e){var n=this,a=t.requests.findIndex((function(e){return e.id===n.id}));a>=0&&(n=t.requests.splice(a,1)[0]),n&&t.dispatcher.eventListeners[e.type]?(delete t.dispatcher.eventListeners[e.type],e.reason="NOT_CONNECTED",n.callback&&n.callback(e.reason,e)):r.default.warning("handleSendError",n)};return t.sendRequest=function(e,i){e=E()({_id:"_request_"+t.requestID},e),t.requestID+=1;var o={id:e._id,timeoutCounter:0,stalledAt:Date.now(),message:e,callback:i};t.requests.push(o),t.addEventListener(e._id,n),t.sendMessage(e,a.bind(o))},t.checkRequestTimeout=function(){for(var e=Math.ceil(Object(o.getParameter)("SIGNAL_REQUEST_TIMEOUT")/Object(o.getParameter)("SIGNAL_REQUEST_WATCH_INTERVAL")),n=t.requests.length-1;n>=0;n--){var a=t.requests[n];a.timeoutCounter>=e?(t.requests.splice(n,1),r.default.error("Request Timeout",a.timeoutCounter,a.message),a.callback&&a.callback("TIMEOUT")):a.timeoutCounter++}},clearInterval(t.requestTimer),t.requestTimer=setInterval(t.checkRequestTimeout,Object(o.getParameter)("SIGNAL_REQUEST_WATCH_INTERVAL")),t.sendReport=function(e){t.sendMessage(e,(function(){}))},t},Ve=function(e,t){var n={connect:function(){t.host=e,n.signal=xe(t),n.on=n.signal.on,n.dispatchEvent=n.signal.dispatchEvent,n.signal.on("onopen",(function(e){n.signal.onEvent=function(e){n.dispatchEvent(p({type:e.event,msg:e}))},n.dispatchEvent(p({type:"connect",msg:e}))})),n.signal.on("onError",(function(e){var t=e.msg;onError(t.code,"error")}))},getLastMsgTime:function(){return n.signal&&n.signal.lastMsgTime},getSendBytes:function(){return n.signal.getSendBytes()},getRecvBytes:function(){return n.signal.getRecvBytes()},getDuration:function(){return n.signal.getDuration()},disconnect:function(){n.signal.disconnect()},close:function(){n.signal.close()},getURL:function(){return n.signal.getURL()},reconnect:function(){n.signal.reconnect()},connectNext:function(){n.signal.connectNext()},replaceHost:function(e){n.signal.replaceHost(e)},emitSimpleMessage:function(e,t){n.signal.sendSignalCommand(e,t)},emitRequest:function(e,t){n.signal.sendRequest(e,t)},emitReport:function(e){n.signal.sendReport(e)}};return n.connect(),n},je=function(e,t){var n=!1,a=0,i={command:"convergeAllocateEdge",sid:e.sid,appId:e.appId,token:e.token,uid:e.uid,cname:e.cname,ts:Math.floor(Date.now()/1e3),version:o.VERSION,seq:0,requestId:1};Object(o.getParameter)("PROXY_CS").map((function(c){var d=(new Date).getTime();Be("https://"+c+"/api/v1",i,(function(i,u){if(i)return r.default.debug("["+e.clientId+"] Request proxy server failed: ",i),a++,s.b.requestProxyAppCenter(e.sid,{lts:d,succ:!1,APAddr:c,workerManagerList:null,ec:JSON.stringify(i),response:JSON.stringify({err:i,res:u})}),void(a>=Object(o.getParameter)("PROXY_CS").length&&t&&t("Get proxy server failed: request all failed"));if(!n)if((u=JSON.parse(u)).json_body){var l=JSON.parse(u.json_body);if(r.default.debug("["+e.clientId+"] App return:",l.servers),200!==l.code){i="Get proxy server failed: response code ["+l.code+"], reason [ "+l.reason+"]";r.default.debug("["+e.clientId+"] "+i),s.b.requestProxyAppCenter(e.sid,{lts:d,succ:!1,APAddr:c,workerManagerList:null,ec:i,response:JSON.stringify({err:i,res:u})})}else{n=!0;var p=We(l.servers);s.b.requestProxyAppCenter(e.sid,{lts:d,succ:!0,APAddr:c,workerManagerList:JSON.stringify(p),ec:null,response:JSON.stringify({res:u})}),t&&t(null,p)}}else r.default.debug("["+e.clientId+"] Get proxy server failed: no json_body"),s.b.requestProxyAppCenter(e.sid,{lts:d,succ:!1,APAddr:c,workerManagerList:null,ec:"Get proxy server failed: no json_body",response:JSON.stringify({res:u})})}))}))},Be=function(e,t,n){var a={service_name:"webrtc_proxy",json_body:JSON.stringify(t)};Object(Ue.post)(e,a,(function(e){n&&n(null,e)}),(function(e){n&&n(e)}),{"X-Packet-Service-Type":0,"X-Packet-URI":61})},Fe=function(e,t,n){var a=!1,i=0,o={command:"request",gatewayType:"http",appId:e.appId,cname:e.cname,uid:e.uid+"",sdkVersion:"2.3.1",sid:e.sid,seq:1,ts:+new Date,requestId:3,clientRequest:{appId:e.appId,cname:e.cname,uid:e.uid+"",sid:e.sid}};t.map((function(c){var d=(new Date).getTime();!function(e,t,n){Object(Ue.post)(e,t,(function(e){n&&n(null,e)}),(function(e){n&&n(e)}))}("https://"+c+":4000/v2/machine",o,(function(o,u){if(o)return r.default.debug("["+e.clientId+"] Request worker manager failed: ",o),i++,s.b.requestProxyWorkerManager(e.sid,{lts:d,succ:!1,workerManagerAddr:c,ec:JSON.stringify(o),response:JSON.stringify({res:u})}),void(i>=t.length&&n&&n("requeet worker manager server failed: request failed"));if(!a){if(!(u=JSON.parse(u)).serverResponse)return n&&n("requeet worker manager server failed: serverResponse is undefined");a=!0,s.b.requestProxyWorkerManager(e.sid,{lts:d,succ:!0,workerManagerAddr:c,ec:JSON.stringify(o),response:JSON.stringify({res:u})}),n&&n(null,{address:c,serverResponse:u.serverResponse})}}))}))},We=function(e){if(!e||[]instanceof Array==!1)return[];var t=[];return e.forEach((function(e){var n;e.address&&e.tcp?(e.address.match(/^[\.\:\d]+$/)?n="".concat(e.address.replace(/[^\d]/g,"-"),".edge.agora.io"):(r.default.info("["+joinInfo.clientId+"] "+"Cannot recognized as IP address ".concat(e.address,". Used As Host instead")),n="".concat(e.address,":").concat(e.tcp)),t.push(n)):r.default.error("["+joinInfo.clientId+"] Invalid address format ",e)})),t},Ge=function(e,t){var n=E()({},e),a=Object(o.getParameter)("CDS_AP"),i=[],r=!1;(a=a.map((function(e){return n.proxyServer?"https://".concat(n.proxyServer,"/ap/?url=").concat(e+"/api/v1"):"https://".concat(e,"/api/v1?action=config")}))).map((function(e){!function(e,t,n){var a={flag:64,cipher_method:0,timeout:1e3,features:t};Object(Ue.post)(e,a,(function(e){try{var t=JSON.parse(e);n&&n(null,t)}catch(e){n&&n(e)}n&&n(null,e)}),(function(e){n&&n(e)}),{"X-Packet-Service-Type":0,"X-Packet-URI":54})}(e,n,(function(e,n){r||(e?(i.push(e),i.length>=a.length&&t&&t("ALL_REQUEST_FAILED")):(r=!0,t&&t(null,n)))}))}))},He=a(18),qe={},Je={},Ye=function(e){return qe[e]},Ke=function(e,t,n,a,i){var c=(new Date).getTime(),d=t,u="";t.multiIP&&t.multiIP.gateway_ip&&(u={vocs_ip:[t.multiIP.uni_lbs_ip],vos_ip:[t.multiIP.gateway_ip]});var l={opid:133,flag:4096,ts:+new Date,key:t.token,cname:t.cname,sid:t.sid,detail:{6:t.stringUid,11:i},uid:t.uid||0};u&&(l.detail[5]=JSON.stringify(u)),Object(Ue.post)(e+"".concat(-1===e.indexOf("?")?"?":"&","action=wrtc_gateway"),l,(function(i){try{var u=JSON.parse(i);u.res&&(u=u.res);var l=u.code}catch(e){var p="requestChooseServer failed with unexpected body "+i;return r.default.error("["+d.clientId+"]",p),a(p)}if(l)return v=new RegExp(/10102\d{2}$/).test(l)?"NO_SERVICE_AVAILABLE":I.APErrorCode[u.code]||l,s.b.joinChooseServer(t.sid,{lts:c,succ:!1,csAddr:e,serverList:null,ec:v}),a("Get server node failed ["+v+"]",e,v);var f=[],g=Object(o.getParameter)("GATEWAY_DOMAINS"),m=0;if(e.indexOf(g[1])>-1&&(m=1),u.addresses.forEach((function(e){var t;e.ip&&e.port?(e.ip.match(/^[\.\:\d]+$/)?t="".concat(e.ip.replace(/[^\d]/g,"-"),".").concat(g[m++%g.length],":").concat(e.port):(r.default.info("["+d.clientId+"] "+"Cannot recognized as IP address ".concat(e.ip,". Used As Host instead")),t="".concat(e.ip,":").concat(e.port)),f.push(t)):r.default.error("["+d.clientId+"] Invalid address format ",e)})),!f.length){r.default.error("["+d.clientId+"] Empty Address response",u);var v="EMPTY_ADDRESS_RESPONSE";return s.b.joinChooseServer(t.sid,{lts:c,succ:!1,csAddr:e,serverList:null,ec:v}),a("Get server node failed ["+v+"]",e,v)}var S={gateway_addr:f,uid:u.uid,cid:u.cid,vid:u.detail&&u.detail[8],res:u,uni_lbs_ip:u.detail};return n(S,e)}),(function(e,n){"timeout"===e.type?(s.b.joinChooseServer(t.sid,{lts:c,succ:!1,csAddr:n,serverList:null,ec:"timeout"}),a("Connect choose server timeout",n)):(s.b.joinChooseServer(t.sid,{lts:c,succ:!1,csAddr:n,serverList:null,ec:"server_wrong"}),a("Connect choose server error",n))}),{"X-Packet-Service-Type":0,"X-Packet-URI":69})},ze=function(e,t,n){var a=!1,i=null,c=1,d=1,u=null,l=e.clientId,p=function t(d,p){if(!a){var f=!1,m=!1,v=[],S=g.getBrowserInfo()||{};Ge({device:S.name,system:S.os,vendor:e.appId,version:o.VERSION,cname:e.cname,sid:e.sid,session_id:Object(s.a)(),detail:"",proxyServer:d},(function(t,n){m=!0;try{var a=Object.keys(n.test_tags)[0],i=JSON.parse(n.test_tags[a]);u=i[1]}catch(e){u=null}s.b.reportApiInvoke(e.sid,{name:"_config-distribute-request",options:{err:t,res:n}})(),Je[l]!==st.DISCONNECTED&&Je[l]!==st.DISCONNECTING?f&&p&&p(v,u):r.default.debug("[".concat(e.clientId,"] Request config success when connection state is ").concat(Je[l]))})),function(e,t,n){for(var a,i=(new Date).getTime(),c=!1,d=!0,u=0,l=Object(o.getParameter)("WEBCS_DOMAIN"),p=Object(o.getParameter)("WEBCS_DOMAIN_BACKUP_LIST"),f=function(n,a){if(c)s.b.joinChooseServer(e.sid,{lts:i,succ:!0,csAddr:a,serverList:n.gateway_addr,cid:n.cid+"",uid:n.uid+"",ec:null},!1);else{if(clearTimeout(_),c=!0,e.proxyServer)for(var o=n.gateway_addr,r=0;r<o.length;r++){var d=o[r].split(":");n.gateway_addr[r]=e.proxyServer+"/ws/?h="+d[0]+"&p="+d[1]}t(n),s.b.joinChooseServer(e.sid,{lts:i,succ:!0,csAddr:a,serverList:n.gateway_addr,cid:n.cid+"",uid:n.uid+"",ec:null},!0)}},g=function(t,i,o){u++,r.default.error("["+e.clientId+"]",t,i,o),o&&-1===I.JOIN_CS_RETRY_LIST.indexOf(o)&&(d=!1,a=o),u===l.length+p.length&&n(a)},m=0;m<l.length;++m){var v;if("string"==typeof l[m]){var S=l[m];v=e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(S+"/api/v1"):"https://".concat(S,"/api/v1");var E=Object(He.getAreaCodeByWebCS)(S);r.default.debug("["+e.clientId+"] "+"Connect to choose_server: ".concat(v,", ").concat(E)),Ke(v,e,f,g,E)}else r.default.error("["+e.clientId+"] Invalid Host",l[m])}var _=setTimeout((function(){if(!c)for(var t=0;t<p.length;++t){if("string"==typeof p[t]){var n=p[t];v=e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(n+"/api/v1"):"https://".concat(n,"/api/v1");var a=Object(He.getAreaCodeByWebCS)(n);r.default.debug("["+e.clientId+"] "+"Connect to backup_choose_server: ".concat(v,", ").concat(a)),Ke(v,e,f,g,a)}else r.default.error("["+e.clientId+"] Invalid Host",p[t])}}),1e3);setTimeout((function(){!c&&d&&n()}),Object(o.getParameter)("WEBCS_BACKUP_CONNECT_TIMEOUT"))}(e,(function(t){a=!0,f=!0,v=t,clearTimeout(i),Je[l]!==st.DISCONNECTED&&Je[l]!==st.DISCONNECTING?m&&p&&p(v,u):r.default.debug("[".concat(e.clientId,"] Request gateway list success when connection state is ").concat(Je[l]))}),(function(a){if(a)return r.default.info("["+e.clientId+"] Join failed: "+a),void(n&&n(a));if(Je[l]===st.DISCONNECTED||Je[l]===st.DISCONNECTING)return r.default.debug("[".concat(e.clientId,"] Request gateway list falied when connection state is ").concat(Je[l])),void(n&&n("OPERATION_ABORT"));r.default.debug("["+e.clientId+"] Request gateway list will be restart in "+c+"s"),i=setTimeout((function(){t(d,p)}),1e3*c),qe[l]=i;var s=Object(o.getParameter)("AP_BACKOFF_MAX_TIME");c=c>=s?s:2*c}))}},f=function n(){!function(e,t){je(e,(function(n,a){if(n)return t&&t(n);r.default.debug("["+e.clientId+"] getProxyServerList: ",a),Fe(e,a,t)}))}(e,(function(a,c){if(a){r.default.debug("["+e.clientId+"]",a),r.default.debug("["+e.clientId+"] Request proxy will be restart in "+d+"s"),i=setTimeout((function(){n()}),1e3*d),qe[l]=i;var u=Object(o.getParameter)("AP_BACKOFF_MAX_TIME");d=d>=u?u:2*d}else{clearTimeout(i);var f=c.address;e.proxyServer=f;var g={mode:"manual",url:c.address,tcpport:c.serverResponse.tcpport||"3433",udpport:c.serverResponse.udpport||"3478",username:c.serverResponse.username||"test",credential:c.serverResponse.password||Object(o.getParameter)("TURN_SERVER_PASSWORD"),forceturn:!0};g.tcpport+="",g.udpport+="",e.turnServers=[],e.turnServers.push(g),s.b.setProxyServer(f),r.default.setProxyServer(f),p(f,t)}}))};e.useProxyServer?1==e.proxyServerType?f():2==e.proxyServerType?function n(){!function(e,t){je(e,(function(n,a){return n?t&&t(n):(r.default.debug("["+e.clientId+"] getProxyServerList: ",a),t&&t(null,{address:a[0],serverResponse:{tcpport:"443",udpport:"3478",username:"test",password:"111111"}}))}))}(e,(function(a,c){if(a)return r.default.debug("["+e.clientId+"]",a),r.default.debug("["+e.clientId+"] Request proxy will be restart in "+d+"s"),i=setTimeout((function(){n()}),1e3*d),qe[l]=i,void(d=d>=3600?3600:2*d);clearTimeout(i);var u=Object(o.getParameter)("PROXY_SERVER_TYPE2");e.proxyServer=u;var f={mode:"manual",url:c.address,tcpport:c.serverResponse.tcpport||"3433",udpport:c.serverResponse.udpport||"3478",username:c.serverResponse.username||"test",credential:c.serverResponse.password||"111111",forceturn:!0};f.tcpport+="",f.udpport+="",e.turnServers=[],e.turnServers.push(f),s.b.setProxyServer(u),r.default.setProxyServer(u),p(u,t)}))}():f():p(null,t)},Xe=function(e,t,n,a){var i=Date.now();a=a||t.stringUid;var o={sid:t.sid,opid:10,appid:t.appId,string_uid:a};return new Promise((function(c,d){Object(Ue.post)(e+"".concat(-1===e.indexOf("?")?"?":"&","action=stringuid"),o,(function(u){try{var l=JSON.parse(u),p=l.code}catch(c){var f="requestUserAccount failed with unexpected body "+u;return r.default.error("["+t.clientId+"]",f),d({retryable:!0,info:f,url:e}),n&&n.dispatchEvent({type:"error",reason:"USER_ACCOUNT_BODY_NOT_JSON"}),void s.b.reqUserAccount(o.sid,{lts:i,success:!1,serverAddress:e,stringUid:a,uid:null,extend:u,errorCode:"USER_ACCOUNT_BODY_NOT_JSON"})}if(p){var g=I.StringUidErrorCode[l.code%1e4]||"REQ_ACCOUNT_ERR_".concat(p);return n&&n.dispatchEvent({type:"error",reason:g}),s.b.reqUserAccount(o.sid,{lts:i,success:!1,serverAddress:e,stringUid:a,uid:null,errorCode:g,extend:o}),d({retryable:!1,info:f="Get String Uid Failed ["+g+"]",url:e,error:g})}var m=l.uid;if(!(m>0&&m<Math.pow(2,32))){r.default.error("["+t.clientId+"] "+"Invalid Uint Uid ".concat(a," => ").concat(m),l);g="INVALID_UINT_UID_".concat(m);return n&&n.dispatchEvent({type:"error",reason:g}),s.b.reqUserAccount(o.sid,{lts:i,success:!1,serverAddress:e,stringUid:a,uid:null,errorCode:g,extend:o}),d({retryable:!0,error:g,info:"Get String Uid failed ["+g+"]",url:e})}c({uid:m,url:e}),s.b.reqUserAccount(o.sid,{lts:i,success:!0,serverAddress:e,stringUid:a,uid:m,errorCode:null,extend:o})}),(function(e,t){if("timeout"===e.type){var r="USER_ACCOUNT_TIMEOUT";n&&n.dispatchEvent({type:"error",reason:r}),s.b.reqUserAccount(o.sid,{lts:i,success:!1,serverAddress:t,stringUid:a,uid:null,errorCode:r,extend:o}),d({retryable:!0,info:r,url:t})}else{var c="USER_ACCOUNT_SERVER_WRONG_".concat(e.type);n&&n.dispatchEvent({type:"error",reason:c}),s.b.reqUserAccount(o.sid,{lts:i,success:!1,serverAddress:t,stringUid:a,uid:null,errorCode:c,extend:o}),d({retryable:!0,info:c,url:t})}}),{"X-Packet-Service-Type":0,"X-Packet-URI":72})}))},Qe=function(e,t,n){Date.now();var a,s=Object(o.getParameter)("ACCOUNT_REGISTER"),c=!1,d=Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT"),u=null,l=null,p=new Promise(function(){var p=ee()(Z.a.mark((function p(f,g){var m,v,S;return Z.a.wrap((function(p){for(;;)switch(p.prev=p.next){case 0:u=f,l=g,a=0;case 3:if(!(a<Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_COUNT_MAX"))){p.next=33;break}if(!c){p.next=6;break}return p.abrupt("return");case 6:return m=s[a%s.length],v=e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(s[i]+"/api/v1"):"https://".concat(m,"/api/v1"),p.prev=8,p.delegateYield(Z.a.mark((function a(){var i;return Z.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,Xe(v,e,t,n);case 2:if(i=a.sent,!c){a.next=5;break}return a.abrupt("return",{v:void 0});case 5:c=!0,setTimeout((function(){r.default.debug("Get UserAccount Successfully",i),u(i)}),0);case 7:case"end":return a.stop()}}),a)}))(),"t0",10);case 10:if(S=p.t0,"object"!==be()(S)){p.next=13;break}return p.abrupt("return",S.v);case 13:p.next=30;break;case 15:if(p.prev=15,p.t1=p.catch(8),!c){p.next=19;break}return p.abrupt("return");case 19:if(!p.t1.retryable){p.next=27;break}return(d=Math.ceil(d*Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_RATIO")))>Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX")&&(d=Object(o.getParameter)("ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX")),r.default.error("".concat(p.t1.info," ").concat(p.t1.url," Will Fetch User Account in ").concat(d/1e3," seconds")),p.next=25,new Promise((function(e){setTimeout(e,d)}));case 25:p.next=30;break;case 27:r.default.error("Get UserAccount Error: ".concat(p.t1.info," ").concat(p.t1.url),p.t1.error),c=!0,l(p.t1);case 30:a++,p.next=3;break;case 33:case"end":return p.stop()}}),p,null,[[8,15]])})));return function(e,t){return p.apply(this,arguments)}}());return p.cancel=function(){c||(c=!0,l({info:"Request Cancelled",retryable:!1}))},p.isFinished=function(){return c},p},Ze={ERR_NO_VOCS_AVAILABLE:"tryNext",ERR_NO_VOS_AVAILABLE:"tryNext",ERR_JOIN_CHANNEL_TIMEOUT:"tryNext",WARN_REPEAT_JOIN:"quit",ERR_JOIN_BY_MULTI_IP:"recover",WARN_LOOKUP_CHANNEL_TIMEOUT:"tryNext",WARN_OPEN_CHANNEL_TIMEOUT:"tryNext",ERR_VOM_SERVICE_UNAVAILABLE:"tryNext",ERR_TOO_MANY_USERS:"tryNext",ERR_MASTER_VOCS_UNAVAILABLE:"tryNext",ERR_INTERNAL_ERROR:"tryNext",K_SERVICE_NOT_READY:"recover",K_SERVICE_TOO_HEAVY:"tryNext",notification_test_recover:"recover",notification_test_tryNext:"tryNext",notification_test_retry:"retry"},$e={googActualEncBitrate:"A_aeb",googAvailableSendBandwidth:"A_asb",googRetransmitBitrate:"A_rb",googAvailableReceiveBandwidth:"A_arb",googTargetEncBitrate:"A_teb",googBucketDelay:"A_bd",googTransmitBitrate:"A_tb",googCodecName:"A_cn",bytesSent:"bytesSent",packetsLost:"packetsLost",packetsSent:"packetsSent",googAdaptationChanges:"A_ac",googAvgEncodeMs:"A_aem",googEncodeUsagePercent:"A_eup",googFirsReceived:"A_fr",googFrameHeightInput:"A_fhi",googFrameHeightSent:"A_fhs",googFrameRateInput:"A_fri",googFrameRateSent:"A_frs",googFrameWidthInput:"A_fwi",googFrameWidthSent:"A_fws",googNacksReceived:"A_nr",googPlisReceived:"A_pr",googRtt:"A_rtt",aecDivergentFilterFraction:"A_adff",audioInputLevel:"A_ail",googEchoCancellationReturnLoss:"A_ecrl",googEchoCancellationReturnLossEnhancement:"A_ecrle",googResidualEchoLikelihood:"A_rel",googResidualEchoLikelihoodRecentMax:"A_relrm",googTargetDelayMs:"A_tdm",bytesReceived:"bytesReceived",packetsReceived:"packetsReceived",googDecodeMs:"A_dm",googMaxDecodeMs:"A_mdm",googRenderDelayMs:"A_rdm",googFrameWidthReceived:"A_fwr",googFrameHeightReceived:"A_fhr",googFrameRateReceived:"A_frr",googFrameRateDecoded:"A_frd",googFrameRateOutput:"A_fro",googJitterBufferMs:"A_jbm",googCurrentDelayMs:"A_cdm",googMinPlayoutDelayMs:"A_mpdm",googNacksSent:"A_ns",googPlisSent:"A_ps",googFirsSent:"A_fs",audioOutputLevel:"A_aol",googAccelerateRate:"A_ar",googDecodingCNG:"A_dcng",googDecodingCTN:"A_dctn",googDecodingCTSG:"A_dctsg",googDecodingNormal:"A_dn",googDecodingPLC:"A_dplc",googDecodingPLCCNG:"A_dplccng",googExpandRate:"A_er",googJitterReceived:"A_jr",googPreemptiveExpandRate:"A_per",googPreferredJitterBufferMs:"A_pjbm",googSecondaryDecodedRate:"A_sdr",googSpeechExpandRate:"A_ser",uplink_fraction_lost:"B_ufl",uplink_cumulative_lost:"B_ucl",uplink_available_bandwidth:"B_uab",period_fir:"B_fir",access_delay:"B_acd",uplink_network_quality:"B_unq",downlink_network_quality:"B_dnq",pub_audio_lost_ratio_400ms:"B_palr4",pub_video_lost_ratio_400ms:"B_pvlr4",e2e_delay:"B_ed",audio_delay:"B_ad",video_delay:"B_vd",stream_type:"B_st",e2e_audio_lost_ratio_400ms:"B_ealr4",e2e_video_lost_ratio_400ms:"B_evlr4",downlink_estimate_bandwidth:"B_deb",peer_publish_audio_duration:"B_ppad",peer_publish_video_duration:"B_ppvd"},et={};for(var tt in $e){var nt=$e[tt];et[nt]&&r.default.error("Key Conflict: ".concat(nt,": ").concat($e[nt],"| ").concat(tt)),et[nt]=tt}var at=function(e){return $e[e]||e},it=function(e){return et[e]||e};var ot=function t(n){var a=!1,i=function(e){return{_type:"control",_message:e}},d=function(e,t){var n={};return Object.keys(t).forEach((function(e){Object(o.getParameter)("STATS_FILTER")[e]||(n[at(e)]=t[e])})),{_type:"subscribe_related_stats",_message:{stream_type:"high",stream_id:e,stats:n}}},m=function(e){return{_type:"publish",_message:e}},v=function(e,t){var n={};return Object.keys(t).forEach((function(e){Object(o.getParameter)("STATS_FILTER")[e]||(n[at(e)]=t[e])})),{_type:"subscribe_stats",_message:{stream_id:e,stats:n}}},S=t.DISCONNECTED,_=t.CONNECTING,h=t.CONNECTED,b=t.DISCONNECTING,T=S,R=c();Object.defineProperty(R,"state",{set:function(e){var n=T;T=e,function(e,t){Je[e]=t}(R.clientId,e),e!==t.CONNECTED&&(R.hasJoined=!1),n!==e&&R.dispatchEvent({type:"connection-state-change",prevState:t.connetionStateMap[n],curState:t.connetionStateMap[e]})},get:function(){return T}}),R.socket=void 0,R.state=S,R.mode=n.mode,R.role=n.role,R.codec=n.codec,R.config={},R.timers={},R.timer_counter={},R.localStreams={},R.remoteStreams={},R.remoteMuteState={},R.attemps=1,R.p2p_attemps=1,R.audioLevel={},R.activeSpeaker=void 0,R.reconnectMode="tryNext",R.rejoinAttempt=0,R.hasChangeBGPAddress=!1,R.traffic_stats={},R.clientId=n.clientId,R.pingpongCounter=0,R.hasInvokeLeave=!1,R.p2ps=new Map,R.liveStreams=new Map,R.injectLiveStreams=new Map,R.remoteStreamsInChannel=new Set,R.subscribeRequestId=new Map,R.publishRequestId=0,R.hasJoined=!1,R.isFirstSuccess=!0,function(e){var t=Me;e.makeRequest=function(n,a,i){if(void 0===e.socket)return r.default.debug("[".concat(e.clientId,"] No socket available")),void t(i,I.default.INVALID_OPERATION);try{e.socket.emitRequest(n,(function(e,t){var n;"success"===e?"function"==typeof a&&a(t):"function"==typeof i&&(n=t&&t.error_code&&I.GatewayErrorCode[t.error_code]?I.GatewayErrorCode[t.error_code]:t&&t.error_str?t.error_str:t&&t.error_code?"UNKNOW_ERROR_".concat(t.error_code):e,i(n,t))}))}catch(a){r.default.debug("[".concat(e.clientId,"] Socket emit message failed ").concat(JSON.stringify(n))),r.default.debug("[".concat(e.clientId,"] "),a),t(i,I.default.SOCKET_ERROR)}},e.makeReport=function(t){void 0===e.socket&&r.default.debug("[".concat(e.clientId,"] No socket available"));try{e.socket.emitReport(t)}catch(n){r.default.debug("[".concat(e.clientId,"] Socket emit report failed ").concat(JSON.stringify(t)))}}}(R),R.inChannelInfo={joinAt:null,duration:0},R._sendMessage=function(e,t){switch(e){case"SubscribeStats":R.makeReport(v.apply(void 0,Pe()(t)));break;case"SubscribeRelatedStats":R.makeReport(d.apply(void 0,Pe()(t)))}};var A=Me;R.p2pCounter=Object(H.random)(1e5),R.generateP2PId=function(){return++R.p2pCounter},R.audioVolumeIndication={enabled:!1,sortedAudioVolumes:[],smooth:3,interval:2e3},R.remoteVideoStreamTypes={REMOTE_VIDEO_STREAM_HIGH:0,REMOTE_VIDEO_STREAM_LOW:1,REMOTE_VIDEO_STREAM_MEDIUM:2},R.streamFallbackTypes={STREAM_FALLBACK_OPTION_DISABLED:0,STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW:1,STREAM_FALLBACK_OPTION_AUDIO_ONLY:2},R.configPublisher=function(e){R.config=e},R.getGatewayInfo=function(e,t){R.makeRequest({_type:"gateway_info"},e,t)},R.setClientRole=function(e,t){r.default.debug("[".concat(R.clientId,"] setClientRole to ").concat(e));var n=s.b.reportApiInvoke(R.joinInfo.sid,{name:"_setClientRole",callback:t});R.makeRequest({_type:"set_client_role",_message:{role:e}},(function(){R.role=e,R.dispatchEvent({type:"client-role-changed",role:e}),n&&n(null,{role:e})}),(function(t,a){if(a&&a.code&&(t=I.GatewayErrorCode[a.code]||"UNKNOW_ERROR_"+a.code),"ERR_SET_CLIENT_ROLE_ALREADY_IN_USE"===t)return n&&n(null);r.default.error("set Client role error to "+e+": "+t),n&&n(t)}))},R.join=function(e,t,a,i){R.hasInvokeLeave=!1,e.useProxyServer&&(R.hasChangeBGPAddress=!0);var c=(new Date).getTime(),d=e.uid;if(R.inChannelInfo.joinAt&&(R.inChannelInfo.duration+=c-R.inChannelInfo.joinAt),R.inChannelInfo.joinAt=c,R.state!==_)return r.default.error("[".concat(R.clientId,"] GatewayClient.join Failed: state "),R.state),i&&i(I.default.INVALID_OPERATION),void s.b.joinGateway(e.sid,{lts:c,succ:!1,ec:I.default.INVALID_OPERATION,addr:null});if(null!=d&&parseInt(d)!==d)return r.default.error("[".concat(R.clientId,"] Input uid is invalid")),R.state=S,i&&i(I.default.INVALID_PARAMETER),void s.b.joinGateway(e.sid,{lts:c,succ:!1,ec:I.default.INVALID_PARAMETER,addr:null});var u=rt.register(R,{uid:d,cname:e&&e.cname});if(u)return R.state=S,i&&i(u),void s.b.joinGateway(e.sid,{lts:c,succ:!1,ec:u,addr:null});R.joinInfo=E()({},e),R.uid=d,R.key=t,R.pingpongCounter=0,N(e,(function(t){if(R.state===b||R.state===S)return i&&i("LEAVE_BEFORE_JOIN_SUCCESS");R.state=h,r.default.debug("[".concat(R.clientId,"] Connected to gateway server")),clearInterval(R.pingTimer),R.pingTimer=setInterval((function(){var e=Object(o.getParameter)("PING_PONG_TIME_OUT");if(++R.pingpongCounter>=e){var t=Date.now();R.socket&&r.default.warning("PINGPONG Timeout. Last Socket Message: ".concat(t-R.socket.getLastMsgTime(),"ms")),R.socket&&R.socket.getLastMsgTime()&&t-R.socket.getLastMsgTime()>Object(o.getParameter)("WEBSOCKET_TIMEOUT_MIN")&&(R.pingpongCounter=0,R.socket.close(),R.socket.dispatchEvent(p({type:"disconnect",event:{msg:"PING_PONG_TIME_OUT"}})))}var n=Date.now();R.makeRequest({_type:"ping"},(function(){R.pingpongCounter=0;var e=Date.now()-n;setTimeout((function(){Object(o.getParameter)("REPORT_STATS")&&R.makeRequest({_type:"ping_back",_message:{pingpongElapse:e}})}),1e3)}),(function(e,t){"TIMEOUT"!==e&&(r.default.error("Ping Error ".concat(e," ").concat(JSON.stringify(t))),t&&t.error_code&&R.socket&&R.socket.signal&&R.socket.signal.connection&&R.socket.signal.connection.readyState===WebSocket.OPEN&&(r.default.info("Disconnecting websocket connection"),R.socket.signal.connection.close()))}))}),3e3),R.makeRequest(function(e){var t=e.role,a=E()({},R.joinInfo.apResponse),i={session_id:R.joinInfo.sid,app_id:n.appId,channel_key:R.key,channel_name:R.joinInfo.cname,sdk_version:o.VERSION,browser:navigator.userAgent,process_id:Object(s.a)(),mode:R.mode,codec:R.codec,role:t,has_changed_gateway:Object(o.getParameter)("FORCE_CHANGED_GATEWAY_FLAG")||R.hasChangeBGPAddress,ap_response:a,extend:Object(o.getParameter)("JOIN_EXTEND"),details:{}};if(R.joinInfo.hasOwnProperty("stringUid")&&(i.string_uid=R.joinInfo.stringUid),R.joinInfo.aesmode&&R.joinInfo.aespassword&&(i.aes_mode=R.joinInfo.aesmode,i.aes_secret=R.joinInfo.aespassword),R.socket&&R.socket.signal&&R.socket.signal&&(a.addresses[R.socket.signal.hostIndex]&&(i.ap_response.ticket=a.addresses[R.socket.signal.hostIndex].ticket,delete a.addresses),Object(o.getParameter)("SET_DEFAULT_TURNSERVER")&&R.socket.signal.turnConfig)){var r={username:"test",credential:Object(o.getParameter)("TURN_SERVER_PASSWORD"),forceturn:Object(o.getParameter)("FORCE_TURN")};r.url=R.socket.signal.turnConfig.url,R.socket.signal.turnConfig.tcpport&&(r.tcpport=""+R.socket.signal.turnConfig.tcpport),R.socket.signal.turnConfig.udpport&&(r.udpport=""+R.socket.signal.turnConfig.udpport),R.joinInfo.turnServers.push(r)}return R.dispatchEvent({type:"join-message-hook",joinMessage:i}),{_type:"join",_message:i}}({role:R.role}),(function(t){if(s.b.joinGateway(e.sid,{lts:c,succ:!0,ec:null,vid:e.vid,addr:R.socket.getURL(),firstSuccess:R.isFirstSuccess}),R.joinSuccessLts=Date.now(),R.isFirstSuccess=!1,R.rejoinAttempt=0,R.hasJoined=!0,a&&a(t.uid),!0===t.return_vosip||!0===Object(o.getParameter)("ENABLE_LIVE_SERVER_LIST")){var n=null;try{n=R.socket.signal.connection.url}catch(e){r.default.debug("[".concat(R.clientId,"] Can not get gateway ip: ").concat(e))}n?Object(o.setParameter)("LIVE_SERVER_LIST",[n]):Object(o.setParameter)("LIVE_SERVER_LIST",[])}R.dispatchEvent({type:"join"}),clearInterval(R.timers.trafficStats),R.timers.trafficStats=setInterval((function(){R.makeRequest({_type:"traffic_stats"},(function(e){var t={};for(var n in e)t[it(n)]=e[n];if(t.peer_delay&&t.peer_delay.length){var a=[];t.peer_delay.forEach((function(e){var t={};for(var n in e)t[it(n)]=e[n];a.push(t)})),t.peer_delay=a}R.traffic_stats=t,R.traffic_stats.timestamp=Date.now();var i=R.joinInfo.stringUid,o=R.localStreams[d]||R.localStreams[i];o&&(o.traffic_stats={access_delay:t.access_delay}),t.peer_delay&&t.peer_delay.forEach((function(e){var n=R.remoteStreams[e.peer_uid];n&&(n.traffic_stats={access_delay:t.access_delay,e2e_delay:e.e2e_delay,audio_delay:e.audio_delay,video_delay:e.video_delay})})),R.dispatchEvent({type:"after-getTrafficStats",trafficStats:t})}))}),3e3)}),(function(t,n){if(r.default.error("[".concat(R.clientId,"] User join failed [").concat(t,"]")),"ERR_JOIN_BY_MULTI_IP"===t){try{s.b.joinGateway(e.sid,{lts:c,succ:!1,ec:"ERR_JOIN_BY_MULTI_IP",addr:R.socket.getURL()})}catch(e){}return R.dispatchEvent({type:"onMultiIP",option:n.option})}Ze[t]&&R.rejoinAttempt<4?R._doWithAction(Ze[t],a,i):i&&i(t),s.b.joinGateway(e.sid,{lts:c,succ:!1,ec:t,addr:R.socket&&R.socket.getURL()})}))}),(function(t){r.default.error("[".concat(R.clientId,"] User join failed [").concat(t,"]")),i&&i(t),s.b.joinGateway(e.sid,{lts:c,succ:!1,ec:t,addr:R.socket.getURL()})})),this.remoteMuteState={},R.resetAudioVolumeIndication()},R.leave=function(e,t){var n=rt.unregister(R);switch(n&&r.default.debug("[".concat(R.clientId,"] "),n),R.state){case S:return r.default.debug("[".concat(R.clientId,"] Client Already in DISCONNECTED status")),void A(e);case b:return r.default.debug("[".concat(R.clientId,"] Client Already in DISCONNECTING status")),void A(t,I.default.INVALID_OPERATION);case _:return R.socket&&R.socket.close(),R.socket=void 0,r.default.info("[".concat(R.clientId,"] Client connecting, Leave channel success")),R.state=S,e&&e()}for(var a in R.state=b,R.channelMediaConfig&&(R.channelMediaRelayController&&R.channelMediaRelayController.dispose(),R.channelMediaConfig,R.channelMediaRelayController=null),clearInterval(R.pingTimer),R.timers)R.timers.hasOwnProperty(a)&&clearInterval(R.timers[a]);for(var a in R.inChannelInfo.joinAt&&(R.inChannelInfo.duration+=Date.now()-R.inChannelInfo.joinAt,R.inChannelInfo.joinAt=null),R.hasJoined?R.makeRequest({_type:"leave"},(function(t){R.socket.close(),R.socket=void 0,r.default.info("[".concat(R.clientId,"] Leave channel success")),R.state=S,e&&e(t)}),(function(e){"TIMEOUT"!==e&&(r.default.error("[".concat(R.clientId,"] Leave Channel Failed"),e),R.state=h,t&&t(e))})):(R.socket&&(R.socket.close(),R.socket=void 0),r.default.info("[".concat(R.clientId,"] Leave channel before joined")),R.state=S,e&&e()),R.localStreams)if(R.localStreams.hasOwnProperty(a)){var i=R.localStreams[a];delete R.localStreams[a],void 0!==i.pc&&(i.pc.close(),i.pc=void 0)}k()},R.publish=function(e,t,n,a){var c=(new Date).getTime(),d=!1;if(e.publishLTS=c,"object"!==be()(e)||null===e)return r.default.error("[".concat(R.clientId,"] Invalid local stream")),a&&a(I.default.INVALID_LOCAL_STREAM),void s.b.publish(R.joinInfo.sid,{lts:c,succ:!1,audio:!1,video:!1,screenshare:!1,audioName:"",videoName:"",screenName:"",ec:I.default.INVALID_LOCAL_STREAM});if(!e.stream&&void 0===e.url)return r.default.error("[".concat(R.clientId,"] Invalid local media stream")),a&&a(I.default.INVALID_LOCAL_STREAM),void s.b.publish(R.joinInfo.sid,{lts:c,succ:!1,audio:!1,video:!1,screenshare:!1,audioName:"",videoName:"",screenName:"",ec:I.default.INVALID_LOCAL_STREAM});if(R.state!==h)return r.default.error("[".concat(R.clientId,"] User is not in the session")),a&&a(I.default.INVALID_OPERATION),void s.b.publish(R.joinInfo.sid,{lts:c,succ:!1,audio:e.hasAudio(),video:e.hasVideo(),screenshare:e.hasScreen(),audioName:e.hasAudio()&&e.audioName,videoName:e.hasVideo()&&e.videoName,screenName:e.hasScreen()&&e.screenName,ec:I.default.INVALID_OPERATION});var u=e.getAttributes()||{};if(e.local&&void 0===R.localStreams[e.getId()]&&(e.hasAudio()||e.hasVideo()||e.hasScreen())){var p=R.generateP2PId();if(R.p2ps.set(p,e),e.p2pId=p,void 0!==e.url)w(m({state:"url",audio:e.hasAudio(),video:e.hasVideo(),attributes:e.getAttributes()},e.url),(function(t,n){"success"===t?(e.getUserId()!==n&&e.setUserId(n),R.localStreams[n]=e,e.onClose=function(){R.unpublish(e)}):r.default.error("[".concat(R.clientId,"] Publish local stream failed"),t)}));else{R.localStreams[e.getId()]=e,e.connectionSpec={callback:function(u){R.makeRequest(m({state:"offer",stream_type:1==t.streamType?"low":"high",p2p_id:p,sdp:u,audio:e.audio||e.screenAudio,video:e.screen||e.video,screen:e.screen,attributes:e.getAttributes(),dtx:e.DTX,hq:e.highQuality,lq:e.lowQuality,stereo:e.stereo,speech:e.speech,codec:R.codec,extend:Object(o.getParameter)("PUB_EXTEND")}),(function(t){e.getUserId()!==t.uid&&e.setUserId(t.uid),r.default.info("[".concat(R.clientId,"] Local stream published with uid"),t.uid),e.onClose=function(){R.unpublish(e)},e._onAudioUnmute=function(){R.makeReport(i({action:"unmute_local_audio",stream_id:e.getId()}))},e._onVideoUnmute=function(){R.makeReport(i({action:"unmute_local_video",stream_id:e.getId()}))},e._onAudioMute=function(){R.makeReport(i({action:"mute_local_audio",stream_id:e.getId()}))},e._onVideoMute=function(){R.makeReport(i({action:"mute_local_video",stream_id:e.getId()}))},e.getId()===e.getUserId()&&(e.isAudioOn()||e.hasAudio()&&(r.default.debug("[".concat(R.clientId,"] local stream audio mute")),e._onAudioMute()),e.isVideoOn()||(e.hasVideo()||e.hasScreen())&&(r.default.debug("[".concat(R.clientId,"] local stream video mute")),e._onVideoMute())),e.pc.oniceconnectionstatechange=function(t){if("failed"===t){if(null!=R.timers[e.getId()]&&(clearInterval(R.timers[e.getId()]),clearInterval(R.timers[e.getId()]+"_RelatedStats")),r.default.error("[".concat(R.clientId,"] Publisher connection is lost -- streamId: ").concat(e.getId(),", p2pId: ").concat(p)),R.p2ps.delete(p),r.default.debug("[".concat(R.clientId,"] publish p2p failed: "),R.p2ps),!d)return d=!0,s.b.publish(R.joinInfo.sid,{lts:c,succ:!1,audio:e.hasAudio(),video:e.hasVideo(),screenshare:e.hasScreen(),audioName:e.hasAudio()&&e.audioName,videoName:e.hasVideo()&&e.videoName,screenName:e.hasScreen()&&e.screenName,ec:I.default.PEERCONNECTION_FAILED,publishRequestid:R.publishRequestId||0,p2pid:p}),R.dispatchEvent(l({type:"pubP2PLost",stream:e})),a&&a(I.default.PEERCONNECTION_FAILED);R.dispatchEvent(l({type:"pubP2PLost",stream:e}))}else if("connected"===t&&(r.default.debug("[".concat(R.clientId,"] publish p2p connected: "),R.p2ps),e.getId()===e.getUserId()&&(e._isAudioMuted()?R.makeReport(i({action:"mute_local_audio",stream_id:e.getId()})):R.makeReport(i({action:"unmute_local_audio",stream_id:e.getId()})),e._isVideoMuted()?R.makeReport(i({action:"mute_local_video",stream_id:e.getId()})):R.makeReport(i({action:"unmute_local_video",stream_id:e.getId()}))),!d))return d=!0,s.b.publish(R.joinInfo.sid,{lts:c,succ:!0,audio:e.hasAudio(),video:e.hasVideo(),screenshare:e.hasScreen(),audioName:e.hasAudio()&&e.audioName,videoName:e.hasVideo()&&e.videoName,screenName:e.hasScreen()&&e.screenName,ec:null,publishRequestid:R.publishRequestId||0,p2pid:p}),n&&n()},e.pc.processSignalingMessage(t.sdp)}),(function(t,n){r.default.error("Publish Failed: ".concat(t)),s.b.publish(R.joinInfo.sid,{lts:c,succ:!1,audio:e.hasAudio(),video:e.hasVideo(),screenshare:e.hasScreen(),audioName:e.hasAudio()&&e.audioName,videoName:e.hasVideo()&&e.videoName,screenName:e.hasScreen()&&e.screenName,ec:t,publishRequestid:R.publishRequestId||0,p2pid:p}),"TIMEOUT"!=t&&(R.processPublishFailure(e),a&&a(t))}))},audio:e.hasAudio(),video:e.hasVideo(),screen:e.hasScreen(),isSubscriber:!1,stunServerUrl:R.stunServerUrl,turnServers:R.joinInfo.turnServers,maxAudioBW:u.maxAudioBW,minVideoBW:u.minVideoBW,maxVideoBW:u.maxVideoBW,mode:R.mode,codec:R.codec,isVideoMute:e.userMuteVideo||e.peerMuteVideo,isAudioMute:e.userMuteAudio||e.peerMuteAudio,maxFrameRate:e.attributes.maxFrameRate,clientId:R.clientId},e.pc=W(e.connectionSpec),e.pc.addStream(e.stream),r.default.debug("[".concat(R.clientId,"] PeerConnection add stream :"),e.stream),e.pc.onnegotiationneeded=function(n){var a={state:"negotiation",stream_type:1===t.streamType?"low":"high",p2p_id:p,sdp:n};R.makeRequest(m(a),(function(t){r.default.debug("Negotating Stream ".concat(e.getId())),e.pc.processSignalingMessage(t.sdp)}),(function(e,t){r.default.error("Negotiation failed ".concat(e),t,a)}))},clearInterval(R.timers[e.getId()]),R.timers[e.getId()]=setInterval((function(){if(Object(o.getParameter)("REPORT_STATS")){var t=0;e&&e.pc&&e.pc.getStats&&e.pc.getStatsRate((function(n){n.forEach((function(n){if(n&&n.id&&!/_recv$/.test(n.id)&&!/^time$/.test(n.id)&&e.getUserId()){if(-1===n.id.indexOf("outbound_rtp")&&-1===n.id.indexOf("OutboundRTP")&&-1===n.type.toLowerCase().indexOf("outbound")||"video"!==n.mediaType||(n.googFrameWidthSent=e.videoWidth+"",n.googFrameHeightSent=e.videoHeight+""),"video"===n.mediaType)try{var a=e.stream.getVideoTracks()[0];n.A_vstd=a.enabled?"0":"1"}catch(e){}if("audio"===n.mediaType)try{var i=e.stream.getAudioTracks()[0];n.A_astd=i.enabled?"0":"1"}catch(e){}if(e.getId()==e.getUserId()){var s=200*t;t++,setTimeout((function(){var e=R.socket&&R.socket.getLastMsgTime()&&Date.now()-R.socket.getLastMsgTime();e>Object(o.getParameter)("REPORT_STATS_TIMEOUT")?r.default.debug("PublishStats report blocked by REPORT_STATS_TIMEOUT ".concat(e)):R.makeReport(function(e){var t={};return Object.keys(e).forEach((function(n){Object(o.getParameter)("STATS_FILTER")[n]||(t[at(n)]=e[n])})),{_type:"publish_stats",_message:{stream_type:"high",stats:t}}}(n))}),s)}else{s=200*t;t++,setTimeout((function(){var e=R.socket&&R.socket.getLastMsgTime()&&Date.now()-R.socket.getLastMsgTime();e>Object(o.getParameter)("REPORT_STATS_TIMEOUT")?r.default.debug("PublishStatsLow report blocked by REPORT_STATS_TIMEOUT ".concat(e)):R.makeReport(function(e){var t={};return Object.keys(e).forEach((function(n){Object(o.getParameter)("STATS_FILTER")[n]||(t[at(n)]=e[n])})),{_type:"publish_stats",_message:{stream_type:"low",stats:t}}}(n))}),s)}}}))}))}}),3e3);var f=function(){Object(o.getParameter)("REPORT_STATS")&&e&&e.pc&&e.pc.getVideoRelatedStats&&e.pc.getVideoRelatedStats((function(t){var n,a,i=R.socket&&R.socket.getLastMsgTime()&&Date.now()-R.socket.getLastMsgTime();i>Object(o.getParameter)("REPORT_STATS_TIMEOUT")?r.default.debug("PublishRelatedStats report blocked by REPORT_STATS_TIMEOUT ".concat(i)):e.getId()===e.getUserId()?R.makeReport((n=t,a={},Object.keys(n).forEach((function(e){Object(o.getParameter)("STATS_FILTER")[e]||(a[at(e)]=n[e])})),{_type:"publish_related_stats",_message:{stream_type:"high",stats:a}})):R.makeReport(function(e){var t={};return Object.keys(e).forEach((function(n){Object(o.getParameter)("STATS_FILTER")[n]||(t[at(n)]=e[n])})),{_type:"publish_related_stats",_message:{stream_type:"low",stats:t}}}(t))}))};f(),clearInterval(R.timers[e.getId()+"_RelatedStats"]),R.timers[e.getId()+"_RelatedStats"]=setInterval(f,1e3)}}},R.unpublish=function(e,t,n,a){if("object"!==be()(e)||null===e)return r.default.error("[".concat(R.clientId,"] Invalid local stream")),void A(a,I.default.INVALID_LOCAL_STREAM);if(R.state!==h)return r.default.error("[".concat(R.clientId,"] User not in the session")),void A(a,I.default.INVALID_OPERATION);if(null!=R.timers[e.getId()]&&(clearInterval(R.timers[e.getId()]),clearInterval(R.timers[e.getId()+"_RelatedStats"])),void 0!==R.socket)if(e.local&&void 0!==R.localStreams[e.getId()]){delete R.localStreams[e.getId()];var i={stream_id:e.getUserId(),stream_type:1===t.streamType?"low":"high"};R.makeRequest({_type:"unpublish",_message:i}),(e.hasAudio()||e.hasVideo()||e.hasScreen())&&void 0===e.url&&void 0!==e.pc&&(e.pc.close(),e.pc=void 0),e.onClose=void 0,e._onAudioMute=void 0,e._onAudioUnute=void 0,e._onVideoMute=void 0,e._onVideoUnmute=void 0,R.p2ps.delete(e.p2pId),R.dispatchEvent({type:"stream-unpublished",stream:e,options:t}),n&&n()}else r.default.error("[".concat(R.clientId,"] Invalid local stream")),A(a,I.default.INVALID_LOCAL_STREAM);else r.default.error("[".concat(R.clientId,"] User not in the session")),A(a,I.default.INVALID_OPERATION)},R.subscribe=function(e,t,n){var a=(new Date).getTime();e.subscribeLTS=a;var c=!1;if(r.default.info("[".concat(R.clientId,"] Gatewayclient ").concat(R.uid," Subscribe ").concat(e.getId(),": ").concat(JSON.stringify(e.subscribeOptions))),"object"!==be()(e)||null===e)return r.default.error("[".concat(R.clientId,"] Invalid remote stream")),n&&n(I.default.INVALID_REMOTE_STREAM),void s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!1,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:I.default.INVALID_REMOTE_STREAM});if(R.state!==h&&(r.default.error("[".concat(R.clientId,"] User is not in the session")),!c))return c=!0,s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!1,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:I.default.INVALID_OPERATION}),n&&n(I.default.INVALID_OPERATION);if(!e.local&&R.remoteStreams.hasOwnProperty(e.getId()))if(e.hasAudio()||e.hasVideo()||e.hasScreen()){var p=R.generateP2PId();R.p2ps.set(p,e),e.p2pId=p,e.pc=W({callback:function(t){var i={stream_id:e.getId(),audio:!e.subscribeOptions||e.subscribeOptions.audio,video:!e.subscribeOptions||e.subscribeOptions.video,codec:R.codec,p2p_id:p,sdp:t,tcc:Object(o.getParameter)("SUBSCRIBE_TCC"),extend:Object(o.getParameter)("SUB_EXTEND")};R.makeRequest({_type:"subscribe",_message:i},(function(t){e.pc.processSignalingMessage(t.sdp)}),(function(t,i){r.default.error("[".concat(R.clientId,"] Subscribe remote stream Failed: ").concat(t,", closing stream "),e.getId(),i),s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!1,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:t}),"TIMEOUT"!=t&&(R.processSubscribeFailure(e),n&&n(t))}))},nop2p:!0,audio:!0,video:!0,screen:e.hasScreen(),isSubscriber:!0,stunServerUrl:R.stunServerUrl,turnServers:R.joinInfo.turnServers,isVideoMute:e.userMuteVideo,isAudioMute:e.userMuteAudio,uid:e.getId(),clientId:R.clientId}),e.pc.onaddstream=function(t,n){if(e._onAudioUnmute=function(){R.makeReport(i({action:"unmute_remote_audio",stream_id:e.getId()}),(function(){}),(function(){}))},e._onAudioMute=function(){R.makeReport(i({action:"mute_remote_audio",stream_id:e.getId()}),(function(){}),(function(){}))},e._onVideoUnmute=function(){R.makeReport(i({action:"unmute_remote_video",stream_id:e.getId()}),(function(){}),(function(){}))},e._onVideoMute=function(){R.makeReport(i({action:"mute_remote_video",stream_id:e.getId()}),(function(){}),(function(){}))},"ontrack"===n&&"video"===t.track.kind||"onaddstream"===n){r.default.info("[".concat(R.clientId,"] Remote stream subscribed with uid "),e.getId());var a=R.remoteStreams[e.getId()];if(R.remoteStreams[e.getId()].stream="onaddstream"===n?t.stream:t.streams[0],R.remoteStreams[e.getId()].hasVideo()){if(Object(g.isFireFox)()||Object(g.isSafari)()){var o=R.remoteStreams[e.getId()].stream;Object(H.vsResHack)(o,(function(t,n){e.videoWidth=t,e.videoHeight=n}),(function(e){return r.default.warning("[".concat(R.clientId,"] vsResHack failed: ")+e)}))}}else{var s=R.remoteStreams[e.getId()];s.peerMuteVideo=!0,R._adjustPCMuteStatus(s)}a&&a.isPlaying()&&a.elementID&&(r.default.debug("[".concat(R.clientId,"] Reload Player ").concat(a.elementID," StreamId ").concat(a.getId())),e.audioOutput=a.audioOutput,a.stop(),e.play(a.elementID,a.playOptions)),delete e.audioLevelHelper;var c=u({type:"stream-subscribed",stream:R.remoteStreams[e.getId()]});R.dispatchEvent(c)}},clearInterval(R.timers[e.getId()]),R.timers[e.getId()]=setInterval((function(){if(Object(o.getParameter)("REPORT_STATS")){var t=0;e&&e.pc&&e.pc.getStats&&e.pc.getStatsRate((function(n){n.forEach((function(n){if(n&&n.id){if(/_send$/.test(n.id)||/^time$/.test(n.id)||/^bweforvideo$/.test(n.id))return;-1===n.id.indexOf("inbound_rtp")&&-1===n.id.indexOf("inbound-rtp")&&-1===n.type.toLowerCase().indexOf("inbound")||"video"!==n.mediaType||(n.googFrameWidthReceived=e.videoWidth+"",n.googFrameHeightReceived=e.videoHeight+"");var a=200*t;t++;var i=e.getId();setTimeout((function(){var t=R.socket&&R.socket.getLastMsgTime()&&Date.now()-R.socket.getLastMsgTime();if(t>Object(o.getParameter)("REPORT_STATS_TIMEOUT"))r.default.debug("SubscribeStats report blocked by REPORT_STATS_TIMEOUT ".concat(t));else{if("video"===n.mediaType)try{var a=e.stream.getVideoTracks()[0];n.A_vrtd=a.enabled?"0":"1"}catch(e){}if("audio"===n.mediaType)try{var s=e.stream.getAudioTracks()[0];n.A_artd=s.enabled?"0":"1"}catch(e){}R.makeReport(v(i,n))}}),a)}else;}))}))}}),3e3),clearInterval(R.timers[e.getId()+"_RelatedStats"]),R.timers[e.getId()+"_RelatedStats"]=setInterval((function(){if(Object(o.getParameter)("REPORT_STATS")&&e&&e.pc){var t=R.socket&&R.socket.getLastMsgTime()&&Date.now()-R.socket.getLastMsgTime();if(t>Object(o.getParameter)("REPORT_STATS_TIMEOUT"))return void r.default.debug("SubscribeRelatedStats report blocked by REPORT_STATS_TIMEOUT ".concat(t));e.pc.getVideoRelatedStats&&e.pc.getVideoRelatedStats((function(t){e.player&&(t.isFreeze=e.player.freezeCount>e.player.lastFreezeCount,e.player.lastFreezeCount=e.player.freezeCount),R.makeReport(d(e.getId(),t))})),e.pc.getAudioRelatedStats&&e.pc.getAudioRelatedStats((function(t){R.makeReport(d(e.getId(),t))}))}}),1e3),R.audioLevel[e.getId()]=0,clearInterval(R.timers[e.getId()+"audio"]),R.timers[e.getId()+"audio"]=setInterval((function(){R.hasListeners("active-speaker")&&e&&e.pc&&"established"===e.pc.state&&e.pc.getStats&&e.pc.getStats((function(t){t.forEach((function(t){if("audio"===t.mediaType){if(t.audioOutputLevel>5e3)for(var n in R.audioLevel[e.getId()]<20&&(R.audioLevel[e.getId()]+=1),R.audioLevel)n!==""+e.getId()&&R.audioLevel[n]>0&&(R.audioLevel[n]-=1);var a=Object.keys(R.audioLevel).sort((function(e,t){return R.audioLevel[t]-R.audioLevel[e]}));if(R.activeSpeaker!==a[0]){var i=l({type:"active-speaker",uid:a[0]});R.dispatchEvent(i),R.activeSpeaker=a[0],r.default.debug("[".concat(R.clientId,"] Update active speaker: ").concat(R.activeSpeaker))}}}))}),50)}),50),e.pc.oniceconnectionstatechange=function(i){if("failed"===i)null!=R.timers[e.getId()]&&(clearInterval(R.timers[e.getId()]),clearInterval(R.timers[e.getId()]+"audio")),r.default.error("[".concat(R.clientId,"] Subscriber connection is lost -- streamId: ").concat(e.getId(),", p2pId: ").concat(p)),r.default.debug("[".concat(R.clientId,"] subscribe p2p failed: "),R.p2ps),c||(c=!0,n&&n(I.default.PEERCONNECTION_FAILED),s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!1,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:I.default.PEERCONNECTION_FAILED,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:p})),R.remoteStreams[e.getId()]&&R.p2ps.has(p)&&(R.p2ps.delete(p),R.dispatchEvent(l({type:"subP2PLost",stream:e})));else if("connected"===i&&(r.default.debug("[".concat(R.clientId,"] subscribe p2p connected: "),R.p2ps),!c)){c=!0,s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!0,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:null,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:p}),R._adjustPCMuteStatus(e);var o=!1,d=!1,u=!1,f=setInterval((function(){o&&d||(e.pc?e.pc.getStats((function(t){t.forEach((function(t){if((-1!==t.id.indexOf("recv")||t.type&&-1!==t.type.toLowerCase().indexOf("inbound")||-1!==t.id.indexOf("inbound_rtp")||-1!==t.id.indexOf("inbound-rtp")||-1!==t.id.indexOf("InboundRTP"))&&"audio"===t.mediaType){if((t.googDecodingNormal>0||t.audioOutputLevel>0)&&!o){o=!0,R.dispatchEvent({type:"first-audio-frame-decode",stream:e}),o&&d&&clearInterval(f);var n=Date.now(),a=s.b.getSessionStartTime(R.joinInfo.sid);s.b.firstAudioDecode(R.joinInfo.sid,{peerid:e.uintId,uid:R.uid,elapse:n-a,subscribeElapse:n-e.subscribeLTS,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:p})}if(parseInt(t.packetsReceived)>0&&!d){d=!0,R.dispatchEvent({type:"first-audio-packet-received",stream:e}),o&&d&&clearInterval(f);n=Date.now(),a=s.b.getSessionStartTime(R.joinInfo.sid);s.b.firstAudioReceived(R.joinInfo.sid,{peerid:e.uintId,uid:R.uid,elapse:n-a,subscribeElapse:n-e.subscribeLTS,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:p})}}}))}),100):clearInterval(f))}),100),g=!1,m=!1,v=setInterval((function(){g&&m||(e.pc?e.pc.getStats((function(t){t.forEach((function(t){if((-1!==t.id.indexOf("recv")||t.type&&-1!==t.type.toLowerCase().indexOf("inbound")||-1!==t.id.indexOf("inbound_rtp")||-1!==t.id.indexOf("inbound-rtp")||-1!==t.id.indexOf("InboundRTP"))&&"video"===t.mediaType){if((t.framesDecoded>0||t.googFramesDecoded>0)&&!g){g=!0,R.dispatchEvent({type:"first-video-frame-decode",stream:e}),g&&m&&clearInterval(v);var n=Date.now(),a=s.b.getSessionStartTime(R.joinInfo.sid);e.firstFrameTime=(new Date).getTime()-e.subscribeLTS,s.b.firstVideoDecode(R.joinInfo.sid,{peerid:e.uintId,width:parseInt(t.googFrameWidthReceived)||0,height:parseInt(t.googFrameHeightReceived)||0,uid:R.uid,elapse:n-a,subscribeElapse:n-e.subscribeLTS,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:p})}if(t.packetsReceived>0&&!m){m=!0,R.dispatchEvent({type:"first-video-packet-received",stream:e}),g&&m&&clearInterval(v);n=Date.now(),a=s.b.getSessionStartTime(R.joinInfo.sid);s.b.firstVideoReceived(R.joinInfo.sid,{peerid:e.uintId,uid:R.uid,elapse:n-a,subscribeElapse:n-e.subscribeLTS,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:p})}}}))}),100):clearInterval(v))}),100),S=setInterval((function(){if(!u){var t=e.getId(),n=R.traffic_stats;if(n&&n.peer_delay){var a=n.peer_delay.find((function(e){return e.peer_uid==t}));if(a){u=!0;var i=s.b.getSessionStartTime(R.joinInfo.sid),o=a.peer_publish_audio_duration+(Date.now()-n.timestamp),r=Date.now();s.b.peerPublishStatus({lts:r,sid:R.joinInfo.sid,cname:R.joinInfo.cname,cid:R.joinInfo.cid,uid:R.joinInfo.uid,elapse:r-i,peer:t,peerPublishDuration:o,joinChannelSuccessElapse:r-R.joinSuccessLts,subscribeElapse:r-e.subscribeLTS}),clearInterval(S)}}}}),1e3);return e.sid=R.joinInfo.sid,t&&t()}}}else r.default.error("[".concat(R.clientId,"] Invalid remote stream")),c||(c=!0,n&&n(I.default.INVALID_REMOTE_STREAM),s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!1,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:I.default.INVALID_REMOTE_STREAM}));else r.default.error("[".concat(R.clientId,"] No such remote stream")),c||(c=!0,n&&n(I.default.NO_SUCH_REMOTE_STREAM),s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!1,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:I.default.NO_SUCH_REMOTE_STREAM}))},R.subscribeChange=function(e,t,n){var a=Date.now();r.default.info("[".concat(R.clientId,"] Gatewayclient ").concat(R.uid," SubscribeChange ").concat(e.getId(),": ").concat(JSON.stringify(e.subscribeOptions))),R._adjustPCMuteStatus(e);var i={stream_id:e.getId(),audio:e.subscribeOptions.audio,video:e.subscribeOptions.video};R.makeRequest({_type:"subscribe_change",_message:i},(function(n){var i=u({type:"stream-subscribe-changed",stream:R.remoteStreams[e.getId()]});s.b.subscribe(R.joinInfo.sid,{lts:a,succ:!0,video:e.subscribeOptions&&e.subscribeOptions.video,audio:e.subscribeOptions&&e.subscribeOptions.audio,peerid:e.getId(),ec:null,subscribeRequestid:R.subscribeRequestId.get(e.getId())||0,p2pid:R.p2ps.get(e.getId())}),R.dispatchEvent(i),t&&t()}),(function(t,a){r.default.error("[".concat(R.clientId,"] Subscribe Change Failed ").concat(e.getId()),t,a),n&&n(t,a)}))},R.processPublishFailure=function(e){e.publishLTS=null,e.p2pId&&R.p2ps.get(e.p2pId)===e&&R.p2ps.delete(e.p2pId),R.localStreams[e.getUserId()]===e&&delete R.localStreams[e.getUserId()],R.localStreams[e.getId()]===e&&delete R.localStreams[e.getId()],e.pc&&(e.pc.processSignalingMessage=function(){},e.pc.oniceconnectionstatechange=function(){},e.pc.close(),delete e.pc),delete e.onClose,delete e._onAudioUnmute,delete e._onVideoUnmute,delete e._onAudioMute,delete e._onVideoMute,delete e._onAudioUnmute},R.processSubscribeFailure=function(e){e.p2pId&&R.p2ps.get(e.p2pId)===e&&R.p2ps.delete(e.p2pId),e.pc&&(e.pc.onaddstream=function(){},e.pc.processSignalingMessage=function(){},e.pc.oniceconnectionstatechange=function(){},e.pc.close(),delete e.pc),delete e.onClose,delete e._onAudioUnmute,delete e._onVideoUnmute,delete e._onAudioMute,delete e._onVideoMute,delete e._onAudioUnmute},R._adjustPCMuteStatus=function(e){!e.local&&e.pc&&e.pc.peerConnection.getReceivers&&e.pc.peerConnection.getReceivers().forEach((function(t){if(t&&t.track&&"audio"===t.track.kind){var n=!e.userMuteAudio&&!e.peerMuteAudio;e.subscribeOptions&&!e.subscribeOptions.audio&&(n=!1),t.track.enabled=!!n}else if(t&&t.track&&"video"===t.track.kind){var a=!e.userMuteVideo&&!e.peerMuteVideo;e.subscribeOptions&&!e.subscribeOptions.video&&(a=!1),t.track.enabled=!!a}}))},R.unsubscribe=function(e,t,n){if("object"!==be()(e)||null===e)return r.default.error("[".concat(R.clientId,"] Invalid remote stream")),void A(n,I.default.INVALID_REMOTE_STREAM);if(R.state!==h)return r.default.error("[".concat(R.clientId,"] User is not in the session")),void A(n,I.default.INVALID_OPERATION);if(null!=R.timers[e.getId()]&&(clearInterval(R.timers[e.getId()]),clearInterval(R.timers[e.getId()]+"audio")),null!=R.audioLevel[e.getId()]&&delete R.audioLevel[e.getId()],null!=R.timer_counter[e.getId()]&&delete R.timer_counter[e.getId()],R.remoteStreams.hasOwnProperty(e.getId())){if(!R.socket)return r.default.error("[".concat(R.clientId,"] User is not in the session")),void A(n,I.default.INVALID_OPERATION);if(e.local)return r.default.error("[".concat(R.clientId,"] Invalid remote stream")),void A(n,I.default.INVALID_REMOTE_STREAM);e.close(),e.stop();var a={stream_id:e.getId()};R.makeRequest({_type:"unsubscribe",_message:a}),void 0!==e.pc&&(e.pc.close(),e.pc=void 0),e.onClose=void 0,e._onAudioMute=void 0,e._onAudioUnute=void 0,e._onVideoMute=void 0,e._onVideoUnmute=void 0,delete e.subscribeOptions,R.p2ps.delete(e.p2pId),r.default.info("[".concat(R.clientId,"] Unsubscribe stream success")),t&&t()}else A(n,I.default.NO_SUCH_REMOTE_STREAM)},R.setRemoteVideoStreamType=function(e,t){if(r.default.debug("[".concat(R.clientId,"] Switching remote video stream ").concat(e.getId()," to ").concat(t)),"object"===be()(e)&&null!==e)if(R.state===h){if(!e.local){switch(t){case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_HIGH:case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_LOW:case R.remoteVideoStreamTypes.REMOTE_VIDEO_STREAM_MEDIUM:break;default:return}var n={stream_id:e.getId(),stream_type:t};R.makeRequest({_type:"switch_video_stream",_message:n},(function(){r.default.debug("SwitchVideoStream Success ".concat(n.stream_id," ").concat(n.stream_type))}),(function(e,t){r.default.error("SwitchVideoStream Error ".concat(e," ").concat(n.stream_id," ").concat(n.stream_type),t)}))}}else r.default.error("[".concat(R.clientId,"] User is not in the session"));else r.default.error("[".concat(R.clientId,"] Invalid remote stream"))},R.renewToken=function(e,t,n){e?R.key?R.state!==h?(r.default.debug("[".concat(R.clientId,"] Client is not connected. Trying to rejoin")),R.key=e,R.rejoin(),t&&t()):(r.default.debug("[".concat(R.clientId,"] renewToken from ").concat(R.key," to ").concat(e)),R.makeRequest({_type:"renew_token",_message:{token:e}},t,n)):(r.default.error("[".concat(R.clientId,"] Client is previously joined without token")),n&&n(I.default.INVALID_PARAMETER)):(r.default.error("[".concat(R.clientId,"] Invalid Token ").concat(e)),n&&n(I.default.INVALID_PARAMETER))},R.setStreamFallbackOption=function(e,t){if(r.default.debug("[".concat(R.clientId,"] Set stream fallback option ").concat(e.getId()," to ").concat(t)),"object"===be()(e)&&null!==e)if(R.state===h){if(!e.local){switch(t){case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_DISABLED:case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW:case R.streamFallbackTypes.STREAM_FALLBACK_OPTION_AUDIO_ONLY:break;default:return}var n={stream_id:e.getId(),fallback_type:t};R.makeRequest({_type:"set_fallback_option",_message:n},(function(){r.default.debug("SetStreamFallbackOption success ".concat(n.stream_id," ").concat(t))}),(function(e,a){r.default.error("Failed to SetStreamFallbackOption ".concat(n.stream_id," ").concat(t," ").concat(e),a)}))}}else r.default.error("[".concat(R.clientId,"] User is not in the session"));else r.default.error("[".concat(R.clientId,"] Invalid remote stream"))},R.enableAudioVolumeIndicator=function(e,t){R.audioVolumeIndication.enabled=!0,R.audioVolumeIndication.interval=e,R.audioVolumeIndication.smooth=t,R.resetAudioVolumeIndication()},R.resetAudioVolumeIndication=function(){if(clearInterval(R.timers.audioVolumeIndication),clearInterval(R.timers.audioVolumeSampling),R.audioVolumeIndication.enabled&&R.audioVolumeIndication.interval){var e=Math.floor(1e3*R.audioVolumeIndication.smooth/100);clearInterval(R.timers.audioVolumeSampling),R.timers.audioVolumeSampling=setInterval((function(){R.audioVolumeSampling||(R.audioVolumeSampling={});var t={};for(var n in R.remoteStreams){var a=R.remoteStreams[n];if(a.stream&&a.hasAudio()){var i=a.getAudioLevel();i>0&&i<1&&(i*=100);var o=R.audioVolumeSampling[n]||[];for(o.push(i);o.length>e;)o.shift();t[n]=o}}R.audioVolumeSampling=t}),100),clearInterval(R.timers.audioVolumeIndication),R.timers.audioVolumeIndication=setInterval((function(){if(R.socket&&R.socket.signal&&R.socket.signal.connection&&R.socket.signal.connection.readyState===WebSocket.OPEN){var e=[];for(var t in R.remoteStreams)if(R.audioVolumeSampling&&R.audioVolumeSampling[t]){var n=R.audioVolumeSampling[t],a=0;n.forEach((function(e){a+=e}));var i={uid:t,level:Math.floor(a/n.length)};i.level&&e.push(i)}var o=e.sort((function(e,t){return e.level-t.level}));r.default.debug("[".concat(R.clientId,"] volume-indicator "),JSON.stringify(o)),R.audioVolumeIndication.sortedAudioVolumes=o;var s=l({type:"volume-indicator",attr:o});R.dispatchEvent(s)}}),R.audioVolumeIndication.interval)}},R.closeGateway=function(){r.default.debug("[".concat(R.clientId,"] close gateway")),R.state=S,R.socket.close(),O()},R.startChannelMediaRelay=function(){var e=ee()(Z.a.mark((function e(t){var n,a,i,o;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!R.channelMediaRelayController){e.next=2;break}throw new Ce.ChannelMediaError("RELAY_ALREADY_START","",Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_ALREADY_START);case 2:return n=function(e){R.dispatchEvent({type:"channel-media-relay-event",code:e})},a=function(e,t,n){e===Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE&&t===Ce.CHANNEL_MEDIA_RELAY_ERROR.SERVER_CONNECTION_LOST&&(R.channelMediaRelayController.dispose(),R.channelMediaRelayController=null),R.dispatchEvent({type:"channel-media-relay-state",state:e,code:t,data:n})},R.channelMediaRelayController=new Ne.a(R.joinInfo,R.clientId),R.channelMediaRelayController.on("event",n),R.channelMediaRelayController.on("state",a),e.prev=7,e.next=10,R.channelMediaRelayController.startChannelMediaRelay(t);case 10:e.next=22;break;case 12:throw e.prev=12,e.t0=e.catch(7),r.default.debug("[".concat(R.clientId,"] startChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),i=Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,o="",o=e.t0 instanceof Ce.ChannelMediaError?"SetSourceChannelStatus"===e.t0.data||e.t0.data&&e.t0.data.serverResponse&&"SetSourceChannel"===e.t0.data.serverResponse.command?"FAILED_JOIN_SRC":"SetDestChannelStatus"===e.t0.data||e.t0.data&&e.t0.data.serverResponse&&"SetDestChannel"===e.t0.data.serverResponse.command?"FAILED_JOIN_DEST":e.t0.data&&e.t0.data.serverResponse&&"StartPacketTransfer"===e.t0.data.serverResponse.command?"FAILED_PACKET_SENT_TO_DEST":e.t0.message===Ce.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===Ce.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":e.t0.message===Ce.CHANNEL_MEDIA_ERROR.AP_REQUEST_TIMEOUT?"NO_RESOURCE_AVAILABLE":e.t0.message===Ce.CHANNEL_MEDIA_ERROR.WS_ABORT||e.t0.message===Ce.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT?"OPERATION_ABORT":"INTERNAL_ERROR":"INTERNAL_ERROR",R.dispatchEvent({type:"channel-media-relay-state",state:i,code:Ce.CHANNEL_MEDIA_RELAY_ERROR[o]}),R.channelMediaRelayController&&(R.channelMediaRelayController.dispose(),R.channelMediaConfig=null,R.channelMediaRelayController=null),R.dispatchEvent({type:"channel-media-relay-state",state:Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new Ce.ChannelMediaError(o,null,Ce.CHANNEL_MEDIA_RELAY_ERROR[o]);case 22:R.dispatchEvent({type:"channel-media-relay-state",state:Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_RUNNING,code:Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_OK}),R.channelMediaConfig=t;case 24:case"end":return e.stop()}}),e,null,[[7,12]])})));return function(t){return e.apply(this,arguments)}}(),R.updateChannelMediaRelay=function(){var t=ee()(Z.a.mark((function t(n){var a,i;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(R.channelMediaRelayController){t.next=2;break}throw new Ce.ChannelMediaError("RELAY_NOT_START",null,Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);case 2:return t.prev=2,t.next=5,R.channelMediaRelayController.updateChannelMediaRelay(n);case 5:t.next=18;break;case 7:throw t.prev=7,t.t0=t.catch(2),r.default.debug("[".concat(R.clientId,"] updateChannelMediaRelay exception: ").concat(JSON.stringify(e))),a=Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,i="",i=e instanceof Ce.ChannelMediaError?e.message===Ce.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.message===Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.message===Ce.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.message===Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":e.message===Ce.CHANNEL_MEDIA_ERROR.WS_ABORT||e.message===Ce.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT?"OPERATION_ABORT":"INTERNAL_ERROR":"INTERNAL_ERROR",R.dispatchEvent({type:"channel-media-relay-event",code:Ce.CHANNEL_MEDIA_RELAY_EVENT.PACKET_UPDATE_DEST_CHANNEL_REFUSED}),R.dispatchEvent({type:"channel-media-relay-state",state:a,code:Ce.CHANNEL_MEDIA_RELAY_ERROR[i]}),R.channelMediaRelayController&&(R.channelMediaRelayController.dispose(),R.channelMediaConfig=null,R.channelMediaRelayController=null),R.dispatchEvent({type:"channel-media-relay-state",state:Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new Ce.ChannelMediaError(i,null,Ce.CHANNEL_MEDIA_RELAY_ERROR[i]);case 18:R.channelMediaConfig=n;case 19:case"end":return t.stop()}}),t,null,[[2,7]])})));return function(e){return t.apply(this,arguments)}}(),R.stopChannelMediaRelay=ee()(Z.a.mark((function t(){var n,a;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(R.channelMediaRelayController){t.next=2;break}throw new Ce.ChannelMediaError("RELAY_NOT_START",null,Ce.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);case 2:return t.prev=2,t.next=5,R.channelMediaRelayController.stopChannelMediaRelay();case 5:t.next=17;break;case 7:throw t.prev=7,t.t0=t.catch(2),r.default.debug("[".concat(R.clientId,"] stopChannelMediaRelay exception: ").concat(JSON.stringify(e))),n=Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,a="",a=e instanceof Ce.ChannelMediaError?e.message===Ce.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.message===Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.message===Ce.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.message===Ce.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":"INTERNAL_ERROR":"INTERNAL_ERROR",R.dispatchEvent({type:"channel-media-relay-state",state:n,code:Ce.CHANNEL_MEDIA_RELAY_ERROR[a]}),R.channelMediaRelayController&&(R.channelMediaRelayController.dispose(),R.channelMediaConfig=null,R.channelMediaRelayController=null),R.dispatchEvent({type:"channel-media-relay-state",state:Ce.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new Ce.ChannelMediaError(a,null,Ce.CHANNEL_MEDIA_RELAY_ERROR[a]);case 17:R.channelMediaConfig=null,R.channelMediaRelayController=null;case 19:case"end":return t.stop()}}),t,null,[[2,7]])}))),R.sendMetadata=function(e,t){R.makeRequest(function(e){return{_type:"send_metadata",_message:{session_id:R.joinInfo.sid,metadata:window.btoa(unescape(encodeURIComponent(e)))}}}(e),(function(){r.default.debug("[".concat(R.clientId,'] send metadata "').concat(e,'" success')),t&&t(null)}),(function(n){r.default.error("[".concat(R.clientId,'] send metadata "').concat(e,'" failed'),n),t&&t(n)}))};var y=function(){r.default.debug("[".concat(R.clientId,"] Reconnect gateway")),R.state=S,R.socket.close(),O(),R.reconnectMode="recover",R.state=_,C()};R.recover=y;var O=function(){for(var e in R.dispatchEvent({type:"before-clear-connection"}),R.timers)R.timers.hasOwnProperty(e)&&clearInterval(R.timers[e]);for(var e in R.remoteStreams)if(R.remoteStreams.hasOwnProperty(e)){var t=R.remoteStreams[e],n=l({type:"stream-removed",uid:t.getId(),stream:t});R.dispatchEvent(n)}R.p2ps.clear(),k(),D(),clearInterval(R.pingTimer)};R.rejoin=function(){R.socket&&(clearInterval(R.pingTimer),R.socket.close(),R.socket=void 0),R.state=_,C()};var C=function(e,t){R.dispatchEvent(l({type:"rejoin-start"})),e=e||function(e){r.default.info("[".concat(R.clientId,"] User ").concat(e," is re-joined to ").concat(R.joinInfo.cname)),R.dispatchEvent(l({type:"rejoin"})),R.channelMediaConfig&&R.startChannelMediaRelay(R.channelMediaConfig).then((function(){r.default.debug("[".concat(R.clientId,"] restartChannelMediaRelay success"))})).catch((function(e){r.default.debug("[".concat(R.clientId,"] restartChannelMediaRelay failed: ").concat(JSON.stringify(e)))})),R.liveStreams&&R.liveStreams.size&&R.liveStreams.forEach((function(e,t){e&&R.setLiveTranscoding(R.transcoding),R.startLiveStreaming(t,e)})),R.injectLiveStreams&&R.injectLiveStreams.size&&R.injectLiveStreams.forEach((function(e,t){R.addInjectStreamUrl(t,e)}))},t=t||function(e){r.default.error("[".concat(R.clientId,"] Re-join to channel failed "),e),R.dispatchEvent(u({type:"error",reason:e}))},R.key?(++R.rejoinAttempt,R.join(R.joinInfo,R.key,e,t)):r.default.error("[".concat(R.clientId,"] Connection recover failed [Invalid channel key]"))},N=function(e,t,n){if(R.onConnect=t,R.socket){if(R.dispatchEvent({type:"reconnect"}),"retry"===R.reconnectMode)r.default.debug("[".concat(R.clientId,"] Retry current gateway")),R.socket.reconnect();else if("tryNext"===R.reconnectMode)r.default.debug("[".concat(R.clientId,"] Try next gateway")),R.socket.connectNext();else if("recover"===R.reconnectMode){r.default.debug("[".concat(R.clientId,"] Recover gateway")),r.default.debug("[".concat(R.clientId,"] Try to reconnect choose server and get gateway list again ")),R.reconnectingCS=!0;var i=R.joinInfo&&R.joinInfo.sid;0,ze(R.joinInfo,(function(e){r.default.debug("[".concat(R.clientId,"] session:  ").concat(i," get gateway list success")),R.joinInfo.apResponse=e.res,R.reconnectingCS?R.socket.replaceHost(e.gateway_addr):r.default.debug("[".concat(R.clientId,"] session:  ").concat(i," already leave"))}))}}else c=e.gatewayAddr,R.socket=Ve(c,{sid:R.joinInfo.sid,clientId:R.clientId}),R.socket.on("start-connection",(function(e){R.ticket=e&&e.msg&&e.msg.ticket})),R.socket.on("on_uplink_stats",(function(e){var t={};for(var n in e)t[it(n)]=e[n];if(R.OutgoingAvailableBandwidth=t.uplink_available_bandwidth,R.localStreams[R.uid]){var a=R.localStreams[R.uid].uplinkStats;a&&a.period_fir===t.period_fir||r.default.debug("[".concat(R.clientId,"]: Period fir change to: ").concat(t.period_fir)),R.localStreams[R.uid].uplinkStats=t}})),R.socket.on("connect",(function(){R.dispatchEvent({type:"connected"}),R.attemps=1,R.onConnect()})),R.socket.on("recover",(function(){R.state=_,r.default.debug("[".concat(R.clientId,"] Try to reconnect choose server and get gateway list again ")),R.reconnectingCS=!0;var e=R.joinInfo&&R.joinInfo.sid;ze(R.joinInfo,(function(t){r.default.debug("[".concat(R.clientId,"] session:  ").concat(e," get gateway list success")),R.reconnectingCS?R.socket.replaceHost(t.gateway_addr):r.default.debug("[".concat(R.clientId,"] session:  ").concat(e," already leave"))}))})),R.socket.on("disconnect",(function(e){if(r.default.debug("[".concat(R.clientId,"] Receive disconnect message")),R.state!==S){R.state=S;var t=u({type:"error",reason:I.default.SOCKET_DISCONNECTED});if(R.dispatchEvent(t),0===R.p2ps.size?R.reconnectMode="tryNext":R.reconnectMode="retry",O(),R.channelMediaRelayController&&R.channelMediaRelayController.dispose(),R.channelMediaRelayController=null,1!=a){var n,i=(n=R.attemps,1e3*Math.min(30,Math.pow(2,n)-1));if(r.default.error("[".concat(R.clientId,"] Disconnect from server [").concat(JSON.stringify(e),"], attempt to recover [#").concat(R.attemps,"] after ").concat(i/1e3," seconds")),R.hasInvokeLeave)return r.default.debug("[".concat(R.clientId,"] No reconnection because Client.leave has been invoked")),void(R.hasInvokeLeave=!1);setTimeout((function(){R.attemps++,R.state=_,R.inChannelInfo&&Date.now()-R.inChannelInfo.joinAt>Object(o.getParameter)("TICKET_RENEW_TIMEOUT")?(r.default.debug("Recovering to renew ticket"),y()):C()}),i)}}})),R.socket.on("on_add_audio_stream",(function(e){if(r.default.info("[".concat(R.clientId,"] Newly added audio stream with uid ").concat(e.uid)),R.joinInfo.stringUid&&"string"!=typeof e.uid&&r.default.error("StringUID is Mixed with UintUID"),R.remoteStreamsInChannel.has(e.uid)||R.remoteStreamsInChannel.add(e.uid),void 0===R.remoteStreams[e.uid]){var t=ye({streamID:e.uid,local:!1,audio:e.audio,video:e.video,uintUID:e.uint_id||e.uid});t.peerMuteVideo=!0,R.remoteStreams[e.uid]=t;var n=u({type:"stream-added",stream:t});R.dispatchEvent(n);var a=R.remoteMuteState[e.uid];if(a&&a.audio){n=l({type:"mute-audio",uid:e.uid});R.dispatchEvent(n)}if(a&&a.video){n=l({type:"mute-video",uid:e.uid});R.dispatchEvent(n)}}s.b.onAddAudioStream(R.joinInfo.sid,{peerid:e.uint_id||e.uid,uid:R.uid})})),R.socket.on("on_update_stream",(function(e){var t=R.remoteStreams[e.uid];if(R.joinInfo.stringUid&&"string"!=typeof e.uid&&r.default.error("StringUID is Mixed with UintUID"),t){t.audio=e.audio,t.video=e.video,t.screen=e.screen,t.pc&&R._adjustPCMuteStatus(t);var n=u({type:"stream-updated",stream:t});R.dispatchEvent(n)}else r.default.debug("[".concat(R.clientId,"] Ignoring onUpdateStream event before onAddStream for uid ").concat(e.uid));s.b.onUpdateStream(R.joinInfo.sid,{peerid:e.uint_id||e.uid,audio:e.audio,video:e.video,uid:R.uid})})),R.socket.on("on_add_video_stream",(function(e){if(r.default.info("[".concat(R.clientId,"] Newly added remote stream with uid ").concat(e.uid,".")),R.joinInfo.stringUid&&"string"!=typeof e.uid&&r.default.error("StringUID is Mixed with UintUID"),R.remoteStreamsInChannel.has(e.uid)||R.remoteStreamsInChannel.add(e.uid),void 0===R.remoteStreams[e.uid]){var t=ye({streamID:e.uid,local:!1,audio:e.audio,video:e.video,uintUID:e.uint_id||e.uid});R.remoteStreams[e.uid]=t;var n=u({type:"stream-added",stream:t});R.dispatchEvent(n);var a=R.remoteMuteState[e.uid];if(a&&a.audio){n=l({type:"mute-audio",uid:e.uid});R.dispatchEvent(n)}if(a&&a.video){n=l({type:"mute-video",uid:e.uid});R.dispatchEvent(n)}}else{var i=R.remoteStreams[e.uid];if(void 0!==i.stream){if((t=R.remoteStreams[e.uid]).video=!0,t.peerMuteVideo=!1,t.pc&&R._adjustPCMuteStatus(t),r.default.info("[".concat(R.clientId,"] Stream changed: enable video ").concat(e.uid)),t.isPlaying()){var o=t.player.elementID;t.stop(),t.play(o,t.playOptions)}}else if(i.p2pId)R.remoteStreams[e.uid].video=!0;else{t=ye({streamID:e.uid,local:!1,audio:!0,video:!0,uintUID:e.uint_id||e.uid});R.remoteStreams[e.uid]=t,r.default.info("[".concat(R.clientId,"] Stream changed: modify video ").concat(e.uid))}}s.b.onAddVideoStream(R.joinInfo.sid,{peerid:e.uint_id||e.uid,uid:R.uid})})),R.socket.on("on_remove_stream",(function(e){R.remoteStreamsInChannel.has(e.uid)&&R.remoteStreamsInChannel.delete(e.uid);var t=R.remoteStreams[e.uid];if(t){delete R.remoteStreams[e.uid],delete R.remoteMuteState[e.uid];var n=u({type:"stream-removed",stream:t});R.dispatchEvent(n),t.close(),void 0!==t.pc&&(t.pc.close(),t.pc=void 0,R.p2ps.delete(t.p2pId)),s.b.onRemoveStream(R.joinInfo.sid,{peerid:e.uint_id||e.uid,uid:R.uid})}else r.default.error("ERROR stream ",e.uid," not found onRemoveStream ",e)})),R.socket.on("on_publish_stream",(function(e){var t=R.localStreams[e.uid],n=u({type:"streamPublished",stream:t});R.dispatchEvent(n)})),R.socket.on("mute_audio",(function(e){r.default.info("[".concat(R.clientId,"] rcv peer mute audio: ").concat(e.uid)),R.remoteMuteState[e.uid]=R.remoteMuteState[e.uid]||{audio:!1,video:!1},R.remoteMuteState[e.uid].audio=!0;var t=l({type:"mute-audio",uid:e.uid}),n=R.remoteStreams[e.uid];n?(n.peerMuteAudio=!0,n.pc&&R._adjustPCMuteStatus(n),R.dispatchEvent(t)):r.default.debug("Ignoring event ".concat(e.type),e)})),R.socket.on("unmute_audio",(function(e){r.default.info("[".concat(R.clientId,"] rcv peer unmute audio: ").concat(e.uid)),R.remoteMuteState[e.uid]=R.remoteMuteState[e.uid]||{audio:!1,video:!1},R.remoteMuteState[e.uid].audio=!1;var t=l({type:"unmute-audio",uid:e.uid}),n=R.remoteStreams[e.uid];n?(n.peerMuteAudio=!1,n.pc&&R._adjustPCMuteStatus(n),R.dispatchEvent(t)):r.default.debug("Ignoring event ".concat(e.type),e)})),R.socket.on("mute_video",(function(e){r.default.info("[".concat(R.clientId,"] rcv peer mute video: ").concat(e.uid)),R.remoteMuteState[e.uid]=R.remoteMuteState[e.uid]||{audio:!1,video:!1},R.remoteMuteState[e.uid].video=!0;var t=l({type:"mute-video",uid:e.uid}),n=R.remoteStreams[e.uid];n?(n.peerMuteVideo=!0,n.pc&&R._adjustPCMuteStatus(n),R.dispatchEvent(t)):r.default.debug("Ignoring event ".concat(e.type),e)})),R.socket.on("unmute_video",(function(e){r.default.info("[".concat(R.clientId,"] rcv peer unmute video: ").concat(e.uid)),R.remoteMuteState[e.uid]=R.remoteMuteState[e.uid]||{audio:!1,video:!1},R.remoteMuteState[e.uid].video=!1;var t=l({type:"unmute-video",uid:e.uid}),n=R.remoteStreams[e.uid];n?(n.peerMuteVideo=!1,n.pc&&R._adjustPCMuteStatus(n),R.dispatchEvent(t)):r.default.debug("Ignoring event ".concat(e.type),e)})),R.socket.on("on_crypt_error",(function(e){r.default.warning("[".concat(R.clientId,"] stream crypt error"));var t=l({type:"crypt-error",cryptType:e.crypt_type});R.dispatchEvent(t)})),R.socket.on("on_user_banned",(function(e){r.default.info("[".concat(R.clientId,"] user banned uid: ").concat(e.uid," error: ").concat(e.error_code));var t=l({type:"client-banned",uid:e.uid,attr:e.error_code});R.dispatchEvent(t),a=!0})),R.socket.on("on_stream_fallback_update",(function(e){r.default.info("[".concat(R.clientId,"] stream fallback peerId: ").concat(e.stream_id," type: ").concat(e.stream_type));var t=l({type:"stream-fallback",uid:e.stream_id,stream:e.stream_id,attr:e.stream_type});R.dispatchEvent(t)})),R.socket.on("stream_recover",(function(e){r.default.info("[".concat(R.clientId,"] stream recover uid: ").concat(e.id," peerId: ").concat(e.peerid," type: ").concat(e.type));var t=l({type:"stream-recover",uid:e.id,stream:e.peerid,attr:e.type});R.dispatchEvent(t)})),R.socket.on("on_p2p_lost",(function(e){r.default.debug("[".concat(R.clientId,"] p2plost: "),e,"p2ps:",R.p2ps);var t,n="DTLS failed";(t=R.localStreams[e.uid]||R.remoteStreams[e.uid])?(t.pc&&t.pc.offerCandidates&&0===t.pc.offerCandidates.length&&(n="NO_CANDIDATES_IN_OFFER"),"publish"===e.event&&s.b.publish(R.joinInfo.sid,{lts:t.publishLTS,succ:!1,audio:t.hasAudio(),video:t.hasVideo(),screenshare:t.hasScreen(),audioName:t.hasAudio()&&t.audioName,videoName:t.hasVideo()&&t.videoName,screenName:t.hasScreen()&&t.screenName,ec:n,publishRequestid:R.publishRequestId||0,p2pid:R.p2ps.get(t.getId())}),"subscribe"===e.event&&s.b.subscribe(R.joinInfo.sid,{lts:t.subscribeLTS,succ:!1,video:t.subscribeOptions&&t.subscribeOptions.video,audio:t.subscribeOptions&&t.subscribeOptions.audio,peerid:e.uid+"",ec:n,subscribeRequestid:R.subscribeRequestId.get(t.getId())||0,p2pid:R.p2ps.get(t.getId())})):r.default.warning("P2PLost Stream Not found",e),r.default.debug("[".concat(R.clientId,"] p2plost:"),e.p2pid),(t=R.p2ps.get(e.p2pid))&&(R.p2ps.delete(e.p2pid),t.local?R.dispatchEvent(l({type:"pubP2PLost",stream:t,attr:n})):R.remoteStreams[t.getId()]&&R.dispatchEvent(l({type:"subP2PLost",stream:t,attr:n})))})),R.socket.on("on_token_privilege_will_expire",(function(e){r.default.debug("[".concat(R.clientId,"] Received Message onTokenPrivilegeWillExpire")),R.dispatchEvent(l({type:"onTokenPrivilegeWillExpire"}))})),R.socket.on("on_token_privilege_did_expire",(function(){r.default.warning("[".concat(R.clientId,"] Received Message onTokenPrivilegeDidExpire, please get new token and join again")),R.closeGateway(),R.dispatchEvent(l({type:"onTokenPrivilegeDidExpire"}))})),R.socket.on("enable_local_video",(function(e){R.dispatchEvent(l({type:"enable-local-video",uid:e.uid}))})),R.socket.on("disable_local_video",(function(e){R.dispatchEvent(l({type:"disable-local-video",uid:e.uid}))})),R._doWithAction=function(e,t,n){"tryNext"===e?function(e,t){r.default.debug("[".concat(R.clientId,"] Connect next gateway")),R.state=S,R.socket.close(),O(),R.reconnectMode="tryNext",R.state=_,C(e,t)}(t,n):"retry"===e?function(e,t){r.default.debug("[".concat(R.clientId,"] Reconnect gateway")),R.state=S,R.socket.close(),O(),R.reconnectMode="retry",R.state=_,C(e,t)}(t,n):"quit"===e?(r.default.debug("[".concat(R.clientId,"] quit gateway")),R.state=S,R.socket.close(),O()):"recover"===e&&y()},R.socket.on("on_notification",(function(e){if(r.default.debug("[".concat(R.clientId,"] Receive notification: "),e),"ERR_JOIN_BY_MULTI_IP"===I.GatewayErrorCode[e.code])return R.dispatchEvent({type:"onMultiIP",option:e.option});e.detail?R._doWithAction(Ze[I.GatewayErrorCode[e.code]]):e.action&&R._doWithAction(e.action)})),R.socket.on("on_user_offline",(function(e){var t=l({type:"peer-leave",uid:e.uid});if(R.remoteStreamsInChannel.has(e.uid)&&R.remoteStreamsInChannel.delete(e.uid),R.remoteStreams.hasOwnProperty(e.uid)&&(t.stream=R.remoteStreams[e.uid]),t.reason=e.reason,R.dispatchEvent(t),R.remoteStreams.hasOwnProperty(e.uid)){r.default.info("[".concat(R.clientId,"] closing stream on peer leave"),e.uid);var n=R.remoteStreams[e.uid];n.close(),delete R.remoteStreams[e.uid],delete R.remoteMuteState[e.uid],s.b.onRemoveStream(R.joinInfo.sid,{peerid:e.uint_id||e.uid,uid:R.uid}),void 0!==n.pc&&(n.pc.close(),n.pc=void 0,R.p2ps.delete(n.p2pId))}R.timers.hasOwnProperty(e.uid)&&(clearInterval(R.timers[e.uid]),clearInterval(R.timers[e.uid]+"_RelatedStats"),delete R.timers[e.uid]),null!=R.audioLevel[e.uid]&&delete R.audioLevel[e.uid],null!=R.timer_counter[e.uid]&&delete R.timer_counter[e.uid]})),R.socket.on("onUplinkStats",(function(e){})),R.socket.on("liveStreamingStarted",(function(e){var t=f({type:"liveStreamingStarted",url:e.url});R.dispatchEvent(t)})),R.socket.on("liveStreamingFailed",(function(e){var t=f({type:"liveStreamingFailed",url:e.url});R.dispatchEvent(t)})),R.socket.on("liveStreamingStopped",(function(e){var t=f({type:"liveStreamingStopped",url:e.url});R.dispatchEvent(t)})),R.socket.on("liveTranscodingUpdated",(function(e){var t=f({type:"liveTranscodingUpdated",reason:e.reason});R.dispatchEvent(t)})),R.socket.on("streamInjectedStatus",(function(e){var t=f({type:"streamInjectedStatus",url:e.url,uid:e.uid,status:e.status});R.dispatchEvent(t)})),R.socket.on("on_user_online",(function(e){R.joinInfo.stringUid&&"string"!=typeof e.uid&&r.default.error("StringUID is Mixed with UintUID"),R.dispatchEvent({type:"peer-online",uid:e.uid})})),R.socket.on("receive_metadata",(function(e){R.joinInfo.stringUid&&"string"!=typeof e.uid&&r.default.error("StringUID is Mixed with UintUID");var t=decodeURIComponent(escape(window.atob(e.metadata)));r.default.debug("[".concat(R.clientId,"] received ").concat(e.uid," metadata: ").concat(t)),R.dispatchEvent({type:"receive-metadata",uid:e.uid,metadata:t})}));var c},w=function(e,t){if(void 0!==R.socket)try{R.socket.emitSimpleMessage(e,(function(e,n){t&&t(e,n)}))}catch(e){r.default.error("[".concat(R.clientId,"] Error in sendSimpleSdp [").concat(e,"]"))}else r.default.error("[".concat(R.clientId,"] Error in sendSimpleSdp [socket not ready]"))},D=function(){for(var e in R.localStreams)if(void 0!==R.localStreams[e]){var t=R.localStreams[e];delete R.localStreams[e],void 0!==t.pc&&(t.pc.close(),t.pc=void 0)}},k=function(){for(var e in R.remoteStreamsInChannel.clear(),R.remoteStreams)if(R.remoteStreams.hasOwnProperty(e)){var t=R.remoteStreams[e];t.isPlaying()&&t.stop(),t.close(),delete R.remoteStreams[e],void 0!==t.pc&&(t.pc.close(),t.pc=void 0)}};return R},rt={_gatewayClients:{},register:function(e,t){if(!t.uid){var n="NO_UID_PROVIDED";return r.default.error("[".concat(e.clientId,"] "),n,t),n}if(t.cname){if(this._gatewayClients[t.cname]&&this._gatewayClients[t.cname][t.uid]&&this._gatewayClients[t.cname][t.uid]!==e){n="UID_CONFLICT";return r.default.error("[".concat(e.clientId,"] "),n,t),n}return r.default.debug("[".concat(e.clientId,"] register client Channel"),t.cname,"Uid",t.uid),this._gatewayClients[t.cname]||(this._gatewayClients[t.cname]={}),this._gatewayClients[t.cname][t.uid]=e,null}var n="NO_CHANNEL_PROVIDED";return r.default.error("[".concat(e.clientId,"] "),n,t),n},unregister:function(e){var t=e&&e.uid,n=e.joinInfo&&e.joinInfo.cname;if(!t||!n){var a="INVALID_GATEWAYCLIENT";return r.default.error("[".concat(e.clientId,"] "),a),a}if(this._gatewayClients[n]&&this._gatewayClients[n][t]){if(this._gatewayClients[n][t]!==e){a="GATEWAYCLIENT_UID_CONFLICT";return r.default.error("[".concat(e.clientId,"] "),a),a}return r.default.debug("[".concat(e.clientId,"] unregister client "),e.uid),delete this._gatewayClients[n][t],null}var a="GATEWEAY_CLIENT_UNREGISTERED";r.default.error("[".concat(e.clientId,"] "),a)}};ot.DISCONNECTED=0,ot.CONNECTING=1,ot.CONNECTED=2,ot.DISCONNECTING=3,ot.connetionStateMap={0:"DISCONNECTED",1:"CONNECTING",2:"CONNECTED",3:"DISCONNECTING"};var st=ot,ct={1001:"FRAMERATE_INPUT_TOO_LOW",1002:"FRAMERATE_SENT_TOO_LOW",1003:"SEND_VIDEO_BITRATE_TOO_LOW",1005:"RECV_VIDEO_DECODE_FAILED",2001:"AUDIO_INPUT_LEVEL_TOO_LOW",2002:"AUDIO_OUTPUT_LEVEL_TOO_LOW",2003:"SEND_AUDIO_BITRATE_TOO_LOW",2005:"RECV_AUDIO_DECODE_FAILED",3001:"FRAMERATE_INPUT_TOO_LOW_RECOVER",3002:"FRAMERATE_SENT_TOO_LOW_RECOVER",3003:"SEND_VIDEO_BITRATE_TOO_LOW_RECOVER",3005:"RECV_VIDEO_DECODE_FAILED_RECOVER",4001:"AUDIO_INPUT_LEVEL_TOO_LOW_RECOVER",4002:"AUDIO_OUTPUT_LEVEL_TOO_LOW_RECOVER",4003:"SEND_AUDIO_BITRATE_TOO_LOW_RECOVER",4005:"RECV_AUDIO_DECODE_FAILED_RECOVER"},dt={FramerateInput:1001,FramerateSent:1002,SendVideoBitrate:1003,VideoDecode:1005,AudioIntputLevel:2001,AudioOutputLevel:2002,SendAudioBitrate:2003,AudioDecode:2005},ut=function(e){var t={remoteStreamStorage:{},localStreamStorage:{}};return t.gatewayClient=e,t.checkAudioOutputLevel=function(e){return!(e&&parseInt(e.audioRecvBytesDelta)>0&&parseInt(e.audioDecodingNormalDelta)>0&&0===parseInt(e.audioOutputLevel))},t.checkAudioIntputLevel=function(e){return!e||0!==parseInt(e.audioInputLevel)},t.checkFramerateInput=function(e,t){if(!e||!t.attributes)return!0;var n=parseInt(t.attributes.maxFrameRate),a=parseInt(e.googFrameRateInput);return!n||!a||!(n>10&&a<5||n<10&&n>=5&&a<=1)},t.checkFramerateSent=function(e){return!(e&&parseInt(e.googFrameRateInput)>5&&parseInt(e.googFrameRateSent)<=1)},t.checkSendVideoBitrate=function(e){return!e||0!==parseInt(e.videoSendBytesDelta)},t.checkSendAudioBitrate=function(e){return!e||0!==parseInt(e.audioSendBytesDelta)},t.checkVideoDecode=function(e){return!e||0===parseInt(e.videoRecvBytesDelta)||0!==parseInt(e.googFrameRateDecoded)},t.checkAudioDecode=function(e){return!e||0===parseInt(e.audioRecvBytesDelta)||0!==parseInt(e.audioDecodingNormalDelta)},t.record=function(e,n,a,i,o){a[e]||(a[e]={isPrevNormal:!0,record:[]});var r=a[e],s=t["check"+e](n,o);if(r.record.push(s),r.record.length>=5){r.isCurNormal=-1!==r.record.indexOf(!0);var c=dt[e];r.isPrevNormal&&!r.isCurNormal&&t.gatewayClient.dispatchEvent({type:"exception",code:c,msg:ct[c],uid:i}),!r.isPrevNormal&&r.isCurNormal&&t.gatewayClient.dispatchEvent({type:"exception",code:c+2e3,msg:ct[c+2e3],uid:i}),r.isPrevNormal=r.isCurNormal,r.record=[]}},t.setLocalStats=function(e){var n={};Object.keys(e).map((function(a){var i=e[a],o=t.gatewayClient.localStreams[parseInt(a)],r=t.localStreamStorage[a]||{};o&&o.hasVideo()&&(t.record("SendVideoBitrate",i.videoStats,r,a),t.record("FramerateInput",i.videoStats,r,a,o),t.record("FramerateSent",i.videoStats,r,a)),o&&o.hasAudio()&&(t.record("AudioIntputLevel",i.audioStats,r,a),t.record("SendAudioBitrate",i.audioStats,r,a)),n[a]=r})),t.localStreamStorage=n},t.setRemoteStats=function(n){var a={};Object.keys(n).map((function(i){var o=n[i],r=e.remoteStreams[i],s=t.remoteStreamStorage[i]||{};r&&r.hasVideo()&&r.isPlaying()&&t.record("VideoDecode",o.videoStats,s,i),r&&r.hasAudio()&&r.isPlaying()&&(t.record("AudioOutputLevel",o.audioStats,s,i),t.record("AudioDecode",o.audioStats,s,i)),a[i]=s})),t.remoteStreamStorage=a},t};function lt(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(!e)return;if("string"==typeof e)return pt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pt(e,t)}(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}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 a,i,o=!0,r=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return o=e.done,e},e:function(e){r=!0,i=e},f:function(){try{o||null==a.return||a.return()}finally{if(r)throw i}}}}function pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}var ft=new function(){var e=c();return e.states={UNINIT:"UNINIT",INITING:"INITING",INITED:"INITED"},e.state=e.states.UNINIT,e.type=null,e.lastConnectedAt=null,e.lastDisconnectedAt=null,e.lastTypeChangedAt=null,e.networkChangeTimer=null,e._init=function(t,n){if(e.state=e.states.INITING,navigator.connection&&navigator.connection.addEventListener){var a=e._getNetworkInfo();e.type=a&&a.type,e.state=e.states.INITED,t&&t()}else e.state=e.states.UNINIT,n&&n("DO_NOT_SUPPORT")},e._getNetworkInfo=function(){return navigator.connection},e._reloadNetworkInfo=function(){var t=e._getNetworkInfo(),n=t&&t.type||"UNSUPPORTED",a=Date.now();if(n!==e.type){e.lastTypeChangedAt=a,"none"==n?e.lastDisconnectedAt=a:"none"==e.type&&(e.lastConnectedAt=a),e.type=n;var i={type:"networkTypeChanged",networkType:n};e.dispatchEvent(i)}},e.getStats=function(t,n){var a={},i=e._getNetworkInfo();i&&(a.NetworkType=i.type||"UNSUPPORTED"),setTimeout((function(){t(a)}),0)},e._init((function(){navigator.connection.addEventListener("change",(function(){e._reloadNetworkInfo()})),e.networkChangeTimer=setInterval((function(){e._reloadNetworkInfo()}),5e3)}),(function(e){})),e},gt="DISCONNECTING",mt="DISCONNECTED",vt="CONNECTED",St="INIT",Et=[],_t=(setInterval((function(){Date.now();Et.forEach((function(e){for(var t=e.requests.length-1;t>=0;t--){var n=e.requests[t];n.timeoutCnt++,n.timeoutCnt>=15&&(e.requests.splice(t,1),n.promises.reject({reason:"TIMEOUT",code:499}))}}))}),1e3),1),ht=1,It=1,bt=function(){var e=ee()(Z.a.mark((function e(t){var n,a,i,s,c,d,u;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.uid,a=t.url,i=t.serviceName,s=t.sid,c=t.appId,d=t.cname,u=t.timeout,e.abrupt("return",new Promise((function(e,t){var l=!1,p=new XMLHttpRequest;p.open("POST",a,!0),p.setRequestHeader("Content-Type","application/json; charset=utf-8"),p.setRequestHeader("X-Packet-Service-Type","0"),p.setRequestHeader("X-Packet-URI","61"),p.onload=function(){if(!l){var n=null,a=null;try{n=JSON.parse(p.responseText)}catch(e){var i="Invalid text ".concat(p.responseText);return r.default.error(i),l=!0,t(i)}if(n.code){var o="AP_ERR_".concat(n.code);return r.default.error(o,n),l=!0,t(o)}try{a=JSON.parse(n.json_body||n.json)}catch(e){var s="Invalid json_body ".concat(p.responseText);return r.default.error(s),l=!0,t(s)}if(200!==a.code){var c="APPCENTER_CODE_".concat(a.code);return r.default.error(c,a),l=!0,t(c)}if(!(a.servers&&a.servers.length>0)){return r.default.error("APPCENTER_EMPTY_SERVER",a),l=!0,t("APPCENTER_EMPTY_SERVER")}return l=!0,e(a)}},p.onerror=function(e){var n="AP_REUEST_".concat(e.type);r.default.error(n,a,e),l||(l=!0,t(n))},p.ontimeout=function(e){r.default.error("AP_REUEST_TIMEOUT",a,e),l||(l=!0,t("AP_REUEST_TIMEOUT"))},u&&(p.timeout=u),p.send(JSON.stringify({service_name:i,json_body:JSON.stringify({command:"convergeAllocateEdge",sid:s,uid:n+"",appId:c,ts:Math.floor(Date.now()/1e3),seq:_t++,cname:d,version:o.VERSION,requestId:ht++})}))})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Tt=function(){var e=ee()(Z.a.mark((function e(t){var n,a,i,s,c,d,u,l,p,f,g,m,v;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.serviceName,a=t.sid,i=t.appId,s=t.cname,c=t.uid,d=t.proxyServer,u=null,e.t0=Z.a.keys(Object(o.getParameter)("UAP_AP"));case 3:if((e.t1=e.t0()).done){e.next=34;break}return l=e.t1.value,p=d?"https://".concat(d,"/ap/?url=").concat(Object(o.getParameter)("UAP_AP")[l],"/api/v1&action=uap"):"https://".concat(Object(o.getParameter)("UAP_AP")[l],"/api/v1?action=uap"),f=void 0,e.prev=7,e.next=10,bt({uid:c,url:p,appId:i,sid:a,serviceName:n,cname:s,timeout:Object(o.getParameter)("HTTP_CONNECT_TIMEOUT")});case 10:f=e.sent,e.next=18;break;case 13:return e.prev=13,e.t2=e.catch(7),r.default.error(e.t2),u=e.t2,e.abrupt("continue",3);case 18:g=Z.a.mark((function e(t){var a,i,o;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=f.servers[t],i=void 0,i=d?"wss://".concat(d,"/ws/?h=").concat(a.address.replace(/\./g,"-"),".edge.").concat(t%2==0?"agora.io":"agoraio.cn","&p=").concat(a.wss,"&serviceName=").concat(encodeURIComponent(n)):"wss://".concat(a.address.replace(/\./g,"-"),".edge.").concat(t%2==0?"agora.io":"agoraio.cn",":").concat(a.wss,"?serviceName=").concat(encodeURIComponent(n)),a.wss){e.next=6;break}return r.default.error("Invalid server response",a),e.abrupt("return","continue");case 6:return e.prev=6,e.next=9,new Promise((function(e,t){var n=new WebSocket(i),a=!1;n.addEventListener("open",(function(){a||(a=!0,e(n))})),n.addEventListener("error",(function(e){a||(a=!0,t(e))}))}));case 9:return(o=e.sent).workerToken=f.workerToken,e.abrupt("return",{v:o});case 14:e.prev=14,e.t0=e.catch(6),r.default.error(e.t0),u=e.t0;case 18:case"end":return e.stop()}}),e,null,[[6,14]])})),m=0;case 20:if(!(m<f.servers.length)){e.next=32;break}return e.delegateYield(g(m),"t3",22);case 22:v=e.t3,e.t4=v,e.next="continue"===e.t4?26:27;break;case 26:return e.abrupt("continue",29);case 27:if("object"!==be()(v)){e.next=29;break}return e.abrupt("return",v.v);case 29:m++,e.next=20;break;case 32:e.next=3;break;case 34:throw u;case 35:case"end":return e.stop()}}),e,null,[[7,13]])})));return function(t){return e.apply(this,arguments)}}(),Rt={},At=function(e){return Rt[e]?(Rt[e]+=1,Rt[e]):(Rt[e]=1,Rt[e])},yt={},Ot=function(e){return yt[e]?(yt[e]+=1,yt[e]):(yt[e]=1,yt[e])},Ct=function(e){var t=e.appId,n=e.cname,a=e.uid,i=e.sid,s=c();return s.status=St,s.pingpongTimer=null,s.connection=null,s.requests=[],s.appId=t,s.cname=n,s.uid=a,s.sid=i,s.connection=null,s.connectionId=It++,s.connect=function(){var e=ee()(Z.a.mark((function e(t){var n;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.wsClient,s.status===St){e.next=4;break}return r.default.debug("Ignored UapConnection.connect: ".concat(s.status)),e.abrupt("return");case 4:s.connection=n,s.status=vt,s._flush(),s.startPingpong(),n.addEventListener("close",(function(e){if(console.log("Weboskcet closed",e),n===s.connection){var t={type:"close",evt:e};s.dispatchEvent(t)}})),n.addEventListener("message",(function(e){if(e.data){var t=null;try{t=JSON.parse(e.data)}catch(e){return void r.default.error("Invalid data from worker manager",t)}if(t.requestId)for(var n=s.requests.length-1;n>=0;n--){var a=s.requests[n];if(a.reqData.requestId===t.requestId){s.requests.splice(n,1),t.code<400&&t.code>=200?a.promises.resolve(t):a.promises.reject(t);break}}else t.type="notification",s.dispatchEvent(t)}}));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),s.disconnect=ee()(Z.a.mark((function e(){var t;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t in s.status=gt,clearInterval(s.pingpongTimer),s.pingpongTimer=null,s.requests)s.requests[t].promises.reject("DISCONNECTED");return s.requests=[],null,s.connection&&(s.connection.close(),s.connection=null),s.status=mt,e.abrupt("return",null);case 9:case"end":return e.stop()}}),e)}))),s.request=function(){var e=ee()(Z.a.mark((function e(t){var n,a,i,c;return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=E()({command:"request",sdkVersion:o.VERSION,seq:Ot(s.sid),appId:s.appId,cname:s.cname,uid:""+s.uid,sid:s.sid,requestId:At(s.sid),ts:Math.floor(Date.now()/1e3)},t),"INIT"!==s.status){e.next=5;break}return e.abrupt("return",new Promise((function(e,t){var a={reqData:n,stalledTs:Date.now(),timeoutCnt:0,promises:{resolve:e,reject:t}};s.requests.push(a)})));case 5:if(s.connection){e.next=11;break}throw a="NO_WEBSOCKET_CONNECTION",r.default.error(a),new Error(a);case 11:if(s.status!==gt||t.clientRequest&&"DestroyWorker"===t.clientRequest.command){e.next=17;break}throw i="WEBSOCKET_DISCONNECTING",r.default.error(i),new Error(i);case 17:if("DISCONNECTED"!==s.status){e.next=23;break}throw c="WEBSOCKET_DISCONNECTED",r.default.error(c),new Error(c);case 23:return e.abrupt("return",new Promise((function(e,t){var a={reqData:n,stalledTs:Date.now(),timeoutCnt:0,promises:{resolve:e,reject:t}};s.requests.push(a),s._flush()})));case 24:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),s._flush=function(){s.connection&&s.status===vt&&s.requests.forEach((function(e){e.sentTs||(e.sentTs=Date.now(),e.reqData.clientRequest&&(e.reqData.clientRequest.workerToken=s.connection.workerToken),s.connection.send(JSON.stringify(e.reqData)))}))},s.startPingpong=function(){clearInterval(s.pingpongTimer),s.pingpongTimer=setInterval(ee()(Z.a.mark((function e(){return Z.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s.status!==vt||!s.connection||1!==s.connection.readyState){e.next=9;break}return e.prev=1,e.next=4,s.request({command:"ping"});case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(1),r.default.error("pingpong",e.t0);case 9:case"end":return e.stop()}}),e,null,[[1,6]])}))),6e3)},s._flush(),s.startPingpong(),Et.push(s),s},Nt=function(e){e.disconnect();var t=Et.find((function(t){return e.connectionId===t.connectionId}));Et.splice(t,1)},wt=function(e){return"number"==typeof e&&0<=e&&e<=4294967295};var Dt=function(e){var t=e;if(Object(o.getParameter)("LIVESTREAMING_ALIGN"))switch(e){case 200:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_SUCCESS;break;case 451:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_ALREADY_EXISTS;break;case 453:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_UNAUTHORIZED;break;case 470:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_BROKEN;break;case 499:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_TIMEDOUT;break;default:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_START_FAILED}return t},kt=function(e){var t=e;if(Object(o.getParameter)("LIVESTREAMING_ALIGN"))switch(e){case 200:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_SUCCESS;break;case 404:case 452:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_NOT_FOUND;break;case 453:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_UNAUTHORIZED;break;case 499:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_TIMEDOUT;break;default:t=I.INJECT_STREAM_STATUS.INJECT_STREAM_STATUS_STOP_FAILED}return t},Lt=a(28),Pt=a.n(Lt),Mt=a(16),Ut="host",xt=function(e){var t={key:void 0,highStream:null,lowStream:null,lowStreamParameter:null,isDualStream:!1,highStreamState:2,lowStreamState:2,proxyServer:null,turnServers:[],useProxyServer:!1};t.mode=e.mode,t.codec=e.codec,t.clientId=Object(H.generateSessionId)().slice(0,5),t.uintUid=null,t.customReportCount=0;e=E()({},e);if(t.aespassword=null,t.aesmode="none",t.hasPublished=!1,t.getSessionId=function(){return e.sessionId},t.startChannelMediaRelay=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e){if(e)return a&&a(e);a&&a()},name:"Client.startChannelMediaRelay",options:arguments,tag:"tracer"});if(!(n instanceof Ce.ChannelMediaRelayConfiguration))throw"Configration should be instance of [ChannelMediaRelayConfiguration]";var o=n.getSrcChannelMediaInfo(),r=n.getDestChannelMediaInfos();if(Object(z.isEmpty)(o))throw"srcChannelMediaInfo should not be empty";if(Object(z.isEmpty)(r)||0===r.length)throw"destChannelMediaInfos should not be empty";if(!Object(H.is32Uint)(o.uid))throw"Invalid uid in srcChannelMediaInfo";if(!Object(z.isValidChannelName)(o.channelName))throw"Invalid channelName in srcChannelMediaInfo";if(o.token&&!Object(z.isValidToken)(o.token))throw"Invalid token in srcChannelMediaInfo";if(r.forEach((function(e){if(!Object(H.is32Uint)(e.uid))throw"Invalid uid in destChannelMediaInfo";if(!Object(z.isValidChannelName)(e.channelName))throw"Invalid channelName in destChannelMediaInfo";if(e.token&&!Object(z.isValidToken)(e.token))throw"Invalid token in destChannelMediaInfo"})),t.gatewayClient.state!==st.CONNECTED)throw"startChannelMediaRelay should be used after join";t.gatewayClient.startChannelMediaRelay(n).then((function(){i&&i()})).catch((function(e){i&&i(e)}))},t.updateChannelMediaRelay=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e){if(e)return a&&a(e);a&&a()},name:"Client.updateChannelMediaRelay",options:arguments,tag:"tracer"});if(!(n instanceof Ce.ChannelMediaRelayConfiguration))throw"Configration should be instance of [ChannelMediaRelayConfiguration]";var o=n.getSrcChannelMediaInfo(),r=n.getDestChannelMediaInfos();if(Object(z.isEmpty)(o))throw"srcChannelMediaInfo should not be empty";if(Object(z.isEmpty)(r)||0===r.length)throw"destChannelMediaInfos should not be empty";if(!Object(H.is32Uint)(o.uid))throw"Invalid uid in srcChannelMediaInfo";if(!Object(z.isValidChannelName)(o.channelName))throw"Invalid channelName in srcChannelMediaInfo";if(o.token&&!Object(z.isValidToken)(o.token))throw"Invalid token in srcChannelMediaInfo";if(r.forEach((function(e){if(!Object(H.is32Uint)(e.uid))throw"Invalid uid in destChannelMediaInfo";if(!Object(z.isValidChannelName)(e.channelName))throw"Invalid channelName in destChannelMediaInfo";if(e.token&&!Object(z.isValidToken)(e.token))throw"Invalid token in destChannelMediaInfo"})),t.gatewayClient.state!==st.CONNECTED)throw"updateChannelMediaRelay should be used after join";t.gatewayClient.updateChannelMediaRelay(n).then((function(){i&&i()})).catch((function(e){i&&i(e)}))},t.stopChannelMediaRelay=function(n){var a=s.b.reportApiInvoke(e.sessionId,{callback:function(e){if(e)return n&&n(e);n&&n()},name:"Client.stopChannelMediaRelay",options:arguments,tag:"tracer"});t.gatewayClient.stopChannelMediaRelay().then((function(){a&&a()})).catch((function(e){a&&a(e)}))},t.getConnectionState=function(){var n=s.b.reportApiInvoke(e.sessionId,{name:"Client.getConnectionState",options:arguments,tag:"tracer"}),a=st.connetionStateMap[t.gatewayClient.state];return n(),a},t.setClientRole=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:a,name:"Client.setClientRole",options:arguments,tag:"tracer"});if(Object(z.checkValidEnum)(n,"setClientRole",[Ut,"audience"]),"rtc"===t.mode){var o="RTC mode can not use setClientRole";return r.default.warning("[".concat(t.clientId,"] ").concat(o)),i&&i(o)}t.gatewayClient&&t.gatewayClient.state===st.CONNECTED?("audience"===n&&(0===this.highStreamState?this._unpublish(this.highStream,(function(){i&&i(null,{role:n})}),(function(e){i&&i(e)})):t.gatewayClient.setClientRole("audience",i)),n===Ut&&t.gatewayClient.setClientRole(Ut,i)):(t.gatewayClient.role=n,i&&i(null,{role:n}))},t.getGatewayInfo=function(e){if(t.gatewayClient.state!==st.CONNECTED){var n="Client is not in connected state";return r.default.error("[".concat(t.clientId,"] ").concat(n)),void e(n)}t.gatewayClient.getGatewayInfo((function(t){e(null,t)}),e)},t.renewToken=function(n,a,i){var o=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return r.default.error("Failed to renew token ".concat(e),t),i&&i(e);a&&a(t)},name:"Client.renewToken",options:arguments,tag:"tracer"});if(!Object(z.isValidToken)(n))throw new Error("Invalid token: Token is of the string type .Length of the string: [1,255]. ASCII characters only.");return t.gatewayClient?t.key?(t.key=n,void t.gatewayClient.renewToken(n,(function(e){return o(null,e)}),o)):(r.default.error("[".concat(t.clientId,"] renewToken should not be called before user join")),o(I.default.INVALID_OPERATION)):(r.default.error("[".concat(t.clientId,"] renewToken Failed. GatewayClient not Exist")),o(I.default.INVALID_OPERATION))},t.setLowStreamParameter=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.setLowStreamParameter",options:arguments,tag:"tracer"});Object(z.checkValidObject)(n,"param");var i=n.width,o=n.height,c=n.framerate,d=n.bitrate;Object(z.isEmpty)(i)||Object(z.checkValidNumber)(i,"width"),Object(z.isEmpty)(o)||Object(z.checkValidNumber)(o,"height"),Object(z.isEmpty)(c)||Object(z.checkValidNumber)(c,"framerate"),Object(z.isEmpty)(d)||Object(z.checkValidNumber)(d,"bitrate",1,1e7),(!i&&o||i&&!o)&&r.default.warning("[".concat(t.clientId,"] The width and height parameters take effect only when both are set")),t.lowStreamParameter=n,a()},t.init=function(t,n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return a&&a(e);n&&n(t)},name:"Client.init",options:arguments,tag:"tracer"});Object(z.checkValidString)(t),Object(g.isChromeKernel)()&&Object(g.getChromeKernelVersion)()<=48?a?i(I.default.BAD_ENVIRONMENT):Object(H.popBanTip)():(e.appId=t,e.sessionId=Object(H.generateSessionId)(),i())},t.setTurnServer=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.setTurnServer",options:arguments,tag:"tracer"});if(t.gatewayClient&&t.gatewayClient.state!==st.DISCONNECTED)throw new Error("Set turn server before join channel");if(t.useProxyServer)throw new Error("You have already set the proxy");n instanceof Array||(n=[n]);var i=[];n.map((function(e,n){Object(z.checkValidObject)(e,"turnServer");var a=e.turnServerURL,o=e.username,s=e.password,c=e.udpport,d=e.forceturn,u=e.tcpport;if(Object(z.checkValidString)(a,"turnServerURL"),Object(z.checkValidString)(o,"username"),Object(z.checkValidString)(s,"password"),Object(z.checkValidString)(c,"udpport"),0===parseInt(c))throw new Error("udpport should not be ".concat(c));Object(z.isEmpty)(d)||Object(z.checkValidBoolean)(d,"forceturn");var l={mode:"manual"};if(l.url=a,l.udpport=c,l.username=o,l.credential=s,l.forceturn=d||!1,!Object(z.isEmpty)(u)){if(Object(z.checkValidString)(u,"tcpport"),0===parseInt(u))throw new Error("tcpport should not be ".concat(u));l.tcpport=u,r.default.info("[".concat(t.clientId,"] Set turnserver[").concat(n,"] tcpurl. ").concat(l.url,":").concat(l.tcpport))}r.default.info("[".concat(t.clientId,"] Set turnserver[").concat(n,"] udpurl. ").concat(l.url,":").concat(l.udpport,",username: ").concat(l.username)),i.push(l)})),t.turnServers=i,a()},t.setProxyServer=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.setProxyServer",options:arguments,tag:"tracer"});if(t.gatewayClient&&t.gatewayClient.state!==st.DISCONNECTED)throw new Error("Set proxy server before join channel");if(!n)throw new Error("Do not set the proxyServer parameter as empty");if(t.useProxyServer)throw new Error("You have already set the proxy");Object(z.checkValidString)(n,"proxyServer"),t.proxyServer=n,s.b.setProxyServer(n),r.default.setProxyServer(n),a()},t.startProxyServer=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.startProxyServer",options:arguments,tag:"tracer"});if(t.gatewayClient&&t.gatewayClient.state!==st.DISCONNECTED)throw new Error("Start proxy server before join channel");if(t.proxyServer)throw new Error("You have already set the proxy");t.useProxyServer=!0,t.proxyServerType=n||1,a()},t.stopProxyServer=function(){var n=s.b.reportApiInvoke(e.sessionId,{name:"Client.stopProxyServer",options:arguments,tag:"tracer"});if(t.gatewayClient&&t.gatewayClient.state!==st.DISCONNECTED)throw new Error("Stop proxy server after leave channel");s.b.setProxyServer(),r.default.setProxyServer(),t.turnServers=[],t.proxyServer=null,t.useProxyServer=!1,t.proxyServerType=null,n()},t.setEncryptionSecret=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.setEncryptionSecret",options:arguments,tag:"tracer"});Object(z.checkValidString)(n,"password"),t.aespassword=n,a()},t.setEncryptionMode=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.setEncryptionMode",options:arguments,tag:"tracer"});if(Object(z.checkValidString)(n,"encryptionMode"),-1===ke.indexOf(n))throw new Error('Invalid encryptionMode: encryptionMode should be "aes-128-xts" | "aes-256-xts" | "aes-128-ecb" | "sm4-128-ecb"');t.aesmode=n,a()},t.configPublisher=function(n){var a=s.b.reportApiInvoke(e.sessionId,{name:"Client.configPublisher",options:arguments,tag:"tracer"});Object(z.checkValidObject)(n,"config");var i=n.width,o=n.height,r=n.framerate,c=n.bitrate,d=n.publisherUrl;Object(z.checkValidNumber)(i,"width"),Object(z.checkValidNumber)(o,"height"),Object(z.checkValidNumber)(r,"framerate"),Object(z.checkValidNumber)(c,"bitrate",1,1e7),d&&Object(z.checkValidString)(d,"publisherUrl"),t.gatewayClient.configPublisher(n),a()},t.enableDualStream=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return a&&a(e);n&&n(t)},name:"Client.enableDualStream",options:arguments,tag:"tracer"});return"iOS"===Object(g.getBrowserOS)()?(s.b.streamSwitch(e.sessionId,{lts:(new Date).getTime(),isdual:!0,succ:!1}),i(I.default.IOS_NOT_SUPPORT)):Object(g.isWeChatBrowser)()?(s.b.streamSwitch(e.sessionId,{lts:(new Date).getTime(),isdual:!0,succ:!1}),i(I.default.WECHAT_NOT_SUPPORT)):(s.b.streamSwitch(e.sessionId,{lts:(new Date).getTime(),isdual:!0,succ:!0}),t.isDualStream=!0,t.highStream&&(t.highStream.isDualStream=!0),void(0===t.highStreamState?t._publishLowStream((function(e){return i(null,e)}),(function(e){r.default.warning("[".concat(t.clientId,"]"),e),i(I.default.ENABLE_DUALSTREAM_FAILED)})):1===t.highStreamState?i(I.default.STILL_ON_PUBLISHING):i(null)))},t.disableDualStream=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return a&&a(e);n&&n(t)},name:"Client.disableDualStream",options:arguments,tag:"tracer"});s.b.streamSwitch(e.sessionId,{lts:(new Date).getTime(),isdual:!1,succ:!0}),t.isDualStream=!1,t.highStream&&(t.highStream.isDualStream=!1),0===t.highStreamState?t._unpublishLowStream((function(){t.highStream.lowStream=null,i()}),(function(e){r.default.warning("[".concat(t.clientId,"]"),e),i(I.default.DISABLE_DUALSTREAM_FAILED)})):1===t.highStreamState?i(I.default.STILL_ON_PUBLISHING):i()},t._getLowStream=function(e,n){t.lowStream?e(t.lowStream):t._createLowStream((function(n){t.lowStream=n,e(t.lowStream)}),n)},t._createLowStream=function(e,n){if(t.highStream&&t.highStream.stream){var a=E()({},t.highStream.params);if(a.streamID+=1,a.audio=!1,a.video)if(t.highStream.stream.getVideoTracks()[0]){var i=new ye(a);if(i.isLowStream=!0,i.streamId=t.highStream.getId()+1,t.lowStreamParameter){var o=E()({},t.lowStreamParameter);o.width&&o.height||(o.width=160,o.height=120),o.framerate=o.framerate||15,o.bitrate=o.bitrate||50,i.setVideoProfileCustomPlus(o)}else i.setVideoProfileCustom(function(e){var t;switch(e){case"120p":case"120p_1":t=["120p_1","120p_1","120p_1"];break;case"120p_3":t=["120p_3","120p_3","120p_3"];break;case"180p":case"180p_1":t=["90p_1","90p_1","180p_1"];break;case"180p_3":t=["120p_3","120p_3","180p_3"];break;case"180p_4":t=["120p_1","120p_1","180p_4"];break;case"240p":case"240p_1":t=["120p_1","120p_1","240p_1"];break;case"240p_3":t=["120p_3","120p_3","240p_3"];break;case"240p_4":t=["120p_4","120p_4","240p_4"];break;case"360p":case"360p_1":case"360p_4":case"360p_9":case"360p_10":case"360p_11":t=["90p_1","90p_1","360p_1"];break;case"360p_3":case"360p_6":t=["120p_3","120p_3","360p_3"];break;case"360p_7":case"360p_8":t=["120p_1","120p_1","360p_7"];break;case"480p":case"480p_1":case"480p_2":case"480p_4":case"480p_10":t=["120p_1","120p_1","480p_1"];break;case"480p_3":case"480p_6":t=["120p_3","120p_3","480p_3"];break;case"480p_8":case"480p_9":t=["120p_4","120p_4","480p_8"];break;case"720p":case"720p_1":case"720p_2":case"720p_3":t=["90p_1","90p_1","720p_1"];break;case"720p_5":case"720p_6":t=["120p_1","120p_1","720p_5"];break;case"1080p":case"1080p_1":case"1080p_2":case"1080p_3":case"1080p_5":t=["90p_1","90p_1","1080p_1"];break;case"1440p":case"1440p_1":case"1440p_2":t=["90p_1","90p_1","1440p_1"];break;case"4k":case"4k_1":case"4k_3":t=["90p_1","90p_1","4k_1"];break;default:t=["120p_1","120p_1","360p_7"]}return Object(g.isOpera)()?[e,15,50]:Object(g.isFireFox)()?[t[1],15,100]:Object(g.isSafari)()?[t[2],15,50]:[t[0],15,50]}(t.highStream.profile));try{console.log(i.videoConstraint);var r=Pt()(t.highStream,{width:i.videoConstraint.width.ideal,height:i.videoConstraint.height.ideal,framerate:i.videoConstraint.frameRate.max});return i.stream=r,t.highStream.lowStream=i,t.highStream.userMuteVideo&&i.muteVideo(),e&&e(i)}catch(e){return n&&n(e)}}else n&&n(I.default.HIGH_STREAM_NOT_VIDEO_TRACE);else n&&n(I.default.HIGH_STREAM_NOT_VIDEO_TRACE)}else n&&n(I.default.HIGH_STREAM_NOT_VIDEO_TRACE)},t._publishLowStream=function(e,n){return 2!==t.lowStreamState?n&&n(I.default.LOW_STREAM_ALREADY_PUBLISHED):t.highStream&&t.highStream.hasScreen()?n&&n(I.default.SHARING_SCREEN_NOT_SUPPORT):void t._getLowStream((function(a){t.lowStreamState=1,t.gatewayClient.publish(a,{streamType:1},(function(){t.lowStreamState=0,e&&e()}),(function(e){1===t.lowStreamState&&(t.lowStreamState=2),r.default.debug("[".concat(t.clientId,"] publish low stream failed")),n&&n(e)}))}),n)},t._unpublishLowStream=function(e,n){if(0!==t.lowStreamState)return n&&n(I.default.LOW_STREAM_NOT_YET_PUBLISHED);t.lowStream&&(t.gatewayClient.unpublish(t.lowStream,{streamType:1},(function(){}),(function(e){r.default.debug("[".concat(t.clientId,"] unpublish low stream failed")),n&&n(e)})),t.lowStream.close(),t.lowStream=null,t.lowStreamState=2,e&&e())},t.join=function(n,a,i,o,c){var d=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return c&&c(e);o&&o(t)},name:"Client.join",options:arguments,tag:"tracer"});if(n&&!Object(z.isValidToken)(n))return r.default.warning("[".concat(t.clientId,"] Param channelKey should be string")),d(I.default.INVALID_PARAMETER);if(!Object(z.isValidChannelName)(a))return r.default.error("Invalid Channel Name ".concat(a)),r.default.warning("[".concat(t.clientId,"] The length must be within 64 bytes. The supported characters: a-z,A-Z,0-9,space,!, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _,  {, }, |, ~, ,")),d(I.default.INVALID_PARAMETER);if("string"==typeof a&&""===a)return r.default.warning("[".concat(t.clientId,"] Param channel should not be empty")),d(I.default.INVALID_PARAMETER);if(i&&!Object(H.is32Uint)(i)&&!Object(z.isValidString)(i,1,255))return r.default.error("Invalid UID ".concat(i," ").concat(be()(i))),r.default.warning("[".concat(t.clientId,"] [String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]")),d(I.default.INVALID_PARAMETER);if("string"==typeof i&&0==i.length)return r.default.warning("[".concat(t.clientId,"] String uid should not be empty")),d(I.default.INVALID_PARAMETER);if("string"==typeof i&&i.length>256)return r.default.warning("[".concat(t.clientId,"] Length of string uid should be less than 255")),d(I.default.INVALID_PARAMETER);t.highStream=null,t.lowStream=null,t.lowStreamParameter=null,t.isDualStream=!1,t.highStreamState=2,t.lowStreamState=2;var u=Date.now(),l=setTimeout((function(){if(1!=t.gatewayClient.hasJoined){r.default.debug("[".concat(t.clientId,"] The time to join the channel is greater than 5 seconds "));var n=Date.now();s.b.joinChannelTimeOut({lts:n,sid:e.sessionId,cname:a,cid:p.cid,uid:p.uid||("string"==typeof i?void 0:i),elapse:n-u,timeout:5})}}),5e3),p={clientId:t.clientId,appId:e.appId,sid:e.sessionId,cname:a,uid:i,turnServers:t.turnServers.concat(),proxyServer:t.proxyServer,token:n||e.appId,useProxyServer:t.useProxyServer,proxyServerType:t.proxyServerType};if("string"==typeof i&&(p.stringUid=i,t.uintUid?(p.uid=t.uintUid,delete t.uintUid):p.uid=0),t.aespassword&&"none"!==t.aesmode&&E()(p,{aespassword:t.aespassword,aesmode:t.aesmode}),s.b.sessionInit(e.sessionId,{lts:(new Date).getTime(),cname:a,appid:e.appId,mode:e.mode,succ:!0}),t.onSuccess=function(e){clearTimeout(l),t.rtcStatsCollector.startNetworkQualityTimer(),t.onSuccess=null,d(null,e)},t.onFailure=function(e){return d(e)},t.channel=a,t.gatewayClient.state!==st.DISCONNECTED)return r.default.error("[".concat(t.clientId,"] Client already in connecting/connected state")),d(I.default.INVALID_OPERATION),void s.b.joinGateway(e.sessionId,{lts:Date.now(),succ:!1,ec:I.default.INVALID_OPERATION,addr:null});t.gatewayClient.state=st.CONNECTING;var f=function(i,o){r.default.info("[".concat(t.clientId,"] Joining channel: ").concat(a)),t.gatewayClient.dispatchEvent({type:"config-distribute",config:o,joinInfo:p}),t.key=n||e.appId,p.cid=i.cid,p.uid||(p.uid=i.uid),p.vid=i.vid,p.clientId=t.clientId,p.apResponse=i.res,i.uni_lbs_ip&&i.uni_lbs_ip[1]&&(p.uni_lbs_ip=i.uni_lbs_ip[1]),p.gatewayAddr=i.gateway_addr,t.joinInfo=p,t.gatewayClient.join(p,t.key,(function(e){r.default.info("[".concat(t.clientId,"] Join channel ").concat(a," success, join with uid: ").concat(e,".")),t.onSuccess=null,t.rtcStatsCollector.startNetworkQualityTimer(),d(null,e)}),(function(e){return d(e)}))};p.stringUid&&!p.uid?(t.userAccountReq&&!t.userAccountReq.isFinished()&&t.userAccountReq.cancel(),t.userAccountReq=Qe(p,t.gatewayClient),t.userAccountReq.then((function(e){r.default.debug("getUserAccount Success ".concat(e.url," ").concat(p.stringUid," => ").concat(e.uid)),p.uid=e.uid,ze(p,f,(function(e){return d(e)}))})).catch((function(e){r.default.error("getUserAccount rejected",e),d(e)}))):ze(p,f,(function(e){return d(e)}))},t.renewChannelKey=function(n,a,i){var o=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return i&&i(e);a&&a(t)},name:"Client.renewChannelKey",options:arguments,tag:"tracer"});Object(z.checkValidString)(n,"key",1,2047),void 0===t.key?(r.default.error("[".concat(t.clientId,"] renewChannelKey should not be called before user join")),o(I.default.INVALID_OPERATION)):(t.key=n,t.gatewayClient.joinInfo.token=n,t.gatewayClient.key=n,t.gatewayClient.recover(),o())},t.leave=function(n,a){t.gatewayClient.isFirstSuccess=!0,t.gatewayClient.hasInvokeLeave=!0;var i=!1,c=s.b.reportApiInvoke(e.sessionId,{callback:function(e,i){if(e)return a&&a(e);t.gatewayClient.reconnectingCS=!1,t.gatewayClient.state=st.DISCONNECTED,clearTimeout(Ye(t.clientId)),t._renewSession(),t.rtcStatsCollector.clearNetworkQualityTimer(),n&&n(i)},name:"Client.leave",options:arguments,tag:"tracer"});r.default.info("[".concat(t.clientId,"] Leaving channel")),t.userAccountReq&&!t.userAccountReq.isFinished()&&(t.userAccountReq.cancel(),t.gatewayClient.state===st.CONNECTING&&(t.gatewayClient.state=st.DISCONNECTED)),t.gatewayClient.leave((function(e){i=!0,c(null,e)}),c),setTimeout((function(){i||(t.gatewayClient.socket&&(t.gatewayClient.socket.close(),t.gatewayClient.socket=null),t.gatewayClient.state=st.DISCONNECTED,c(null,"LEAVE_MSG_TIMEOUT"))}),Object(o.getParameter)("LEAVE_MSG_TIMEOUT"))},t._renewSession=function(){var n=Object(H.generateSessionId)();if(r.default.debug("renewSession ".concat(e.sessionId," => ").concat(n)),e.sessionId=n,t.joinInfo&&(t.joinInfo.sid=n),t.gatewayClient&&(t.gatewayClient.joinInfo&&(t.gatewayClient.joinInfo.sid=n),t.gatewayClient.localStreams))for(var a in t.gatewayClient.localStreams){var i=t.gatewayClient.localStreams[a];i&&(i.sid=n)}},t._publish=function(n,a,i,s){if(2!==t.highStreamState)return r.default.warning("[".concat(t.clientId,"] Can't publish stream when stream already publish ").concat(n.getId())),i&&i(I.default.STREAM_ALREADY_PUBLISHED);if(0===t.turnServers.length&&Object(o.getParameter)("FORCE_TURN")&&!Object(o.getParameter)("TURN_ENABLE_TCP")&&!Object(o.getParameter)("TURN_ENABLE_UDP"))throw new Error("force TURN With No TURN Configuration");r.default.info("[".concat(t.clientId,"] Publishing stream, uid ").concat(n.getId())),t.highStream=n,t.highStreamState=1,t.highStream.streamId=t.joinInfo.stringUid||t.joinInfo.uid,t.hasPublished=!1;var c=function(n,a,i){t.gatewayClient.publish(n,{streamType:0},(function(){n.sid=e.sessionId,t.highStreamState=0,r.default.info("[".concat(t.clientId,"] Publish success, uid: ").concat(n.getId())),t.highStream&&(t.highStream.isDualStream=t.isDualStream),t.isDualStream?t._publishLowStream((function(){a&&a()}),(function(e){r.default.warning("[".concat(t.clientId,"] "),e),he.replaceWithCanvasTrack(n).then((function(){a&&a()}))})):he.replaceWithCanvasTrack(n).then((function(){a&&a()}))}),i)};"audience"!==t.gatewayClient.role||"live"!==t.mode||s?c(n,a,i):t.gatewayClient.setClientRole(Ut,(function(e){if(e)return i&&i(e);c(n,a,i)}))},t._unpublish=function(e,n,a,i){if(0!==t.highStreamState)return r.default.warning("[".concat(t.clientId,"] Can't unpublish stream when stream not publish")),a&&a(I.default.STREAM_NOT_YET_PUBLISHED);r.default.info("[".concat(t.clientId,"] Unpublish stream, uid ").concat(e.getId()));var o=function(e,n,a){t.isDualStream&&t.lowStream&&t._unpublishLowStream(null,a),t.gatewayClient.unpublish(e,{streamType:0},(function(){t.highStreamState=2,r.default.info("[".concat(t.clientId,"] Unpublish stream success, uid: ").concat(e.getId())),n&&n()}),(function(n){r.default.info("[".concat(t.clientId,"] Unpublish stream fail, uid: ").concat(e.getId())),a&&a(n)}))};t.gatewayClient.role!==Ut||"live"!==t.mode||i?o(e,n,a):t.gatewayClient.setClientRole("audience",(function(t){if(t)return a&&a(t);o(e,n,a)}))},t.publish=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e,n){if(e)return 1===t.highStreamState&&(t.highStreamState=2),a&&a(e)},name:"Client.publish",tag:"tracer",options:{stream:"too long to show",onFailure:!!a}});2===t.highStreamState?n._hasVideoTracks()||n._hasAudioTracks()?(t.gatewayClient.publishRequestId=Object(H.generateId)(),t._publish(n,(function(e){return i(null,e)}),(function(e){return i(e)}))):i(I.default.NO_TRACK_IN_STREAM):i(I.default.STREAM_ALREADY_PUBLISHED)},t.unpublish=function(n,a,i){var o=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return a&&a(e);i&&i(t)},name:"Client.unpublish",tag:"tracer",options:{stream:"too long to show",onFailure:!!a}});0===t.highStreamState?(t.gatewayClient.publishRequestId=null,t._unpublish(n,(function(e){return o(null,e)}),(function(e){return o(e)}))):o(I.default.STREAM_NOT_YET_PUBLISHED)},t.subscribe=function(n,a,i){var o=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return i&&i(e)},name:"Client.subscribe",tag:"tracer",options:{stream:"too long to show",options:a,onFailure:!!i}});"function"==typeof a&&(i=a,a=null),Object(z.checkValidObject)(n,"stream"),Object(z.isEmpty)(a)||(Object(z.checkValidObject)(a,"options"),Object(z.isEmpty)(a.video)||Object(z.checkValidBoolean)(a.video,"options.video"),Object(z.isEmpty)(a.audio)||Object(z.checkValidBoolean)(a.audio,"options.audio"));var c={video:!0,audio:!0};if(!Object(z.isEmpty)(a)){if(Object(g.isSafari)()&&(!a.video||!a.audio)){var d="SAFARI_NOT_SUPPORTED_FOR_TRACK_SUBSCRIPTION";return r.default.error("[".concat(t.clientId,"] "),d),void o(d)}if(!Object(z.isEmpty)(a.video)&&!Object(z.isValidBoolean)(a.video)||!Object(z.isEmpty)(a.audio)&&!Object(z.isValidBoolean)(a.audio)||!1===a.audio&&!1===a.video){d="INVALID_PARAMETER ".concat(JSON.stringify(a));return r.default.error("[".concat(t.clientId,"] "),d),void o(d)}}n.subscribeOptions?(E()(n.subscribeOptions,c,a),t.gatewayClient.subscribeChange(n,(function(e){return o(null,e)}),o)):(t.gatewayClient.subscribeRequestId.set(n.getId(),Object(H.generateId)()),n.subscribeOptions=E()({},c,a),t.gatewayClient.subscribe(n,(function(e){return o(null,e)}),o))},t.unsubscribe=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{callback:function(e,t){if(e)return a&&a(e)},name:"Client.unsubscribe",tag:"tracer",options:{stream:"too long to show",onFailure:!!a}});r.default.info("[".concat(t.clientId,"] Unsubscribe stream, uid: ").concat(n.getId())),t.gatewayClient.subscribeRequestId.delete(n.getId()),t.gatewayClient.unsubscribe(n,(function(e){return i(null,e)}),i)},t.setRemoteVideoStreamType=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{name:"Client.setRemoteVideoStreamType",tag:"tracer",options:{stream:"too long to show",streamType:a}});Object(z.checkValidEnum)(a,"streamType",[0,1]),t.gatewayClient.setRemoteVideoStreamType(n,a),i()},t.setStreamFallbackOption=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{name:"Client.setStreamFallbackOption",tag:"tracer",options:{stream:"too long to show",fallbackType:a}});Object(z.checkValidEnum)(a,"fallbackType",[0,1,2]),t.gatewayClient.setStreamFallbackOption(n,a),i()},t.enableAudioVolumeIndicator=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{name:"Client.enableAudioVolumeIndicator",options:arguments,tag:"tracer"});n=n||2e3,a=a||3,Object(z.checkValidNumber)(a,"smooth",1,100),Object(z.checkValidNumber)(n,"interval",50,1e5),t.audioVolumeIndication=t.audioVolumeIndication||{enabled:!0},t.audioVolumeIndication.interval=n,t.audioVolumeIndication.smooth=a,t.audioVolumeIndication={interval:n,smooth:a},r.default.info("[".concat(t.clientId,"] enableAudioVolumeIndicator interval ").concat(n," smooth ").concat(a)),t.gatewayClient.enableAudioVolumeIndicator(n,a),i()},t.getNetworkStats=function(e,n){return r.default.deprecate("[".concat(t.clientId,"] client.getNetworkStats is deprecated. Use client.getTransportStats instead.")),ft.getStats(e,n)},t.getSystemStats=function(e,t){return v.getStats(e,t)},t.getRecordingDevices=function(e,t){return K.getRecordingDevices(e,t)},t.getPlayoutDevices=function(e,t){return K.getPlayoutDevices(e,t)},t.getCameras=function(e,t){return K.getCameras(e,t)},t.getRemoteAudioStats=function(e,n){return t.rtcStatsCollector.getRemoteAudioStats(e,n)},t.getLocalAudioStats=function(e,n){return t.rtcStatsCollector.getLocalAudioStats(e,n)},t.getRemoteVideoStats=function(e,n){return t.rtcStatsCollector.getRemoteVideoStats(e,n)},t.getLocalVideoStats=function(e,n){return t.rtcStatsCollector.getLocalVideoStats(e,n)},t._getRemoteVideoQualityStats=function(e,n){return t.rtcStatsCollector.getRemoteVideoQualityStats(e,n)},t._getRemoteAudioQualityStats=function(e,n){return t.rtcStatsCollector.getRemoteAudioQualityStats(e,n)},t.getTransportStats=function(e,n){return t.rtcStatsCollector.getTransportStats((function(t){return ft.getStats((function(n){var a=E()({},t,n);e&&e(a)}),n)}),n)},t.getSessionStats=function(e,n){return t.rtcStatsCollector.getSessionStats(e,n)},t.onNetworkQuality=function(){return t.rtcStatsCollector.onNetworkQuality(onSuccess,onFailure)},t.sendMetadata=function(n,a){var i=s.b.reportApiInvoke(e.sessionId,{name:"Client.sendMetadata",tag:"tracer",callback:function(e){if(e)return a&&a(e);a&&a()}});t.gatewayClient.sendMetadata(n,i)},t.sendCustomReportMessage=function(n,a,i,c,d,u){Object(o.getParameter)("CR")?t.customReportCount>Object(o.getParameter)("CRL")?u&&u("REPORT_LIMITED"):(t.gatewayClient.hasJoined||(r.default.WARNING("Should invoke Client.sendCustomReportMessage after join"),u&&u("REPORT_BEFORE_JOINED")),t.customReportTimer||(t.customReportTimer=setInterval((function(){t.customReportCount=0}),Object(o.getParameter)("CRI"))),Object(z.checkValidString)(n,"reportId",0,100,!1),Object(z.checkValidString)(a,"category",0,100,!1),Object(z.checkValidString)(i,"event",0,100,!1),Object(z.checkValidString)(c,"label",0,100,!1),Object(z.checkValidNumber)(d,"value",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),t.customReportCount++,s.b.sendCustomReportMessage(e.sessionId,{reportId:n,category:a,event:i,label:c,value:d,lts:Date.now()},(function(e){e?u&&u("REPORT_FAILED"):u&&u()}))):u&&u("REPORT_FORBIDDEN")},e.clientId=t.clientId,t.gatewayClient=st(e),t.listenerLoggerTimer=null,t.listenerLoggerCache=[],t.on=function(e,n){t.gatewayClient.on(e,n),t.listenerLoggerCache.push("".concat(e).concat(n.name?":"+n.name:"")),t.listenerLoggerTimer?clearTimeout(t.listenerLoggerTimer):r.default.info("[".concat(t.clientId,"] Adding event handler on ").concat(e)),t.listenerLoggerTimer=setTimeout((function(){t.listenerLoggerCache.length&&(t.listenerLoggerTimer=null,r.default.info("[".concat(t.clientId,"] Added event handler on ").concat(t.listenerLoggerCache.join(", "))),t.listenerLoggerCache=[])}),0)},t.off=function(e,n){r.default.info("remove event handler from [".concat(e,"]")),t.gatewayClient.removeEventListener(e,n)},t.rtcStatsCollector=function(e){var t=c();return t.gatewayClient=e,t.exceptionMonitor=new ut(e),t.localStats={},t.remoteStats={},t.session={sendBytes:0,recvBytes:0,WSSendBytes:0,WSSendBytesDelta:0,WSRecvBytes:0,WSRecvBytesDelta:0,HTTPSendBytes:0,HTTPSendBytesDelta:0,HTTPRecvBytes:0,HTTPRecvBytesDelta:0},t.getRemoteAudioStats=function(e){var n=t.gatewayClient.traffic_stats,a={};for(var i in t.remoteStats){var o={},r=t.remoteStats[i];if(q(o,"End2EndDelay",r.peer_delay&&r.peer_delay.audio_delay),q(o,"TransportDelay",r.peer_delay&&r.peer_delay.e2e_delay),q(o,"PacketLossRate",r.peer_delay&&r.peer_delay.e2e_audio_lost_ratio_400ms),q(o,"RecvLevel",r.audioStats&&r.audioStats.audioOutputLevel),q(o,"RecvBitrate",r.audioRecvBitrate),q(o,"CodecType",r.audioStats&&r.audioStats.googCodecName),q(o,"MuteState",r.audioDisabled),q(o,"TotalFreezeTime",r.audioStats&&r.audioStats.audioTotalFreezeTime),q(o,"TotalPlayDuration",r.audioStats&&r.audioStats.audioTotalPlayDuration),n&&n.peer_delay){var s=n.peer_delay.find((function(e){return e.peer_uid==i}));if(s){var c=s.peer_publish_audio_duration+(Date.now()-n.timestamp);q(o,"AudioPublishDuration",c)}else q(o,"AudioPublishDuration",-1)}a[i]=o}e&&e(a)},t.getLocalAudioStats=function(e){var n={};for(var a in t.localStats){var i={},o=t.localStats[a];q(i,"RecordingLevel",o.audioStats&&o.audioStats.audioInputLevel),q(i,"SendLevel",o.audioStats&&o.audioStats.totalAudioEnergy),q(i,"SamplingRate",o.audioStats&&o.audioStats.totalSamplesDuration),q(i,"SendBitrate",o.audioSendBitrate),q(i,"CodecType",o.audioStats&&o.audioStats.googCodecName),q(i,"MuteState",o.audioDisabled),q(i,"audioSendPacketsLost",o.audioStats&&o.audioStats.packetsLost);var r=t.gatewayClient.localStreams[a];r&&r.isPlaying()&&q(i,"MuteState",r.userMuteAudio?"1":"0"),n[a]=i}e&&e(n)},t.getRemoteVideoStats=function(e){var n=t.gatewayClient.traffic_stats,a={};for(var i in t.remoteStats){var o={},r=t.remoteStats[i];if(q(o,"End2EndDelay",r.peer_delay&&r.peer_delay.video_delay),q(o,"TransportDelay",r.peer_delay&&r.peer_delay.e2e_delay),q(o,"PacketLossRate",r.peer_delay&&r.peer_delay.e2e_video_lost_ratio_400ms),q(o,"RecvBitrate",r.videoRecvBitrate),q(o,"RecvResolutionWidth",r.videoStats&&r.videoStats.googFrameWidthReceived),q(o,"RecvResolutionHeight",r.videoStats&&r.videoStats.googFrameHeightReceived),q(o,"RenderResolutionWidth",r.videoStats&&r.videoStats.renderRemoteWidth),q(o,"RenderResolutionHeight",r.videoStats&&r.videoStats.renderRemoteHeight),q(o,"RenderFrameRate",r.videoStats&&r.videoStats.googFrameRateOutput),q(o,"MuteState",r.videoDisabled),q(o,"TotalFreezeTime",r.videoStats&&r.videoStats.videoTotalFreezeTime),q(o,"TotalPlayDuration",r.videoStats&&r.videoStats.videoTotalPlayDuration),n&&n.peer_delay){var s=n.peer_delay.find((function(e){return e.peer_uid==i}));if(s){var c=s.peer_publish_video_duration+(Date.now()-n.timestamp);q(o,"VideoPublishDuration",c)}else q(o,"VideoPublishDuration",-1)}a[i]=o}e&&e(a)},t.getLocalVideoStats=function(e){var n={};for(var a in t.localStats){var i={},o=t.localStats[a];q(i,"TargetSendBitrate",o.videoTargetSendBitrate),q(i,"SendFrameRate",o.videoStats&&o.videoStats.googFrameRateSent),q(i,"SendBitrate",o.videoSendBitrate),q(i,"SendResolutionWidth",o.videoStats&&o.videoStats.googFrameWidthSent),q(i,"SendResolutionHeight",o.videoStats&&o.videoStats.googFrameHeightSent),q(i,"CaptureResolutionWidth",o.videoStats&&o.videoStats.googFrameWidthInput),q(i,"CaptureResolutionHeight",o.videoStats&&o.videoStats.googFrameHeightInput),q(i,"EncodeDelay",o.videoStats&&o.videoStats.googAvgEncodeMs),q(i,"MuteState",o.videoDisabled),q(i,"TotalFreezeTime",o.videoStats&&o.videoStats.videoTotalFreezeTime),q(i,"TotalDuration",o.videoStats&&o.videoStats.videoTotalPlayDuration),q(i,"CaptureFrameRate",o.videoStats&&o.videoStats.googFrameRateSent),q(i,"videoSendPacketsLost",o.videoStats&&o.videoStats.packetsLost),o.videoStats&&!o.videoStats.googFrameWidthInput&&q(i,"CaptureResolutionWidth",o.videoStats&&o.videoStats.renderLocalWidth),o.videoStats&&!o.videoStats.googFrameHeightInput&&q(i,"CaptureResolutionHeight",o.videoStats&&o.videoStats.renderLocalHeight),n[a]=i}e&&e(n)},t.getRemoteVideoQualityStats=function(e){var n={};for(var a in t.remoteStats){var i={},o=t.remoteStats[a];q(i,"videoReceiveDelay",o.videoStats&&o.videoStats.googCurrentDelayMs),q(i,"VideoFreezeRate",o.videoStats&&o.videoStats.videoFreezeRate),q(i,"FirstFrameTime",o.firstFrameTime),n[a]=i}e&&e(n)},t.getRemoteAudioQualityStats=function(e){var n={};for(var a in t.remoteStats){var i={},o=t.remoteStats[a];q(i,"audioReceiveDelay",o.audioStats&&o.audioStats.googCurrentDelayMs),q(i,"AudioFreezeRate",o.videoStats&&o.videoStats.videoFreezeRate),n[a]=i}e&&e(n)},t.getTransportStats=function(e){var n={},a={},i=t.gatewayClient.traffic_stats,o=i.peer_delay;if(q(n,"OutgoingAvailableBandwidth",t.gatewayClient.OutgoingAvailableBandwidth/1e3),q(n,"RTT",i&&2*i.access_delay),o){var r,s=lt(o);try{for(s.s();!(r=s.n()).done;){var c=r.value;c.downlink_estimate_bandwidth&&(a[c.peer_uid]=c.downlink_estimate_bandwidth/1e3+"")}}catch(e){s.e(e)}finally{s.f()}}n.IncomingAvailableBandwidth=a,e&&e(n)},t.getSessionStats=function(e){var n={},a=t.gatewayClient.traffic_stats,i=t.gatewayClient.socket,o=0,r=0;for(var s in t.remoteStats){(c=t.remoteStats[s])&&c.videoStats&&c.videoStats.videoRecvBytesDelta&&(r+=parseInt(c.videoStats.videoRecvBytesDelta)),c&&c.audioStats&&c.audioStats.audioRecvBytesDelta&&(r+=parseInt(c.audioStats.audioRecvBytesDelta))}for(var s in t.localStats){var c;(c=t.localStats[s])&&c.videoStats&&c.videoStats.videoSendBytesDelta&&(o+=parseInt(c.videoStats.videoSendBytesDelta)),c&&c.audioStats&&c.audioStats.audioSendBytesDelta&&(o+=parseInt(c.audioStats.audioSendBytesDelta))}var d=o+t.session.WSSendBytesDelta+t.session.HTTPSendBytesDelta,u=r+t.session.WSRecvBytesDelta+t.session.HTTPRecvBytesDelta,l=t.session.sendBytes+Object(Ue.getHTTPSendBytes)(),p=t.session.recvBytes+Object(Ue.getHTTPRecvBytes)();t.gatewayClient.socket&&t.gatewayClient.socket.state===t.gatewayClient.CONNECTED&&(l+=i.getSendBytes(),p+=i.getRecvBytes());var f=1;a.peer_delay&&(f=a.peer_delay.length,f+=1),q(n,"Duration",i.getDuration()),q(n,"UserCount",f),q(n,"SendBytes",l),q(n,"RecvBytes",p),q(n,"SendBitrate",8*d/1e3),q(n,"RecvBitrate",8*u/1e3),e&&e(n)},t.isLocalVideoFreeze=function(e,t){var n=0,a=0;if(!e||!t)return!1;if(Object(g.isChrome)()||Object(g.isOpera)())n=e.googFrameRateInput,a=e.googFrameRateSent;else if(Object(g.isSafari)())n=parseInt(e.framerateMean),a=parseInt(e.framesEncoded)-parseInt(t.framesEncoded);else{if(!Object(g.isFireFox)())return!1;n=parseInt(e.framerateMean),a=parseInt(e.framesEncoded)-parseInt(t.framesEncoded)}return n>5&&a<3},t.isRemoteVideoFreeze=function(e,t){var n=0,a=0;if(!e||!t)return!1;if(Object(g.isChrome)()||Object(g.isOpera)())n=e.googFrameRateReceived,a=e.googFrameRateDecoded;else if(Object(g.isSafari)())n=e.framerateMean,a=parseInt(e.framesDecoded)-parseInt(t.framesDecoded);else{if(!Object(g.isFireFox)())return!1;n=parseInt(e.framesReceived)-parseInt(t.framesReceived),a=parseInt(e.framesDecoded)-parseInt(t.framesDecoded)}return n>5&&n<10&&a<3||(n>10&&n<20&&a<4||n>20&&a<5)},t.isAudioFreeze=function(e){if(Object(g.isChrome)()&&e){if(e.googDecodingPLC&&e.googDecodingPLCCNG&&e.googDecodingCTN)return(parseInt(e.googDecodingPLC)+parseInt(e.googDecodingPLCCNG))/parseInt(e.googDecodingCTN)>.2}else if((Object(g.isSafari)()||Object(g.isFireFox)())&&e.packetsLost&&e.packetsReceived)return parseInt(e.packetsLost)/(parseInt(e.packetsLost)+parseInt(e.packetsReceived))>.2;return!1},t.isAudioDecodeFailed=function(e){return!!((Object(g.isChrome)()||Object(g.isOpera)())&&e&&parseInt(e.bytesReceived)>0&&0===parseInt(e.googDecodingNormal))},t.startNetworkQualityTimer=function(){t.clearNetworkQualityTimer(),t.networkQualityTimer=setInterval((function(){if(t.gatewayClient.state!==st.CONNECTED)t.gatewayClient.dispatchEvent({type:"network-quality",uplinkNetworkQuality:0,downlinkNetworkQuality:0});else{var e=t.gatewayClient.traffic_stats;t.gatewayClient.dispatchEvent({type:"network-quality",uplinkNetworkQuality:t.networkQualityTrans(e.uplink_network_quality),downlinkNetworkQuality:t.networkQualityTrans(e.downlink_network_quality)})}}),2e3)},t.clearNetworkQualityTimer=function(){t.networkQualityTimer&&clearInterval(t.networkQualityTimer)},t.networkQualityTrans=function(e){return e>=0&&e<.17?1:e>=.17&&e<.36?2:e>=.36&&e<.59?3:e>=.59&&e<=1?4:e>1?5:0},t.getStatsTimer=setInterval((function(){var e=t.gatewayClient.traffic_stats,n=Date.now();t.gatewayClient.dispatchEvent({type:"_testException"}),Object.keys(t.localStats).length&&t.exceptionMonitor.setLocalStats(t.localStats),Object.keys(t.remoteStats).length&&t.exceptionMonitor.setRemoteStats(t.remoteStats);var a={};Object.keys(t.gatewayClient.remoteStreams).forEach((function(i){var o=t.gatewayClient.remoteStreams[i],r=t.remoteStats[i],s={id:i,updatedAt:n};a[i]=s,s.firstFrameTime=o.firstFrameTime,r?(s.audioTotalPlayDuration=r.audioTotalPlayDuration+1,s.audioTotalFreezeTime=r.audioTotalFreezeTime,s.isAudioFreeze=!1,s.isAudioDecodeFailed=!1,s.videoTotalPlayDuration=r.videoTotalPlayDuration+1,s.videoTotalFreezeTime=r.videoTotalFreezeTime,s.isVideoFreeze=!1):(s.audioTotalPlayDuration=1,s.audioTotalFreezeTime=0,s.videoTotalPlayDuration=1,s.videoTotalFreezeTime=0);var c=e&&e.peer_delay&&e.peer_delay.find((function(e){return e.peer_uid==i}));c&&(s.peer_delay=c),o&&(o.isPlaying()&&(s.audioDisabled=o.userMuteAudio||o.peerMuteAudio?"1":"0",s.videoDisabled=o.userMuteVideo||o.peerMuteVideo?"1":"0"),r&&r.peer_delay&&c&&r.peer_delay.stream_type!==c.stream_type&&t.gatewayClient.dispatchEvent({type:"streamTypeChange",uid:i,streamType:c.stream_type}),o.pc&&"established"==o.pc.state&&o.pc.getStats((function(e){if(s.pcStats=e,s.audioStats=e.find((function(e){return"audio"==e.mediaType&&(e.id.indexOf("_recv")>-1||e.id.toLowerCase().indexOf("inbound")>-1)})),s.videoStats=e.find((function(e){return"video"==e.mediaType&&(e.id.indexOf("_recv")>-1||e.id.toLowerCase().indexOf("inbound")>-1)})),r&&r.audioStats&&s.audioStats){var n=parseInt(s.audioStats.bytesReceived)-parseInt(r.audioStats.bytesReceived),a=parseInt(s.audioStats.googDecodingNormal)-parseInt(r.audioStats.googDecodingNormal);if(s.audioStats.audioRecvBytesDelta=n,s.audioStats.audioDecodingNormalDelta=a,t.session.recvBytes+=n,isFinite(n)&&s.audioStats.timestamp){var i=s.audioStats.timestamp.getTime()-r.audioStats.timestamp.getTime();s.audioRecvBitrate=Math.floor(8*n/i)}t.isAudioFreeze(s.audioStats)&&s.audioTotalPlayDuration>10&&(s.audioTotalFreezeTime++,s.isAudioFreeze=!0),t.isAudioDecodeFailed(s.audioStats)&&s.audioTotalPlayDuration>10&&(s.isAudioDecodeFailed=!0),s.audioStats.audioTotalFreezeTime=s.audioTotalFreezeTime,s.audioStats.audioTotalPlayDuration=s.audioTotalPlayDuration,s.audioStats.audioFreezeRate=Math.ceil(100*s.audioTotalFreezeTime/s.audioTotalPlayDuration)}if(r&&r.videoStats&&s.videoStats){var c=parseInt(s.videoStats.bytesReceived)-parseInt(r.videoStats.bytesReceived);if(s.videoStats.videoRecvBytesDelta=c,t.session.recvBytes+=c,isFinite(c)&&s.videoStats.timestamp){i=s.videoStats.timestamp.getTime()-r.videoStats.timestamp.getTime();s.videoRecvBitrate=Math.floor(8*c/i)}t.isRemoteVideoFreeze(s.videoStats,r.videoStats)&&(s.videoTotalFreezeTime++,s.isVideoFreeze=!0),s.videoStats.videoTotalFreezeTime=s.videoTotalFreezeTime,s.videoStats.videoTotalPlayDuration=s.videoTotalPlayDuration,s.videoStats.videoFreezeRate=Math.ceil(100*s.videoTotalFreezeTime/s.videoTotalPlayDuration),o.player&&o.player.video&&o.player.video.videoWidth&&o.player.video.videoHeight?(s.videoStats.renderRemoteWidth=o.player.video.videoWidth,s.videoStats.renderRemoteHeight=o.player.video.videoHeight):(s.videoStats.renderRemoteWidth=o.videoWidth||s.videoStats.googFrameWidthReceived,s.videoStats.renderRemoteHeight=o.videoHeight||s.videoStats.googFrameHeightReceived)}})))})),t.remoteStats=a;var i={};if(Object.keys(t.gatewayClient.localStreams).forEach((function(e){var a=t.gatewayClient.localStreams[e],o=t.localStats[e],r={id:e,updatedAt:n};i[e]=r,o?(r.videoTotalPlayDuration=o.videoTotalPlayDuration+1,r.videoTotalFreezeTime=o.videoTotalFreezeTime,r.isVideoFreeze=!1):(r.videoTotalPlayDuration=1,r.videoTotalFreezeTime=0),a&&(a.isPlaying()&&(r.audioDisabled=a.userMuteAudio?"1":"0",r.videoDisabled=a.userMuteVideo?"1":"0"),a.video&&a.attributes.maxVideoBW?r.videoTargetSendBitrate=a.attributes.maxVideoBW:a.video&&a.screenAttributes&&(r.videoTargetSendBitrate=a.screenAttributes.maxVideoBW),a.pc&&"established"==a.pc.state&&a.pc.getStats((function(e){if(r.pcStats=e.reverse(),r.audioStats=e.find((function(e){return"audio"==e.mediaType&&(e.id.indexOf("_send")>-1||e.id.toLowerCase().indexOf("outbound")>-1)})),r.videoStats=e.find((function(e){return"video"==e.mediaType&&(e.id.indexOf("_send")>-1||e.id.toLowerCase().indexOf("outbound")>-1)})),r.audioStats&&o&&o.audioStats){var n=parseInt(r.audioStats.bytesSent)-parseInt(o.audioStats.bytesSent);if(r.audioStats.audioSendBytesDelta=n,t.session.sendBytes+=n,isFinite(n)&&r.audioStats.timestamp){var i=r.audioStats.timestamp.getTime()-o.audioStats.timestamp.getTime();r.audioSendBitrate=Math.floor(8*n/i)}}if(r.videoStats&&o&&o.videoStats){var s=parseInt(r.videoStats.bytesSent)-parseInt(o.videoStats.bytesSent);if(r.videoStats.videoSendBytesDelta=s,t.session.sendBytes+=s,isFinite(s)&&r.videoStats.timestamp){i=r.videoStats.timestamp.getTime()-o.videoStats.timestamp.getTime();r.videoSendBitrate=Math.floor(8*s/i)}t.isLocalVideoFreeze(r.videoStats,o.videoStats)&&(r.videoTotalFreezeTime++,r.isVideoFreeze=!0),r.videoStats.videoTotalFreezeTime=r.videoTotalFreezeTime,r.videoStats.videoTotalPlayDuration=r.videoTotalPlayDuration,r.videoStats.videoFreezeRate=Math.ceil(100*r.videoTotalFreezeTime/r.videoTotalPlayDuration),r.videoStats.renderLocalWidth=a.videoWidth||r.videoStats.googFrameWidthSent,r.videoStats.renderLocalHeight=a.videoHeight||r.videoStats.googFrameHeightSent}})))})),t.localStats=i,t.session.HTTPSendBytesDelta=Object(Ue.getHTTPSendBytes)()-t.session.HTTPSendBytes,t.session.HTTPSendBytes=Object(Ue.getHTTPSendBytes)(),t.session.HTTPRecvBytesDelta=Object(Ue.getHTTPRecvBytes)()-t.session.HTTPRecvBytes,t.session.HTTPRecvBytes=Object(Ue.getHTTPRecvBytes)(),t.gatewayClient.socket&&t.gatewayClient.socket.state===t.gatewayClient.CONNECTED){var o=t.gatewayClient.socket;t.session.WSSendBytesDelta=o.getSendBytes()-t.session.WSSendBytes,t.session.WSSendBytes=o.getSendBytes(),t.session.WSRecvBytesDelta=o.getRecvBytes()-t.session.WSRecvBytes,t.session.WSRecvBytes=o.getRecvBytes()}}),1e3),t.gatewayClient.on("join",(function(){t.session={sendBytes:0,recvBytes:0,WSSendBytes:0,WSSendBytesDelta:0,WSRecvBytes:0,WSRecvBytesDelta:0,HTTPSendBytes:0,HTTPSendBytesDelta:0,HTTPRecvBytes:0,HTTPRecvBytesDelta:0}})),t}(t.gatewayClient),t.configDistributManager=function(e){var t={};return t.client=e,t.client.gatewayClient&&t.client.gatewayClient.on("config-distribute",(function(n){var a=n.joinInfo,i=n.config;if(i){Object(z.isEmpty)(i.uploadLog)||(Object(o.setParameter)("UPLOAD_LOG",i.uploadLog),s.b.reportApiInvoke(a.sid,{name:"_configDistribute",options:{feature:"uploadLog",value:i.uploadLog}})()),Object(z.isEmpty)(i.dualStream)||(e.isDualStream=i.dualStream,s.b.reportApiInvoke(a.sid,{name:"_configDistribute",options:{feature:"dualStream",value:i.dualStream}})()),Object(z.isEmpty)(i.streamFallbackOption)||t.client.gatewayClient&&t.client.gatewayClient.on("stream-subscribed",(function(e){var n=e.stream;n?(t.client.gatewayClient.setStreamFallbackOption(n,i.streamFallbackOption),s.b.reportApiInvoke(a.sid,{name:"_configDistribute",options:{feature:"streamFallbackOption",value:i.streamFallbackOption,streamId:n.getId()}})()):s.b.reportApiInvoke(a.sid,{name:"_configDistribute",options:{feature:"streamFallbackOption",value:i.streamFallbackOption,streamId:n.getId(),err:"invalid stream"}})()}));try{r.default.debug("[".concat(e.clientId,"] setParameter in distribution: ").concat(JSON.stringify(i))),Object.keys(i).map((function(e){return Object(o.setParameter)(e,i[e])}))}catch(t){r.default.debug("[".concat(e.clientId,"] setParameter in distribution failed: ").concat(JSON.stringify(i)))}}})),t}(t),function(e,t){var n=arguments;e.liveStreaming=c(),e.liveStreaming.connections={inject_streaming:null,mix_streaming:null,raw_streaming:null},e.liveStreaming.connectionTypes={inject_streaming:"pull",mix_streaming:"push",raw_streaming:"push"},e.liveStreaming.pushStates={},e.liveStreaming.pullStates={},e.gatewayClient.addEventListener("join",(function(t){e.liveStreaming.resumeStates("pull")})),e.gatewayClient.addEventListener("stream-unpublished",(function(t){if(t.options&&0===t.options.streamType)for(var n in e.liveStreaming.pushStates){var a=e.liveStreaming.pushStates[n];a.url&&e._stopLiveStreaming(a.url,a.transcodingEnabled,!0)}})),e.gatewayClient.addEventListener("stream-published",(function(t){e.liveStreaming.resumeStates("push")})),e.liveStreaming.connect=function(){var n=ee()(Z.a.mark((function n(a){var i,o;return Z.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.joinInfo&&e.joinInfo.uid&&parseInt(e.joinInfo.vid,10)){n.next=3;break}throw"CLIENT_NOT_JOINED",new Error("CLIENT_NOT_JOINED");case 3:return i=new Ct({appId:t.appId,cname:e.channel,sid:t.sessionId,uid:e.joinInfo.uid}),e.liveStreaming.connections[a]=i,n.next=7,Tt({proxyServer:e.useProxyServer&&e.joinInfo&&e.joinInfo.proxyServer,appId:t.appId,cname:e.channel,serviceName:a,sid:t.sessionId,uid:e.joinInfo.uid});case 7:return o=n.sent,n.next=10,i.connect({wsClient:o});case 10:return i.on("notification",(function(t){if(t.serviceName=a,e.liveStreaming.dispatchEvent(t),503===t.code);else switch(t.serviceName){case"inject_streaming":var n={reason:t&&t.reason,status:Dt(t&&t.code),type:"streamInjectedStatus",uid:t&&t.serverStatus&&t.serverStatus.inject_uid,url:t&&t.serverStatus&&t.serverStatus.url};e.gatewayClient.dispatchEvent(n);break;case"raw_streaming":case"mix_streaming":var i={reason:t&&t.reason,status:t&&t.code,type:t&&200===t.code?"liveStreamingStarted":"liveStreamingFailed",uid:t&&t.serverStatus&&t.uid,url:t&&t.serverStatus&&t.serverStatus.url};e.gatewayClient.dispatchEvent(i)}})),i.on("close",(function(t){Nt(i),r.default.debug("Reconnect ".concat(a)),e.liveStreaming.connect(a).catch((function(t){e.liveStreaming.connections[a]=null,e.gatewayClient.dispatchEvent({type:"".concat(a.replace("_","-"),"-disconnected")})}))})),r.default.debug("".concat(a," connected")),n.abrupt("return",i);case 14:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),e.liveStreaming.disconnect=function(){var t=ee()(Z.a.mark((function t(n){var a,i;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=Z.a.keys(e.liveStreaming.connections);case 1:if((t.t1=t.t0()).done){t.next=13;break}if(a=t.t1.value,!e.liveStreaming.connections.hasOwnProperty(a)){t.next=11;break}if(!(i=e.liveStreaming.connections[a])||n&&n!==a){t.next=11;break}return r.default.info("Disconnecting liveStreaming ".concat(a)),t.next=9,i.disconnect();case 9:t.sent,e.liveStreaming.connections[a]=null;case 11:t.next=1;break;case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),e.liveStreaming.resumeStates=function(){var t=ee()(Z.a.mark((function t(n){var a,i,o,s,c,d,u,l;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=Z.a.keys(e.liveStreaming.connections);case 1:if((t.t1=t.t0()).done){t.next=8;break}if(a=t.t1.value,!n||e.liveStreaming.connectionTypes[a]===n){t.next=5;break}return t.abrupt("continue",1);case 5:e.liveStreaming.connections.hasOwnProperty(a)&&(i=e.liveStreaming.connections[a])&&(r.default.info("LiveStreaming closing connection ".concat(a)),i.disconnect(),e.liveStreaming.connections[a]=null),t.next=1;break;case 8:t.t2=Z.a.keys(e.liveStreaming.pushStates);case 9:if((t.t3=t.t2()).done){t.next=37;break}if(o=t.t3.value,!n||"push"===n){t.next=13;break}return t.abrupt("continue",9);case 13:if(!e.liveStreaming.pushStates.hasOwnProperty(o)){t.next=35;break}if(s=e.liveStreaming.pushStates[o],"audience"!==e.gatewayClient.role){t.next=19;break}r.default.warning("Cannot resume LiveStreaming in audience mode. ".concat(s.url),s),t.next=35;break;case 19:if(!s){t.next=35;break}return r.default.debug("Resuming LiveStreaming ".concat(s.url),s),t.prev=21,t.next=24,e._startLiveStreaming(s.url,s.transcodingEnabled);case 24:c=t.sent,r.default.debug("Resumed LiveStreaming ".concat(s.url,": ").concat(c.reason)),t.next=35;break;case 28:if(t.prev=28,t.t4=t.catch(21),454!==t.t4.code){t.next=34;break}r.default.debug("Resumed LiveStreaming ".concat(s.url,": ").concat(t.t4.reason)),t.next=35;break;case 34:throw t.t4;case 35:t.next=9;break;case 37:t.t5=Z.a.keys(e.liveStreaming.pullStates);case 38:if((t.t6=t.t5()).done){t.next=62;break}if(d=t.t6.value,!n||"pull"===n){t.next=42;break}return t.abrupt("continue",38);case 42:if(!e.liveStreaming.pullStates.hasOwnProperty(d)){t.next=60;break}if(u=e.liveStreaming.pullStates[d],"audience"!==e.gatewayClient.role){t.next=48;break}r.default.warning("Cannot resume addInjectStreamUrl in audience mode. ".concat(u.url),u),t.next=60;break;case 48:if(!u){t.next=60;break}return r.default.debug("Resuming LiveStreaming pullStream ".concat(u.url),u),t.prev=50,t.next=53,e._addInjectStreamUrl(u.url,u.transcodingConfig);case 53:l=t.sent,r.default.debug("Resumed LiveStreaming pullStream ".concat(u.url,": ").concat(l.reason)),t.next=60;break;case 57:t.prev=57,t.t7=t.catch(50),451===t.t7.code&&r.default.debug("Resumed LiveStreaming pullStream ".concat(u.url,": ").concat(t.t7.reason));case 60:t.next=38;break;case 62:case"end":return t.stop()}}),t,null,[[21,28],[50,57]])})));return function(e){return t.apply(this,arguments)}}(),e.liveStreaming.startOptions={autoDestroyTime:30},e.liveStreaming.transcodingConfig={audioBitrate:48,audioChannels:1,audioSampleRate:48e3,backgroundColor:0,height:360,images:[],lowLatency:!1,metadata:"",userConfigExtraInfo:"",userConfigs:[],videoBitrate:400,videoCodecProfile:100,videoCodecType:1,videoFramerate:15,videoGop:30,width:640},e.startLiveStreaming=function(n,a){Object(z.isEmpty)(a)||Object(z.checkValidBoolean)(a,"transcodingEnabled"),Object(z.checkValidString)(n,"url",1,1024);var i=s.b.reportApiInvoke(t.sessionId,{name:"Client.startLiveStreaming",options:arguments,tag:"tracer"});if(e.gatewayClient&&"audience"===e.gatewayClient.role){var o={code:403,reason:"AUDIENCE_STREAMING_FORBIDDEN"};throw i(o),o}var r=e._startLiveStreaming(n,a);return r.then((function(e){i(null,e)})).catch((function(e){i(e)})),r},e._startLiveStreaming=function(){var n=ee()(Z.a.mark((function n(a,i){var o,s,c,d;return Z.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=E()({allocate:!0,clientRequest:{command:"PublishStream"},command:"request"}),r.default.debug("startLiveStreaming ".concat(a,", ").concat(i)),E()(o.clientRequest,e.liveStreaming.startOptions,{ts:Date.now(),url:a,vid:parseInt(e.joinInfo.vid,10)}),s=null,i?(e.liveStreaming.connections.mix_streaming||e.liveStreaming.connect("mix_streaming"),o.clientRequest.transcodingConfig=JSON.parse(JSON.stringify(e.liveStreaming.transcodingConfig)),s=e.liveStreaming.connections.mix_streaming):("vp8"===t.codec&&r.default.warning("VP8 is not supported by raw_streaming. Subscriber side will suffer"),"rtc"===t.mode&&r.default.warning("RTC mode is not supported by raw_streaming. Subscriber side will suffer"),e.liveStreaming.connections.raw_streaming||e.liveStreaming.connect("raw_streaming"),s=e.liveStreaming.connections.raw_streaming),c=null,d={},n.prev=7,n.next=10,s.request(o);case 10:c=n.sent,d.type="liveStreamingStarted",d.reason=c&&c.reason,d.status=c&&c.code,d.url=c&&c.serverResponse&&c.serverResponse.url,e.gatewayClient.dispatchEvent(d),n.next=26;break;case 18:throw n.prev=18,n.t0=n.catch(7),d.type="liveStreamingFailed",d.reason=n.t0&&n.t0.reason,d.status=n.t0&&n.t0.code,d.url=n.t0&&n.t0.serverResponse&&n.t0.serverResponse.url,e.gatewayClient.dispatchEvent(d),n.t0;case 26:return e.liveStreaming.pushStates[a]={transcodingEnabled:i,url:a},n.abrupt("return",c);case 28:case"end":return n.stop()}}),n,null,[[7,18]])})));return function(e,t){return n.apply(this,arguments)}}(),e.setLiveTranscoding=function(n,a){r.default.debug("setLiveTranscoding: ".concat(JSON.stringify(n))),Object(z.checkValidObject)(n,"transcoding");var i=n,o=i.width,c=i.height,d=i.videoBitrate,u=i.videoFramerate,l=i.lowLatency,p=i.audioSampleRate,f=i.audioBitrate,g=i.audioChannels,m=i.videoGop,v=i.images,S=i.videoCodecProfile,E=i.userCount,_=i.backgroundColor,h=i.transcodingUsers;if(h||(h=n.userConfigs),Object(z.isEmpty)(o)||Object(z.checkValidNumber)(o,"width"),Object(z.isEmpty)(c)||Object(z.checkValidNumber)(c,"height"),Object(z.isEmpty)(d)||Object(z.checkValidNumber)(d,"videoBitrate",1,1e6),Object(z.isEmpty)(u)||Object(z.checkValidNumber)(u,"videoFramerate"),Object(z.isEmpty)(l)||Object(z.checkValidBoolean)(l,"lowLatency"),Object(z.isEmpty)(p)||Object(z.checkValidEnum)(p,"audioSampleRate",[32e3,44100,48e3]),Object(z.isEmpty)(f)||Object(z.checkValidNumber)(f,"audioBitrate",1,128),Object(z.isEmpty)(g)||Object(z.checkValidEnum)(g,"audioChannels",[1,2,3,4,5]),Object(z.isEmpty)(m)||Object(z.checkValidNumber)(m,"videoGop"),Object(z.isEmpty)(S)||Object(z.checkValidEnum)(S,"videoCodecProfile",[66,77,100]),Object(z.isEmpty)(E)||Object(z.checkValidNumber)(E,"userCount",0,17),Object(z.isEmpty)(_)||Object(z.checkValidNumber)(_,"backgroundColor",0,16777215),!Object(z.isEmpty)(h)){if(!Object(z.isArray)(h))throw new Error("[transcodingUsers]: transcodingUsers should be Array");if(h.length>17)throw new Error("The length of transcodingUsers cannot greater than 17");h.map((function(e,t){if(!Object(z.isEmpty)(e.uid)&&!wt(e.uid)&&!Object(z.isValidString)(e.uid,1,255))throw new Error("[String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]");if(Object(z.isEmpty)(e.x)?e.x=0:Object(z.checkValidNumber)(e.x,"transcodingUser[".concat(t,"].x"),0,1e4),Object(z.isEmpty)(e.y)?e.y=0:Object(z.checkValidNumber)(e.y,"transcodingUser[".concat(t,"].y"),0,1e4),Object(z.isEmpty)(e.width)?e.width=640:Object(z.checkValidNumber)(e.width,"transcodingUser[".concat(t,"].width"),0,1e4),Object(z.isEmpty)(e.height)?e.height=360:Object(z.checkValidNumber)(e.height,"transcodingUser[".concat(t,"].height"),0,1e4),Object(z.isEmpty)(e.zOrder)?e.zOrder=0:Object(z.checkValidNumber)(e.zOrder,"transcodingUser[".concat(t,"].zOrder"),0,100),Object(z.isEmpty)(e.alpha))e.alpha=1;else if(!(Object(z.isNumber)(e.alpha)&&e.alpha<=1&&e.alpha>=0))throw new Error("transcodingUser[${index}].alpha: The value range is [0, 1]")}))}if(!Object(z.isEmpty)(v)){if(!Object(z.isArray)(v))throw new Error("[images]: images should be Array");v.map((function(e,t){if(Object(z.checkValidString)(e.url,"images[".concat(t,"].url"),1,1024),Object(z.isEmpty)(e.x)?e.x=0:Object(z.checkValidNumber)(e.x,"images[".concat(t,"].x"),0,1e4),Object(z.isEmpty)(e.y)?e.y=0:Object(z.checkValidNumber)(e.y,"images[".concat(t,"].y"),0,1e4),Object(z.isEmpty)(e.width)?e.width=160:Object(z.checkValidNumber)(e.width,"images[".concat(t,"].width"),0,1e4),Object(z.isEmpty)(e.height)?e.height=160:Object(z.checkValidNumber)(e.height,"images[".concat(t,"].height"),0,1e4),Object(z.isEmpty)(e.zOrder)?e.zOrder=0:Object(z.checkValidNumber)(e.zOrder,"images[".concat(t,"].zOrder"),0,100),Object(z.isEmpty)(e.alpha))e.alpha=1;else if(!(Object(z.isNumber)(e.alpha)&&e.alpha<=1&&e.alpha>=0))throw new Error("image[${index}].alpha: The value range is [0, 1]")}))}var I=s.b.reportApiInvoke(t.sessionId,{name:"Client.setLiveTranscoding",options:arguments,tag:"tracer"});if((n=JSON.parse(JSON.stringify(n))).transcodingUsers&&(n.userConfigs=n.transcodingUsers,delete n.transcodingUsers),e.joinInfo.stringUid&&n.userConfigs&&n.userConfigs.length){var b=[];n.userConfigs.forEach((function(t){b.push(Qe(e.joinInfo,e.gatewayClient,t.uid).then((function(e){t.uid=e.uid})))}));var T=Promise.all(b).then((function(){return e._setLiveTranscoding(n,a)}));return T.then((function(e){I(null,e)})).catch((function(e){I(e)})),T}var R=e._setLiveTranscoding(n,a);return R.then((function(e){I(null,e)})).catch((function(e){I(e)})),R},e._setLiveTranscoding=function(){var t=ee()(Z.a.mark((function t(n,a){var i,o,r;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.liveStreaming.transcodingConfig=E()(e.liveStreaming.transcodingConfig,n),"boolean"!=typeof a&&(a=!!e.liveStreaming.connections.mix_streaming),i=JSON.parse(JSON.stringify({allocate:!1,clientRequest:{command:"UpdateTranscoding",transcodingConfig:e.liveStreaming.transcodingConfig},command:"request"})),o={},!a){t.next=16;break}return e.liveStreaming.connections.mix_streaming||e.liveStreaming.connect("mix_streaming"),t.next=8,e.liveStreaming.connections.mix_streaming.request(i);case 8:return r=t.sent,o.type="liveTranscodingUpdated",o.reason=r.reason,o.status=r.code,e.gatewayClient.dispatchEvent(o),t.abrupt("return",r);case 16:return t.abrupt("return",{code:200,reason:"success"});case 17:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),e.stopLiveStreaming=function(n,a){Object(z.checkValidString)(n,"url",1,1024);var i=s.b.reportApiInvoke(t.sessionId,{name:"Client.stopLiveStreaming",options:arguments,tag:"tracer"}),o=e._stopLiveStreaming(n,a);return o.then((function(e){i(null,e)})).catch((function(e){i(e)})),o},e._stopLiveStreaming=function(){var t=ee()(Z.a.mark((function t(n,a,i){var o,r,s,c,d,u;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=null,r=e.liveStreaming.pushStates[n],o=r?r.transcodingEnabled?"mix_streaming":"raw_streaming":a?"mix_streaming":"raw_streaming",s={allocate:!1,clientRequest:{command:"UnpublishStream",url:n},command:"request"},e.liveStreaming.connections[o]||e.liveStreaming.connect(o),c=null,t.prev=6,t.next=9,e.liveStreaming.connections[o].request(s);case 9:c=t.sent,(d={}).type="liveStreamingStopped",d.reason=c&&c.reason,d.status=c&&c.code,d.url=c&&c.serverResponse&&c.serverResponse.url,e.gatewayClient.dispatchEvent(d),t.next=27;break;case 18:throw t.prev=18,t.t0=t.catch(6),(u={}).type="liveStreamingStopped",u.reason=t.t0&&t.t0.reason,u.status=t.t0&&t.t0.code,u.url=t.t0&&t.t0.serverResponse&&t.t0.serverResponse.url,e.gatewayClient.dispatchEvent(u),t.t0;case 27:return i||delete e.liveStreaming.pushStates[n],t.abrupt("return",c);case 29:case"end":return t.stop()}}),t,null,[[6,18]])})));return function(e,n,a){return t.apply(this,arguments)}}(),e.liveStreaming.injectStreamTranscodingConfig={autoDestroyTime:30,audioBitrate:48,audioChannels:1,audioSampleRate:44100,height:0,videoBitrate:400,videoFramerate:15,videoGop:30,width:0},e.addInjectStreamUrl=function(a,i){Object(z.checkValidString)(a,"url",1,1024),Object(z.checkValidObject)(i,"config"),!Object(z.isEmpty)(i&&i.width)&&Object(z.checkValidNumber)(i.width,"config.width",0,1e4),!Object(z.isEmpty)(i&&i.height)&&Object(z.checkValidNumber)(i.height,"config.height",0,1e4),!Object(z.isEmpty)(i&&i.videoGop)&&Object(z.checkValidNumber)(i.videoGop,"config.videoGop",1,1e4),!Object(z.isEmpty)(i&&i.videoFramerate)&&Object(z.checkValidNumber)(i.videoFramerate,"config.videoFramerate",1,1e4),!Object(z.isEmpty)(i&&i.videoBitrate)&&Object(z.checkValidNumber)(i.videoBitrate,"config.videoBitrate",1,1e4),!Object(z.isEmpty)(i&&i.audioSampleRate)&&Object(z.checkValidEnum)(i.audioSampleRate,"config.audioSampleRate",[32e3,44100,48e3]),!Object(z.isEmpty)(i&&i.audioBitrate)&&Object(z.checkValidNumber)(i.audioBitrate,"config.audioBitrate",1,1e4),!Object(z.isEmpty)(i&&i.audioChannels)&&Object(z.checkValidNumber)(i.audioChannels,"config.audioChannels",1,2);var o=s.b.reportApiInvoke(t.sessionId,{name:"Client.addInjectStreamUrl",options:n,tag:"tracer"});if("audience"===e.gatewayClient.role){var r={code:403,reason:"AUDIENCE_INJECTING_FORBIDDEN"};throw o(r),r}var c=e._addInjectStreamUrl(a,i);return c.then((function(e){o(null,e)})).catch((function(e){o(e)})),c},e._addInjectStreamUrl=function(){var n=ee()(Z.a.mark((function n(a,i){var o,r,s,c,d;return Z.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=E()({},e.liveStreaming.injectStreamTranscodingConfig,i),r={allocate:!0,clientRequest:{cname:e.channel,command:"InjectStream",sid:t.sessionId,transcodingConfig:o,ts:Date.now(),url:a,vid:parseInt(e.joinInfo.vid,10)},command:"request"},e.liveStreaming.connections.inject_streaming||e.liveStreaming.connect("inject_streaming"),s=null,n.prev=4,n.next=7,e.liveStreaming.connections.inject_streaming.request(r);case 7:s=n.sent,c={reason:s&&s.reason,status:Dt(s&&s.code),type:"streamInjectedStatus",uid:s&&s.serverResponse&&s.serverResponse.inject_uid,url:s&&s.serverResponse&&s.serverResponse.url},e.gatewayClient.dispatchEvent(c),n.next=17;break;case 12:throw n.prev=12,n.t0=n.catch(4),d={reason:n.t0&&n.t0.reason,status:Dt(n.t0&&n.t0.code),type:"streamInjectedStatus",uid:n.t0&&n.t0.serverResponse&&n.t0.serverResponse.inject_uid,url:n.t0&&n.t0.serverResponse&&n.t0.serverResponse.url},e.gatewayClient.dispatchEvent(d),n.t0;case 17:return e.liveStreaming.pullStates[a]={transcodingConfig:o,url:a},n.abrupt("return",s);case 19:case"end":return n.stop()}}),n,null,[[4,12]])})));return function(e,t){return n.apply(this,arguments)}}(),e.removeInjectStreamUrl=function(){var n=ee()(Z.a.mark((function n(a){var i,o,r=arguments;return Z.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return Object(z.checkValidString)(a,"url",1,255),i=s.b.reportApiInvoke(t.sessionId,{name:"Client.removeInjectStreamUrl",options:r,tag:"tracer"}),(o=e._removeInjectStreamUrl(a)).then((function(e){i(null,e)})).catch((function(e){i(e)})),n.abrupt("return",o);case 5:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),e._removeInjectStreamUrl=function(){var t=ee()(Z.a.mark((function t(n){var a,i,o,r;return Z.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={allocate:!1,clientRequest:{command:"UninjectStream",url:n},command:"request"},e.liveStreaming.connections.inject_streaming||e.liveStreaming.connect("inject_streaming"),i=null,t.prev=3,t.next=6,e.liveStreaming.connections.inject_streaming.request(a);case 6:i=t.sent,o={reason:i&&i.reason,status:kt(i&&i.code),type:"streamInjectedStatus",uid:i&&i.serverResponse&&i.serverResponse.inject_uid,url:i&&i.serverResponse&&i.serverResponse.url},e.gatewayClient.dispatchEvent(o),t.next=16;break;case 11:throw t.prev=11,t.t0=t.catch(3),r={reason:t.t0&&t.t0.reason,status:kt(t.t0&&t.t0.code),type:"streamInjectedStatus",uid:t.t0&&t.t0.serverResponse&&t.t0.serverResponse.inject_uid,url:t.t0&&t.t0.serverResponse&&t.t0.serverResponse.url},e.gatewayClient.dispatchEvent(r),t.t0;case 16:return delete e.liveStreaming.pullStates[n],t.abrupt("return",i);case 18:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e){return t.apply(this,arguments)}}()}(t,e),e.areaCode){var n=Object(Mt.getAreaDomainConfig)(e.areaCode);Object.keys(n).map((function(e){"LOG_UPLOAD_SERVER"==e||"EVENT_REPORT_DOMAIN"==e||"EVENT_REPORT_BACKUP_DOMAIN"==e?Object(o.setParameter)(e,n[e][0]):Object(o.setParameter)(e,n[e])}))}return Object(z.isEmpty)(e.turnServer)||t.setTurnServer(e.turnServer),Object(z.isEmpty)(e.proxyServer)||t.setProxyServer(e.proxyServer),"live"===t.mode&&(t.gatewayClient.role="audience"),"rtc"===t.mode&&(t.gatewayClient.role=Ut),t.gatewayClient.on("onMultiIP",(function(e){t.gatewayClient.closeGateway(),t.gatewayClient.socket=void 0,t.gatewayClient.hasChangeBGPAddress=!0,t.joinInfo.multiIP=e.option,t.gatewayClient.state=st.CONNECTING;var n=function(e){r.default.info("[".concat(t.clientId,"] Joining channel: ").concat(t.channel)),t.joinInfo.cid=e.cid,t.joinInfo.uid||(t.joinInfo.uid=e.uid),t.joinInfo.uni_lbs_ip=e.uni_lbs_ip,t.joinInfo.gatewayAddr=e.gateway_addr,t.onSuccess?t.gatewayClient.join(t.joinInfo,t.key,(function(e){r.default.info("[".concat(t.clientId,"] Join channel ").concat(t.channel," success"));var n=t.onSuccess;t.onSuccess=null,t.onFailure=null,n(e)}),t.onFailure):(t.gatewayClient.joinInfo=E()({},t.joinInfo),t.gatewayClient.rejoin())};t.joinInfo.stringUid&&!t.joinInfo.uid?(t.userAccountReq&&!t.userAccountReq.isFinished()&&t.userAccountReq.cancel(),t.userAccountReq=Qe(joinInfo,t.gatewayClient),t.userAccountReq.then((function(e){r.default.error("getUserAccount Success ".concat(e.url," ").concat(joinInfo.stringUid," => ").concat(e.uid)),t.joinInfo.uid=e.uid,ze(t.joinInfo,n,t.onFailure)})).catch((function(e){r.default.error("getUserAccount rejected",e),t.onFailure(e)}))):ze(t.joinInfo,n,t.onFailure)})),t.gatewayClient.on("rejoin-start",(function(){t._renewSession(),s.b.sessionInit(e.sessionId,{lts:(new Date).getTime(),extend:{rejoin:!0},cname:t.channel,appid:e.appId,mode:e.mode,succ:!0})})),t.gatewayClient.on("recover",(function(){t._renewSession(),console.log("recover",e.sessionId),s.b.sessionInit(e.sessionId,{lts:(new Date).getTime(),extend:{recover:!0},cname:t.channel,appid:e.appId,mode:e.mode,succ:!0})})),t.gatewayClient.on("rejoin",(function(){var e=t.highStreamState;if(r.default.debug("[".concat(t.clientId,"] Client local stream preState: ").concat(e)),t.onSuccess){var n=t.onSuccess;t.onSuccess=null,t.onFailure=null,n(t.joinInfo.uid)}!t.highStream||0!==e&&1!==e||(r.default.info("[".concat(t.clientId,"] publish after rejoin")),t.highStreamState=2,t.lowStreamState=2,t.publish(t.highStream,(function(e){e&&r.default.info("[".concat(t.clientId,"] "),e)})))})),t.gatewayClient.on("streamPublished",(function(e){t.hasPublished||(t.hasPublished=!0,t.gatewayClient.dispatchEvent(u({type:"stream-published",stream:e.stream})))})),t.gatewayClient.on("pubP2PLost",(function(e){r.default.debug("[".concat(t.clientId,"] Start reconnect local peerConnection: ").concat(t.highStream.getId())),t.gatewayClient.dispatchEvent({type:"stream-reconnect-start",uid:t.highStream.getId()}),1===t.highStreamState&&(t.highStreamState=0,t.lowStreamState=0),t._unpublish(t.highStream,(function(){t._publish(t.highStream,(function(){r.default.debug("[".concat(t.clientId,"] Reconnect local peerConnection success: ").concat(t.highStream.getId())),t.gatewayClient.dispatchEvent({type:"stream-reconnect-end",uid:t.highStream.getId(),success:!0,reason:""})}),(function(e){r.default.debug("[".concat(t.clientId,"] Reconnect local peerConnection failed: ").concat(e)),t.gatewayClient.dispatchEvent({type:"stream-reconnect-end",uid:t.highStream.getId(),success:!1,reason:e})}),!0)}),(function(e){r.default.debug("[".concat(t.clientId,"] Reconnect local peerConnection failed: ").concat(e)),t.gatewayClient.dispatchEvent({type:"stream-reconnect-end",uid:t.highStream.getId(),success:!1,reason:e})}),!0)})),t.gatewayClient.on("subP2PLost",(function(e){r.default.debug("[".concat(t.clientId,"] Start reconnect remote peerConnection: ").concat(e.stream.getId()," ").concat(e.stream.subscribeOptions)),t.gatewayClient.dispatchEvent({type:"stream-reconnect-start",uid:e.stream.getId()});var n=e.stream.subscribeOptions;console.log("Re-subscribe stream",n,e.stream),t.gatewayClient.unsubscribe(e.stream,(function(){e.stream.subscribeOptions=n,t.gatewayClient.subscribe(e.stream,(function(){r.default.debug("[".concat(t.clientId,"] Reconnect remote peerConnection success: ").concat(e.stream.getId())),t.gatewayClient.dispatchEvent({type:"stream-reconnect-end",uid:e.stream.getId(),success:!0,reason:""})}),(function(n){r.default.debug("[".concat(t.clientId,"] Reconnect remote peerConnection failed: "),n),t.gatewayClient.dispatchEvent({type:"stream-reconnect-end",uid:e.stream.getId(),success:!1,reason:n})}))}),(function(n){r.default.debug("[".concat(t.clientId,"] Reconnect remote peerConnection failed: "),n),t.gatewayClient.dispatchEvent({type:"stream-reconnect-end",uid:e.stream.getId(),success:!1,reason:n})}))})),ft.on("networkTypeChanged",(function(e){t.gatewayClient&&t.gatewayClient.dispatchEvent(e);var n=E()({},e,{type:"network-type-changed"});t.gatewayClient.dispatchEvent(n)})),K.on("recordingDeviceChanged",(function(e){t.gatewayClient&&t.gatewayClient.dispatchEvent(e);var n=E()({},e,{type:"recording-device-changed"});t.gatewayClient.dispatchEvent(n)})),K.on("playoutDeviceChanged",(function(e){t.gatewayClient&&t.gatewayClient.dispatchEvent(e);var n=E()({},e,{type:"playout-device-changed"});t.gatewayClient.dispatchEvent(n)})),K.on("cameraChanged",(function(e){t.gatewayClient&&t.gatewayClient.dispatchEvent(e);var n=E()({},e,{type:"camera-changed"});t.gatewayClient.dispatchEvent(n)})),t.gatewayClient.on("streamTypeChange",(function(n){var a=E()({},n,{type:"stream-type-changed"});t.gatewayClient.dispatchEvent(a),s.b.reportApiInvoke(e.sessionId,{name:"streamTypeChange"})(null,JSON.stringify(n))})),t},Vt={width:640,height:360,videoBitrate:400,videoFramerate:15,lowLatency:!1,audioSampleRate:48e3,audioBitrate:48,audioChannels:1,videoGop:30,videoCodecProfile:100,userCount:0,userConfigExtraInfo:{},backgroundColor:0,transcodingUsers:[]},jt=function(e){switch(e){case"h264_interop":return"h264";default:return"vp8"}},Bt=function(e){return-1===we.indexOf(e.mode)?I.default.INVALID_CLIENT_MODE:-1===De.indexOf(e.codec)?I.default.INVALID_CLIENT_CODEC:"h264_interop"==e.mode&&"h264"!==e.codec&&I.default.CLIENT_MODE_CODEC_MISMATCH},Ft=function(e){switch(e.mode){case"interop":case"h264_interop":e.mode="live";break;case"web-only":e.mode="rtc"}},Wt=K.getDevices,Gt=V,Ht=JSON.parse(JSON.stringify(o.SUPPORT_RESOLUTION_LIST));n.default={TranscodingUser:{uid:0,x:0,y:0,width:0,height:0,zOrder:0,alpha:1},LiveTranscoding:Vt,createClient:function(e){var t=s.b.reportApiInvoke(null,{name:"createClient",options:arguments,tag:"tracer"});(e=E()({},e||{})).codec||(e.codec=jt(e.mode));var n=Bt(e);if(n)throw r.default.error("Invalid parameter setting MODE: ".concat(e.mode," CODEC: ").concat(e.codec," ERROR ").concat(n)),t(n),new Error(n);return r.default.info("Creating client, MODE: ".concat(e.mode," CODEC: ").concat(e.codec)),Ft(e),t(null,e),xt(e)},createStream:function(e){var t=s.b.reportApiInvoke(null,{name:"createStream",options:arguments,tag:"tracer",getStates:function(){return{audioTrackEnable:e&&e.audioSource?e.audioSource.enabled:null,videoTrackEnable:e&&e.videoSource?e.videoSource.enabled:null}}});Object(z.checkValidObject)(e,"StreamSpec");var n=e.streamID,a=e.audio,i=e.video,o=e.screen,c=e.screenAudio,d=(e.audioSource,e.videoSource,e.cameraId),u=e.facingMode,l=e.microphoneId,p=e.mirror,f=e.extensionId,g=e.mediaSource,m=e.audioProcessing;if(!Object(z.isEmpty)(n)&&!Object(H.is32Uint)(n)&&!Object(z.isValidString)(n,1,255))throw new Error("[String streamID] Length of the string: [1,255]. ASCII characters only. [Number streamID] The value range is Uint32");if(Object(z.checkValidBoolean)(a,"audio"),Object(z.checkValidBoolean)(i,"video"),Object(z.isEmpty)(o)||Object(z.checkValidBoolean)(o,"screen"),Object(z.isEmpty)(c)||Object(z.checkValidBoolean)(c,"screenAudio"),Object(z.isEmpty)(d)||Object(z.checkValidString)(d,"cameraId",0,255,!1),Object(z.isEmpty)(u)||Object(z.checkValidEnum)(u,"facingMode",["user","environment","left","right"]),Object(z.isEmpty)(l)||Object(z.checkValidString)(l,"microphoneId",0,255,!1),Object(z.isEmpty)(f)||Object(z.checkValidString)(f,"extensionId"),Object(z.isEmpty)(g)||Object(z.checkValidEnum)(g,"mediaSource",["screen","application","window"]),Object(z.isEmpty)(p)||Object(z.checkValidBoolean)(p,"mirror"),!Object(z.isEmpty)(m)){var v=m.AGC,S=m.AEC,E=m.ANS;Object(z.isEmpty)(v)||Object(z.checkValidBoolean)(v,"AGC"),Object(z.isEmpty)(S)||Object(z.checkValidBoolean)(S,"AEC"),Object(z.isEmpty)(E)||Object(z.checkValidBoolean)(E,"ANS")}r.default.debug("Create stream"),!0===c&&!0===a&&r.default.warning("Do not set both 'screenAudio' and 'audio' to true at the same time");var _=ye(e);return t(),_},Logger:r.default,report:s.b,getDevices:Wt,getScreenSources:Gt,getParameter:o.getParameter,setParameter:o.setParameter,checkSystemRequirements:function(){var e=s.b.reportApiInvoke(null,{name:"checkSystemRequirements",options:arguments,tag:"tracer"}),t=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,n=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia,a=window.WebSocket,i=!!t&&!!n&&!!a,o=!1;g.isChrome()&&g.getBrowserVersion()>=58&&"iOS"!==g.getBrowserOS()&&(o=!0),g.isFireFox()&&g.getBrowserVersion()>=56&&(o=!0),g.isOpera()&&g.getBrowserVersion()>=45&&(o=!0),g.isSafari()&&g.getBrowserVersion()>=11&&(o=!0),g.isEdge()&&(o=!0),(g.isWeChatBrowser()||g.isQQBrowser())&&"iOS"!==g.getBrowserOS()&&(o=!0),g.isSupportedPC()||g.isSupportedMobile()||(o=!1),r.default.debug(g.getBrowserInfo(),"isAPISupport: "+i+", isVendorAndVersionSupport: "+o);var c=i&&o;return e(null,c),c},getSupportedCodec:Oe.getSupportedCodec,ChannelMediaRelayConfiguration:Ce.ChannelMediaRelayConfiguration,VERSION:o.VERSION,BUILD:o.BUILD,PROFILE_TABLE:Ht,AUDIO_SAMPLE_RATE_32000:32e3,AUDIO_SAMPLE_RATE_44100:44100,AUDIO_SAMPLE_RATE_48000:48e3,VIDEO_CODEC_PROFILE_BASELINE:66,VIDEO_CODEC_PROFILE_MAIN:77,VIDEO_CODEC_PROFILE_HIGH:100,REMOTE_VIDEO_STREAM_HIGH:0,REMOTE_VIDEO_STREAM_LOW:1,REMOTE_VIDEO_STREAM_MEDIUM:2,AREAS:Mt.AREAS,AREA_VERSION:"global"}}]).default}));