From 3fe319a781281a9e6efe564e1134649b7af19961 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Fri, 26 Apr 2024 11:47:19 +0200 Subject: [PATCH] Added custom-layout for v2 compatibility to PRO deloyment --- pro/custom-layout/index.html | 76 +++++++++++++++++-- pro/custom-layout/opentok-layout.min.js | 12 +++ .../openvidu-browser-3.0.0-dev2.min.js | 2 + ...vidu-browser-3.0.0-dev2.min.js.LICENSE.txt | 13 ++++ 4 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 pro/custom-layout/opentok-layout.min.js create mode 100644 pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js create mode 100644 pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js.LICENSE.txt diff --git a/pro/custom-layout/index.html b/pro/custom-layout/index.html index fbb8350..b401532 100644 --- a/pro/custom-layout/index.html +++ b/pro/custom-layout/index.html @@ -1,11 +1,71 @@ - - - - Recording custom layout - - - Create here your custom layout - + + + + OpenVidu Layout + + + + + + + +
+ + + diff --git a/pro/custom-layout/opentok-layout.min.js b/pro/custom-layout/opentok-layout.min.js new file mode 100644 index 0000000..57c555c --- /dev/null +++ b/pro/custom-layout/opentok-layout.min.js @@ -0,0 +1,12 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.initLayoutContainer=e():t.initLayoutContainer=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)i.d(o,a,function(e){return t[e]}.bind(null,a));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1)}([function(t,e,i){"use strict";e.__esModule=!0;var o=function(t,e,i,o,a,n,r,h){for(var d,f,l,s,g,c,u,v,p=1;p<=a;p+=1){var m=p,b=Math.ceil(a/m);(v=(u=Math.floor(o/b))/(c=Math.floor(i/m)))>e?u=c*(v=e):v=d){if(h&&w===d&&m*b%a>l*f%a)continue;d=w,s=u,g=c,f=m,l=b}}return{maxArea:d,targetCols:f,targetRows:l,targetHeight:s,targetWidth:g,ratio:s/g}},a=function(t,e){var i,a=t.maxRatio,n=t.minRatio,r=t.fixedRatio,h=t.containerWidth,d=t.containerHeight,f=t.offsetLeft,l=void 0===f?0:f,s=t.offsetTop,g=void 0===s?0:s,c=t.alignItems,u=void 0===c?"center":c,v=t.maxWidth,p=void 0===v?1/0:v,m=t.maxHeight,b=void 0===m?1/0:m,w=t.scaleLastRow,x=void 0===w||w,y=t.evenRows,R=void 0===y||y,M=e.map((function(t){return t.height/t.width})),H=M.length;if(r){var W=M.length>0?M[0]:null;i=o(W,W,h,d,H,p,b,R)}else i=o(n,a,h,d,H,p,b,R);for(var L,_=0,O=0,j=[],T=[],I=0;Ih?(L.height=Math.floor(L.height*(h/L.width)),L.width=h):L.width0){var k=d-A;A=0;for(I=0;I(h-L.width)/L.width&&(q=Math.floor((h-L.width)/L.width*L.height)),L.width+=Math.floor(q/L.height*L.width),L.height+=q,k-=q,E-=1}A+=L.height}}switch(u){case"start":O=0;break;case"end":O=d-A;break;case"center":default:O=(d-A)/2}for(I=0;I0&&at.length>0){var dt=void 0,ft=void 0,lt=!0===R;if(X>(i=ot[0]).height/i.width){if(dt=H,ft=Math.floor(L*g),u>0){var st=void 0;if(p){var gt=ot[0].height/ot[0].width;st=o(gt,gt,dt,ft,ot.length,z,V,U)}else st=o(x,b,dt,ft,ot.length,z,V,U);ft=Math.max(L*u,Math.min(ft,st.targetHeight*st.targetRows));var ct=a({containerWidth:H,containerHeight:L-ft,offsetLeft:0,offsetTop:0,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:S,maxWidth:q,maxHeight:F,scaleLastRow:G,evenRows:U},at),ut=0,vt=void 0;ct.forEach((function(t){vt!==t.top&&(vt=t.top,ut+=t.height)})),ft=Math.max(ft,L-ut)}tt=L-(Z=ft),"column"===R?lt=!1:"row"===R&&(lt=!0)}else{if(ft=L,dt=Math.floor(H*g),u>0){st=void 0;if(p){gt=ot[0].height/ot[0].width;st=o(gt,gt,dt,ft,ot.length,z,V,U)}else st=o(x,b,dt,ft,ot.length,z,V,U);dt=Math.max(H*u,Math.min(dt,st.targetWidth*st.targetCols));var pt=a({containerWidth:H-dt,containerHeight:L,offsetLeft:0,offsetTop:0,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:S,maxWidth:q,maxHeight:F,scaleLastRow:G,evenRows:U},at),mt=0,bt=0,wt=0;pt.forEach((function(t){t.top!==wt&&(bt=0,wt=t.top),bt+=t.width,mt=Math.max(mt,bt)})),dt=Math.max(dt,H-mt)}et=H-(Y=dt),"column"===R?lt=!0:"row"===R&&(lt=!1)}lt?(ht.big={top:0,left:0,width:dt,height:ft},ht.small={top:Z,left:Y,width:H-Y,height:L-Z}):(ht.big={left:et,top:tt,width:dt,height:ft},ht.small={top:0,left:0,width:H-Y,height:L-Z})}else ot.length>0&&0===at.length?ht.big={top:0,left:0,width:H,height:L}:ht.small={top:Z,left:Y,width:H-Y,height:L-Z};ht.big&&(nt=a({containerWidth:ht.big.width,containerHeight:ht.big.height,offsetLeft:ht.big.left,offsetTop:ht.big.top,fixedRatio:p,minRatio:x,maxRatio:b,alignItems:T,maxWidth:z,maxHeight:V,scaleLastRow:K,evenRows:U},ot)),ht.small&&(rt=a({containerWidth:ht.small.width,containerHeight:ht.small.height,offsetLeft:ht.small.left,offsetTop:ht.small.top,fixedRatio:l,minRatio:d,maxRatio:r,alignItems:ht.big?S:O,maxWidth:ht.big?q:P,maxHeight:ht.big?F:E,scaleLastRow:G,evenRows:U},at));var xt=[],yt=0,Rt=0;return e.forEach((function(t,e){it.indexOf(e)>-1?(xt[e]=nt[yt],yt+=1):(xt[e]=rt[Rt],Rt+=1)})),{boxes:xt,areas:ht}}},function(t,e,i){"use strict"; +/*! + * opentok-layout-js (http://github.com/aullman/opentok-layout-js) + * + * Automatic layout of video elements (publisher and subscriber) minimising + * white-space for the OpenTok on WebRTC API. + * + * @Author: Adam Ullman (http://github.com/aullman) + * @Copyright (c) 2014 Adam Ullman + * @License: Released under the MIT license (http://opensource.org/licenses/MIT) + * */e.__esModule=!0;var o=i(0),a=i(2);t.exports=function(t,e){var i=e&&e.window||("undefined"==typeof window?void 0:window);return t="string"==typeof t?i.document.querySelector(t):t,void 0===(i&&i.HTMLElement)||t instanceof i.HTMLElement||e?e||(e={}):e=t,{layout:a.default.bind(this,t,e),getLayout:o.default.bind(this,e)}}},function(t,e,i){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(t){for(var e,i=1,o=arguments.length;i0?"".concat(u.offsetHeight,"px"):i(u,"height"))?parseInt(v,10):0)-n(t,"border-top")-n(t,"border-bottom"),e.containerWidth=function(t){var e,o=(e=t).offsetWidth>0?"".concat(e.offsetWidth,"px"):i(e,"width");return o?parseInt(o,10):0}(t)-n(t,"border-left")-n(t,"border-right");var m=Array.prototype.filter.call(t.querySelectorAll("#".concat(p,">*:not(.").concat(s,")")),(function(t){return"none"!==i(t,"display")})),b=m.map((function(t){return o(o({},function(t){if(t){if(t.videoHeight&&t.videoWidth)return{height:t.videoHeight,width:t.videoWidth};var e=t.querySelector("video");if(e&&e.videoHeight&&e.videoWidth)return{height:e.videoHeight,width:e.videoWidth}}return{height:480,width:640}}(t)),{big:t.classList.contains(f),fixedRatio:t.classList.contains(c)})}));(0,a.default)(e,b).boxes.forEach((function(t,o){var a=m[o];i(a,"position","absolute");var r=t.width-n(a,"margin-left")-n(a,"margin-right")-("border-box"!==i(a,"box-sizing")?n(a,"padding-left")+n(a,"padding-right")+n(a,"border-left")+n(a,"border-right"):0),d=t.height-n(a,"margin-top")-n(a,"margin-bottom")-("border-box"!==i(a,"box-sizing")?n(a,"padding-top")+n(a,"padding-bottom")+n(a,"border-top")+n(a,"border-bottom"):0);!function(t,e,o,a,n,r,h){var d=this,f={left:"".concat(e,"px"),top:"".concat(o,"px"),width:"".concat(a,"px"),height:"".concat(n,"px")},l=function(){var e=t.querySelector(".OT_root");if(e){var i=e.style.width;e.style.width="".concat(a,"px"),e.style.width=i||""}};if(r&&"undefined"!=typeof $){$(t).stop();var s="boolean"==typeof r?{duration:200,easing:"swing"}:r;$(t).animate(f,s.duration,s.easing,(function(){l(),s.complete&&s.complete.call(d),h&&h(t,{left:e,top:o,width:a,height:n})}))}else i(t,f),t.classList.contains("ot-layout")||t.classList.add("ot-layout"),h&&h(t,{left:e,top:o,width:a,height:n});l()}(a,t.left,t.top,r,d,h,e.onLayout)}))}}}])})); +//# sourceMappingURL=opentok-layout.min.js.map \ No newline at end of file diff --git a/pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js b/pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js new file mode 100644 index 0000000..ff186e4 --- /dev/null +++ b/pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js @@ -0,0 +1,2 @@ +/*! For license information please see openvidu-browser-3.0.0-dev2.min.js.LICENSE.txt */ +(()=>{var e={7319:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=n(8608),r={getLiveKitURL(){const e=d("url");if(!e)throw new Error("url is not found in query string");return e},getAccessToken(){const e=d("token");if(!e)throw new Error("token is not found in query string");return e},getLayout(){if(a.layout)return a.layout;const e=d("layout");return null!=e?e:""},setRoom(e){o&&o.off(i.RoomEvent.Disconnected,r.endRecording),o=e,o.localParticipant.on(i.ParticipantEvent.ParticipantMetadataChanged,c),o.on(i.RoomEvent.Disconnected,r.endRecording),c()},startRecording(){console.log("START_RECORDING")},endRecording(){o=void 0,console.log("END_RECORDING")},onLayoutChanged(e){s=e}};let o,s,a={layout:""};function c(){const e=null==o?void 0:o.localParticipant.metadata;if(e){const t=JSON.parse(e);t&&t.layout!==a.layout&&(a=t,s(a.layout))}}function d(e){return new URLSearchParams(window.location.search).get(e)}t.default=r},6617:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(r=i))})),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(9040)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},9040:(e,t,n)=>{e.exports=function(e){function t(e){let n,r,o,s=null;function a(...e){if(!a.enabled)return;const i=a,r=Number(new Date),o=r-(n||r);i.diff=o,i.prev=n,i.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";s++;const o=t.formatters[r];if("function"==typeof o){const t=e[s];n=o.call(i,t),e.splice(s,1),s--}return n})),t.formatArgs.call(i,e),(i.log||t.log).apply(i,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),r=i.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{var t=1e3,n=60*t,i=60*n,r=24*i,o=7*r;function s(e,t,n,i){var r=t>=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}e.exports=function(e,a){a=a||{};var c,d,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(s){var a=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*r;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===l&&isFinite(e))return a.long?(c=e,(d=Math.abs(c))>=r?s(c,d,r,"day"):d>=i?s(c,d,i,"hour"):d>=n?s(c,d,n,"minute"):d>=t?s(c,d,t,"second"):c+" ms"):function(e){var o=Math.abs(e);return o>=r?Math.round(e/r)+"d":o>=i?Math.round(e/i)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},6885:(e,t,n)=>{var i,r=n(8499);"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext);var o=null;e.exports=function(e,t){var n=new r;if(!i)return n;var s,a,c,d=(t=t||{}).smoothing||.1,l=t.interval||50,u=t.threshold,h=t.play,p=t.history||10,m=!0;o=t.audioContext||o||new i,(c=o.createAnalyser()).fftSize=512,c.smoothingTimeConstant=d,a=new Float32Array(c.frequencyBinCount),e.jquery&&(e=e[0]),e instanceof HTMLAudioElement||e instanceof HTMLVideoElement?(s=o.createMediaElementSource(e),void 0===h&&(h=!0),u=u||-50):(s=o.createMediaStreamSource(e),u=u||-50),s.connect(c),h&&c.connect(o.destination),n.speaking=!1,n.suspend=function(){return o.suspend()},n.resume=function(){return o.resume()},Object.defineProperty(n,"state",{get:function(){return o.state}}),o.onstatechange=function(){n.emit("state_change",o.state)},n.setThreshold=function(e){u=e},n.setInterval=function(e){l=e},n.stop=function(){m=!1,n.emit("volume_change",-100,u),n.speaking&&(n.speaking=!1,n.emit("stopped_speaking")),c.disconnect(),s.disconnect()},n.speakingHistory=[];for(var f=0;fn&&t[i]<0&&(n=t[i]);return n}(c,a);n.emit("volume_change",e,u);var t=0;if(e>u&&!n.speaking){for(var i=n.speakingHistory.length-3;i=2&&(n.speaking=!0,n.emit("speaking"))}else if(eu)),g()}}),l)};return g(),n}},8608:function(e,t,n){!function(e){"use strict";function t(e,t){if(!e)throw new Error(t)}const i=34028234663852886e22,r=-34028234663852886e22,o=4294967295,s=2147483647,a=-2147483648;function c(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>s||eo||e<0)throw new Error("invalid uint 32: "+e)}function l(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>i||e({no:t.no,name:t.name,localName:e[t.no]}))))}function p(e,t,n){const i=Object.create(null),r=Object.create(null),o=[];for(const e of t){const t=m(e);o.push(t),i[e.name]=t,r[e.no]=t}return{typeName:e,values:o,findName:e=>i[e],findNumber:e=>r[e]}}function m(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class f{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,i=n.makeReadOptions(t);return n.readMessage(this,i.readerFactory(e),e.byteLength,i),this}fromJson(e,t){const n=this.getType(),i=n.runtime.json,r=i.makeReadOptions(t);return i.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(e){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(e instanceof Error?e.message:String(e)))}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),i=n.writerFactory();return t.writeMessage(this,i,n),i.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}var g,v;function y(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(127&i)<>4,!(128&n))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(127&i)<>>i,o=!(r>>>7==0&&0==t),s=255&(o?128|r:r);if(n.push(s),!o)return}const i=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|i:i)),r){for(let e=3;e<31;e+=7){const i=t>>>e,r=!(i>>>7==0),o=255&(r?128|i:i);if(n.push(o),!r)return}n.push(t>>>31&1)}}!function(e){e[e.DOUBLE=1]="DOUBLE",e[e.FLOAT=2]="FLOAT",e[e.INT64=3]="INT64",e[e.UINT64=4]="UINT64",e[e.INT32=5]="INT32",e[e.FIXED64=6]="FIXED64",e[e.FIXED32=7]="FIXED32",e[e.BOOL=8]="BOOL",e[e.STRING=9]="STRING",e[e.BYTES=12]="BYTES",e[e.UINT32=13]="UINT32",e[e.SFIXED32=15]="SFIXED32",e[e.SFIXED64=16]="SFIXED64",e[e.SINT32=17]="SINT32",e[e.SINT64=18]="SINT64"}(g||(g={})),function(e){e[e.BIGINT=0]="BIGINT",e[e.STRING=1]="STRING"}(v||(v={}));const k=4294967296;function T(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let i=0,r=0;function o(t,o){const s=Number(e.slice(t,o));r*=n,i=i*n+s,i>=k&&(r+=i/k|0,i%=k)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?C(i,r):S(i,r)}function E(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(k*t+e);const n=16777215&(e>>>24|t<<8),i=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*i,o=n+8147497*i,s=2*i;const a=1e7;return r>=a&&(o+=Math.floor(r/a),r%=a),o>=a&&(s+=Math.floor(o/a),o%=a),s.toString()+w(o)+w(r)}function S(e,t){return{lo:0|e,hi:0|t}}function C(e,t){return t=~t,e?e=1+~e:t+=1,S(e,t)}const w=e=>{const t=String(e);return"0000000".slice(t.length)+t};function P(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function _(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;128&e&&t<10;t++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const R=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const i="bigint"==typeof e?e:BigInt(e);if(i>n||ir||t(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const n=e=>t(/^-?[0-9]+$/.test(e),"int64 invalid: ".concat(e)),i=e=>t(/^[0-9]+$/.test(e),"uint64 invalid: ".concat(e));return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),i(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),n(e),T(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),i(e),T(e)),dec:(e,t)=>function(e,t){let n=S(e,t);const i=2147483648&n.hi;i&&(n=C(n.lo,n.hi));const r=E(n.lo,n.hi);return i?"-"+r:r}(e,t),uDec:(e,t)=>E(e,t)}}();var O;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(O||(O={}));class x{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(d(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return c(e),P(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){l(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){d(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){c(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return c(e),P(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=R.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=R.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=R.enc(e);return b(t.lo,t.hi,this.buf),this}sint64(e){let t=R.enc(e),n=t.hi>>31;return b(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=R.uEnc(e);return b(t.lo,t.hi,this.buf),this}}class I{constructor(e,t){this.varint64=y,this.uint32=_,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e){let t=this.pos;switch(e){case O.Varint:for(;128&this.buf[this.pos++];);break;case O.Bit64:this.pos+=4;case O.Bit32:this.pos+=4;break;case O.LengthDelimited:let t=this.uint32();this.pos+=t;break;case O.StartGroup:let n;for(;(n=this.tag()[1])!==O.EndGroup;)this.skip(n);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return R.dec(...this.varint64())}uint64(){return R.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,R.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return R.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return R.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function A(e,t,n){if(t===n)return!0;if(e==g.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;en[t]]}function L(e,t){return t instanceof f||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}g.DOUBLE,g.FLOAT,g.INT64,g.UINT64,g.INT32,g.UINT32,g.BOOL,g.STRING,g.BYTES;const U=Symbol("@bufbuild/protobuf/unknown-fields"),F={readUnknownFields:!0,readerFactory:e=>new I(e)},j={writeUnknownFields:!0,writerFactory:()=>new x};function V(e,t,n,i,r){let{repeated:o,localName:s}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=s&&delete e.value,e.case=s,s="value"),n.kind){case"scalar":case"enum":const a="enum"==n.kind?g.INT32:n.T;let c=q;if("scalar"==n.kind&&n.L>0&&(c=G),o){let n=e[s];if(i==O.LengthDelimited&&a!=g.STRING&&a!=g.BYTES){let e=t.uint32()+t.pos;for(;t.pos>4,s=n,o=2;break;case 2:i[r++]=(15&s)<<4|(60&n)>>2,s=n,o=3;break;case 3:i[r++]=(3&s)<<6|n,o=0}}if(1==o)throw Error("invalid base64 string.");return i.subarray(0,r)},enc(e){let t,n="",i=0,r=0;for(let o=0;o>2],r=(3&t)<<4,i=1;break;case 1:n+=J[r|t>>4],r=(15&t)<<2,i=2;break;case 2:n+=J[r|t>>6],n+=J[63&t],i=0}return i&&(n+=J[r],n+="=",1==i&&(n+="=")),n}};function Q(e,t,n){ee(t,e);const i=t.runtime.bin.makeReadOptions(n),r=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[o,s]=N(t);for(const e of r)t.runtime.bin.readField(o,i.readerFactory(e.data),t.field,e.wireType,i);return s()}function $(e,t,n,i){ee(t,e);const r=t.runtime.bin.makeReadOptions(i),o=t.runtime.bin.makeWriteOptions(i);if(Z(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const s=o.writerFactory();let a=t.field;a.opt||a.repeated||"enum"!=a.kind&&"scalar"!=a.kind||(a=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(a,n,s,o);const c=r.readerFactory(s.finish());for(;c.pose.no==t.field.no))}function ee(e,n){t(e.extendee.typeName==n.getType().typeName,"extension ".concat(e.typeName," can only be applied to message ").concat(e.extendee.typeName))}const te={ignoreUnknownFields:!1},ne={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function ie(e){return e?Object.assign(Object.assign({},te),e):te}function re(e){return e?Object.assign(Object.assign({},ne),e):ne}function oe(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":'"'.concat(e.split('"').join('\\"'),'"');default:return String(e)}}function se(e,t,n,i,r,o){let s=n.localName;if(n.oneof){if(null===t&&"scalar"==n.kind)return;e=e[n.oneof.localName]={case:s},s="value"}if(n.repeated){if(null===t)return;if(!Array.isArray(t))throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(t)));const o=e[s];for(const e of t){if(null===e)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(e)));let s;switch(n.kind){case"message":s=n.T.fromJson(e,i);break;case"enum":if(s=ce(n.T,e,i.ignoreUnknownFields,!0),void 0===s)continue;break;case"scalar":try{s=ae(n.T,e,n.L,!0)}catch(t){let i="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(e));throw t instanceof Error&&t.message.length>0&&(i+=": ".concat(t.message)),new Error(i)}}o.push(s)}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(t)));const o=e[s];for(const[s,a]of Object.entries(t)){if(null===a)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: map value null"));let c;switch(n.V.kind){case"message":c=n.V.T.fromJson(a,i);break;case"enum":if(c=ce(n.V.T,a,i.ignoreUnknownFields,!0),void 0===c)continue;break;case"scalar":try{c=ae(n.V.T,a,v.BIGINT,!0)}catch(e){let i="cannot decode map value for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(t));throw e instanceof Error&&e.message.length>0&&(i+=": ".concat(e.message)),new Error(i)}}try{o[ae(n.K,n.K==g.BOOL?"true"==s||"false"!=s&&s:s,v.BIGINT,!0).toString()]=c}catch(e){let i="cannot decode map key for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(t));throw e instanceof Error&&e.message.length>0&&(i+=": ".concat(e.message)),new Error(i)}}}else switch(n.kind){case"message":const a=n.T;if(null===t&&"google.protobuf.Value"!=a.typeName){if(n.oneof)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: null is invalid for oneof field"));return}e[s]instanceof f?e[s].fromJson(t,i):(e[s]=a.fromJson(t,i),a.fieldWrapper&&!n.oneof&&(e[s]=a.fieldWrapper.unwrapField(e[s])));break;case"enum":const c=ce(n.T,t,i.ignoreUnknownFields,o);void 0!==c&&(e[s]=c);break;case"scalar":try{e[s]=ae(n.T,t,n.L,o)}catch(e){let i="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(oe(t));throw e instanceof Error&&e.message.length>0&&(i+=": ".concat(e.message)),new Error(i)}}}function ae(e,t,n,i){switch(e){case g.DOUBLE:case g.FLOAT:if(null===t)return i?0:void 0;if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const r=Number(t);if(Number.isNaN(r))break;if(!Number.isFinite(r))break;return e==g.FLOAT&&l(r),r;case g.INT32:case g.FIXED32:case g.SFIXED32:case g.SINT32:case g.UINT32:if(null===t)return i?0:void 0;let o;if("number"==typeof t?o=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(o=Number(t)),void 0===o)break;return e==g.UINT32?d(o):c(o),o;case g.INT64:case g.SFIXED64:case g.SINT64:if(null===t)return i?R.zero:void 0;if("number"!=typeof t&&"string"!=typeof t)break;const s=R.parse(t);return n?s.toString():s;case g.FIXED64:case g.UINT64:if(null===t)return i?R.zero:void 0;if("number"!=typeof t&&"string"!=typeof t)break;const a=R.uParse(t);return n?a.toString():a;case g.BOOL:if(null===t)return!i&&void 0;if("boolean"!=typeof t)break;return t;case g.STRING:if(null===t)return i?"":void 0;if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(e){throw new Error("invalid UTF8")}return t;case g.BYTES:if(null===t)return i?new Uint8Array(0):void 0;if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return Y.dec(t)}throw new Error}function ce(e,t,n,i){if(null===t)return i?e.values[0].no:void 0;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const i=e.findName(t);if(i||n)return null==i?void 0:i.no}throw new Error("cannot decode enum ".concat(e.typeName," from JSON: ").concat(oe(t)))}function de(e,t,n,i){var r;if(void 0===t)return t;if(!n&&e.values[0].no===t)return;if(i)return t;if("google.protobuf.NullValue"==e.typeName)return null;const o=e.findNumber(t);return null!==(r=null==o?void 0:o.name)&&void 0!==r?r:t}function le(e,n,i){if(void 0!==n)switch(e){case g.INT32:case g.SFIXED32:case g.SINT32:case g.FIXED32:case g.UINT32:return t("number"==typeof n),0!=n||i?n:void 0;case g.FLOAT:case g.DOUBLE:return t("number"==typeof n),Number.isNaN(n)?"NaN":n===Number.POSITIVE_INFINITY?"Infinity":n===Number.NEGATIVE_INFINITY?"-Infinity":0!==n||i?n:void 0;case g.STRING:return t("string"==typeof n),n.length>0||i?n:void 0;case g.BOOL:return t("boolean"==typeof n),n||i?n:void 0;case g.UINT64:case g.FIXED64:case g.INT64:case g.SFIXED64:case g.SINT64:return t("bigint"==typeof n||"string"==typeof n||"number"==typeof n),i||0!=n?n.toString(10):void 0;case g.BYTES:return t(n instanceof Uint8Array),i||n.byteLength>0?Y.enc(n):void 0}}function ue(e){if(void 0===e)return e;if(e instanceof f)return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function he(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class pe{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function me(e,t){const n=ge(e);return t?n:Te(ke(n))}const fe=ge;function ge(e){let t=!1;const n=[];for(let i=0;i"".concat(e,"$"),ke=e=>ye.has(e)?be(e):e,Te=e=>ve.has(e)?be(e):e;class Ee{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=me(e,!1)}addField(e){t(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e0?": ".concat(n):""))}return r},readScalar:(t,n,i)=>ae(t,n,i,e),writeScalar:le,debug:oe}}(!0,((e,n)=>function(i,r,o){if("map"==i.kind){const s={};switch(i.V.kind){case"scalar":for(const[e,o]of Object.entries(r)){const r=n(i.V.T,o,!0);t(void 0!==r),s[e.toString()]=r}break;case"message":for(const[e,t]of Object.entries(r))s[e.toString()]=t.toJson(o);break;case"enum":const a=i.V.T;for(const[n,i]of Object.entries(r)){t(void 0===i||"number"==typeof i);const r=e(a,i,!0,o.enumAsInteger);t(void 0!==r),s[n.toString()]=r}}return o.emitDefaultValues||Object.keys(s).length>0?s:void 0}if(i.repeated){const t=[];switch(i.kind){case"scalar":for(let e=0;e0?t:void 0}if(void 0!==r)switch(i.kind){case"scalar":return n(i.T,r,!!i.oneof||i.opt||o.emitDefaultValues);case"enum":return e(i.T,r,!!i.oneof||i.opt||o.emitDefaultValues,o.enumAsInteger);case"message":return L(i.T,r).toJson(o)}})),we=Object.assign(Object.assign({},{makeReadOptions:function(e){return e?Object.assign(Object.assign({},F),e):F},makeWriteOptions:function(e){return e?Object.assign(Object.assign({},j),e):j},listUnknownFields(e){var t;return null!==(t=e[U])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[U]},writeUnknownFields(e,t){const n=e[U];if(n)for(const e of n)t.tag(e.no,e.wireType).raw(e.data)},onUnknownField(e,t,n,i){const r=e;Array.isArray(r[U])||(r[U]=[]),r[U].push({no:t,wireType:n,data:i})},readMessage(e,t,n,i,r){const o=e.getType(),s=r?t.len:t.pos+n;let a,c;for(;t.pose instanceof c?e:new c(e)));else if(void 0!==o[n]){const e=o[n];c.fieldWrapper?"google.protobuf.BytesValue"===c.typeName?r[n]=he(e):r[n]=e:r[n]=e instanceof c?e:new c(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const i=t[e.localName],r=n[e.localName];if(e.repeated){if(i.length!==r.length)return!1;switch(e.kind){case"message":return i.every(((t,n)=>e.T.equals(t,r[n])));case"scalar":return i.every(((t,n)=>A(e.T,t,r[n])));case"enum":return i.every(((e,t)=>A(g.INT32,e,r[t])))}throw new Error("repeated cannot contain ".concat(e.kind))}switch(e.kind){case"message":return e.T.equals(i,r);case"enum":return A(g.INT32,i,r);case"scalar":return A(e.T,i,r);case"oneof":if(i.case!==r.case)return!1;const t=e.findField(i.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(i.value,r.value);case"enum":return A(g.INT32,i.value,r.value);case"scalar":return A(t.T,i.value,r.value)}throw new Error("oneof cannot contain ".concat(t.kind));case"map":const n=Object.keys(i).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(i[e],r[e])));case"enum":return n.every((e=>A(g.INT32,i[e],r[e])));case"scalar":const o=e.V.T;return n.every((e=>A(o,i[e],r[e])))}}})),clone(e){const t=e.getType(),n=new t,i=n;for(const n of t.fields.byMember()){const t=e[n.localName];let r;if(n.repeated)r=t.map(ue);else if("map"==n.kind){r=i[n.localName];for(const[e,n]of Object.entries(t))r[e]=ue(n)}else r="oneof"==n.kind?n.findField(t.case)?{case:t.case,value:ue(t.value)}:{case:void 0}:ue(t);i[n.localName]=r}return n}}),{newFieldList:e=>new pe(e,_e),initFields(e){for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,i=e;if(t.repeated)i[n]=[];else switch(t.kind){case"oneof":i[n]={case:void 0};break;case"enum":i[n]=0;break;case"map":i[n]={};break;case"scalar":i[n]=M(t.T,t.L)}}}}),{syntax:"proto3",json:Ce,bin:we,util:Pe,makeMessageType(e,t,n){return function(e,t,n,i){var r;const o=null!==(r=null==i?void 0:i.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),s={[o]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[o];return Object.setPrototypeOf(s.prototype,new f),Object.assign(s,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new s).fromBinary(e,t),fromJson:(e,t)=>(new s).fromJson(e,t),fromJsonString:(e,t)=>(new s).fromJsonString(e,t),equals:(t,n)=>e.util.equals(s,t,n)}),s}(this,e,t,n)},makeEnum:function(e,t,n){const i={};for(const e of t){const t=m(e);i[t.localName]=t.no,i[t.no]=t.localName}return h(i,e,t),i},makeEnumType:p,getEnumType:function(e){const n=e[u];return t(n,"missing enum type on enum object"),n},makeExtension(e,t,n){return function(e,t,n,i){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof i?i():i;n.name=t.split(".").pop(),n.jsonName="[".concat(t,"]"),r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var Ce,we,Pe;function _e(e){var t,n,i,r;const o=[];let s;for(const a of"function"==typeof e?e():e){const e=a;if(e.localName=me(a.name,void 0!==a.oneof),e.jsonName=null!==(t=a.jsonName)&&void 0!==t?t:fe(a.name),e.repeated=null!==(n=a.repeated)&&void 0!==n&&n,"scalar"==a.kind&&(e.L=null!==(i=a.L)&&void 0!==i?i:v.BIGINT),void 0!==a.oneof){const t="string"==typeof a.oneof?a.oneof:a.oneof.name;s&&s.name==t||(s=new Ee(t)),e.oneof=s,s.addField(e)}"message"==a.kind&&(e.delimited=!1),e.packed=null!==(r=a.packed)&&void 0!==r?r:"enum"==a.kind||"scalar"==a.kind&&a.T!=g.BYTES&&a.T!=g.STRING,o.push(e)}return o}class Re extends f{constructor(e){super(),this.seconds=R.zero,this.nanos=0,Se.util.initPartial(e,this)}fromJson(e,t){if("string"!=typeof e)throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(Se.json.debug(e)));const n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(iDate.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=R.parse(i/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),this}toJson(e){const t=1e3*Number(this.seconds);if(tDate.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let n="Z";if(this.nanos>0){const e=(this.nanos+1e9).toString().substring(1);n="000000"===e.substring(3)?"."+e.substring(0,3)+"Z":"000"===e.substring(6)?"."+e.substring(0,6)+"Z":"."+e+"Z"}return new Date(t).toISOString().replace(".000Z",n)}toDate(){return new Date(1e3*Number(this.seconds)+Math.ceil(this.nanos/1e6))}static now(){return Re.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new Re({seconds:R.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return(new Re).fromBinary(e,t)}static fromJson(e,t){return(new Re).fromJson(e,t)}static fromJsonString(e,t){return(new Re).fromJsonString(e,t)}static equals(e,t){return Se.util.equals(Re,e,t)}}Re.runtime=Se,Re.typeName="google.protobuf.Timestamp",Re.fields=Se.util.newFieldList((()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]));const Oe=Se.makeEnum("livekit.AudioCodec",[{no:0,name:"DEFAULT_AC"},{no:1,name:"OPUS"},{no:2,name:"AAC"}]),xe=Se.makeEnum("livekit.VideoCodec",[{no:0,name:"DEFAULT_VC"},{no:1,name:"H264_BASELINE"},{no:2,name:"H264_MAIN"},{no:3,name:"H264_HIGH"},{no:4,name:"VP8"}]),Ie=Se.makeEnum("livekit.ImageCodec",[{no:0,name:"IC_DEFAULT"},{no:1,name:"IC_JPEG"}]),Ae=Se.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),Me=Se.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),De=Se.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),Ne=Se.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),Le=Se.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),Ue=Se.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"}]),Fe=Se.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),je=Se.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),Ve=Se.makeMessageType("livekit.Room",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:Be,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:ut}])),Be=Se.makeMessageType("livekit.Codec",(()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]));Se.makeMessageType("livekit.PlayoutDelay",(()=>[{no:1,name:"enabled",kind:"scalar",T:8},{no:2,name:"min",kind:"scalar",T:13},{no:3,name:"max",kind:"scalar",T:13}]));const Ge=Se.makeMessageType("livekit.ParticipantPermission",(()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:Se.getEnumType(Me),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8}])),qe=Se.makeMessageType("livekit.ParticipantInfo",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:Se.getEnumType(He)},{no:4,name:"tracks",kind:"message",T:Je,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:Ge},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:Se.getEnumType(We)}])),He=Se.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),We=Se.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"}]);Se.makeMessageType("livekit.Encryption",[]);const Ke=Se.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),ze=Se.makeMessageType("livekit.SimulcastCodecInfo",(()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:Xe,repeated:!0}])),Je=Se.makeMessageType("livekit.TrackInfo",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:Se.getEnumType(Ae)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:Se.getEnumType(Me)},{no:10,name:"layers",kind:"message",T:Xe,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:ze,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:Se.getEnumType(Ke)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:ut}])),Xe=Se.makeMessageType("livekit.VideoLayer",(()=>[{no:1,name:"quality",kind:"enum",T:Se.getEnumType(De)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13}])),Ye=Se.makeMessageType("livekit.DataPacket",(()=>[{no:1,name:"kind",kind:"enum",T:Se.getEnumType(Qe)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:et,oneof:"value"},{no:3,name:"speaker",kind:"message",T:$e,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:tt,oneof:"value"}])),Qe=Se.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),$e=Se.makeMessageType("livekit.ActiveSpeakerUpdate",(()=>[{no:1,name:"speakers",kind:"message",T:Ze,repeated:!0}])),Ze=Se.makeMessageType("livekit.SpeakerInfo",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}])),et=Se.makeMessageType("livekit.UserPacket",(()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0}])),tt=Se.makeMessageType("livekit.SipDTMF",(()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}])),nt=Se.makeMessageType("livekit.ParticipantTracks",(()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}])),it=Se.makeMessageType("livekit.ServerInfo",(()=>[{no:1,name:"edition",kind:"enum",T:Se.getEnumType(rt)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9}])),rt=Se.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),ot=Se.makeMessageType("livekit.ClientInfo",(()=>[{no:1,name:"sdk",kind:"enum",T:Se.getEnumType(st)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9}])),st=Se.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"}]),at=Se.makeMessageType("livekit.ClientConfiguration",(()=>[{no:1,name:"video",kind:"message",T:ct},{no:2,name:"screen",kind:"message",T:ct},{no:3,name:"resume_connection",kind:"enum",T:Se.getEnumType(Le)},{no:4,name:"disabled_codecs",kind:"message",T:dt},{no:5,name:"force_relay",kind:"enum",T:Se.getEnumType(Le)}])),ct=Se.makeMessageType("livekit.VideoConfiguration",(()=>[{no:1,name:"hardware_encoder",kind:"enum",T:Se.getEnumType(Le)}])),dt=Se.makeMessageType("livekit.DisabledCodecs",(()=>[{no:1,name:"codecs",kind:"message",T:Be,repeated:!0},{no:2,name:"publish",kind:"message",T:Be,repeated:!0}])),lt=Se.makeMessageType("livekit.RTPDrift",(()=>[{no:1,name:"start_time",kind:"message",T:Re},{no:2,name:"end_time",kind:"message",T:Re},{no:3,name:"duration",kind:"scalar",T:1},{no:4,name:"start_timestamp",kind:"scalar",T:4},{no:5,name:"end_timestamp",kind:"scalar",T:4},{no:6,name:"rtp_clock_ticks",kind:"scalar",T:4},{no:7,name:"drift_samples",kind:"scalar",T:3},{no:8,name:"drift_ms",kind:"scalar",T:1},{no:9,name:"clock_rate",kind:"scalar",T:1}]));Se.makeMessageType("livekit.RTPStats",(()=>[{no:1,name:"start_time",kind:"message",T:Re},{no:2,name:"end_time",kind:"message",T:Re},{no:3,name:"duration",kind:"scalar",T:1},{no:4,name:"packets",kind:"scalar",T:13},{no:5,name:"packet_rate",kind:"scalar",T:1},{no:6,name:"bytes",kind:"scalar",T:4},{no:39,name:"header_bytes",kind:"scalar",T:4},{no:7,name:"bitrate",kind:"scalar",T:1},{no:8,name:"packets_lost",kind:"scalar",T:13},{no:9,name:"packet_loss_rate",kind:"scalar",T:1},{no:10,name:"packet_loss_percentage",kind:"scalar",T:2},{no:11,name:"packets_duplicate",kind:"scalar",T:13},{no:12,name:"packet_duplicate_rate",kind:"scalar",T:1},{no:13,name:"bytes_duplicate",kind:"scalar",T:4},{no:40,name:"header_bytes_duplicate",kind:"scalar",T:4},{no:14,name:"bitrate_duplicate",kind:"scalar",T:1},{no:15,name:"packets_padding",kind:"scalar",T:13},{no:16,name:"packet_padding_rate",kind:"scalar",T:1},{no:17,name:"bytes_padding",kind:"scalar",T:4},{no:41,name:"header_bytes_padding",kind:"scalar",T:4},{no:18,name:"bitrate_padding",kind:"scalar",T:1},{no:19,name:"packets_out_of_order",kind:"scalar",T:13},{no:20,name:"frames",kind:"scalar",T:13},{no:21,name:"frame_rate",kind:"scalar",T:1},{no:22,name:"jitter_current",kind:"scalar",T:1},{no:23,name:"jitter_max",kind:"scalar",T:1},{no:24,name:"gap_histogram",kind:"map",K:5,V:{kind:"scalar",T:13}},{no:25,name:"nacks",kind:"scalar",T:13},{no:37,name:"nack_acks",kind:"scalar",T:13},{no:26,name:"nack_misses",kind:"scalar",T:13},{no:38,name:"nack_repeated",kind:"scalar",T:13},{no:27,name:"plis",kind:"scalar",T:13},{no:28,name:"last_pli",kind:"message",T:Re},{no:29,name:"firs",kind:"scalar",T:13},{no:30,name:"last_fir",kind:"message",T:Re},{no:31,name:"rtt_current",kind:"scalar",T:13},{no:32,name:"rtt_max",kind:"scalar",T:13},{no:33,name:"key_frames",kind:"scalar",T:13},{no:34,name:"last_key_frame",kind:"message",T:Re},{no:35,name:"layer_lock_plis",kind:"scalar",T:13},{no:36,name:"last_layer_lock_pli",kind:"message",T:Re},{no:44,name:"packet_drift",kind:"message",T:lt},{no:45,name:"report_drift",kind:"message",T:lt}]));const ut=Se.makeMessageType("livekit.TimedVersion",(()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}])),ht=Se.makeEnum("livekit.EncodedFileType",[{no:0,name:"DEFAULT_FILETYPE"},{no:1,name:"MP4"},{no:2,name:"OGG"}]),pt=Se.makeEnum("livekit.SegmentedFileProtocol",[{no:0,name:"DEFAULT_SEGMENTED_FILE_PROTOCOL"},{no:1,name:"HLS_PROTOCOL"}]),mt=Se.makeEnum("livekit.SegmentedFileSuffix",[{no:0,name:"INDEX"},{no:1,name:"TIMESTAMP"}]),ft=Se.makeEnum("livekit.ImageFileSuffix",[{no:0,name:"IMAGE_SUFFIX_INDEX"},{no:1,name:"IMAGE_SUFFIX_TIMESTAMP"}]),gt=Se.makeEnum("livekit.StreamProtocol",[{no:0,name:"DEFAULT_PROTOCOL"},{no:1,name:"RTMP"}]),vt=Se.makeEnum("livekit.EncodingOptionsPreset",[{no:0,name:"H264_720P_30"},{no:1,name:"H264_720P_60"},{no:2,name:"H264_1080P_30"},{no:3,name:"H264_1080P_60"},{no:4,name:"PORTRAIT_H264_720P_30"},{no:5,name:"PORTRAIT_H264_720P_60"},{no:6,name:"PORTRAIT_H264_1080P_30"},{no:7,name:"PORTRAIT_H264_1080P_60"}]),yt=Se.makeEnum("livekit.EgressStatus",[{no:0,name:"EGRESS_STARTING"},{no:1,name:"EGRESS_ACTIVE"},{no:2,name:"EGRESS_ENDING"},{no:3,name:"EGRESS_COMPLETE"},{no:4,name:"EGRESS_FAILED"},{no:5,name:"EGRESS_ABORTED"},{no:6,name:"EGRESS_LIMIT_REACHED"}]),bt=Se.makeMessageType("livekit.RoomCompositeEgressRequest",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"layout",kind:"scalar",T:9},{no:3,name:"audio_only",kind:"scalar",T:8},{no:4,name:"video_only",kind:"scalar",T:8},{no:5,name:"custom_base_url",kind:"scalar",T:9},{no:6,name:"file",kind:"message",T:Ct,oneof:"output"},{no:7,name:"stream",kind:"message",T:At,oneof:"output"},{no:10,name:"segments",kind:"message",T:wt,oneof:"output"},{no:8,name:"preset",kind:"enum",T:Se.getEnumType(vt),oneof:"options"},{no:9,name:"advanced",kind:"message",T:Mt,oneof:"options"},{no:11,name:"file_outputs",kind:"message",T:Ct,repeated:!0},{no:12,name:"stream_outputs",kind:"message",T:At,repeated:!0},{no:13,name:"segment_outputs",kind:"message",T:wt,repeated:!0},{no:14,name:"image_outputs",kind:"message",T:_t,repeated:!0}])),kt=Se.makeMessageType("livekit.WebEgressRequest",(()=>[{no:1,name:"url",kind:"scalar",T:9},{no:2,name:"audio_only",kind:"scalar",T:8},{no:3,name:"video_only",kind:"scalar",T:8},{no:12,name:"await_start_signal",kind:"scalar",T:8},{no:4,name:"file",kind:"message",T:Ct,oneof:"output"},{no:5,name:"stream",kind:"message",T:At,oneof:"output"},{no:6,name:"segments",kind:"message",T:wt,oneof:"output"},{no:7,name:"preset",kind:"enum",T:Se.getEnumType(vt),oneof:"options"},{no:8,name:"advanced",kind:"message",T:Mt,oneof:"options"},{no:9,name:"file_outputs",kind:"message",T:Ct,repeated:!0},{no:10,name:"stream_outputs",kind:"message",T:At,repeated:!0},{no:11,name:"segment_outputs",kind:"message",T:wt,repeated:!0},{no:13,name:"image_outputs",kind:"message",T:_t,repeated:!0}])),Tt=Se.makeMessageType("livekit.ParticipantEgressRequest",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"screen_share",kind:"scalar",T:8},{no:4,name:"preset",kind:"enum",T:Se.getEnumType(vt),oneof:"options"},{no:5,name:"advanced",kind:"message",T:Mt,oneof:"options"},{no:6,name:"file_outputs",kind:"message",T:Ct,repeated:!0},{no:7,name:"stream_outputs",kind:"message",T:At,repeated:!0},{no:8,name:"segment_outputs",kind:"message",T:wt,repeated:!0},{no:9,name:"image_outputs",kind:"message",T:_t,repeated:!0}])),Et=Se.makeMessageType("livekit.TrackCompositeEgressRequest",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"audio_track_id",kind:"scalar",T:9},{no:3,name:"video_track_id",kind:"scalar",T:9},{no:4,name:"file",kind:"message",T:Ct,oneof:"output"},{no:5,name:"stream",kind:"message",T:At,oneof:"output"},{no:8,name:"segments",kind:"message",T:wt,oneof:"output"},{no:6,name:"preset",kind:"enum",T:Se.getEnumType(vt),oneof:"options"},{no:7,name:"advanced",kind:"message",T:Mt,oneof:"options"},{no:11,name:"file_outputs",kind:"message",T:Ct,repeated:!0},{no:12,name:"stream_outputs",kind:"message",T:At,repeated:!0},{no:13,name:"segment_outputs",kind:"message",T:wt,repeated:!0},{no:14,name:"image_outputs",kind:"message",T:_t,repeated:!0}])),St=Se.makeMessageType("livekit.TrackEgressRequest",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"track_id",kind:"scalar",T:9},{no:3,name:"file",kind:"message",T:Pt,oneof:"output"},{no:4,name:"websocket_url",kind:"scalar",T:9,oneof:"output"}])),Ct=Se.makeMessageType("livekit.EncodedFileOutput",(()=>[{no:1,name:"file_type",kind:"enum",T:Se.getEnumType(ht)},{no:2,name:"filepath",kind:"scalar",T:9},{no:6,name:"disable_manifest",kind:"scalar",T:8},{no:3,name:"s3",kind:"message",T:Rt,oneof:"output"},{no:4,name:"gcp",kind:"message",T:Ot,oneof:"output"},{no:5,name:"azure",kind:"message",T:xt,oneof:"output"},{no:7,name:"aliOSS",kind:"message",T:It,oneof:"output"}])),wt=Se.makeMessageType("livekit.SegmentedFileOutput",(()=>[{no:1,name:"protocol",kind:"enum",T:Se.getEnumType(pt)},{no:2,name:"filename_prefix",kind:"scalar",T:9},{no:3,name:"playlist_name",kind:"scalar",T:9},{no:11,name:"live_playlist_name",kind:"scalar",T:9},{no:4,name:"segment_duration",kind:"scalar",T:13},{no:10,name:"filename_suffix",kind:"enum",T:Se.getEnumType(mt)},{no:8,name:"disable_manifest",kind:"scalar",T:8},{no:5,name:"s3",kind:"message",T:Rt,oneof:"output"},{no:6,name:"gcp",kind:"message",T:Ot,oneof:"output"},{no:7,name:"azure",kind:"message",T:xt,oneof:"output"},{no:9,name:"aliOSS",kind:"message",T:It,oneof:"output"}])),Pt=Se.makeMessageType("livekit.DirectFileOutput",(()=>[{no:1,name:"filepath",kind:"scalar",T:9},{no:5,name:"disable_manifest",kind:"scalar",T:8},{no:2,name:"s3",kind:"message",T:Rt,oneof:"output"},{no:3,name:"gcp",kind:"message",T:Ot,oneof:"output"},{no:4,name:"azure",kind:"message",T:xt,oneof:"output"},{no:6,name:"aliOSS",kind:"message",T:It,oneof:"output"}])),_t=Se.makeMessageType("livekit.ImageOutput",(()=>[{no:1,name:"capture_interval",kind:"scalar",T:13},{no:2,name:"width",kind:"scalar",T:5},{no:3,name:"height",kind:"scalar",T:5},{no:4,name:"filename_prefix",kind:"scalar",T:9},{no:5,name:"filename_suffix",kind:"enum",T:Se.getEnumType(ft)},{no:6,name:"image_codec",kind:"enum",T:Se.getEnumType(Ie)},{no:7,name:"disable_manifest",kind:"scalar",T:8},{no:8,name:"s3",kind:"message",T:Rt,oneof:"output"},{no:9,name:"gcp",kind:"message",T:Ot,oneof:"output"},{no:10,name:"azure",kind:"message",T:xt,oneof:"output"},{no:11,name:"aliOSS",kind:"message",T:It,oneof:"output"}])),Rt=Se.makeMessageType("livekit.S3Upload",(()=>[{no:1,name:"access_key",kind:"scalar",T:9},{no:2,name:"secret",kind:"scalar",T:9},{no:3,name:"region",kind:"scalar",T:9},{no:4,name:"endpoint",kind:"scalar",T:9},{no:5,name:"bucket",kind:"scalar",T:9},{no:6,name:"force_path_style",kind:"scalar",T:8},{no:7,name:"metadata",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:8,name:"tagging",kind:"scalar",T:9},{no:9,name:"content_disposition",kind:"scalar",T:9}])),Ot=Se.makeMessageType("livekit.GCPUpload",(()=>[{no:1,name:"credentials",kind:"scalar",T:9},{no:2,name:"bucket",kind:"scalar",T:9},{no:3,name:"endpoint",kind:"scalar",T:9}])),xt=Se.makeMessageType("livekit.AzureBlobUpload",(()=>[{no:1,name:"account_name",kind:"scalar",T:9},{no:2,name:"account_key",kind:"scalar",T:9},{no:3,name:"container_name",kind:"scalar",T:9}])),It=Se.makeMessageType("livekit.AliOSSUpload",(()=>[{no:1,name:"access_key",kind:"scalar",T:9},{no:2,name:"secret",kind:"scalar",T:9},{no:3,name:"region",kind:"scalar",T:9},{no:4,name:"endpoint",kind:"scalar",T:9},{no:5,name:"bucket",kind:"scalar",T:9}])),At=Se.makeMessageType("livekit.StreamOutput",(()=>[{no:1,name:"protocol",kind:"enum",T:Se.getEnumType(gt)},{no:2,name:"urls",kind:"scalar",T:9,repeated:!0}])),Mt=Se.makeMessageType("livekit.EncodingOptions",(()=>[{no:1,name:"width",kind:"scalar",T:5},{no:2,name:"height",kind:"scalar",T:5},{no:3,name:"depth",kind:"scalar",T:5},{no:4,name:"framerate",kind:"scalar",T:5},{no:5,name:"audio_codec",kind:"enum",T:Se.getEnumType(Oe)},{no:6,name:"audio_bitrate",kind:"scalar",T:5},{no:11,name:"audio_quality",kind:"scalar",T:5},{no:7,name:"audio_frequency",kind:"scalar",T:5},{no:8,name:"video_codec",kind:"enum",T:Se.getEnumType(xe)},{no:9,name:"video_bitrate",kind:"scalar",T:5},{no:12,name:"video_quality",kind:"scalar",T:5},{no:10,name:"key_frame_interval",kind:"scalar",T:1}]));Se.makeMessageType("livekit.UpdateLayoutRequest",(()=>[{no:1,name:"egress_id",kind:"scalar",T:9},{no:2,name:"layout",kind:"scalar",T:9}])),Se.makeMessageType("livekit.UpdateStreamRequest",(()=>[{no:1,name:"egress_id",kind:"scalar",T:9},{no:2,name:"add_output_urls",kind:"scalar",T:9,repeated:!0},{no:3,name:"remove_output_urls",kind:"scalar",T:9,repeated:!0}])),Se.makeMessageType("livekit.ListEgressRequest",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"egress_id",kind:"scalar",T:9},{no:3,name:"active",kind:"scalar",T:8}])),Se.makeMessageType("livekit.ListEgressResponse",(()=>[{no:1,name:"items",kind:"message",T:Dt,repeated:!0}])),Se.makeMessageType("livekit.StopEgressRequest",(()=>[{no:1,name:"egress_id",kind:"scalar",T:9}]));const Dt=Se.makeMessageType("livekit.EgressInfo",(()=>[{no:1,name:"egress_id",kind:"scalar",T:9},{no:2,name:"room_id",kind:"scalar",T:9},{no:13,name:"room_name",kind:"scalar",T:9},{no:3,name:"status",kind:"enum",T:Se.getEnumType(yt)},{no:10,name:"started_at",kind:"scalar",T:3},{no:11,name:"ended_at",kind:"scalar",T:3},{no:18,name:"updated_at",kind:"scalar",T:3},{no:21,name:"details",kind:"scalar",T:9},{no:9,name:"error",kind:"scalar",T:9},{no:4,name:"room_composite",kind:"message",T:bt,oneof:"request"},{no:14,name:"web",kind:"message",T:kt,oneof:"request"},{no:19,name:"participant",kind:"message",T:Tt,oneof:"request"},{no:5,name:"track_composite",kind:"message",T:Et,oneof:"request"},{no:6,name:"track",kind:"message",T:St,oneof:"request"},{no:7,name:"stream",kind:"message",T:Nt,oneof:"result"},{no:8,name:"file",kind:"message",T:Ft,oneof:"result"},{no:12,name:"segments",kind:"message",T:jt,oneof:"result"},{no:15,name:"stream_results",kind:"message",T:Lt,repeated:!0},{no:16,name:"file_results",kind:"message",T:Ft,repeated:!0},{no:17,name:"segment_results",kind:"message",T:jt,repeated:!0},{no:20,name:"image_results",kind:"message",T:Vt,repeated:!0}])),Nt=Se.makeMessageType("livekit.StreamInfoList",(()=>[{no:1,name:"info",kind:"message",T:Lt,repeated:!0}])),Lt=Se.makeMessageType("livekit.StreamInfo",(()=>[{no:1,name:"url",kind:"scalar",T:9},{no:2,name:"started_at",kind:"scalar",T:3},{no:3,name:"ended_at",kind:"scalar",T:3},{no:4,name:"duration",kind:"scalar",T:3},{no:5,name:"status",kind:"enum",T:Se.getEnumType(Ut)},{no:6,name:"error",kind:"scalar",T:9}])),Ut=Se.makeEnum("livekit.StreamInfo.Status",[{no:0,name:"ACTIVE"},{no:1,name:"FINISHED"},{no:2,name:"FAILED"}]),Ft=Se.makeMessageType("livekit.FileInfo",(()=>[{no:1,name:"filename",kind:"scalar",T:9},{no:2,name:"started_at",kind:"scalar",T:3},{no:3,name:"ended_at",kind:"scalar",T:3},{no:6,name:"duration",kind:"scalar",T:3},{no:4,name:"size",kind:"scalar",T:3},{no:5,name:"location",kind:"scalar",T:9}])),jt=Se.makeMessageType("livekit.SegmentsInfo",(()=>[{no:1,name:"playlist_name",kind:"scalar",T:9},{no:8,name:"live_playlist_name",kind:"scalar",T:9},{no:2,name:"duration",kind:"scalar",T:3},{no:3,name:"size",kind:"scalar",T:3},{no:4,name:"playlist_location",kind:"scalar",T:9},{no:9,name:"live_playlist_location",kind:"scalar",T:9},{no:5,name:"segment_count",kind:"scalar",T:3},{no:6,name:"started_at",kind:"scalar",T:3},{no:7,name:"ended_at",kind:"scalar",T:3}])),Vt=Se.makeMessageType("livekit.ImagesInfo",(()=>[{no:1,name:"image_count",kind:"scalar",T:3},{no:2,name:"started_at",kind:"scalar",T:3},{no:3,name:"ended_at",kind:"scalar",T:3}])),Bt=Se.makeMessageType("livekit.AutoParticipantEgress",(()=>[{no:1,name:"preset",kind:"enum",T:Se.getEnumType(vt),oneof:"options"},{no:2,name:"advanced",kind:"message",T:Mt,oneof:"options"},{no:3,name:"file_outputs",kind:"message",T:Ct,repeated:!0},{no:4,name:"segment_outputs",kind:"message",T:wt,repeated:!0}])),Gt=Se.makeMessageType("livekit.AutoTrackEgress",(()=>[{no:1,name:"filepath",kind:"scalar",T:9},{no:5,name:"disable_manifest",kind:"scalar",T:8},{no:2,name:"s3",kind:"message",T:Rt,oneof:"output"},{no:3,name:"gcp",kind:"message",T:Ot,oneof:"output"},{no:4,name:"azure",kind:"message",T:xt,oneof:"output"}]));Se.makeMessageType("livekit.CreateRoomRequest",(()=>[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"empty_timeout",kind:"scalar",T:13},{no:10,name:"departure_timeout",kind:"scalar",T:13},{no:3,name:"max_participants",kind:"scalar",T:13},{no:4,name:"node_id",kind:"scalar",T:9},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"egress",kind:"message",T:qt},{no:7,name:"min_playout_delay",kind:"scalar",T:13},{no:8,name:"max_playout_delay",kind:"scalar",T:13},{no:9,name:"sync_streams",kind:"scalar",T:8}]));const qt=Se.makeMessageType("livekit.RoomEgress",(()=>[{no:1,name:"room",kind:"message",T:bt},{no:3,name:"participant",kind:"message",T:Bt},{no:2,name:"tracks",kind:"message",T:Gt}]));Se.makeMessageType("livekit.ListRoomsRequest",(()=>[{no:1,name:"names",kind:"scalar",T:9,repeated:!0}])),Se.makeMessageType("livekit.ListRoomsResponse",(()=>[{no:1,name:"rooms",kind:"message",T:Ve,repeated:!0}])),Se.makeMessageType("livekit.DeleteRoomRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9}])),Se.makeMessageType("livekit.DeleteRoomResponse",[]),Se.makeMessageType("livekit.ListParticipantsRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9}])),Se.makeMessageType("livekit.ListParticipantsResponse",(()=>[{no:1,name:"participants",kind:"message",T:qe,repeated:!0}])),Se.makeMessageType("livekit.RoomParticipantIdentity",(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9}])),Se.makeMessageType("livekit.RemoveParticipantResponse",[]),Se.makeMessageType("livekit.MuteRoomTrackRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"track_sid",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8}])),Se.makeMessageType("livekit.MuteRoomTrackResponse",(()=>[{no:1,name:"track",kind:"message",T:Je}])),Se.makeMessageType("livekit.UpdateParticipantRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"metadata",kind:"scalar",T:9},{no:4,name:"permission",kind:"message",T:Ge},{no:5,name:"name",kind:"scalar",T:9}])),Se.makeMessageType("livekit.UpdateSubscriptionsRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"subscribe",kind:"scalar",T:8},{no:5,name:"participant_tracks",kind:"message",T:nt,repeated:!0}])),Se.makeMessageType("livekit.UpdateSubscriptionsResponse",[]),Se.makeMessageType("livekit.SendDataRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"data",kind:"scalar",T:12},{no:3,name:"kind",kind:"enum",T:Se.getEnumType(Qe)},{no:4,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:5,name:"topic",kind:"scalar",T:9,opt:!0}])),Se.makeMessageType("livekit.SendDataResponse",[]),Se.makeMessageType("livekit.UpdateRoomMetadataRequest",(()=>[{no:1,name:"room",kind:"scalar",T:9},{no:2,name:"metadata",kind:"scalar",T:9}]));const Ht=Se.makeEnum("livekit.JobType",[{no:0,name:"JT_ROOM"},{no:1,name:"JT_PUBLISHER"}]),Wt=Se.makeEnum("livekit.WorkerStatus",[{no:0,name:"WS_AVAILABLE"},{no:1,name:"WS_FULL"}]),Kt=Se.makeEnum("livekit.JobStatus",[{no:0,name:"JS_UNKNOWN"},{no:1,name:"JS_SUCCESS"},{no:2,name:"JS_FAILED"}]);Se.makeMessageType("livekit.AgentInfo",(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"version",kind:"scalar",T:9}]));const zt=Se.makeMessageType("livekit.Job",(()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:Se.getEnumType(Ht)},{no:3,name:"room",kind:"message",T:Ve},{no:4,name:"participant",kind:"message",T:qe,opt:!0}]));Se.makeMessageType("livekit.WorkerMessage",(()=>[{no:1,name:"register",kind:"message",T:Jt,oneof:"message"},{no:2,name:"availability",kind:"message",T:Qt,oneof:"message"},{no:3,name:"status",kind:"message",T:en,oneof:"message"},{no:4,name:"job_update",kind:"message",T:$t,oneof:"message"}])),Se.makeMessageType("livekit.ServerMessage",(()=>[{no:1,name:"register",kind:"message",T:Xt,oneof:"message"},{no:2,name:"availability",kind:"message",T:Yt,oneof:"message"},{no:3,name:"assignment",kind:"message",T:Zt,oneof:"message"}]));const Jt=Se.makeMessageType("livekit.RegisterWorkerRequest",(()=>[{no:1,name:"type",kind:"enum",T:Se.getEnumType(Ht)},{no:2,name:"worker_id",kind:"scalar",T:9},{no:3,name:"version",kind:"scalar",T:9},{no:4,name:"name",kind:"scalar",T:9}])),Xt=Se.makeMessageType("livekit.RegisterWorkerResponse",(()=>[{no:1,name:"worker_id",kind:"scalar",T:9},{no:2,name:"server_version",kind:"scalar",T:9}])),Yt=Se.makeMessageType("livekit.AvailabilityRequest",(()=>[{no:1,name:"job",kind:"message",T:zt}])),Qt=Se.makeMessageType("livekit.AvailabilityResponse",(()=>[{no:1,name:"job_id",kind:"scalar",T:9},{no:2,name:"available",kind:"scalar",T:8}])),$t=Se.makeMessageType("livekit.JobStatusUpdate",(()=>[{no:1,name:"job_id",kind:"scalar",T:9},{no:2,name:"status",kind:"enum",T:Se.getEnumType(Kt)},{no:3,name:"error",kind:"scalar",T:9},{no:4,name:"user_data",kind:"scalar",T:9}])),Zt=Se.makeMessageType("livekit.JobAssignment",(()=>[{no:1,name:"job",kind:"message",T:zt}])),en=Se.makeMessageType("livekit.UpdateWorkerStatus",(()=>[{no:1,name:"status",kind:"enum",T:Se.getEnumType(Wt)}])),tn=Se.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),nn=Se.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),rn=Se.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),on=Se.makeMessageType("livekit.SignalRequest",(()=>[{no:1,name:"offer",kind:"message",T:fn,oneof:"message"},{no:2,name:"answer",kind:"message",T:fn,oneof:"message"},{no:3,name:"trickle",kind:"message",T:dn,oneof:"message"},{no:4,name:"add_track",kind:"message",T:cn,oneof:"message"},{no:5,name:"mute",kind:"message",T:ln,oneof:"message"},{no:6,name:"subscription",kind:"message",T:vn,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:yn,oneof:"message"},{no:8,name:"leave",kind:"message",T:bn,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:Tn,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:Dn,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:Ln,oneof:"message"},{no:13,name:"simulate",kind:"message",T:Fn,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:En,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:jn,oneof:"message"}])),sn=Se.makeMessageType("livekit.SignalResponse",(()=>[{no:1,name:"join",kind:"message",T:un,oneof:"message"},{no:2,name:"answer",kind:"message",T:fn,oneof:"message"},{no:3,name:"offer",kind:"message",T:fn,oneof:"message"},{no:4,name:"trickle",kind:"message",T:dn,oneof:"message"},{no:5,name:"update",kind:"message",T:gn,oneof:"message"},{no:6,name:"track_published",kind:"message",T:pn,oneof:"message"},{no:8,name:"leave",kind:"message",T:bn,oneof:"message"},{no:9,name:"mute",kind:"message",T:ln,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:Cn,oneof:"message"},{no:11,name:"room_update",kind:"message",T:wn,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:_n,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:On,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:An,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:Nn,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:mn,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:hn,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:Vn,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:qn,oneof:"message"}])),an=Se.makeMessageType("livekit.SimulcastCodec",(()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9}])),cn=Se.makeMessageType("livekit.AddTrackRequest",(()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:Se.getEnumType(Ae)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:Se.getEnumType(Me)},{no:9,name:"layers",kind:"message",T:Xe,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:an,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:Se.getEnumType(Ke)},{no:15,name:"stream",kind:"scalar",T:9}])),dn=Se.makeMessageType("livekit.TrickleRequest",(()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:Se.getEnumType(tn)}])),ln=Se.makeMessageType("livekit.MuteTrackRequest",(()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}])),un=Se.makeMessageType("livekit.JoinResponse",(()=>[{no:1,name:"room",kind:"message",T:Ve},{no:2,name:"participant",kind:"message",T:qe},{no:3,name:"other_participants",kind:"message",T:qe,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:Sn,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:at},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:it},{no:13,name:"sif_trailer",kind:"scalar",T:12}])),hn=Se.makeMessageType("livekit.ReconnectResponse",(()=>[{no:1,name:"ice_servers",kind:"message",T:Sn,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:at}])),pn=Se.makeMessageType("livekit.TrackPublishedResponse",(()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Je}])),mn=Se.makeMessageType("livekit.TrackUnpublishedResponse",(()=>[{no:1,name:"track_sid",kind:"scalar",T:9}])),fn=Se.makeMessageType("livekit.SessionDescription",(()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9}])),gn=Se.makeMessageType("livekit.ParticipantUpdate",(()=>[{no:1,name:"participants",kind:"message",T:qe,repeated:!0}])),vn=Se.makeMessageType("livekit.UpdateSubscription",(()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:nt,repeated:!0}])),yn=Se.makeMessageType("livekit.UpdateTrackSettings",(()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:Se.getEnumType(De)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}])),bn=Se.makeMessageType("livekit.LeaveRequest",(()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:Se.getEnumType(Ue)},{no:3,name:"action",kind:"enum",T:Se.getEnumType(kn)},{no:4,name:"regions",kind:"message",T:Bn}])),kn=Se.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),Tn=Se.makeMessageType("livekit.UpdateVideoLayers",(()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:Xe,repeated:!0}])),En=Se.makeMessageType("livekit.UpdateParticipantMetadata",(()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9}])),Sn=Se.makeMessageType("livekit.ICEServer",(()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}])),Cn=Se.makeMessageType("livekit.SpeakersChanged",(()=>[{no:1,name:"speakers",kind:"message",T:Ze,repeated:!0}])),wn=Se.makeMessageType("livekit.RoomUpdate",(()=>[{no:1,name:"room",kind:"message",T:Ve}])),Pn=Se.makeMessageType("livekit.ConnectionQualityInfo",(()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:Se.getEnumType(Ne)},{no:3,name:"score",kind:"scalar",T:2}])),_n=Se.makeMessageType("livekit.ConnectionQualityUpdate",(()=>[{no:1,name:"updates",kind:"message",T:Pn,repeated:!0}])),Rn=Se.makeMessageType("livekit.StreamStateInfo",(()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:Se.getEnumType(nn)}])),On=Se.makeMessageType("livekit.StreamStateUpdate",(()=>[{no:1,name:"stream_states",kind:"message",T:Rn,repeated:!0}])),xn=Se.makeMessageType("livekit.SubscribedQuality",(()=>[{no:1,name:"quality",kind:"enum",T:Se.getEnumType(De)},{no:2,name:"enabled",kind:"scalar",T:8}])),In=Se.makeMessageType("livekit.SubscribedCodec",(()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:xn,repeated:!0}])),An=Se.makeMessageType("livekit.SubscribedQualityUpdate",(()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:xn,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:In,repeated:!0}])),Mn=Se.makeMessageType("livekit.TrackPermission",(()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}])),Dn=Se.makeMessageType("livekit.SubscriptionPermission",(()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:Mn,repeated:!0}])),Nn=Se.makeMessageType("livekit.SubscriptionPermissionUpdate",(()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}])),Ln=Se.makeMessageType("livekit.SyncState",(()=>[{no:1,name:"answer",kind:"message",T:fn},{no:2,name:"subscription",kind:"message",T:vn},{no:3,name:"publish_tracks",kind:"message",T:pn,repeated:!0},{no:4,name:"data_channels",kind:"message",T:Un,repeated:!0},{no:5,name:"offer",kind:"message",T:fn},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0}])),Un=Se.makeMessageType("livekit.DataChannelInfo",(()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:Se.getEnumType(tn)}])),Fn=Se.makeMessageType("livekit.SimulateScenario",(()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:Se.getEnumType(rn),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"}])),jn=Se.makeMessageType("livekit.Ping",(()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}])),Vn=Se.makeMessageType("livekit.Pong",(()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}])),Bn=Se.makeMessageType("livekit.RegionSettings",(()=>[{no:1,name:"regions",kind:"message",T:Gn,repeated:!0}])),Gn=Se.makeMessageType("livekit.RegionInfo",(()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}])),qn=Se.makeMessageType("livekit.SubscriptionResponse",(()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:Se.getEnumType(je)}])),Hn=Se.makeEnum("livekit.IngressInput",[{no:0,name:"RTMP_INPUT"},{no:1,name:"WHIP_INPUT"},{no:2,name:"URL_INPUT"}]),Wn=Se.makeEnum("livekit.IngressAudioEncodingPreset",[{no:0,name:"OPUS_STEREO_96KBPS"},{no:1,name:"OPUS_MONO_64KBS"}]),Kn=Se.makeEnum("livekit.IngressVideoEncodingPreset",[{no:0,name:"H264_720P_30FPS_3_LAYERS"},{no:1,name:"H264_1080P_30FPS_3_LAYERS"},{no:2,name:"H264_540P_25FPS_2_LAYERS"},{no:3,name:"H264_720P_30FPS_1_LAYER"},{no:4,name:"H264_1080P_30FPS_1_LAYER"},{no:5,name:"H264_720P_30FPS_3_LAYERS_HIGH_MOTION"},{no:6,name:"H264_1080P_30FPS_3_LAYERS_HIGH_MOTION"},{no:7,name:"H264_540P_25FPS_2_LAYERS_HIGH_MOTION"},{no:8,name:"H264_720P_30FPS_1_LAYER_HIGH_MOTION"},{no:9,name:"H264_1080P_30FPS_1_LAYER_HIGH_MOTION"}]);Se.makeMessageType("livekit.CreateIngressRequest",(()=>[{no:1,name:"input_type",kind:"enum",T:Se.getEnumType(Hn)},{no:9,name:"url",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"room_name",kind:"scalar",T:9},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"participant_name",kind:"scalar",T:9},{no:10,name:"participant_metadata",kind:"scalar",T:9},{no:8,name:"bypass_transcoding",kind:"scalar",T:8},{no:6,name:"audio",kind:"message",T:zn},{no:7,name:"video",kind:"message",T:Jn}]));const zn=Se.makeMessageType("livekit.IngressAudioOptions",(()=>[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"source",kind:"enum",T:Se.getEnumType(Me)},{no:3,name:"preset",kind:"enum",T:Se.getEnumType(Wn),oneof:"encoding_options"},{no:4,name:"options",kind:"message",T:Xn,oneof:"encoding_options"}])),Jn=Se.makeMessageType("livekit.IngressVideoOptions",(()=>[{no:1,name:"name",kind:"scalar",T:9},{no:2,name:"source",kind:"enum",T:Se.getEnumType(Me)},{no:3,name:"preset",kind:"enum",T:Se.getEnumType(Kn),oneof:"encoding_options"},{no:4,name:"options",kind:"message",T:Yn,oneof:"encoding_options"}])),Xn=Se.makeMessageType("livekit.IngressAudioEncodingOptions",(()=>[{no:1,name:"audio_codec",kind:"enum",T:Se.getEnumType(Oe)},{no:2,name:"bitrate",kind:"scalar",T:13},{no:3,name:"disable_dtx",kind:"scalar",T:8},{no:4,name:"channels",kind:"scalar",T:13}])),Yn=Se.makeMessageType("livekit.IngressVideoEncodingOptions",(()=>[{no:1,name:"video_codec",kind:"enum",T:Se.getEnumType(xe)},{no:2,name:"frame_rate",kind:"scalar",T:1},{no:3,name:"layers",kind:"message",T:Xe,repeated:!0}])),Qn=Se.makeMessageType("livekit.IngressInfo",(()=>[{no:1,name:"ingress_id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"stream_key",kind:"scalar",T:9},{no:4,name:"url",kind:"scalar",T:9},{no:5,name:"input_type",kind:"enum",T:Se.getEnumType(Hn)},{no:13,name:"bypass_transcoding",kind:"scalar",T:8},{no:6,name:"audio",kind:"message",T:zn},{no:7,name:"video",kind:"message",T:Jn},{no:8,name:"room_name",kind:"scalar",T:9},{no:9,name:"participant_identity",kind:"scalar",T:9},{no:10,name:"participant_name",kind:"scalar",T:9},{no:14,name:"participant_metadata",kind:"scalar",T:9},{no:11,name:"reusable",kind:"scalar",T:8},{no:12,name:"state",kind:"message",T:$n}])),$n=Se.makeMessageType("livekit.IngressState",(()=>[{no:1,name:"status",kind:"enum",T:Se.getEnumType(Zn)},{no:2,name:"error",kind:"scalar",T:9},{no:3,name:"video",kind:"message",T:ei},{no:4,name:"audio",kind:"message",T:ti},{no:5,name:"room_id",kind:"scalar",T:9},{no:7,name:"started_at",kind:"scalar",T:3},{no:8,name:"ended_at",kind:"scalar",T:3},{no:9,name:"resource_id",kind:"scalar",T:9},{no:6,name:"tracks",kind:"message",T:Je,repeated:!0}])),Zn=Se.makeEnum("livekit.IngressState.Status",[{no:0,name:"ENDPOINT_INACTIVE"},{no:1,name:"ENDPOINT_BUFFERING"},{no:2,name:"ENDPOINT_PUBLISHING"},{no:3,name:"ENDPOINT_ERROR"},{no:4,name:"ENDPOINT_COMPLETE"}]),ei=Se.makeMessageType("livekit.InputVideoState",(()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"average_bitrate",kind:"scalar",T:13},{no:3,name:"width",kind:"scalar",T:13},{no:4,name:"height",kind:"scalar",T:13},{no:5,name:"framerate",kind:"scalar",T:1}])),ti=Se.makeMessageType("livekit.InputAudioState",(()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"average_bitrate",kind:"scalar",T:13},{no:3,name:"channels",kind:"scalar",T:13},{no:4,name:"sample_rate",kind:"scalar",T:13}]));Se.makeMessageType("livekit.UpdateIngressRequest",(()=>[{no:1,name:"ingress_id",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"room_name",kind:"scalar",T:9},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"participant_name",kind:"scalar",T:9},{no:9,name:"participant_metadata",kind:"scalar",T:9},{no:8,name:"bypass_transcoding",kind:"scalar",T:8,opt:!0},{no:6,name:"audio",kind:"message",T:zn},{no:7,name:"video",kind:"message",T:Jn}])),Se.makeMessageType("livekit.ListIngressRequest",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"ingress_id",kind:"scalar",T:9}])),Se.makeMessageType("livekit.ListIngressResponse",(()=>[{no:1,name:"items",kind:"message",T:Qn,repeated:!0}])),Se.makeMessageType("livekit.DeleteIngressRequest",(()=>[{no:1,name:"ingress_id",kind:"scalar",T:9}])),Se.makeMessageType("livekit.WebhookEvent",(()=>[{no:1,name:"event",kind:"scalar",T:9},{no:2,name:"room",kind:"message",T:Ve},{no:3,name:"participant",kind:"message",T:qe},{no:9,name:"egress_info",kind:"message",T:Dt},{no:10,name:"ingress_info",kind:"message",T:Qn},{no:8,name:"track",kind:"message",T:Je},{no:6,name:"id",kind:"scalar",T:9},{no:7,name:"created_at",kind:"scalar",T:3},{no:11,name:"num_dropped",kind:"scalar",T:5}])),Se.makeMessageType("livekit.CreateSIPTrunkRequest",(()=>[{no:1,name:"inbound_addresses",kind:"scalar",T:9,repeated:!0},{no:2,name:"outbound_address",kind:"scalar",T:9},{no:3,name:"outbound_number",kind:"scalar",T:9},{no:4,name:"inbound_numbers_regex",kind:"scalar",T:9,repeated:!0},{no:9,name:"inbound_numbers",kind:"scalar",T:9,repeated:!0},{no:5,name:"inbound_username",kind:"scalar",T:9},{no:6,name:"inbound_password",kind:"scalar",T:9},{no:7,name:"outbound_username",kind:"scalar",T:9},{no:8,name:"outbound_password",kind:"scalar",T:9}]));const ni=Se.makeMessageType("livekit.SIPTrunkInfo",(()=>[{no:1,name:"sip_trunk_id",kind:"scalar",T:9},{no:2,name:"inbound_addresses",kind:"scalar",T:9,repeated:!0},{no:3,name:"outbound_address",kind:"scalar",T:9},{no:4,name:"outbound_number",kind:"scalar",T:9},{no:5,name:"inbound_numbers_regex",kind:"scalar",T:9,repeated:!0},{no:10,name:"inbound_numbers",kind:"scalar",T:9,repeated:!0},{no:6,name:"inbound_username",kind:"scalar",T:9},{no:7,name:"inbound_password",kind:"scalar",T:9},{no:8,name:"outbound_username",kind:"scalar",T:9},{no:9,name:"outbound_password",kind:"scalar",T:9}]));Se.makeMessageType("livekit.ListSIPTrunkRequest",[]),Se.makeMessageType("livekit.ListSIPTrunkResponse",(()=>[{no:1,name:"items",kind:"message",T:ni,repeated:!0}])),Se.makeMessageType("livekit.DeleteSIPTrunkRequest",(()=>[{no:1,name:"sip_trunk_id",kind:"scalar",T:9}]));const ii=Se.makeMessageType("livekit.SIPDispatchRuleDirect",(()=>[{no:1,name:"room_name",kind:"scalar",T:9},{no:2,name:"pin",kind:"scalar",T:9}])),ri=Se.makeMessageType("livekit.SIPDispatchRuleIndividual",(()=>[{no:1,name:"room_prefix",kind:"scalar",T:9},{no:2,name:"pin",kind:"scalar",T:9}])),oi=Se.makeMessageType("livekit.SIPDispatchRule",(()=>[{no:1,name:"dispatch_rule_direct",kind:"message",T:ii,oneof:"rule"},{no:2,name:"dispatch_rule_individual",kind:"message",T:ri,oneof:"rule"}]));Se.makeMessageType("livekit.CreateSIPDispatchRuleRequest",(()=>[{no:1,name:"rule",kind:"message",T:oi},{no:2,name:"trunk_ids",kind:"scalar",T:9,repeated:!0},{no:3,name:"hide_phone_number",kind:"scalar",T:8}]));const si=Se.makeMessageType("livekit.SIPDispatchRuleInfo",(()=>[{no:1,name:"sip_dispatch_rule_id",kind:"scalar",T:9},{no:2,name:"rule",kind:"message",T:oi},{no:3,name:"trunk_ids",kind:"scalar",T:9,repeated:!0},{no:4,name:"hide_phone_number",kind:"scalar",T:8}]));Se.makeMessageType("livekit.ListSIPDispatchRuleRequest",[]),Se.makeMessageType("livekit.ListSIPDispatchRuleResponse",(()=>[{no:1,name:"items",kind:"message",T:si,repeated:!0}])),Se.makeMessageType("livekit.DeleteSIPDispatchRuleRequest",(()=>[{no:1,name:"sip_dispatch_rule_id",kind:"scalar",T:9}])),Se.makeMessageType("livekit.CreateSIPParticipantRequest",(()=>[{no:1,name:"sip_trunk_id",kind:"scalar",T:9},{no:2,name:"sip_call_to",kind:"scalar",T:9},{no:3,name:"room_name",kind:"scalar",T:9},{no:4,name:"participant_identity",kind:"scalar",T:9}])),Se.makeMessageType("livekit.SIPParticipantInfo",(()=>[{no:1,name:"participant_id",kind:"scalar",T:9},{no:2,name:"participant_identity",kind:"scalar",T:9},{no:3,name:"room_name",kind:"scalar",T:9}]));var ai="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};var ci={exports:{}};!function(e){var t,n;t=ai,n=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(t,n){for(var r=0;r=0&&n<=a.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(o=n,!1!==r&&function(e){var n=(i[e]||"silent").toUpperCase();if(typeof window!==t&&d){try{return void(window.localStorage[d]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(d)+"="+n+";"}catch(e){}}}(n),s.call(a,n,e),typeof console===t&&nui.getLogger(e)));function mi(e){const t=ui.getLogger(e);return t.setDefaultLevel(hi.getLevel()),t}hi.setDefaultLevel(e.LogLevel.info);const fi=ui.getLogger("lk-e2ee"),gi=7e3,vi=[0,300,1200,2700,4800,gi,gi,gi,gi,gi];class yi{constructor(e){this._retryDelays=void 0!==e?[...e]:vi}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+1e3*Math.random()}}function bi(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function ki(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){!function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)}(i,r,(t=e[n](t)).done,t.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var Ti,Ei={exports:{}},Si="object"==typeof Reflect?Reflect:null,Ci=Si&&"function"==typeof Si.apply?Si.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};Ti=Si&&"function"==typeof Si.ownKeys?Si.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var wi=Number.isNaN||function(e){return e!=e};function Pi(){Pi.init.call(this)}Ei.exports=Pi,Ei.exports.once=function(e,t){return new Promise((function(n,i){function r(n){e.removeListener(t,o),i(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}Li(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&Li(e,"error",t,{once:!0})}(e,r)}))},Pi.EventEmitter=Pi,Pi.prototype._events=void 0,Pi.prototype._eventsCount=0,Pi.prototype._maxListeners=void 0;var _i=10;function Ri(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Oi(e){return void 0===e._maxListeners?Pi.defaultMaxListeners:e._maxListeners}function xi(e,t,n,i){var r,o,s,a;if(Ri(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(r=Oi(e))>0&&s.length>r&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return e}function Ii(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ai(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=Ii.bind(i);return r.listener=n,i.wrapFn=r,r}function Mi(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=r[e];if(void 0===a)return!1;if("function"==typeof a)Ci(a,this,t);else{var c=a.length,d=Ni(a,c);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},Pi.prototype.listeners=function(e){return Mi(this,e,!0)},Pi.prototype.rawListeners=function(e){return Mi(this,e,!1)},Pi.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Di.call(e,t)},Pi.prototype.listenerCount=Di,Pi.prototype.eventNames=function(){return this._eventsCount>0?Ti(this._events):[]};var Ui=Ei.exports;let Fi=!0,ji=!0;function Vi(e,t,n){const i=e.match(t);return i&&i.length>=n&&parseInt(i[n],10)}function Bi(e,t,n){if(!e.RTCPeerConnection)return;const i=e.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(e,i){if(e!==t)return r.apply(this,arguments);const o=e=>{const t=n(e);t&&(i.handleEvent?i.handleEvent(t):i(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(i,o),r.apply(this,[e,o])};const o=i.removeEventListener;i.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const i=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,i])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function Gi(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Fi=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function qi(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(ji=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Hi(){if("object"==typeof window){if(Fi)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Wi(e,t){ji&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Ki(e){return"[object Object]"===Object.prototype.toString.call(e)}function zi(e){return Ki(e)?Object.keys(e).reduce((function(t,n){const i=Ki(e[n]),r=i?zi(e[n]):e[n],o=i&&!Object.keys(r).length;return void 0===r||o?t:Object.assign(t,{[n]:r})}),{}):e}function Ji(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((i=>{i.endsWith("Id")?Ji(e,e.get(t[i]),n):i.endsWith("Ids")&&t[i].forEach((t=>{Ji(e,e.get(t),n)}))})))}function Xi(e,t,n){const i=n?"outbound-rtp":"inbound-rtp",r=new Map;if(null===t)return r;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===i&&n.trackId===t.id&&Ji(e,n,r)}))})),r}const Yi=Hi;function Qi(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const i=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const i="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);const r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];let e={};"number"==typeof i.ideal?(e[r("min",n)]=i.ideal,t.optional.push(e),e={},e[r("max",n)]=i.ideal,t.optional.push(e)):(e[r("",n)]=i.ideal,t.optional.push(e))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",n)]=i.exact):["min","max"].forEach((e=>{void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,n)]=i[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},r=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=i(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let s=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&n.length&&t.includes("back")&&(s=n[n.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=i(e.video),Yi("chrome: "+JSON.stringify(e)),r(e)}))}e.video=i(e.video)}return Yi("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,i){r(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{i&&i(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return r(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function $i(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Zi(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const r=new Event("track");r.track=n.track,r.receiver=i,r.transceiver={receiver:i},r.streams=[t.stream],this.dispatchEvent(r)})),t.stream.getTracks().forEach((n=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const r=new Event("track");r.track=n,r.receiver=i,r.transceiver={receiver:i},r.streams=[t.stream],this.dispatchEvent(r)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Bi(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function er(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){let r=n.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function tr(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,i]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const r=function(e){const t={};return e.result().forEach((e=>{const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{n[t]=e.stat(t)})),t[n.id]=n})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const i=function(e){n(o(r(e)))};return t.apply(this,[i,e])}return new Promise(((e,n)=>{t.apply(this,[function(t){e(o(r(t)))},n])})).then(n,i)}}function nr(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>Xi(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),Bi(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>Xi(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,i;return this.getSenders().forEach((n=>{n.track===e&&(t?i=!0:t=n)})),this.getReceivers().forEach((t=>(t.track===e&&(n?i=!0:n=t),t.track===e))),i||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function ir(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const i=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(i)&&this._shimmedLocalStreams[n.id].push(i):this._shimmedLocalStreams[n.id]=[n,i],i};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();n.apply(this,arguments);const i=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(i)};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],i.apply(this,arguments)};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),r.apply(this,arguments)}}function rr(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return ir(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}i.apply(this,[t])};const r=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const i=e._reverseStreams[t],r=e._streams[i.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const r=this._streams[n.id];if(r)r.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const i=new e.MediaStream([t]);this._streams[n.id]=i,this._reverseStreams[i.id]=n,this.addStream(i)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=i[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const i=e._reverseStreams[t],r=e._streams[i.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((n=>{this._streams[n].getTracks().find((t=>e.track===t))&&(t=this._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function or(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]}))}function sr(e,t){Bi(e,"negotiationneeded",(e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var ar=Object.freeze({__proto__:null,fixNegotiationNeeded:sr,shimAddTrackRemoveTrack:rr,shimAddTrackRemoveTrackWithNative:ir,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((t=>{const i=n.video&&n.video.width,r=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},i&&(n.video.mandatory.maxWidth=i),r&&(n.video.mandatory.maxHeight=r),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))},shimGetSendersWithDtmf:er,shimGetStats:tr,shimGetUserMedia:Qi,shimMediaStream:$i,shimOnTrack:Zi,shimPeerConnection:or,shimSenderReceiverGetStats:nr});function cr(e,t){const n=e&&e.navigator,i=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,i){Wi("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,i)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},i&&i.prototype.getSettings){const t=i.prototype.getSettings;i.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(i&&i.prototype.applyConstraints){const t=i.prototype.applyConstraints;i.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function dr(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function lr(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]}));const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,o]=arguments;return i.apply(this,[e||null]).then((e=>{if(t.version<53&&!r)try{e.forEach((e=>{e.type=n[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,i)=>{e.set(i,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(r,o)}}function ur(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function hr(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),Bi(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function pr(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Wi("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function mr(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function fr(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const n=e.length>0;n&&e.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const i=t.apply(this,arguments);if(n){const{sender:t}=i,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(n).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return i})}function gr(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function vr(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function yr(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var br=Object.freeze({__proto__:null,shimAddTransceiver:fr,shimCreateAnswer:yr,shimCreateOffer:vr,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})},shimGetParameters:gr,shimGetUserMedia:cr,shimOnTrack:dr,shimPeerConnection:lr,shimRTCDataChannel:mr,shimReceiverGetStats:hr,shimRemoveStream:pr,shimSenderGetStats:ur});function kr(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((n=>t.call(this,n,e))),e.getVideoTracks().forEach((n=>t.call(this,n,e)))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach((e=>{n.includes(e.track)&&this.removeTrack(e)}))})}}function Tr(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}))}),t.apply(e,arguments)}}}function Er(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,i=t.createAnswer,r=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Promise.resolve()):r},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r};let a=function(e,t,n){const i=r.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i};t.setLocalDescription=a,a=function(e,t,n){const i=o.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i},t.setRemoteDescription=a,a=function(e,t,n){const i=s.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i},t.addIceCandidate=a}function Sr(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(Cr(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,i){t.mediaDevices.getUserMedia(e).then(n,i)}.bind(t))}function Cr(e){return e&&void 0!==e.video?Object.assign({},e,{video:zi(e.video)}):e}function wr(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;nt.generateCertificate})}function Pr(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function _r(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Rr(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Or=Object.freeze({__proto__:null,shimAudioContext:Rr,shimCallbacksAPI:Er,shimConstraints:Cr,shimCreateOfferLegacy:_r,shimGetUserMedia:Sr,shimLocalStreamsAPI:kr,shimRTCIceServerUrls:wr,shimRemoteStreamsAPI:Tr,shimTrackEventTransceiver:Pr}),xr={exports:{}};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){const n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((e=>0===e.indexOf(n)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const n={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let n;const i=e.substring(e.indexOf(" ")+1).split(";");for(let e=0;e{void 0!==e.parameters[t]?i.push(t+"="+e.parameters[t]):i.push(t)})),t+="a=fmtp:"+n+" "+i.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},i=e.indexOf(":",t);return i>-1?(n.attribute=e.substring(t+1,i),n.value=e.substring(i+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){const i=t.matchPrefix(e+n,"a=ice-ufrag:")[0],r=t.matchPrefix(e+n,"a=ice-pwd:")[0];return i&&r?{usernameFragment:i.substring(12),password:r.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(e)[0].split(" ");n.profile=i[2];for(let r=3;r{n.headerExtensions.push(t.parseExtmap(e))}));const r=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach((e=>{r.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),n},t.writeRtpDescription=function(e,n){let i="";i+="m="+e+" ",i+=n.codecs.length>0?"9":"0",i+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",i+=n.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((e=>{i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)}));let r=0;return n.codecs.forEach((e=>{e.maxptime>r&&(r=e.maxptime)})),r>0&&(i+="a=maxptime:"+r+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach((e=>{i+=t.writeExtmap(e)})),i},t.parseRtpEncodingParameters=function(e){const n=[],i=t.parseRtpParameters(e),r=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),a=s.length>0&&s[0].ssrc;let c;const d=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));d.length>0&&d[0].length>1&&d[0][0]===a&&(c=d[0][1]),i.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&c&&(t.rtx={ssrc:c}),n.push(t),r&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&a&&n.push({ssrc:a});let l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,n.forEach((e=>{e.maxBitrate=l}))),n},t.parseRtcpParameters=function(e){const n={},i=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);const r=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=r.length>0,n.compound=0===r.length;const o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let n;const i=t.matchPrefix(e,"a=msid:");if(1===i.length)return n=i[0].substring(7).split(" "),{stream:n[0],track:n[1]};const r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return r.length>0?(n=r[0].value.split(" "),{stream:n[0],track:n[1]}):void 0},t.parseSctpDescription=function(e){const n=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");let r;i.length>0&&(r=parseInt(i[0].substring(19),10)),isNaN(r)&&(r=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:n.fmt,maxMessageSize:r};const s=t.matchPrefix(e,"a=sctpmap:");if(s.length>0){const e=s[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){let n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,i){let r;const o=void 0!==n?n:2;return r=e||t.generateSessionId(),"v=0\r\no="+(i||"thisisadapterortc")+" "+r+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){const i=t.splitLines(e);for(let e=0;e(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Nr(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||Bi(e,"icecandidate",(e=>{if(e.candidate){const t=Ar.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function Lr(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=Ar.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=Ar.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(e),i=function(e,n){let i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);const r=Ar.matchPrefix(e.sdp,"a=max-message-size:");return r.length>0?i=parseInt(r[0].substring(19),10):"firefox"===t.browser&&-1!==n&&(i=2147483637),i}(arguments[0],e);let r;r=0===n&&0===i?Number.POSITIVE_INFINITY:0===n||0===i?Math.max(n,i):Math.min(n,i);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>r}),this._sctp=o}return n.apply(this,arguments)}}function Ur(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const i=arguments[0],r=i.length||i.size||i.byteLength;if("open"===e.readyState&&t.sctp&&r>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},Bi(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Fr(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}function jr(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function Vr(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Br(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.setLocalDescription;n&&0!==n.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return n.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}return e.sdp||"offer"!==e.type&&"answer"!==e.type?n.apply(this,[e]):("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>n.apply(this,[e])))})}var Gr=Object.freeze({__proto__:null,removeExtmapAllowMixed:jr,shimAddIceCandidateNullOrEmpty:Vr,shimConnectionState:Fr,shimMaxMessageSize:Lr,shimParameterlessSetLocalDescription:Br,shimRTCIceCandidate:Dr,shimRTCIceCandidateRelayProtocol:Nr,shimSendThrowTypeError:Ur});!function(){let{window:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const n=Hi,i=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.mozGetUserMedia)t.browser="firefox",t.version=Vi(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=Vi(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Vi(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),r={browserDetails:i,commonShim:Gr,extractVersion:Vi,disableLog:Gi,disableWarnings:qi,sdp:Mr};switch(i.browser){case"chrome":if(!ar||!or||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),r;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),r;n("adapter.js shimming chrome."),r.browserShim=ar,Vr(e,i),Br(e),Qi(e,i),$i(e),or(e,i),Zi(e),rr(e,i),er(e),tr(e),nr(e),sr(e,i),Dr(e),Nr(e),Fr(e),Lr(e,i),Ur(e),jr(e,i);break;case"firefox":if(!br||!lr||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),r;n("adapter.js shimming firefox."),r.browserShim=br,Vr(e,i),Br(e),cr(e,i),lr(e,i),dr(e),pr(e),ur(e),hr(e),mr(e),fr(e),gr(e),vr(e),yr(e),Dr(e),Fr(e),Lr(e,i),Ur(e);break;case"safari":if(!Or||!t.shimSafari)return n("Safari shim is not included in this adapter release."),r;n("adapter.js shimming safari."),r.browserShim=Or,Vr(e,i),Br(e),wr(e),_r(e),Er(e),kr(e),Tr(e),Pr(e),Sr(e),Rr(e),Dr(e),Nr(e),Lr(e,i),Ur(e),jr(e,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});const qr="AES-GCM",Hr="lk_e2ee",Wr={sharedKey:!1,ratchetSalt:"LKFrameEncryptionKey",ratchetWindowSize:8,failureTolerance:10,keyringSize:16};var Kr,zr,Jr,Xr,Yr,Qr,$r;function Zr(){return to()||eo()}function eo(){return void 0!==window.RTCRtpScriptTransform}function to(){return void 0!==window.RTCRtpSender&&void 0!==window.RTCRtpSender.prototype.createEncodedStreams}function no(e){return bi(this,void 0,void 0,(function*(){let t=new TextEncoder;return yield crypto.subtle.importKey("raw",t.encode(e),{name:"PBKDF2"},!1,["deriveBits","deriveKey"])}))}function io(e){return bi(this,void 0,void 0,(function*(){return yield crypto.subtle.importKey("raw",e,"HKDF",!1,["deriveBits","deriveKey"])}))}function ro(e,t){const n=(new TextEncoder).encode(t);switch(e){case"HKDF":return{name:"HKDF",salt:n,hash:"SHA-256",info:new ArrayBuffer(128)};case"PBKDF2":return{name:"PBKDF2",salt:n,hash:"SHA-256",iterations:1e5};default:throw new Error("algorithm ".concat(e," is currently unsupported"))}}e.KeyProviderEvent=void 0,(Kr=e.KeyProviderEvent||(e.KeyProviderEvent={})).SetKey="setKey",Kr.RatchetRequest="ratchetRequest",Kr.KeyRatcheted="keyRatcheted",e.KeyHandlerEvent=void 0,(e.KeyHandlerEvent||(e.KeyHandlerEvent={})).KeyRatcheted="keyRatcheted",e.EncryptionEvent=void 0,(zr=e.EncryptionEvent||(e.EncryptionEvent={})).ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",zr.EncryptionError="encryptionError",e.CryptorEvent=void 0,(e.CryptorEvent||(e.CryptorEvent={})).Error="cryptorError";class oo extends Ui.EventEmitter{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.onKeyRatcheted=(e,t)=>{hi.debug("key ratcheted event received",{material:e,keyIndex:t})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},Wr),t),this.on(e.KeyProviderEvent.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(t,n,i){const r={key:t,participantIdentity:n,keyIndex:i};if(!this.options.sharedKey&&!n)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(null!=n?n:"shared","-").concat(null!=i?i:0),r),this.emit(e.KeyProviderEvent.SetKey,r)}getKeys(){return Array.from(this.keyInfoMap.values())}getOptions(){return this.options}ratchetKey(t,n){this.emit(e.KeyProviderEvent.RatchetRequest,t,n)}}class so extends Error{constructor(e,t){super(t||"an error has occured"),this.code=e}}class ao extends so{constructor(e,t,n){super(1,e),this.status=n,this.reason=t}}class co extends so{constructor(e){super(21,null!=e?e:"device is unsupported")}}class lo extends so{constructor(e){super(20,null!=e?e:"track is invalid")}}class uo extends so{constructor(e){super(10,null!=e?e:"unsupported server")}}class ho extends so{constructor(e){super(12,null!=e?e:"unexpected connection state")}}class po extends so{constructor(e){super(13,null!=e?e:"unable to negotiate")}}function mo(e,t,n){var i,r,o;void 0===t&&(t=50),void 0===n&&(n={});var s=null!=(i=n.isImmediate)&&i,a=null!=(r=n.callback)&&r,c=n.maxWait,d=Date.now(),l=[];function u(){if(void 0!==c){var e=Date.now()-d;if(e+t>=c)return c-e}return t}var h=function(){var t=[].slice.call(arguments),n=this;return new Promise((function(i,r){var c=s&&void 0===o;if(void 0!==o&&clearTimeout(o),o=setTimeout((function(){if(o=void 0,d=Date.now(),!s){var i=e.apply(n,t);a&&a(i),l.forEach((function(e){return(0,e.resolve)(i)})),l=[]}}),u()),c){var h=e.apply(n,t);return a&&a(h),i(h)}l.push({resolve:i,reject:r})}))};return h.cancel=function(e){void 0!==o&&clearTimeout(o),l.forEach((function(t){return(0,t.reject)(e)})),l=[]},h}e.MediaDeviceFailure=void 0,(Jr=e.MediaDeviceFailure||(e.MediaDeviceFailure={})).PermissionDenied="PermissionDenied",Jr.NotFound="NotFound",Jr.DeviceInUse="DeviceInUse",Jr.Other="Other",function(e){e.getFailure=function(t){if(t&&"name"in t)return"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?e.NotFound:"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?e.PermissionDenied:"NotReadableError"===t.name||"TrackStartError"===t.name?e.DeviceInUse:e.Other}}(e.MediaDeviceFailure||(e.MediaDeviceFailure={})),e.RoomEvent=void 0,(Xr=e.RoomEvent||(e.RoomEvent={})).Connected="connected",Xr.Reconnecting="reconnecting",Xr.Reconnected="reconnected",Xr.Disconnected="disconnected",Xr.ConnectionStateChanged="connectionStateChanged",Xr.MediaDevicesChanged="mediaDevicesChanged",Xr.ParticipantConnected="participantConnected",Xr.ParticipantDisconnected="participantDisconnected",Xr.TrackPublished="trackPublished",Xr.TrackSubscribed="trackSubscribed",Xr.TrackSubscriptionFailed="trackSubscriptionFailed",Xr.TrackUnpublished="trackUnpublished",Xr.TrackUnsubscribed="trackUnsubscribed",Xr.TrackMuted="trackMuted",Xr.TrackUnmuted="trackUnmuted",Xr.LocalTrackPublished="localTrackPublished",Xr.LocalTrackUnpublished="localTrackUnpublished",Xr.LocalAudioSilenceDetected="localAudioSilenceDetected",Xr.ActiveSpeakersChanged="activeSpeakersChanged",Xr.ParticipantMetadataChanged="participantMetadataChanged",Xr.ParticipantNameChanged="participantNameChanged",Xr.RoomMetadataChanged="roomMetadataChanged",Xr.DataReceived="dataReceived",Xr.ConnectionQualityChanged="connectionQualityChanged",Xr.TrackStreamStateChanged="trackStreamStateChanged",Xr.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",Xr.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",Xr.AudioPlaybackStatusChanged="audioPlaybackChanged",Xr.VideoPlaybackStatusChanged="videoPlaybackChanged",Xr.MediaDevicesError="mediaDevicesError",Xr.ParticipantPermissionsChanged="participantPermissionsChanged",Xr.SignalConnected="signalConnected",Xr.RecordingStatusChanged="recordingStatusChanged",Xr.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",Xr.EncryptionError="encryptionError",Xr.DCBufferStatusChanged="dcBufferStatusChanged",Xr.ActiveDeviceChanged="activeDeviceChanged",e.ParticipantEvent=void 0,(Yr=e.ParticipantEvent||(e.ParticipantEvent={})).TrackPublished="trackPublished",Yr.TrackSubscribed="trackSubscribed",Yr.TrackSubscriptionFailed="trackSubscriptionFailed",Yr.TrackUnpublished="trackUnpublished",Yr.TrackUnsubscribed="trackUnsubscribed",Yr.TrackMuted="trackMuted",Yr.TrackUnmuted="trackUnmuted",Yr.LocalTrackPublished="localTrackPublished",Yr.LocalTrackUnpublished="localTrackUnpublished",Yr.ParticipantMetadataChanged="participantMetadataChanged",Yr.ParticipantNameChanged="participantNameChanged",Yr.DataReceived="dataReceived",Yr.IsSpeakingChanged="isSpeakingChanged",Yr.ConnectionQualityChanged="connectionQualityChanged",Yr.TrackStreamStateChanged="trackStreamStateChanged",Yr.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",Yr.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",Yr.MediaDevicesError="mediaDevicesError",Yr.AudioStreamAcquired="audioStreamAcquired",Yr.ParticipantPermissionsChanged="participantPermissionsChanged",Yr.PCTrackAdded="pcTrackAdded",e.EngineEvent=void 0,(Qr=e.EngineEvent||(e.EngineEvent={})).TransportsCreated="transportsCreated",Qr.Connected="connected",Qr.Disconnected="disconnected",Qr.Resuming="resuming",Qr.Resumed="resumed",Qr.Restarting="restarting",Qr.Restarted="restarted",Qr.SignalResumed="signalResumed",Qr.SignalRestarted="signalRestarted",Qr.Closing="closing",Qr.MediaTrackAdded="mediaTrackAdded",Qr.ActiveSpeakersUpdate="activeSpeakersUpdate",Qr.DataPacketReceived="dataPacketReceived",Qr.RTPVideoMapUpdate="rtpVideoMapUpdate",Qr.DCBufferStatusChanged="dcBufferStatusChanged",Qr.ParticipantUpdate="participantUpdate",Qr.RoomUpdate="roomUpdate",Qr.SpeakersChanged="speakersChanged",Qr.StreamStateChanged="streamStateChanged",Qr.ConnectionQualityUpdate="connectionQualityUpdate",Qr.SubscriptionError="subscriptionError",Qr.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",Qr.RemoteMute="remoteMute",Qr.SubscribedQualityUpdate="subscribedQualityUpdate",Qr.LocalTrackUnpublished="localTrackUnpublished",Qr.Offline="offline",e.TrackEvent=void 0,($r=e.TrackEvent||(e.TrackEvent={})).Message="message",$r.Muted="muted",$r.Unmuted="unmuted",$r.Restarted="restarted",$r.Ended="ended",$r.Subscribed="subscribed",$r.Unsubscribed="unsubscribed",$r.UpdateSettings="updateSettings",$r.UpdateSubscription="updateSubscription",$r.AudioPlaybackStarted="audioPlaybackStarted",$r.AudioPlaybackFailed="audioPlaybackFailed",$r.AudioSilenceDetected="audioSilenceDetected",$r.VisibilityChanged="visibilityChanged",$r.VideoDimensionsChanged="videoDimensionsChanged",$r.VideoPlaybackStarted="videoPlaybackStarted",$r.VideoPlaybackFailed="videoPlaybackFailed",$r.ElementAttached="elementAttached",$r.ElementDetached="elementDetached",$r.UpstreamPaused="upstreamPaused",$r.UpstreamResumed="upstreamResumed",$r.SubscriptionPermissionChanged="subscriptionPermissionChanged",$r.SubscriptionStatusChanged="subscriptionStatusChanged",$r.SubscriptionFailed="subscriptionFailed",$r.TrackProcessorUpdate="trackProcessorUpdate";const fo=/version\/(\d+(\.?_?\d+)+)/i;let go;function vo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(void 0===e&&"undefined"==typeof navigator)return;const n=(null!=e?e:navigator.userAgent).toLowerCase();if(void 0===go||t){const e=yo.find((e=>{let{test:t}=e;return t.test(n)}));go=null==e?void 0:e.describe(n)}return go}const yo=[{test:/firefox|iceweasel|fxios/i,describe:e=>({name:"Firefox",version:bo(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes("fxios")?"iOS":void 0})},{test:/chrom|crios|crmo/i,describe:e=>({name:"Chrome",version:bo(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes("crios")?"iOS":void 0})},{test:/safari|applewebkit/i,describe:e=>({name:"Safari",version:bo(fo,e),os:e.includes("mobile/")?"iOS":"macOS"})}];function bo(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const i=t.match(e);return i&&i.length>=n&&i[n]||""}const ko="2.0.10";class To{}To.setTimeout=function(){return setTimeout(...arguments)},To.setInterval=function(){return setInterval(...arguments)},To.clearTimeout=function(){return clearTimeout(...arguments)},To.clearInterval=function(){return clearInterval(...arguments)};class Eo{constructor(e,t,n,i,r){if("object"==typeof e)this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else{if(void 0===t||void 0===n)throw new TypeError("Unsupported options: provide at least width, height and maxBitrate");this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:n,maxFramerate:i,priority:r}}}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const So=["vp8","h264"],Co=["vp8","h264","vp9","av1"];function wo(e){return!!So.find((t=>t===e))}var Po;e.AudioPresets=void 0,(Po=e.AudioPresets||(e.AudioPresets={})).telephone={maxBitrate:12e3},Po.speech={maxBitrate:2e4},Po.music={maxBitrate:32e3},Po.musicStereo={maxBitrate:48e3},Po.musicHighQuality={maxBitrate:64e3},Po.musicHighQualityStereo={maxBitrate:96e3};const _o={h90:new Eo(160,90,9e4,20),h180:new Eo(320,180,16e4,20),h216:new Eo(384,216,18e4,20),h360:new Eo(640,360,45e4,20),h540:new Eo(960,540,8e5,25),h720:new Eo(1280,720,17e5,30),h1080:new Eo(1920,1080,3e6,30),h1440:new Eo(2560,1440,5e6,30),h2160:new Eo(3840,2160,8e6,30)},Ro={h120:new Eo(160,120,7e4,20),h180:new Eo(240,180,125e3,20),h240:new Eo(320,240,14e4,20),h360:new Eo(480,360,33e4,20),h480:new Eo(640,480,5e5,20),h540:new Eo(720,540,6e5,25),h720:new Eo(960,720,13e5,30),h1080:new Eo(1440,1080,23e5,30),h1440:new Eo(1920,1440,38e5,30)},Oo={h360fps3:new Eo(640,360,2e5,3,"medium"),h360fps15:new Eo(640,360,4e5,15,"medium"),h720fps5:new Eo(1280,720,8e5,5,"medium"),h720fps15:new Eo(1280,720,15e5,15,"medium"),h720fps30:new Eo(1280,720,2e6,30,"medium"),h1080fps15:new Eo(1920,1080,25e5,15,"medium"),h1080fps30:new Eo(1920,1080,5e6,30,"medium"),original:new Eo(0,0,7e6,30,"medium")},xo=[];e.VideoQuality=void 0,function(e){e[e.LOW=0]="LOW",e[e.MEDIUM=1]="MEDIUM",e[e.HIGH=2]="HIGH"}(e.VideoQuality||(e.VideoQuality={}));class Io extends Ui.EventEmitter{constructor(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r;super(),this.attachedElements=[],this.isMuted=!1,this.streamState=Io.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=hi,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),"hidden"===document.visibilityState?this.backgroundTimeout=setTimeout((()=>this.handleAppVisibilityChanged()),5e3):this.handleAppVisibilityChanged()},this.log=mi(null!==(r=i.loggerName)&&void 0!==r?r:e.LoggerNames.Track),this.loggerContextCb=i.loggerContextCb,this.setMaxListeners(100),this.kind=n,this._mediaStreamTrack=t,this._mediaStreamID=t.id,this.source=Io.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this)),Bo(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(t){let n="audio";this.kind===Io.Kind.Video&&(n="video"),0===this.attachedElements.length&&Io.Kind.Video&&this.addAppVisibilityListener(),t||("audio"===n&&(xo.forEach((e=>{null!==e.parentElement||t||(t=e)})),t&&xo.splice(xo.indexOf(t),1)),t||(t=document.createElement(n))),this.attachedElements.includes(t)||this.attachedElements.push(t),Ao(this.mediaStreamTrack,t);const i=t.srcObject.getTracks(),r=i.some((e=>"audio"===e.kind));return t.play().then((()=>{this.emit(r?e.TrackEvent.AudioPlaybackStarted:e.TrackEvent.VideoPlaybackStarted)})).catch((n=>{"NotAllowedError"===n.name?this.emit(r?e.TrackEvent.AudioPlaybackFailed:e.TrackEvent.VideoPlaybackFailed,n):"AbortError"===n.name?hi.debug("".concat(r?"audio":"video"," playback aborted, likely due to new play request")):hi.warn("could not playback ".concat(r?"audio":"video"),n),r&&t&&i.some((e=>"video"===e.kind))&&"NotAllowedError"===n.name&&(t.muted=!0,t.play().catch((()=>{})))})),this.emit(e.TrackEvent.ElementAttached,t),t}detach(t){try{if(t){Mo(this.mediaStreamTrack,t);const n=this.attachedElements.indexOf(t);return n>=0&&(this.attachedElements.splice(n,1),this.recycleElement(t),this.emit(e.TrackEvent.ElementDetached,t)),t}const n=[];return this.attachedElements.forEach((t=>{Mo(this.mediaStreamTrack,t),n.push(t),this.recycleElement(t),this.emit(e.TrackEvent.ElementDetached,t)})),this.attachedElements=[],n}finally{0===this.attachedElements.length&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval)}updateLoggerOptions(e){e.loggerName&&(this.log=mi(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),xo.forEach((e=>{e.parentElement||(t=!1)})),t&&xo.push(e)}}handleAppVisibilityChanged(){return bi(this,void 0,void 0,(function*(){this.isInBackground="hidden"===document.visibilityState}))}addAppVisibilityListener(){ns()?(this.isInBackground="hidden"===document.visibilityState,document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){ns()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function Ao(e,t){let n,i;n=t.srcObject instanceof MediaStream?t.srcObject:new MediaStream,i="audio"===e.kind?n.getAudioTracks():n.getVideoTracks(),i.includes(e)||(i.forEach((e=>{n.removeTrack(e)})),n.addTrack(e)),Zo()&&t instanceof HTMLVideoElement||(t.autoplay=!0),t.muted=0===n.getAudioTracks().length,t instanceof HTMLVideoElement&&(t.playsInline=!0),t.srcObject!==n&&(t.srcObject=n,(Zo()||$o())&&t instanceof HTMLVideoElement&&setTimeout((()=>{t.srcObject=n,t.play().catch((()=>{}))}),0))}function Mo(e,t){if(t.srcObject instanceof MediaStream){const n=t.srcObject;n.removeTrack(e),n.getTracks().length>0?t.srcObject=n:t.srcObject=null}}function Do(e,t,n){var i;const r=null!==(i=function(e){if(void 0!==e)return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}(e))&&void 0!==i?i:{};return!0===r.audio&&(r.audio={}),!0===r.video&&(r.video={}),r.audio&&No(r.audio,t),r.video&&No(r.video,n),r}function No(e,t){return Object.keys(t).forEach((n=>{void 0===e[n]&&(e[n]=t[n])})),e}function Lo(e){const t={};if(e.video)if("object"==typeof e.video){const n={},i=n,r=e.video;Object.keys(r).forEach((e=>{"resolution"===e?No(i,r.resolution):i[e]=r[e]})),t.video=n}else t.video=e.video;else t.video=!1;return e.audio?"object"==typeof e.audio?t.audio=e.audio:t.audio=!0:t.audio=!1,t}function Uo(){const e="undefined"!=typeof window&&(window.AudioContext||window.webkitAudioContext);if(e)return new e({latencyHint:"interactive"})}function Fo(e){var t,n;let i=null===(t=e.video)||void 0===t||t;return e.resolution&&e.resolution.width>0&&e.resolution.height>0&&(i="boolean"==typeof i?{}:i,i=Zo()?Object.assign(Object.assign({},i),{width:{max:e.resolution.width},height:{max:e.resolution.height},frameRate:e.resolution.frameRate}):Object.assign(Object.assign({},i),{width:{ideal:e.resolution.width},height:{ideal:e.resolution.height},frameRate:e.resolution.frameRate})),{audio:null!==(n=e.audio)&&void 0!==n&&n,video:i,controller:e.controller,selfBrowserSurface:e.selfBrowserSurface,surfaceSwitching:e.surfaceSwitching,systemAudio:e.systemAudio,preferCurrentTab:e.preferCurrentTab}}function jo(e){const t=e.split("/")[1].toLowerCase();if(!Co.includes(t))throw Error("Video codec not supported: ".concat(t));return t}function Vo(e){const t=[];return e.forEach((e=>{void 0!==e.track&&t.push(new pn({cid:e.track.mediaStreamID,track:e.trackInfo}))})),t}function Bo(e){return e instanceof Io?{trackID:e.sid,source:e.source,muted:e.isMuted,enabled:e.mediaStreamTrack.enabled,kind:e.kind,streamID:e.mediaStreamID,streamTrackID:e.mediaStreamTrack.id}:{trackID:e.trackSid,enabled:e.isEnabled,muted:e.isMuted,trackInfo:Object.assign({mimeType:e.mimeType,name:e.trackName,encrypted:e.isEncrypted,kind:e.kind,source:e.source},e.track?Bo(e.track):{})}}!function(e){let t,n,i;!function(e){e.Audio="audio",e.Video="video",e.Unknown="unknown"}(t=e.Kind||(e.Kind={})),function(e){e.Camera="camera",e.Microphone="microphone",e.ScreenShare="screen_share",e.ScreenShareAudio="screen_share_audio",e.Unknown="unknown"}(n=e.Source||(e.Source={})),function(e){e.Active="active",e.Paused="paused",e.Unknown="unknown"}(i=e.StreamState||(e.StreamState={})),e.kindToProto=function(e){switch(e){case t.Audio:return Ae.AUDIO;case t.Video:return Ae.VIDEO;default:return Ae.DATA}},e.kindFromProto=function(e){switch(e){case Ae.AUDIO:return t.Audio;case Ae.VIDEO:return t.Video;default:return t.Unknown}},e.sourceToProto=function(e){switch(e){case n.Camera:return Me.CAMERA;case n.Microphone:return Me.MICROPHONE;case n.ScreenShare:return Me.SCREEN_SHARE;case n.ScreenShareAudio:return Me.SCREEN_SHARE_AUDIO;default:return Me.UNKNOWN}},e.sourceFromProto=function(e){switch(e){case Me.CAMERA:return n.Camera;case Me.MICROPHONE:return n.Microphone;case Me.SCREEN_SHARE:return n.ScreenShare;case Me.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}},e.streamStateFromProto=function(e){switch(e){case nn.ACTIVE:return i.Active;case nn.PAUSED:return i.Paused;default:return i.Unknown}}}(Io||(Io={}));const Go="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function qo(e){return bi(this,void 0,void 0,(function*(){return new Promise((t=>To.setTimeout(t,e)))}))}function Ho(){return"addTransceiver"in RTCPeerConnection.prototype}function Wo(){return"addTrack"in RTCPeerConnection.prototype}function Ko(){if(!("getCapabilities"in RTCRtpSender))return!1;if(Zo())return!1;const e=RTCRtpSender.getCapabilities("video");let t=!1;if(e)for(const n of e.codecs)if("video/AV1"===n.mimeType){t=!0;break}return t}function zo(){if(!("getCapabilities"in RTCRtpSender))return!1;if($o())return!1;if(Zo()){const e=vo();if((null==e?void 0:e.version)&&cs(e.version,"16")<0)return!1}const e=RTCRtpSender.getCapabilities("video");let t=!1;if(e)for(const n of e.codecs)if("video/VP9"===n.mimeType){t=!0;break}return t}function Jo(e){return"av1"===e||"vp9"===e}function Xo(e){return!!document&&(e||(e=document.createElement("audio")),"setSinkId"in e)}const Yo={Chrome:"100",Safari:"15",Firefox:"100"};function Qo(){return"undefined"!=typeof RTCPeerConnection&&(Ho()||Wo())}function $o(){var e;return"Firefox"===(null===(e=vo())||void 0===e?void 0:e.name)}function Zo(){var e;return"Safari"===(null===(e=vo())||void 0===e?void 0:e.name)}function es(){const e=vo();return"Safari"===(null==e?void 0:e.name)&&e.version.startsWith("17.")}function ts(){return!!ns()&&/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent)}function ns(){return"undefined"!=typeof document}function is(){return"ReactNative"==navigator.product}function rs(e){return e.hostname.endsWith(".livekit.cloud")||e.hostname.endsWith(".livekit.run")}function os(){if(n.g&&n.g.LiveKitReactNativeGlobal)return n.g.LiveKitReactNativeGlobal}function ss(){if(!is())return;let e=os();return e?e.platform:void 0}function as(){if(ns())return window.devicePixelRatio;if(is()){let e=os();if(e)return e.devicePixelRatio}return 1}function cs(e,t){const n=e.split("."),i=t.split("."),r=Math.min(n.length,i.length);for(let e=0;eo)return 1;if(t(us||(us=new ResizeObserver(ds)),us);let ps=null;const ms=()=>(ps||(ps=new IntersectionObserver(ls,{root:null,rootMargin:"0px"})),ps);let fs,gs;function vs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=document.createElement("canvas");r.width=e,r.height=t;const o=r.getContext("2d");null==o||o.fillRect(0,0,r.width,r.height),i&&o&&(o.beginPath(),o.arc(e/2,t/2,50,0,2*Math.PI,!0),o.closePath(),o.fillStyle="grey",o.fill());const s=r.captureStream(),[a]=s.getTracks();if(!a)throw Error("Could not get empty media stream video track");return a.enabled=n,a}function ys(){if(!gs){const e=new AudioContext,t=e.createOscillator(),n=e.createGain();n.gain.setValueAtTime(0,0);const i=e.createMediaStreamDestination();if(t.connect(n),n.connect(i),t.start(),[gs]=i.stream.getAudioTracks(),!gs)throw Error("Could not get empty media stream audio track");gs.enabled=!1}return gs.clone()}class bs{constructor(e,t){this.onFinally=t,this.promise=new Promise(((t,n)=>bi(this,void 0,void 0,(function*(){this.resolve=t,this.reject=n,e&&(yield e(t,n))})))).finally((()=>{var e;return null===(e=this.onFinally)||void 0===e?void 0:e.call(this)}))}}class ks{constructor(){this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){let e;this._locks+=1;const t=new Promise((t=>e=()=>{this._locks-=1,t()})),n=this._locking.then((()=>e));return this._locking=this._locking.then((()=>t)),n}}function Ts(e){if("string"==typeof e)return e;if(Array.isArray(e))return e[0];if(e.exact)return Array.isArray(e.exact)?e.exact[0]:e.exact;if(e.ideal)return Array.isArray(e.ideal)?e.ideal[0]:e.ideal;throw Error("could not unwrap constraint")}function Es(e){return e.startsWith("ws")?e.replace(/^(ws)/,"http"):e}const Ss="default";class Cs{static getInstance(){return void 0===this.instance&&(this.instance=new Cs),this.instance}getDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var n;return bi(this,void 0,void 0,(function*(){if((null===(n=Cs.userMediaPromiseMap)||void 0===n?void 0:n.size)>0){hi.debug("awaiting getUserMedia promise");try{e?yield Cs.userMediaPromiseMap.get(e):yield Promise.all(Cs.userMediaPromiseMap.values())}catch(e){hi.warn("error waiting for media permissons")}}let i=yield navigator.mediaDevices.enumerateDevices();if(t&&(!Zo()||!this.hasDeviceInUse(e))&&(0===i.length||i.some((t=>{const n=""===t.label,i=!e||t.kind===e;return n&&i})))){const t={video:"audioinput"!==e&&"audiooutput"!==e,audio:"videoinput"!==e},n=yield navigator.mediaDevices.getUserMedia(t);i=yield navigator.mediaDevices.enumerateDevices(),n.getTracks().forEach((e=>{e.stop()}))}return e&&(i=i.filter((t=>t.kind===e))),i}))}normalizeDeviceId(e,t,n){return bi(this,void 0,void 0,(function*(){if(t!==Ss)return t;const i=yield this.getDevices(e),r=new Map(i.map((e=>[e.groupId,0])));i.forEach((e=>{var t;return r.set(e.groupId,(null!==(t=r.get(e.groupId))&&void 0!==t?t:0)+1)}));const o=i.find((e=>{var t;return(n===e.groupId||(null!==(t=r.get(e.groupId))&&void 0!==t?t:0)>1)&&e.deviceId!==Ss}));return null==o?void 0:o.deviceId}))}hasDeviceInUse(e){return e?Cs.userMediaPromiseMap.has(e):Cs.userMediaPromiseMap.size>0}}Cs.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],Cs.userMediaPromiseMap=new Map;class ws extends Io{get constraints(){return this._constraints}constructor(t,n,i){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];super(t,n,arguments.length>4?arguments[4]:void 0),this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch((()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext))),this.debouncedTrackMuteHandler=mo((()=>bi(this,void 0,void 0,(function*(){yield this.pauseUpstream()}))),5e3),this.handleTrackUnmuteEvent=()=>bi(this,void 0,void 0,(function*(){this.debouncedTrackMuteHandler.cancel("unmute"),yield this.resumeUpstream()})),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),this.emit(e.TrackEvent.Ended,this)},this.reacquireTrack=!1,this.providedByUser=r,this.muteLock=new ks,this.pauseUpstreamLock=new ks,this.processorLock=new ks,this.restartLock=new ks,this.setMediaStreamTrack(t,!0),this._constraints=t.getConstraints(),i&&(this._constraints=i)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==Io.Kind.Video)return;const{width:e,height:t}=this._mediaStreamTrack.getSettings();return e&&t?{width:e,height:t}:void 0}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,t;return null!==(t=null===(e=this.processor)||void 0===e?void 0:e.processedTrack)&&void 0!==t?t:this._mediaStreamTrack}setMediaStreamTrack(e,t){return bi(this,void 0,void 0,(function*(){if(e===this._mediaStreamTrack&&!t)return;let n;if(this._mediaStreamTrack&&(this.attachedElements.forEach((e=>{Mo(this._mediaStreamTrack,e)})),this.debouncedTrackMuteHandler.cancel("new-track"),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener("ended",this.handleEnded),e.addEventListener("mute",this.handleTrackMuteEvent),e.addEventListener("unmute",this.handleTrackUnmuteEvent),this._constraints=e.getConstraints()),this.processor&&e){const t=yield this.processorLock.lock();try{if(this.log.debug("restarting processor",this.logContext),"unknown"===this.kind)throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(Ao(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),n=this.processor.processedTrack}finally{t()}}this.sender&&(yield this.sender.replaceTrack(null!=n?n:e)),this.providedByUser||this._mediaStreamTrack===e||this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach((t=>{Ao(null!=n?n:e,t)})))}))}waitForDimensions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;var t;return bi(this,void 0,void 0,(function*(){if(this.kind===Io.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");"iOS"===(null===(t=vo())||void 0===t?void 0:t.os)&&(yield qo(10));const n=Date.now();for(;Date.now()-n{Mo(this.mediaStreamTrack,e)})),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const i=(yield navigator.mediaDevices.getUserMedia(n)).getTracks()[0];return i.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(i),this._constraints=t,this.emit(e.TrackEvent.Restarted,this),this}finally{n()}}))}setTrackMuted(t){this.log.debug("setting ".concat(this.kind," track ").concat(t?"muted":"unmuted"),this.logContext),this.isMuted===t&&this._mediaStreamTrack.enabled!==t||(this.isMuted=t,this._mediaStreamTrack.enabled=!t,this.emit(t?e.TrackEvent.Muted:e.TrackEvent.Unmuted,this))}get needsReAcquisition(){return"live"!==this._mediaStreamTrack.readyState||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return bi(this,void 0,void 0,(function*(){yield e.handleAppVisibilityChanged.call(this),ts()&&(this.log.debug("visibility changed, is in Background: ".concat(this.isInBackground),this.logContext),this.isInBackground||!this.needsReAcquisition||this.isUserProvided||this.isMuted||(this.log.debug("track needs to be reacquired, restarting ".concat(this.source),this.logContext),yield this.restart(),this.reacquireTrack=!1))}))}stop(){var e;super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),null===(e=this.processor)||void 0===e||e.destroy(),this.processor=void 0}pauseUpstream(){return bi(this,void 0,void 0,(function*(){const t=yield this.pauseUpstreamLock.lock();try{if(!0===this._isUpstreamPaused)return;if(!this.sender)return void this.log.warn("unable to pause upstream for an unpublished track",this.logContext);this._isUpstreamPaused=!0,this.emit(e.TrackEvent.UpstreamPaused,this);const t=vo();if("Safari"===(null==t?void 0:t.name)&&cs(t.version,"12.0")<0)throw new co("pauseUpstream is not supported on Safari < 12.");yield this.sender.replaceTrack(null)}finally{t()}}))}resumeUpstream(){return bi(this,void 0,void 0,(function*(){const t=yield this.pauseUpstreamLock.lock();try{if(!1===this._isUpstreamPaused)return;if(!this.sender)return void this.log.warn("unable to resume upstream for an unpublished track",this.logContext);this._isUpstreamPaused=!1,this.emit(e.TrackEvent.UpstreamResumed,this),yield this.sender.replaceTrack(this._mediaStreamTrack)}finally{t()}}))}getRTCStatsReport(){var e;return bi(this,void 0,void 0,(function*(){if(null===(e=this.sender)||void 0===e?void 0:e.getStats)return yield this.sender.getStats()}))}setProcessor(t){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var i,r;return bi(this,void 0,void 0,(function*(){const o=yield this.processorLock.lock();try{this.log.debug("setting up processor",this.logContext),this.processorElement=null!==(i=this.processorElement)&&void 0!==i?i:document.createElement(this.kind);const o={kind:this.kind,track:this._mediaStreamTrack,element:this.processorElement,audioContext:this.audioContext};if(yield t.init(o),this.processor&&(yield this.stopProcessor()),"unknown"===this.kind)throw TypeError("cannot set processor on track of unknown kind");if(Ao(this._mediaStreamTrack,this.processorElement),this.processorElement.muted=!0,this.processorElement.play().catch((e=>this.log.error("failed to play processor element",Object.assign(Object.assign({},this.logContext),{error:e})))),this.processor=t,this.processor.processedTrack){for(const e of this.attachedElements)e!==this.processorElement&&n&&(Mo(this._mediaStreamTrack,e),Ao(this.processor.processedTrack,e));yield null===(r=this.sender)||void 0===r?void 0:r.replaceTrack(this.processor.processedTrack)}this.emit(e.TrackEvent.TrackProcessorUpdate,this.processor)}finally{o()}}))}getProcessor(){return this.processor}stopProcessor(){var t,n;return bi(this,void 0,void 0,(function*(){this.processor&&(this.log.debug("stopping processor",this.logContext),null===(t=this.processor.processedTrack)||void 0===t||t.stop(),yield this.processor.destroy(),this.processor=void 0,null===(n=this.processorElement)||void 0===n||n.remove(),this.processorElement=void 0,yield this._mediaStreamTrack.applyConstraints(this._constraints),yield this.setMediaStreamTrack(this._mediaStreamTrack,!0),this.emit(e.TrackEvent.TrackProcessorUpdate))}))}}class Ps extends Ui.EventEmitter{constructor(t){super(),this.onWorkerMessage=t=>{var n,i;const{kind:r,data:o}=t.data;switch(r){case"error":hi.error(o.error.message),this.emit(e.EncryptionEvent.EncryptionError,o.error);break;case"initAck":o.enabled&&this.keyProvider.getKeys().forEach((e=>{this.postKey(e)}));break;case"enable":if(this.encryptionEnabled!==o.enabled&&o.participantIdentity===(null===(n=this.room)||void 0===n?void 0:n.localParticipant.identity))this.emit(e.EncryptionEvent.ParticipantEncryptionStatusChanged,o.enabled,this.room.localParticipant),this.encryptionEnabled=o.enabled;else if(o.participantIdentity){const t=null===(i=this.room)||void 0===i?void 0:i.getParticipantByIdentity(o.participantIdentity);if(!t)throw TypeError("couldn't set encryption status, participant not found".concat(o.participantIdentity));this.emit(e.EncryptionEvent.ParticipantEncryptionStatusChanged,o.enabled,t)}this.encryptionEnabled&&this.keyProvider.getKeys().forEach((e=>{this.postKey(e)}));break;case"ratchetKey":this.keyProvider.emit(e.KeyProviderEvent.KeyRatcheted,o.material,o.keyIndex)}},this.onWorkerError=t=>{hi.error("e2ee worker encountered an error:",{error:t.error}),this.emit(e.EncryptionEvent.EncryptionError,t.error)},this.keyProvider=t.keyProvider,this.worker=t.worker,this.encryptionEnabled=!1}setup(e){if(!Zr())throw new co("tried to setup end-to-end encryption on an unsupported browser");if(hi.info("setting up e2ee"),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);const t={kind:"init",data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:fi.getLevel()}};this.worker&&(hi.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){hi.debug("set e2ee to ".concat(e," for participant ").concat(t)),this.postEnable(e,t)}setSifTrailer(e){e&&0!==e.length?this.postSifTrailer(e):hi.warn("ignoring server sent trailer as it's empty")}setupEngine(t){t.on(e.EngineEvent.RTPVideoMapUpdate,(e=>{this.postRTPMap(e)}))}setupEventListeners(t,n){t.on(e.RoomEvent.TrackPublished,((e,t)=>this.setParticipantCryptorEnabled(e.trackInfo.encryption!==Ke.NONE,t.identity))),t.on(e.RoomEvent.ConnectionStateChanged,(n=>{n===e.ConnectionState.Connected&&t.remoteParticipants.forEach((e=>{e.trackPublications.forEach((t=>{this.setParticipantCryptorEnabled(t.trackInfo.encryption!==Ke.NONE,e.identity)}))}))})).on(e.RoomEvent.TrackUnsubscribed,((e,t,n)=>{var i;const r={kind:"removeTransform",data:{participantIdentity:n.identity,trackId:e.mediaStreamID}};null===(i=this.worker)||void 0===i||i.postMessage(r)})).on(e.RoomEvent.TrackSubscribed,((e,t,n)=>{this.setupE2EEReceiver(e,n.identity,t.trackInfo)})).on(e.RoomEvent.SignalConnected,(()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity),n.getKeys().forEach((e=>{this.postKey(e)}))})),t.localParticipant.on(e.ParticipantEvent.LocalTrackPublished,(e=>bi(this,void 0,void 0,(function*(){this.setupE2EESender(e.track,e.track.sender)})))),n.on(e.KeyProviderEvent.SetKey,(e=>this.postKey(e))).on(e.KeyProviderEvent.RatchetRequest,((e,t)=>this.postRatchetRequest(e,t)))}postRatchetRequest(e,t){if(!this.worker)throw Error("could not ratchet key, worker is missing");const n={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:t}};this.worker.postMessage(n)}postKey(e){let{key:t,participantIdentity:n,keyIndex:i}=e;var r;if(!this.worker)throw Error("could not set key, worker is missing");const o={kind:"setKey",data:{participantIdentity:n,isPublisher:n===(null===(r=this.room)||void 0===r?void 0:r.localParticipant.identity),key:t,keyIndex:i}};this.worker.postMessage(o)}postEnable(e,t){if(!this.worker)throw new ReferenceError("failed to enable e2ee, worker is not ready");{const n={kind:"enable",data:{enabled:e,participantIdentity:t}};this.worker.postMessage(n)}}postRTPMap(e){var t;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(null===(t=this.room)||void 0===t?void 0:t.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const n={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(n)}postSifTrailer(e){if(!this.worker)throw Error("could not post SIF trailer, worker is missing");const t={kind:"setSifTrailer",data:{trailer:e}};this.worker.postMessage(t)}setupE2EEReceiver(e,t,n){if(e.receiver){if(!(null==n?void 0:n.mimeType)||""===n.mimeType)throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,t,"video"===e.kind?jo(n.mimeType):void 0)}}setupE2EESender(e,t){e instanceof ws&&t?this.handleSender(t,e.mediaStreamID,void 0):t||hi.warn("early return because sender is not ready")}handleReceiver(e,t,n,i){return bi(this,void 0,void 0,(function*(){if(this.worker){if(eo()){const r={kind:"decode",participantIdentity:n,trackId:t,codec:i};e.transform=new RTCRtpScriptTransform(this.worker,r)}else{if(Hr in e&&i){const e={kind:"updateCodec",data:{trackId:t,codec:i,participantIdentity:n}};return void this.worker.postMessage(e)}let r=e.writableStream,o=e.readableStream;if(!r||!o){const t=e.createEncodedStreams();e.writableStream=t.writable,r=t.writable,e.readableStream=t.readable,o=t.readable}const s={kind:"decode",data:{readableStream:o,writableStream:r,trackId:t,codec:i,participantIdentity:n}};this.worker.postMessage(s,[o,r])}e[Hr]=!0}}))}handleSender(e,t,n){var i;if(!(Hr in e)&&this.worker){if(!(null===(i=this.room)||void 0===i?void 0:i.localParticipant.identity)||""===this.room.localParticipant.identity)throw TypeError("local identity needs to be known in order to set up encrypted sender");if(eo()){hi.info("initialize script transform");const i={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:t,codec:n};e.transform=new RTCRtpScriptTransform(this.worker,i)}else{hi.info("initialize encoded streams");const i=e.createEncodedStreams(),r={kind:"encode",data:{readableStream:i.readable,writableStream:i.writable,codec:n,trackId:t,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(r,[i.readable,i.writable])}e[Hr]=!0}}}var _s;!function(e){e[e.WAITING=0]="WAITING",e[e.RUNNING=1]="RUNNING",e[e.COMPLETED=2]="COMPLETED"}(_s||(_s={}));class Rs{constructor(){this.pendingTasks=new Map,this.taskMutex=new ks,this.nextTaskIndex=0}run(e){return bi(this,void 0,void 0,(function*(){const t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:_s.WAITING};this.pendingTasks.set(t.id,t);const n=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=_s.RUNNING,yield e()}finally{t.status=_s.COMPLETED,this.pendingTasks.delete(t.id),n()}}))}flush(){return bi(this,void 0,void 0,(function*(){return this.run((()=>bi(this,void 0,void 0,(function*(){}))))}))}snapshot(){return Array.from(this.pendingTasks.values())}}const Os=["syncState","trickle","offer","answer","simulate","leave"];var xs;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.CONNECTED=1]="CONNECTED",e[e.RECONNECTING=2]="RECONNECTING",e[e.DISCONNECTING=3]="DISCONNECTING",e[e.DISCONNECTED=4]="DISCONNECTED"}(xs||(xs={}));class Is{get currentState(){return this.state}get isDisconnected(){return this.state===xs.DISCONNECTING||this.state===xs.DISCONNECTED}get isEstablishingConnection(){return this.state===xs.CONNECTING||this.state===xs.RECONNECTING}constructor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i;this.rtt=0,this.state=xs.DISCONNECTED,this.log=hi,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0},this.log=mi(null!==(i=n.loggerName)&&void 0!==i?i:e.LoggerNames.Signal),this.loggerContextCb=n.loggerContextCb,this.useJSON=t,this.requestQueue=new Rs,this.queuedRequests=[],this.closingLock=new ks,this.connectionLock=new ks,this.state=xs.DISCONNECTED}get logContext(){var e,t;return null!==(t=null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this))&&void 0!==t?t:{}}join(e,t,n,i){return bi(this,void 0,void 0,(function*(){return this.state=xs.CONNECTING,this.options=n,yield this.connect(e,t,n,i)}))}reconnect(e,t,n,i){return bi(this,void 0,void 0,(function*(){if(this.options)return this.state=xs.RECONNECTING,this.clearPingInterval(),yield this.connect(e,t,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:n,reconnectReason:i}));this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext)}))}connect(e,t,n,i){this.connectOptions=n,e=(e=function(e){return e.startsWith("http")?e.replace(/^(http)/,"ws"):e}(e)).replace(/\/$/,""),e+="/rtc";const r=function(e,t,n){var i;const r=new URLSearchParams;return r.set("access_token",e),n.reconnect&&(r.set("reconnect","1"),n.sid&&r.set("sid",n.sid)),r.set("auto_subscribe",n.autoSubscribe?"1":"0"),r.set("sdk",is()?"reactnative":"js"),r.set("version",t.version),r.set("protocol",t.protocol.toString()),t.deviceModel&&r.set("device_model",t.deviceModel),t.os&&r.set("os",t.os),t.osVersion&&r.set("os_version",t.osVersion),t.browser&&r.set("browser",t.browser),t.browserVersion&&r.set("browser_version",t.browserVersion),n.adaptiveStream&&r.set("adaptive_stream","1"),n.reconnectReason&&r.set("reconnect_reason",n.reconnectReason.toString()),(null===(i=navigator.connection)||void 0===i?void 0:i.type)&&r.set("network",navigator.connection.type),"?".concat(r.toString())}(t,function(){var e;const t=new ot({sdk:st.JS,protocol:12,version:ko});return is()&&(t.os=null!==(e=ss())&&void 0!==e?e:""),t}(),n);return new Promise(((t,o)=>bi(this,void 0,void 0,(function*(){const s=yield this.connectionLock.lock();try{const s=()=>bi(this,void 0,void 0,(function*(){this.close(),clearTimeout(a),o(new ao("room connection has been cancelled (signal)"))})),a=setTimeout((()=>{this.close(),o(new ao("room connection has timed out (signal)"))}),n.websocketTimeout);(null==i?void 0:i.aborted)&&s(),null==i||i.addEventListener("abort",s),this.log.debug("connecting to ".concat(e+r),this.logContext),this.ws&&(yield this.close(!1)),this.ws=new WebSocket(e+r),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{clearTimeout(a)},this.ws.onerror=t=>bi(this,void 0,void 0,(function*(){if(this.state===xs.CONNECTED)this.handleWSError(t);else{this.state=xs.DISCONNECTED,clearTimeout(a);try{const t=yield fetch("http".concat(e.substring(2),"/validate").concat(r));if(t.status.toFixed(0).startsWith("4")){const e=yield t.text();o(new ao(e,0,t.status))}else o(new ao("Internal error",2,t.status))}catch(e){o(new ao("server was not reachable",1))}}})),this.ws.onmessage=e=>bi(this,void 0,void 0,(function*(){var r,a,c;let d;if("string"==typeof e.data){const t=JSON.parse(e.data);d=sn.fromJson(t,{ignoreUnknownFields:!0})}else{if(!(e.data instanceof ArrayBuffer))return void this.log.error("could not decode websocket message: ".concat(typeof e.data),this.logContext);d=sn.fromBinary(new Uint8Array(e.data))}if(this.state!==xs.CONNECTED){let e=!1;if("join"===(null===(r=d.message)||void 0===r?void 0:r.case)?(this.state=xs.CONNECTED,null==i||i.removeEventListener("abort",s),this.pingTimeoutDuration=d.message.value.pingTimeout,this.pingIntervalDuration=d.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&(this.log.debug("ping config",Object.assign(Object.assign({},this.logContext),{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration})),this.startPingInterval()),t(d.message.value)):this.state===xs.RECONNECTING&&"leave"!==d.message.case?(this.state=xs.CONNECTED,null==i||i.removeEventListener("abort",s),this.startPingInterval(),"reconnect"===(null===(a=d.message)||void 0===a?void 0:a.case)?t(d.message.value):(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),t(void 0),e=!0)):this.isEstablishingConnection&&"leave"===d.message.case?o(new ao("Received leave request while trying to (re)connect",4)):n.reconnect||o(new ao("did not receive join response, got ".concat(null===(c=d.message)||void 0===c?void 0:c.case," instead"))),!e)return}this.signalLatency&&(yield qo(this.signalLatency)),this.handleSignalResponse(d)})),this.ws.onclose=e=>{this.isEstablishingConnection&&o(new ao("Websocket got closed during a (re)connection attempt")),this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:e.reason,code:e.code,wasClean:e.wasClean,state:this.state})),this.handleOnClose(e.reason)}}finally{s()}}))))}close(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return bi(this,void 0,void 0,(function*(){const t=yield this.closingLock.lock();try{if(e&&(this.state=xs.DISCONNECTING),this.ws){this.ws.onmessage=null,this.ws.onopen=null,this.ws.onclose=null;const e=new Promise((e=>{this.ws?this.ws.onclose=()=>{e()}:e()}));this.ws.readyState1&&void 0!==arguments[1]&&arguments[1];return bi(this,void 0,void 0,(function*(){const n=!t&&!function(e){const t=Os.indexOf(e.case)>=0;return hi.trace("request allowed to bypass queue:",{canPass:t,req:e}),t}(e);if(n&&this.state===xs.RECONNECTING)return void this.queuedRequests.push((()=>bi(this,void 0,void 0,(function*(){yield this.sendRequest(e,!0)}))));if(t||(yield this.requestQueue.flush()),this.signalLatency&&(yield qo(this.signalLatency)),!this.ws||this.ws.readyState!==this.ws.OPEN)return void this.log.error("cannot send signal request before connected, type: ".concat(null==e?void 0:e.case),this.logContext);const i=new on({message:e});try{this.useJSON?this.ws.send(i.toJsonString()):this.ws.send(i.toBinary())}catch(e){this.log.error("error sending signal message",Object.assign(Object.assign({},this.logContext),{error:e}))}}))}handleSignalResponse(e){var t,n;const i=e.message;if(null==i)return void this.log.debug("received unsupported message",this.logContext);let r=!1;if("answer"===i.case){const e=As(i.value);this.onAnswer&&this.onAnswer(e)}else if("offer"===i.case){const e=As(i.value);this.onOffer&&this.onOffer(e)}else if("trickle"===i.case){const e=JSON.parse(i.value.candidateInit);this.onTrickle&&this.onTrickle(e,i.value.target)}else"update"===i.case?this.onParticipantUpdate&&this.onParticipantUpdate(null!==(t=i.value.participants)&&void 0!==t?t:[]):"trackPublished"===i.case?this.onLocalTrackPublished&&this.onLocalTrackPublished(i.value):"speakersChanged"===i.case?this.onSpeakersChanged&&this.onSpeakersChanged(null!==(n=i.value.speakers)&&void 0!==n?n:[]):"leave"===i.case?this.onLeave&&this.onLeave(i.value):"mute"===i.case?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(i.value.sid,i.value.muted):"roomUpdate"===i.case?this.onRoomUpdate&&i.value.room&&this.onRoomUpdate(i.value.room):"connectionQuality"===i.case?this.onConnectionQuality&&this.onConnectionQuality(i.value):"streamStateUpdate"===i.case?this.onStreamStateUpdate&&this.onStreamStateUpdate(i.value):"subscribedQualityUpdate"===i.case?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(i.value):"subscriptionPermissionUpdate"===i.case?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(i.value):"refreshToken"===i.case?this.onTokenRefresh&&this.onTokenRefresh(i.value):"trackUnpublished"===i.case?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(i.value):"subscriptionResponse"===i.case?this.onSubscriptionError&&this.onSubscriptionError(i.value):"pong"===i.case||("pongResp"===i.case?(this.rtt=Date.now()-Number.parseInt(i.value.lastPingTimestamp.toString()),this.resetPingTimeout(),r=!0):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:i.case})));r||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return bi(this,void 0,void 0,(function*(){if(this.state===xs.DISCONNECTED)return;const t=this.onClose;yield this.close(),this.log.debug("websocket connection closed: ".concat(e),Object.assign(Object.assign({},this.logContext),{reason:e})),t&&t(e)}))}handleWSError(e){this.log.error("websocket error",Object.assign(Object.assign({},this.logContext),{error:e}))}resetPingTimeout(){this.clearPingTimeout(),this.pingTimeoutDuration?this.pingTimeout=To.setTimeout((()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-1e3*this.pingTimeoutDuration).toUTCString()),this.logContext),this.handleOnClose("ping timeout")}),1e3*this.pingTimeoutDuration):this.log.warn("ping timeout duration not set",this.logContext)}clearPingTimeout(){this.pingTimeout&&To.clearTimeout(this.pingTimeout)}startPingInterval(){this.clearPingInterval(),this.resetPingTimeout(),this.pingIntervalDuration?(this.log.debug("start ping interval",this.logContext),this.pingInterval=To.setInterval((()=>{this.sendPing()}),1e3*this.pingIntervalDuration)):this.log.warn("ping interval duration not set",this.logContext)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&To.clearInterval(this.pingInterval)}}function As(e){const t={type:"offer",sdp:e.sdp};switch(e.type){case"answer":case"offer":case"pranswer":case"rollback":t.type=e.type}return t}function Ms(e){return new fn({sdp:e.sdp,type:e.type})}var Ds={},Ns={exports:{}},Ls=Ns.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Ls).forEach((function(e){Ls[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}));var Us=Ns.exports;!function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,i){var r=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:r&&!n[e.name]&&(n[e.name]={});var o=e.push?{}:r?n[e.name]:n;!function(e,n,i,r){if(r&&!i)n[r]=t(e[1]);else for(var o=0;o1&&(e[i[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],i=e.split(" ").map(t),r=0;r=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},Bs=function(e,t,n){var i=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{};var i;super(),this.log=hi,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=mo((e=>bi(this,void 0,void 0,(function*(){this.emit(Ks);try{yield this.createAndSendOffer()}catch(t){if(!e)throw t;e(t)}}))),100),this.close=()=>{this._pc&&(this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc=null)},this.log=mi(null!==(i=n.loggerName)&&void 0!==i?i:e.LoggerNames.PCTransport),this.loggerOptions=n,this.config=t,this._pc=this.createPC()}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=e=>{var t;e.candidate&&(null===(t=this.onIceCandidate)||void 0===t||t.call(this,e.candidate))},e.onicecandidateerror=e=>{var t;null===(t=this.onIceCandidateError)||void 0===t||t.call(this,e)},e.oniceconnectionstatechange=()=>{var t;null===(t=this.onIceConnectionStateChange)||void 0===t||t.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var t;null===(t=this.onSignalingStatechange)||void 0===t||t.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var t;null===(t=this.onConnectionStateChange)||void 0===t||t.call(this,e.connectionState)},e.ondatachannel=e=>{var t;null===(t=this.onDataChannel)||void 0===t||t.call(this,e)},e.ontrack=e=>{var t;null===(t=this.onTrack)||void 0===t||t.call(this,e)},e}get logContext(){var e,t;return Object.assign({},null===(t=(e=this.loggerOptions).loggerContextCb)||void 0===t?void 0:t.call(e))}get isICEConnected(){return null!==this._pc&&("connected"===this.pc.iceConnectionState||"completed"===this.pc.iceConnectionState)}addIceCandidate(e){return bi(this,void 0,void 0,(function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)}))}setRemoteDescription(e){var t;return bi(this,void 0,void 0,(function*(){let n;if("offer"===e.type){let{stereoMids:t,nackMids:n}=function(e){var t;const n=[],i=[],r=Ws(null!==(t=e.sdp)&&void 0!==t?t:"");let o=0;return r.media.forEach((e=>{var t;"audio"===e.type&&(e.rtp.some((e=>"opus"===e.codec&&(o=e.payload,!0))),(null===(t=e.rtcpFb)||void 0===t?void 0:t.some((e=>e.payload===o&&"nack"===e.type)))&&i.push(e.mid),e.fmtp.some((t=>t.payload===o&&(t.config.includes("sprop-stereo=1")&&n.push(e.mid),!0))))})),{stereoMids:n,nackMids:i}}(e);this.remoteStereoMids=t,this.remoteNackMids=n}else if("answer"===e.type){const i=Ws(null!==(t=e.sdp)&&void 0!==t?t:"");i.media.forEach((e=>{"audio"===e.type&&this.trackBitrates.some((t=>{if(!t.transceiver||e.mid!=t.transceiver.mid)return!1;let n=0;if(e.rtp.some((e=>e.codec.toUpperCase()===t.codec.toUpperCase()&&(n=e.payload,!0))),0===n)return!0;let i=!1;for(const r of e.fmtp)if(r.payload===n){r.config=r.config.split(";").filter((e=>!e.includes("maxaveragebitrate"))).join(";"),t.maxbr>0&&(r.config+=";maxaveragebitrate=".concat(1e3*t.maxbr)),i=!0;break}return i||t.maxbr>0&&e.fmtp.push({payload:n,config:"maxaveragebitrate=".concat(1e3*t.maxbr)}),!0}))})),n=Hs(i)}yield this.setMungedSDP(e,n,!0),this.pendingCandidates.forEach((e=>{this.pc.addIceCandidate(e)})),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):"answer"===e.type&&(this.emit(zs),e.sdp)&&Ws(e.sdp).media.forEach((e=>{"video"===e.type&&this.emit(Js,e.rtp)}))}))}createAndSendOffer(e){var t;return bi(this,void 0,void 0,(function*(){if(void 0===this.onOffer)return;if((null==e?void 0:e.iceRestart)&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&"have-local-offer"===this._pc.signalingState){const t=this._pc.remoteDescription;if(!(null==e?void 0:e.iceRestart)||!t)return void(this.renegotiate=!0);yield this._pc.setRemoteDescription(t)}else if(!this._pc||"closed"===this._pc.signalingState)return void this.log.warn("could not createOffer with closed peer connection",this.logContext);this.log.debug("starting to negotiate",this.logContext);const n=yield this.pc.createOffer(e),i=Ws(null!==(t=n.sdp)&&void 0!==t?t:"");i.media.forEach((e=>{"audio"===e.type?Ys(e,[],[]):"video"===e.type&&(function(e){var t,n,i,r;if(!Jo(null===(n=null===(t=e.rtp[0])||void 0===t?void 0:t.codec)||void 0===n?void 0:n.toLowerCase()))return;let o=0;const s=null===(i=e.ext)||void 0===i?void 0:i.some((e=>e.uri===Go||(e.value>o&&(o=e.value),!1)));s||null===(r=e.ext)||void 0===r||r.push({value:o+1,uri:Go})}(e),this.trackBitrates.some((t=>{if(!e.msid||!t.cid||!e.msid.includes(t.cid))return!1;let n=0;if(e.rtp.some((e=>e.codec.toUpperCase()===t.codec.toUpperCase()&&(n=e.payload,!0))),0===n)return!0;const i=Math.round(.7*t.maxbr);for(const t of e.fmtp)if(t.payload===n){t.config.includes("x-google-start-bitrate")||(t.config+=";x-google-start-bitrate=".concat(i));break}return!0})))})),yield this.setMungedSDP(n,Hs(i)),this.onOffer(n)}))}createAndSetAnswer(){var e;return bi(this,void 0,void 0,(function*(){const t=yield this.pc.createAnswer(),n=Ws(null!==(e=t.sdp)&&void 0!==e?e:"");return n.media.forEach((e=>{"audio"===e.type&&Ys(e,this.remoteStereoMids,this.remoteNackMids)})),yield this.setMungedSDP(t,Hs(n)),t}))}createDataChannel(e,t){return this.pc.createDataChannel(e,t)}addTransceiver(e,t){return this.pc.addTransceiver(e,t)}addTrack(e){if(!this._pc)throw new ho("PC closed, cannot add track");return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){var t;if(!this._pc)throw new ho("PC closed, cannot configure");return null===(t=this._pc)||void 0===t?void 0:t.setConfiguration(e)}canRemoveTrack(){var e;return!!(null===(e=this._pc)||void 0===e?void 0:e.removeTrack)}removeTrack(e){var t;return null===(t=this._pc)||void 0===t?void 0:t.removeTrack(e)}getConnectionState(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.connectionState)&&void 0!==t?t:"closed"}getICEConnectionState(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.iceConnectionState)&&void 0!==t?t:"closed"}getSignallingState(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.signalingState)&&void 0!==t?t:"closed"}getTransceivers(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.getTransceivers())&&void 0!==t?t:[]}getSenders(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.getSenders())&&void 0!==t?t:[]}getLocalDescription(){var e;return null===(e=this._pc)||void 0===e?void 0:e.localDescription}getRemoteDescription(){var e;return null===(e=this.pc)||void 0===e?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){var e;return bi(this,void 0,void 0,(function*(){if(!this._pc)return;let t="";const n=new Map,i=new Map;if((yield this._pc.getStats()).forEach((e=>{switch(e.type){case"transport":t=e.selectedCandidatePairId;break;case"candidate-pair":""===t&&e.selected&&(t=e.id),n.set(e.id,e);break;case"remote-candidate":i.set(e.id,"".concat(e.address,":").concat(e.port))}})),""===t)return;const r=null===(e=n.get(t))||void 0===e?void 0:e.remoteCandidateId;return void 0!==r?i.get(r):void 0}))}setMungedSDP(e,t,n){return bi(this,void 0,void 0,(function*(){if(t){const i=e.sdp;e.sdp=t;try{return this.log.debug("setting munged ".concat(n?"remote":"local"," description"),this.logContext),void(n?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e))}catch(n){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:n,sdp:t})),e.sdp=i}}try{n?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(t){let i="unknown error";t instanceof Error?i=t.message:"string"==typeof t&&(i=t);const r={error:i,sdp:e.sdp};throw!n&&this.pc.remoteDescription&&(r.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:r})),new po(i)}}))}}function Ys(e,t,n){let i=0;e.rtp.some((e=>"opus"===e.codec&&(i=e.payload,!0))),i>0&&(e.rtcpFb||(e.rtcpFb=[]),n.includes(e.mid)&&!e.rtcpFb.some((e=>e.payload===i&&"nack"===e.type))&&e.rtcpFb.push({payload:i,type:"nack"}),t.includes(e.mid)&&e.fmtp.some((e=>e.payload===i&&(e.config.includes("stereo=1")||(e.config+=";stereo=1"),!0))))}const Qs="vp8",$s={audioPreset:e.AudioPresets.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:Oo.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:Qs,backupCodec:!0},Zs={autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0},ea={resolution:_o.h720.resolution},ta={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new yi,disconnectOnPageLeave:!0,webAudioMix:!0},na={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var ia;!function(e){e[e.NEW=0]="NEW",e[e.CONNECTING=1]="CONNECTING",e[e.CONNECTED=2]="CONNECTED",e[e.FAILED=3]="FAILED",e[e.CLOSING=4]="CLOSING",e[e.CLOSED=5]="CLOSED"}(ia||(ia={}));class ra{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}constructor(t,n,i){var r;this.peerConnectionTimeout=na.peerConnectionTimeout,this.log=hi,this.updateState=()=>{var e;const t=this.state,n=this.requiredTransports.map((e=>e.getConnectionState()));n.every((e=>"connected"===e))?this.state=ia.CONNECTED:n.some((e=>"failed"===e))?this.state=ia.FAILED:n.some((e=>"connecting"===e))?this.state=ia.CONNECTING:n.every((e=>"closed"===e))?this.state=ia.CLOSED:n.some((e=>"closed"===e))?this.state=ia.CLOSING:n.every((e=>"new"===e))&&(this.state=ia.NEW),t!==this.state&&(this.log.debug("pc state change: from ".concat(ia[t]," to ").concat(ia[this.state]),this.logContext),null===(e=this.onStateChange)||void 0===e||e.call(this,this.state,this.publisher.getConnectionState(),this.subscriber.getConnectionState()))},this.log=mi(null!==(r=i.loggerName)&&void 0!==r?r:e.LoggerNames.PCManager),this.loggerOptions=i,this.isPublisherConnectionRequired=!n,this.isSubscriberConnectionRequired=n,this.publisher=new Xs(t,i),this.subscriber=new Xs(t,i),this.publisher.onConnectionStateChange=this.updateState,this.subscriber.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=e=>{var t;null===(t=this.onIceCandidate)||void 0===t||t.call(this,e,tn.PUBLISHER)},this.subscriber.onIceCandidate=e=>{var t;null===(t=this.onIceCandidate)||void 0===t||t.call(this,e,tn.SUBSCRIBER)},this.subscriber.onDataChannel=e=>{var t;null===(t=this.onDataChannel)||void 0===t||t.call(this,e)},this.subscriber.onTrack=e=>{var t;null===(t=this.onTrack)||void 0===t||t.call(this,e)},this.publisher.onOffer=e=>{var t;null===(t=this.onPublisherOffer)||void 0===t||t.call(this,e)},this.state=ia.NEW,this.connectionLock=new ks}get logContext(){var e,t;return Object.assign({},null===(t=(e=this.loggerOptions).loggerContextCb)||void 0===t?void 0:t.call(e))}requirePublisher(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.isPublisherConnectionRequired=e,this.updateState()}requireSubscriber(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.isSubscriberConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e){return this.publisher.setRemoteDescription(e)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return bi(this,void 0,void 0,(function*(){if(this.publisher&&"closed"!==this.publisher.getSignallingState()){const e=this.publisher;for(const t of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(t)}catch(e){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:e}))}}yield Promise.all([this.publisher.close(),this.subscriber.close()]),this.updateState()}))}triggerIceRestart(){return bi(this,void 0,void 0,(function*(){this.subscriber.restartingIce=!0,this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))}))}addIceCandidate(e,t){return bi(this,void 0,void 0,(function*(){t===tn.PUBLISHER?yield this.publisher.addIceCandidate(e):yield this.subscriber.addIceCandidate(e)}))}createSubscriberAnswerFromOffer(e){return bi(this,void 0,void 0,(function*(){return this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:this.subscriber.getSignallingState().toString()})),yield this.subscriber.setRemoteDescription(e),yield this.subscriber.createAndSetAnswer()}))}updateConfiguration(e,t){this.publisher.setConfiguration(e),this.subscriber.setConfiguration(e),t&&this.triggerIceRestart()}ensurePCTransportConnection(e,t){var n;return bi(this,void 0,void 0,(function*(){const i=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&"connected"!==this.publisher.getConnectionState()&&"connecting"!==this.publisher.getConnectionState()&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all(null===(n=this.requiredTransports)||void 0===n?void 0:n.map((n=>this.ensureTransportConnected(n,e,t))))}finally{i()}}))}negotiate(e){return bi(this,void 0,void 0,(function*(){return new Promise(((t,n)=>bi(this,void 0,void 0,(function*(){const i=setTimeout((()=>{n("negotiation timed out")}),this.peerConnectionTimeout);e.signal.addEventListener("abort",(()=>{clearTimeout(i),n("negotiation aborted")})),this.publisher.once(Ks,(()=>{e.signal.aborted||this.publisher.once(zs,(()=>{clearTimeout(i),t()}))})),yield this.publisher.negotiate((e=>{clearTimeout(i),n(e)}))}))))}))}addPublisherTransceiver(e,t){return this.publisher.addTransceiver(e,t)}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,t){return this.publisher.createDataChannel(e,t)}getConnectedAddress(e){return e===tn.PUBLISHER||e===tn.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&e.push(this.subscriber),e}ensureTransportConnected(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.peerConnectionTimeout;return bi(this,void 0,void 0,(function*(){if("connected"!==e.getConnectionState())return new Promise(((e,i)=>bi(this,void 0,void 0,(function*(){const r=()=>{this.log.warn("abort transport connection",this.logContext),To.clearTimeout(o),i(new ao("room connection has been cancelled",3))};(null==t?void 0:t.signal.aborted)&&r(),null==t||t.signal.addEventListener("abort",r);const o=To.setTimeout((()=>{null==t||t.signal.removeEventListener("abort",r),i(new ao("could not establish pc connection"))}),n);for(;this.state!==ia.CONNECTED;)if(yield qo(50),null==t?void 0:t.signal.aborted)return void i(new ao("room connection has been cancelled",3));To.clearTimeout(o),null==t||t.signal.removeEventListener("abort",r),e()}))))}))}}const oa="_lossy",sa="_reliable",aa="leave-reconnect";var ca;!function(e){e[e.New=0]="New",e[e.Connected=1]="Connected",e[e.Disconnected=2]="Disconnected",e[e.Reconnecting=3]="Reconnecting",e[e.Closed=4]="Closed"}(ca||(ca={}));class da extends Ui.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(t){var n;super(),this.options=t,this.rtcConfig={},this.peerConnectionTimeout=na.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.subscriberPrimary=!1,this.pcState=ca.New,this._isClosed=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.log=hi,this.handleDataChannel=e=>{let{channel:t}=e;return bi(this,void 0,void 0,(function*(){if(t){if(t.label===sa)this.reliableDCSub=t;else{if(t.label!==oa)return;this.lossyDCSub=t}this.log.debug("on data channel ".concat(t.id,", ").concat(t.label),this.logContext),t.onmessage=this.handleDataMessage}}))},this.handleDataMessage=t=>bi(this,void 0,void 0,(function*(){var n,i;const r=yield this.dataProcessLock.lock();try{let r;if(t.data instanceof ArrayBuffer)r=t.data;else{if(!(t.data instanceof Blob))return void this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:t.data}));r=yield t.data.arrayBuffer()}const o=Ye.fromBinary(new Uint8Array(r));"speaker"===(null===(n=o.value)||void 0===n?void 0:n.case)?this.emit(e.EngineEvent.ActiveSpeakersUpdate,o.value.value.speakers):"user"===(null===(i=o.value)||void 0===i?void 0:i.case)&&this.emit(e.EngineEvent.DataPacketReceived,o.value.value,o.kind)}finally{r()}})),this.handleDataError=e=>{const t=0===e.currentTarget.maxRetransmits?"lossy":"reliable";if(e instanceof ErrorEvent&&e.error){const{error:n}=e.error;this.log.error("DataChannel error on ".concat(t,": ").concat(e.message),Object.assign(Object.assign({},this.logContext),{error:n}))}else this.log.error("Unknown DataChannel error on ".concat(t),Object.assign(Object.assign({},this.logContext),{event:e}))},this.handleBufferedAmountLow=e=>{const t=0===e.currentTarget.maxRetransmits?Qe.LOSSY:Qe.RELIABLE;this.updateAndEmitDCBufferStatus(t)},this.handleDisconnect=(t,n)=>{if(this._isClosed)return;this.log.warn("".concat(t," disconnected"),this.logContext),0===this.reconnectAttempts&&(this.reconnectStart=Date.now());const i=Date.now()-this.reconnectStart;let r=this.getNextRetryDelay({elapsedMs:i,retryCount:this.reconnectAttempts});null!==r?(t===aa&&(r=0),this.log.debug("reconnecting in ".concat(r,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=To.setTimeout((()=>this.attemptReconnect(n).finally((()=>this.reconnectTimeout=void 0))),r)):(t=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(t,"ms. giving up"),this.logContext),this.emit(e.EngineEvent.Disconnected),this.close()})(i)},this.waitForRestarted=()=>new Promise(((t,n)=>{this.pcState===ca.Connected&&t();const i=()=>{this.off(e.EngineEvent.Disconnected,r),t()},r=()=>{this.off(e.EngineEvent.Restarted,i),n()};this.once(e.EngineEvent.Restarted,i),this.once(e.EngineEvent.Disconnected,r)})),this.updateAndEmitDCBufferStatus=t=>{const n=this.isBufferStatusLow(t);void 0!==n&&n!==this.dcBufferStatus.get(t)&&(this.dcBufferStatus.set(t,n),this.emit(e.EngineEvent.DCBufferStatusChanged,n,t))},this.isBufferStatusLow=e=>{const t=this.dataChannelForKind(e);if(t)return t.bufferedAmount<=t.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>{this.client.currentState===xs.RECONNECTING&&(this.clearReconnectTimeout(),this.attemptReconnect(Fe.RR_SIGNAL_DISCONNECTED))},this.log=mi(null!==(n=t.loggerName)&&void 0!==n?n:e.LoggerNames.Engine),this.loggerOptions={loggerName:t.loggerName,loggerContextCb:()=>this.logContext},this.client=new Is(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new ks,this.dataProcessLock=new ks,this.dcBufferStatus=new Map([[Qe.LOSSY,!0],[Qe.RELIABLE,!0]]),this.client.onParticipantUpdate=t=>this.emit(e.EngineEvent.ParticipantUpdate,t),this.client.onConnectionQuality=t=>this.emit(e.EngineEvent.ConnectionQualityUpdate,t),this.client.onRoomUpdate=t=>this.emit(e.EngineEvent.RoomUpdate,t),this.client.onSubscriptionError=t=>this.emit(e.EngineEvent.SubscriptionError,t),this.client.onSubscriptionPermissionUpdate=t=>this.emit(e.EngineEvent.SubscriptionPermissionUpdate,t),this.client.onSpeakersChanged=t=>this.emit(e.EngineEvent.SpeakersChanged,t),this.client.onStreamStateUpdate=t=>this.emit(e.EngineEvent.StreamStateChanged,t)}get logContext(){var e,t,n,i,r,o,s,a;return{room:null===(t=null===(e=this.latestJoinResponse)||void 0===e?void 0:e.room)||void 0===t?void 0:t.name,roomID:null===(i=null===(n=this.latestJoinResponse)||void 0===n?void 0:n.room)||void 0===i?void 0:i.sid,participant:null===(o=null===(r=this.latestJoinResponse)||void 0===r?void 0:r.participant)||void 0===o?void 0:o.identity,pID:null===(a=null===(s=this.latestJoinResponse)||void 0===s?void 0:s.participant)||void 0===a?void 0:a.sid}}join(e,t,n,i){return bi(this,void 0,void 0,(function*(){this.url=e,this.token=t,this.signalOpts=n,this.maxJoinAttempts=n.maxRetries;try{this.joinAttempts+=1,this.setupSignalClientCallbacks();const r=yield this.client.join(e,t,n,i);return this._isClosed=!1,this.latestJoinResponse=r,this.subscriberPrimary=r.subscriberPrimary,this.pcManager||(yield this.configure(r)),this.subscriberPrimary||this.negotiate(),this.clientConfiguration=r.clientConfiguration,r}catch(r){if(r instanceof ao&&1===r.reason&&(this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts),this.logContext),this.joinAttempts{e&&(e.close(),e.onbufferedamountlow=null,e.onclose=null,e.onclosing=null,e.onerror=null,e.onmessage=null,e.onopen=null)};t(this.lossyDC),t(this.lossyDCSub),t(this.reliableDC),t(this.reliableDCSub),this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0}))}cleanupClient(){return bi(this,void 0,void 0,(function*(){yield this.client.close(),this.client.resetCallbacks()}))}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new lo("a track with the same ID has already been published");return new Promise(((t,n)=>{const i=setTimeout((()=>{delete this.pendingTrackResolvers[e.cid],n(new ao("publication of local track timed out, no response from server"))}),1e4);this.pendingTrackResolvers[e.cid]={resolve:e=>{clearTimeout(i),t(e)},reject:()=>{clearTimeout(i),n(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)}))}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:t}=this.pendingTrackResolvers[e.track.id];t&&t(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(e){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:e}))}return!1}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return null===(e=this.reliableDCSub)||void 0===e?void 0:e.readyState}getConnectedServerAddress(){var e;return bi(this,void 0,void 0,(function*(){return null===(e=this.pcManager)||void 0===e?void 0:e.getConnectedAddress()}))}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(t){var n;return bi(this,void 0,void 0,(function*(){if(this.pcManager&&this.pcManager.currentState!==ia.NEW)return;this.participantSid=null===(n=t.participant)||void 0===n?void 0:n.sid;const i=this.makeRTCConfiguration(t);this.pcManager=new ra(i,t.subscriberPrimary,this.loggerOptions),this.emit(e.EngineEvent.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(e,t)=>{this.client.sendIceCandidate(e,t)},this.pcManager.onPublisherOffer=e=>{this.client.sendOffer(e)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(n,i,r)=>bi(this,void 0,void 0,(function*(){if(this.log.debug("primary PC state changed ".concat(n),this.logContext),n===ia.CONNECTED){const n=this.pcState===ca.New;this.pcState=ca.Connected,n&&this.emit(e.EngineEvent.Connected,t)}else n===ia.FAILED&&this.pcState===ca.Connected&&(this.pcState=ca.Disconnected,this.handleDisconnect("peerconnection failed","failed"===r?Fe.RR_SUBSCRIBER_FAILED:Fe.RR_PUBLISHER_FAILED));const i=this.client.isDisconnected||this.client.currentState===xs.RECONNECTING,o=[ia.FAILED,ia.CLOSING,ia.CLOSED].includes(n);i&&o&&!this._isClosed&&this.emit(e.EngineEvent.Offline)})),this.pcManager.onTrack=t=>{this.emit(e.EngineEvent.MediaTrackAdded,t.track,t.streams[0],t.receiver)},this.createDataChannels()}))}setupSignalClientCallbacks(){this.client.onAnswer=e=>bi(this,void 0,void 0,(function*(){this.pcManager&&(this.log.debug("received server answer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type})),yield this.pcManager.setPublisherAnswer(e))})),this.client.onTrickle=(e,t)=>{this.pcManager&&(this.log.trace("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:t})),this.pcManager.addIceCandidate(e,t))},this.client.onOffer=e=>bi(this,void 0,void 0,(function*(){if(!this.pcManager)return;const t=yield this.pcManager.createSubscriberAnswerFromOffer(e);this.client.sendAnswer(t)})),this.client.onLocalTrackPublished=e=>{var t;if(this.log.debug("received trackPublishedResponse",Object.assign(Object.assign({},this.logContext),{cid:e.cid,track:null===(t=e.track)||void 0===t?void 0:t.sid})),!this.pendingTrackResolvers[e.cid])return void this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));const{resolve:n}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],n(e.track)},this.client.onLocalTrackUnpublished=t=>{this.emit(e.EngineEvent.LocalTrackUnpublished,t)},this.client.onTokenRefresh=e=>{this.token=e},this.client.onRemoteMuteChanged=(t,n)=>{this.emit(e.EngineEvent.RemoteMute,t,n)},this.client.onSubscribedQualityUpdate=t=>{this.emit(e.EngineEvent.SubscribedQualityUpdate,t)},this.client.onClose=()=>{this.handleDisconnect("signal",Fe.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=t=>{(null==t?void 0:t.canReconnect)?(this.fullReconnectOnNext=!0,this.handleDisconnect(aa)):(this.emit(e.EngineEvent.Disconnected,null==t?void 0:t.reason),this.close()),this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:null==t?void 0:t.reason}))}}makeRTCConfiguration(e){var t;const n=Object.assign({},this.rtcConfig);if((null===(t=this.signalOpts)||void 0===t?void 0:t.e2eeEnabled)&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),n.encodedInsertableStreams=!0),e.iceServers&&!n.iceServers){const t=[];e.iceServers.forEach((e=>{const n={urls:e.urls};e.username&&(n.username=e.username),e.credential&&(n.credential=e.credential),t.push(n)})),n.iceServers=t}return e.clientConfiguration&&e.clientConfiguration.forceRelay===Le.ENABLED&&(n.iceTransportPolicy="relay"),n.sdpSemantics="unified-plan",n.continualGatheringPolicy="gather_continually",n}createDataChannels(){this.pcManager&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.lossyDC=this.pcManager.createPublisherDataChannel(oa,{ordered:!0,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(sa,{ordered:!0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError,this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=this.handleBufferedAmountLow,this.reliableDC.onbufferedamountlow=this.handleBufferedAmountLow)}setPreferredCodec(e,t,n){if(!("getCapabilities"in RTCRtpReceiver))return;const i=RTCRtpReceiver.getCapabilities(t);if(!i)return;this.log.debug("get receiver capabilities",Object.assign(Object.assign({},this.logContext),{cap:i}));const r=[],o=[],s=[];i.codecs.forEach((e=>{const t=e.mimeType.toLowerCase();"audio/opus"!==t?t==="video/".concat(n)?"h264"!==n||e.sdpFmtpLine&&e.sdpFmtpLine.includes("profile-level-id=42e01f")?r.push(e):o.push(e):s.push(e):r.push(e)})),function(e){if(!ns())return!1;if(!("setCodecPreferences"in e))return!1;const t=vo();if(!(null==t?void 0:t.name)||!t.version)return!1;const n=Yo[t.name];return!!n&&cs(t.version,n)>=0}(e)&&e.setCodecPreferences(r.concat(o,s))}createSender(e,t,n){return bi(this,void 0,void 0,(function*(){if(Ho())return yield this.createTransceiverRTCRtpSender(e,t,n);if(Wo())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new ho("Required webRTC APIs not supported on this device")}))}createSimulcastSender(e,t,n,i){return bi(this,void 0,void 0,(function*(){if(Ho())return this.createSimulcastTransceiverSender(e,t,n,i);if(Wo())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new ho("Cannot stream on this device")}))}createTransceiverRTCRtpSender(e,t,n){return bi(this,void 0,void 0,(function*(){if(!this.pcManager)throw new ho("publisher is closed");const i=[];e.mediaStream&&i.push(e.mediaStream);const r={direction:"sendonly",streams:i};n&&(r.sendEncodings=n);const o=yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,r);return e.kind===Io.Kind.Video&&t.videoCodec&&(this.setPreferredCodec(o,e.kind,t.videoCodec),e.codec=t.videoCodec),o.sender}))}createSimulcastTransceiverSender(e,t,n,i){return bi(this,void 0,void 0,(function*(){if(!this.pcManager)throw new ho("publisher is closed");const r={direction:"sendonly"};i&&(r.sendEncodings=i);const o=yield this.pcManager.addPublisherTransceiver(t.mediaStreamTrack,r);if(n.videoCodec)return this.setPreferredCodec(o,e.kind,n.videoCodec),e.setSimulcastTrackSender(n.videoCodec,o.sender),o.sender}))}createRTCRtpSender(e){return bi(this,void 0,void 0,(function*(){if(!this.pcManager)throw new ho("publisher is closed");return this.pcManager.addPublisherTrack(e)}))}attemptReconnect(t){var n,i,r;return bi(this,void 0,void 0,(function*(){if(!this._isClosed)if(this.attemptingReconnect)hi.warn("already attempting reconnect, returning early",this.logContext);else{(null===(n=this.clientConfiguration)||void 0===n?void 0:n.resumeConnection)!==Le.DISABLED&&(null!==(r=null===(i=this.pcManager)||void 0===i?void 0:i.currentState)&&void 0!==r?r:ia.NEW)!==ia.NEW||(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(t),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(t){this.reconnectAttempts+=1;let n=!0;t instanceof ho?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:t})),n=!1):t instanceof la||(this.fullReconnectOnNext=!0),n?this.handleDisconnect("reconnect",Fe.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up"),this.logContext),this.emit(e.EngineEvent.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}}))}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(e){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:e}))}return null}restartConnection(t){var n,i,r;return bi(this,void 0,void 0,(function*(){try{if(!this.url||!this.token)throw new ho("could not reconnect, url or token not saved");let i;this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(e.EngineEvent.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new la;i=yield this.join(null!=t?t:this.url,this.token,this.signalOpts)}catch(e){if(e instanceof ao&&0===e.reason)throw new ho("could not reconnect, token might be expired");throw new la}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(e.EngineEvent.SignalRestarted,i),yield this.waitForPCReconnected(),this.client.currentState!==xs.CONNECTED)throw new la("Signal connection got severed during reconnect");null===(n=this.regionUrlProvider)||void 0===n||n.resetAttempts(),this.emit(e.EngineEvent.Restarted)}catch(e){const t=yield null===(i=this.regionUrlProvider)||void 0===i?void 0:i.getNextBestRegionUrl();if(t)return void(yield this.restartConnection(t));throw null===(r=this.regionUrlProvider)||void 0===r||r.resetAttempts(),e}}))}resumeConnection(t){var n;return bi(this,void 0,void 0,(function*(){if(!this.url||!this.token)throw new ho("could not reconnect, url or token not saved");if(!this.pcManager)throw new ho("publisher and subscriber connections unset");let i;this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(e.EngineEvent.Resuming);try{this.setupSignalClientCallbacks(),i=yield this.client.reconnect(this.url,this.token,this.participantSid,t)}catch(e){let t="";if(e instanceof Error&&(t=e.message,this.log.error(e.message,Object.assign(Object.assign({},this.logContext),{error:e}))),e instanceof ao&&0===e.reason)throw new ho("could not reconnect, token might be expired");if(e instanceof ao&&4===e.reason)throw e;throw new la(t)}if(this.emit(e.EngineEvent.SignalResumed),i){const e=this.makeRTCConfiguration(i);this.pcManager.updateConfiguration(e)}else this.log.warn("Did not receive reconnect response",this.logContext);if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==xs.CONNECTED)throw new la("Signal connection got severed during reconnect");this.client.setReconnected(),"open"===(null===(n=this.reliableDC)||void 0===n?void 0:n.readyState)&&null===this.reliableDC.id&&this.createDataChannels(),this.emit(e.EngineEvent.Resumed)}))}waitForPCInitialConnection(e,t){return bi(this,void 0,void 0,(function*(){if(!this.pcManager)throw new ho("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(t,e)}))}waitForPCReconnected(){return bi(this,void 0,void 0,(function*(){this.pcState=ca.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield qo(2e3),!this.pcManager)throw new ho("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=ca.Connected}catch(e){throw this.pcState=ca.Disconnected,new ao("could not establish PC connection, ".concat(e.message))}}))}sendDataPacket(e,t){return bi(this,void 0,void 0,(function*(){const n=e.toBinary();yield this.ensurePublisherConnected(t);const i=this.dataChannelForKind(t);i&&i.send(n),this.updateAndEmitDCBufferStatus(t)}))}ensureDataTransportConnected(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscriberPrimary;var n;return bi(this,void 0,void 0,(function*(){if(!this.pcManager)throw new ho("PC manager is closed");const i=t?this.pcManager.subscriber:this.pcManager.publisher,r=t?"Subscriber":"Publisher";if(!i)throw new ao("".concat(r," connection not set"));t||this.pcManager.publisher.isICEConnected||"checking"===this.pcManager.publisher.getICEConnectionState()||this.negotiate();const o=this.dataChannelForKind(e,t);if("open"===(null==o?void 0:o.readyState))return;const s=(new Date).getTime()+this.peerConnectionTimeout;for(;(new Date).getTime()bi(this,void 0,void 0,(function*(){if(!this.pcManager)return void n(new po("PC manager is closed"));this.pcManager.requirePublisher();const i=new AbortController,r=()=>{i.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),t()};this.isClosed&&n("cannot negotiate on closed engine"),this.on(e.EngineEvent.Closing,r),this.pcManager.publisher.once(Js,(t=>{const n=new Map;t.forEach((e=>{const t=e.codec.toLowerCase();var i;i=t,Co.includes(i)&&n.set(e.payload,t)})),this.emit(e.EngineEvent.RTPVideoMapUpdate,n)}));try{yield this.pcManager.negotiate(i),t()}catch(e){e instanceof po&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",Fe.RR_UNKNOWN),n(e)}finally{this.off(e.EngineEvent.Closing,r)}}))))}))}dataChannelForKind(e,t){if(t){if(e===Qe.LOSSY)return this.lossyDCSub;if(e===Qe.RELIABLE)return this.reliableDCSub}else{if(e===Qe.LOSSY)return this.lossyDC;if(e===Qe.RELIABLE)return this.reliableDC}}sendSyncState(e,t){var n,i;if(!this.pcManager)return void this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);const r=this.pcManager.subscriber.getLocalDescription(),o=this.pcManager.subscriber.getRemoteDescription(),s=null===(i=null===(n=this.signalOpts)||void 0===n?void 0:n.autoSubscribe)||void 0===i||i,a=new Array,c=new Array;e.forEach((e=>{e.isDesired!==s&&a.push(e.trackSid),e.isEnabled||c.push(e.trackSid)})),this.client.sendSyncState(new Ln({answer:r?Ms({sdp:r.sdp,type:r.type}):void 0,offer:o?Ms({sdp:o.sdp,type:o.type}):void 0,subscription:new vn({trackSids:a,subscribe:!s,participantTracks:[]}),publishTracks:Vo(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:c}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],t=(t,n)=>{void 0!==(null==t?void 0:t.id)&&null!==t.id&&e.push(new Un({label:t.label,id:t.id,target:n}))};return t(this.dataChannelForKind(Qe.LOSSY),tn.PUBLISHER),t(this.dataChannelForKind(Qe.RELIABLE),tn.PUBLISHER),t(this.dataChannelForKind(Qe.LOSSY,!0),tn.SUBSCRIBER),t(this.dataChannelForKind(Qe.RELIABLE,!0),tn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&To.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){ns()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){ns()&&window.removeEventListener("online",this.handleBrowserOnLine)}}class la extends Error{}class ua{constructor(e,t){this.lastUpdateAt=0,this.settingsCacheTime=3e3,this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=t}updateToken(e){this.token=e}isCloud(){return rs(this.serverUrl)}getServerUrl(){return this.serverUrl}getNextBestRegionUrl(e){return bi(this,void 0,void 0,(function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");(!this.regionSettings||Date.now()-this.lastUpdateAt>this.settingsCacheTime)&&(this.regionSettings=yield this.fetchRegionSettings(e));const t=this.regionSettings.regions.filter((e=>!this.attemptedRegions.find((t=>t.url===e.url))));if(t.length>0){const e=t[0];return this.attemptedRegions.push(e),hi.debug("next region: ".concat(e.region)),e.url}return null}))}resetAttempts(){this.attemptedRegions=[]}fetchRegionSettings(e){return bi(this,void 0,void 0,(function*(){const t=yield fetch("".concat((n=this.serverUrl,"".concat(n.protocol.replace("ws","http"),"//").concat(n.host,"/settings")),"/regions"),{headers:{authorization:"Bearer ".concat(this.token)},signal:e});var n;if(t.ok){const e=yield t.json();return this.lastUpdateAt=Date.now(),e}throw new ao("Could not fetch region settings: ".concat(t.statusText),401===t.status?0:void 0,t.status)}))}}const ha=2e3;function pa(e,t){if(!t)return 0;let n,i;return"bytesReceived"in e?(n=e.bytesReceived,i=t.bytesReceived):"bytesSent"in e&&(n=e.bytesSent,i=t.bytesSent),void 0===n||void 0===i||void 0===e.timestamp||void 0===t.timestamp?0:8*(n-i)*1e3/(e.timestamp-t.timestamp)}class ma extends ws{constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;super(e,Io.Kind.Audio,t,n,r),this.stopOnMute=!1,this.monitorSender=()=>bi(this,void 0,void 0,(function*(){if(!this.sender)return void(this._currentBitrate=0);let e;try{e=yield this.getSenderStats()}catch(e){return void this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:e}))}e&&this.prevStats&&(this._currentBitrate=pa(e,this.prevStats)),this.prevStats=e})),this.audioContext=i,this.checkForSilence()}setDeviceId(e){return bi(this,void 0,void 0,(function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Ts(e)||(this._constraints.deviceId=e,this.isMuted||(yield this.restartTrack()),this.isMuted||Ts(e)===this._mediaStreamTrack.getSettings().deviceId)}))}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return bi(this,void 0,void 0,(function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===Io.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}}))}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return bi(this,void 0,void 0,(function*(){const t=yield this.muteLock.lock();try{if(!this.isMuted)return this.log.debug("Track already unmuted",this.logContext),this;const t=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Ts(this._constraints.deviceId);return this.source!==Io.Source.Microphone||!this.stopOnMute&&"ended"!==this._mediaStreamTrack.readyState&&!t||this.isUserProvided||(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{t()}}))}restartTrack(e){return bi(this,void 0,void 0,(function*(){let t;if(e){const n=Lo({audio:e});"boolean"!=typeof n.audio&&(t=n.audio)}yield this.restart(t)}))}restart(e){const t=Object.create(null,{restart:{get:()=>super.restart}});return bi(this,void 0,void 0,(function*(){const n=yield t.restart.call(this,e);return this.checkForSilence(),n}))}startMonitor(){ns()&&(this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),ha)))}setProcessor(t){var n;return bi(this,void 0,void 0,(function*(){const i=yield this.processorLock.lock();try{if(!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.stopProcessor());const i={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(t.name),this.logContext),yield t.init(i),this.processor=t,this.processor.processedTrack&&(yield null===(n=this.sender)||void 0===n?void 0:n.replaceTrack(this.processor.processedTrack)),this.emit(e.TrackEvent.TrackProcessorUpdate,this.processor)}finally{i()}}))}setAudioContext(e){this.audioContext=e}getSenderStats(){var e;return bi(this,void 0,void 0,(function*(){if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return;let t;return(yield this.sender.getStats()).forEach((e=>{"outbound-rtp"===e.type&&(t={type:"audio",streamId:e.id,packetsSent:e.packetsSent,packetsLost:e.packetsLost,bytesSent:e.bytesSent,timestamp:e.timestamp,roundTripTime:e.roundTripTime,jitter:e.jitter})})),t}))}checkForSilence(){return bi(this,void 0,void 0,(function*(){const t=yield function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;return bi(this,void 0,void 0,(function*(){const n=Uo();if(n){const i=n.createAnalyser();i.fftSize=2048;const r=i.frequencyBinCount,o=new Uint8Array(r);n.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(i),yield qo(t),i.getByteTimeDomainData(o);const s=o.some((e=>128!==e&&0!==e));return n.close(),!s}return!1}))}(this);return t&&(this.isMuted||this.log.warn("silence detected on local audio track",this.logContext),this.emit(e.TrackEvent.AudioSilenceDetected)),t}))}}function fa(e,t,n){switch(e.kind){case"audio":return new ma(e,t,!1,void 0,n);case"video":return new Ra(e,t,!1,n);default:throw new lo("unsupported track type: ".concat(e.kind))}}const ga=Object.values(_o),va=Object.values(Ro),ya=Object.values(Oo),ba=[_o.h180,_o.h360],ka=[Ro.h180,Ro.h360],Ta=e=>[{scaleResolutionDownBy:2,fps:e.encoding.maxFramerate}].map((t=>{var n,i;return new Eo(Math.floor(e.width/t.scaleResolutionDownBy),Math.floor(e.height/t.scaleResolutionDownBy),Math.max(15e4,Math.floor(e.encoding.maxBitrate/(Math.pow(t.scaleResolutionDownBy,2)*((null!==(n=e.encoding.maxFramerate)&&void 0!==n?n:30)/(null!==(i=t.fps)&&void 0!==i?i:30))))),t.fps,e.encoding.priority)})),Ea=["q","h","f"];function Sa(e,t,n,i){var r,o;let s=null==i?void 0:i.videoEncoding;e&&(s=null==i?void 0:i.screenShareEncoding);const a=null==i?void 0:i.simulcast,c=null==i?void 0:i.scalabilityMode,d=null==i?void 0:i.videoCodec;if(!s&&!a&&!c||!t||!n)return[{}];s||(s=function(e,t,n,i){const r=function(e,t,n){if(e)return ya;const i=t>n?t/n:n/t;return Math.abs(i-16/9)=s)break}if(i)switch(i){case"av1":o=Object.assign({},o),o.maxBitrate=.7*o.maxBitrate;break;case"vp9":o=Object.assign({},o),o.maxBitrate=.85*o.maxBitrate}return o}(e,t,n,d),hi.debug("using video encoding",s));const l=new Eo(t,n,s.maxBitrate,s.maxFramerate,s.priority);if(c&&Jo(d)){const e=new _a(c),t=[];if(e.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(c));const n=vo();if(Zo()||"Chrome"===(null==n?void 0:n.name)&&cs(null==n?void 0:n.version,"113")<0){for(let n=0;n0){const e=h[0];h.length>1&&([,u]=h);const i=Math.max(t,n);if(i>=960&&u)return wa(t,n,[e,u,l]);if(i>=480)return wa(t,n,[e,l])}return wa(t,n,[l])}function Ca(e,t){if(e)return Ta(t);const{width:n,height:i}=t,r=n>i?n/i:i/n;return Math.abs(r-16/9){if(r>=Ea.length)return;const o=Math.min(e,t),s={rid:Ea[r],scaleResolutionDownBy:Math.max(1,o/Math.min(n.width,n.height)),maxBitrate:n.encoding.maxBitrate};n.encoding.maxFramerate&&(s.maxFramerate=n.encoding.maxFramerate);const a=$o()||0===r;n.encoding.priority&&a&&(s.priority=n.encoding.priority,s.networkPriority=n.encoding.priority),i.push(s)})),is()&&"ios"===ss()){let e;i.forEach((t=>{e?t.maxFramerate&&t.maxFramerate>e&&(e=t.maxFramerate):e=t.maxFramerate}));let t=!0;i.forEach((n=>{var i;n.maxFramerate!=e&&(t&&(t=!1,hi.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),hi.info('Setting framerate of encoding "'.concat(null!==(i=n.rid)&&void 0!==i?i:"",'" to ').concat(e)),n.maxFramerate=e)}))}return i}function Pa(e){if(e)return e.sort(((e,t)=>{const{encoding:n}=e,{encoding:i}=t;return n.maxBitrate>i.maxBitrate?1:n.maxBitratei.maxFramerate?1:-1:0}))}class _a{constructor(e){const t=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!t)throw new Error("invalid scalability mode");if(this.spatial=parseInt(t[1]),this.temporal=parseInt(t[2]),t.length>3)switch(t[3]){case"h":case"_KEY":case"_KEY_SHIFT":this.suffix=t[3]}}toString(){var e;return"L".concat(this.spatial,"T").concat(this.temporal).concat(null!==(e=this.suffix)&&void 0!==e?e:"")}}class Ra extends ws{constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0;super(e,Io.Kind.Video,t,n,i),this.simulcastCodecs=new Map,this.monitorSender=()=>bi(this,void 0,void 0,(function*(){if(!this.sender)return void(this._currentBitrate=0);let e;try{e=yield this.getSenderStats()}catch(e){return void this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:e}))}const t=new Map(e.map((e=>[e.rid,e])));if(this.prevStats){let e=0;t.forEach(((t,n)=>{var i;const r=null===(i=this.prevStats)||void 0===i?void 0:i.get(n);e+=pa(t,r)})),this._currentBitrate=e}this.prevStats=t})),this.senderLock=new ks}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!ns())return;const n=null===(t=this.sender)||void 0===t?void 0:t.getParameters();n&&(this.encodings=n.encodings),this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),ha))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach((e=>{e.mediaStreamTrack.stop()})),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});var t,n,i,r,o;return bi(this,void 0,void 0,(function*(){yield e.pauseUpstream.call(this);try{for(var s,a=!0,c=ki(this.simulcastCodecs.values());s=yield c.next(),!(t=s.done);a=!0){r=s.value,a=!1;const e=r;yield null===(o=e.sender)||void 0===o?void 0:o.replaceTrack(null)}}catch(e){n={error:e}}finally{try{a||t||!(i=c.return)||(yield i.call(c))}finally{if(n)throw n.error}}}))}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});var t,n,i,r,o;return bi(this,void 0,void 0,(function*(){yield e.resumeUpstream.call(this);try{for(var s,a=!0,c=ki(this.simulcastCodecs.values());s=yield c.next(),!(t=s.done);a=!0){r=s.value,a=!1;const e=r;yield null===(o=e.sender)||void 0===o?void 0:o.replaceTrack(e.mediaStreamTrack)}}catch(e){n={error:e}}finally{try{a||t||!(i=c.return)||(yield i.call(c))}finally{if(n)throw n.error}}}))}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return bi(this,void 0,void 0,(function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source!==Io.Source.Camera||this.isUserProvided||(this.log.debug("stopping camera track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}}))}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return bi(this,void 0,void 0,(function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source!==Io.Source.Camera||this.isUserProvided||(this.log.debug("reacquiring camera track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{t()}}))}setTrackMuted(e){super.setTrackMuted(e);for(const t of this.simulcastCodecs.values())t.mediaStreamTrack.enabled=!e}getSenderStats(){var e;return bi(this,void 0,void 0,(function*(){if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return[];const t=[],n=yield this.sender.getStats();return n.forEach((e=>{var i;if("outbound-rtp"===e.type){const r={type:"video",streamId:e.id,frameHeight:e.frameHeight,frameWidth:e.frameWidth,framesPerSecond:e.framesPerSecond,framesSent:e.framesSent,firCount:e.firCount,pliCount:e.pliCount,nackCount:e.nackCount,packetsSent:e.packetsSent,bytesSent:e.bytesSent,qualityLimitationReason:e.qualityLimitationReason,qualityLimitationDurations:e.qualityLimitationDurations,qualityLimitationResolutionChanges:e.qualityLimitationResolutionChanges,rid:null!==(i=e.rid)&&void 0!==i?i:e.id,retransmittedPacketsSent:e.retransmittedPacketsSent,targetBitrate:e.targetBitrate,timestamp:e.timestamp},o=n.get(e.remoteId);o&&(r.jitter=o.jitter,r.packetsLost=o.packetsLost,r.roundTripTime=o.roundTripTime),t.push(r)}})),t.sort(((e,t)=>{var n,i;return(null!==(n=t.frameWidth)&&void 0!==n?n:0)-(null!==(i=e.frameWidth)&&void 0!==i?i:0)})),t}))}setPublishingQuality(t){const n=[];for(let i=e.VideoQuality.LOW;i<=e.VideoQuality.HIGH;i+=1)n.push(new xn({quality:i,enabled:i<=t}));this.log.debug("setting publishing quality. max quality ".concat(t),this.logContext),this.setPublishingLayers(n)}setDeviceId(e){return bi(this,void 0,void 0,(function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Ts(e)||(this._constraints.deviceId=e,this.isMuted||(yield this.restartTrack()),this.isMuted||Ts(e)===this._mediaStreamTrack.getSettings().deviceId)}))}restartTrack(e){var t,n,i,r;return bi(this,void 0,void 0,(function*(){let o;if(e){const t=Lo({video:e});"boolean"!=typeof t.video&&(o=t.video)}yield this.restart(o);try{for(var s,a=!0,c=ki(this.simulcastCodecs.values());s=yield c.next(),!(t=s.done);a=!0){r=s.value,a=!1;const e=r;e.sender&&(e.mediaStreamTrack=this.mediaStreamTrack.clone(),yield e.sender.replaceTrack(e.mediaStreamTrack))}}catch(e){n={error:e}}finally{try{a||t||!(i=c.return)||(yield i.call(c))}finally{if(n)throw n.error}}}))}setProcessor(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});var i,r,o,s,a,c;return bi(this,void 0,void 0,(function*(){if(yield n.setProcessor.call(this,e,t),null===(a=this.processor)||void 0===a?void 0:a.processedTrack)try{for(var d,l=!0,u=ki(this.simulcastCodecs.values());d=yield u.next(),!(i=d.done);l=!0){s=d.value,l=!1;const e=s;yield null===(c=e.sender)||void 0===c?void 0:c.replaceTrack(this.processor.processedTrack)}}catch(e){r={error:e}}finally{try{l||i||!(o=u.return)||(yield o.call(u))}finally{if(r)throw r.error}}}))}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e))return void this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);const n={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,n),n}setSimulcastTrackSender(e,t){const n=this.simulcastCodecs.get(e);n&&(n.sender=t,setTimeout((()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)}),5e3))}setPublishingCodecs(e){var t,n,i,r,o,s,a;return bi(this,void 0,void 0,(function*(){if(this.log.debug("setting publishing codecs",Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(e[0].qualities),[];this.subscribedCodecs=e;const c=[];try{for(t=!0,n=ki(e);i=yield n.next(),!(r=i.done);t=!0){a=i.value,t=!1;const e=a;if(this.codec&&this.codec!==e.codec){const t=this.simulcastCodecs.get(e.codec);if(this.log.debug("try setPublishingCodec for ".concat(e.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:t})),t&&t.sender)t.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(e.codec),this.logContext),yield Oa(t.sender,t.encodings,e.qualities,this.senderLock,this.log,this.logContext));else for(const t of e.qualities)if(t.enabled){c.push(e.codec);break}}else yield this.setPublishingLayers(e.qualities)}}catch(e){o={error:e}}finally{try{t||r||!(s=n.return)||(yield s.call(n))}finally{if(o)throw o.error}}return c}))}setPublishingLayers(e){return bi(this,void 0,void 0,(function*(){this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:e})),this.sender&&this.encodings&&(yield Oa(this.sender,this.encodings,e,this.senderLock,this.log,this.logContext))}))}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return bi(this,void 0,void 0,(function*(){yield e.handleAppVisibilityChanged.call(this),ts()&&this.isInBackground&&this.source===Io.Source.Camera&&(this._mediaStreamTrack.enabled=!1)}))}}function Oa(e,t,n,i,r,o){return bi(this,void 0,void 0,(function*(){const s=yield i.lock();r.debug("setPublishingLayersForSender",Object.assign(Object.assign({},o),{sender:e,qualities:n,senderEncodings:t}));try{const i=e.getParameters(),{encodings:s}=i;if(!s)return;if(s.length!==t.length)return void r.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},o),{encodings:s,senderEncodings:t}));let a=!1;s.forEach(((e,i)=>{var s;let c=null!==(s=e.rid)&&void 0!==s?s:"";""===c&&(c="q");const d=xa(c),l=n.find((e=>e.quality===d));l&&e.active!==l.enabled&&(a=!0,e.active=l.enabled,r.debug("setting layer ".concat(l.quality," to ").concat(e.active?"enabled":"disabled"),o),$o()&&(l.enabled?(e.scaleResolutionDownBy=t[i].scaleResolutionDownBy,e.maxBitrate=t[i].maxBitrate,e.maxFrameRate=t[i].maxFrameRate):(e.scaleResolutionDownBy=4,e.maxBitrate=10,e.maxFrameRate=2)))})),a&&(i.encodings=s,r.debug("setting encodings",Object.assign(Object.assign({},o),{encodings:i.encodings})),yield e.setParameters(i))}finally{s()}}))}function xa(t){switch(t){case"f":default:return e.VideoQuality.HIGH;case"h":return e.VideoQuality.MEDIUM;case"q":return e.VideoQuality.LOW}}function Ia(t,n,i,r){if(!i)return[new Xe({quality:e.VideoQuality.HIGH,width:t,height:n,bitrate:0,ssrc:0})];if(r){const r=i[0].scalabilityMode,o=new _a(r),s=[];for(let r=0;r{var i,r,o;const s=null!==(i=e.scaleResolutionDownBy)&&void 0!==i?i:1;let a=xa(null!==(r=e.rid)&&void 0!==r?r:"");return new Xe({quality:a,width:Math.ceil(t/s),height:Math.ceil(n/s),bitrate:null!==(o=e.maxBitrate)&&void 0!==o?o:0,ssrc:0})}))}class Aa extends Io{constructor(e,t,n,i,r){super(e,n,r),this.sid=t,this.receiver=i}setMuted(t){this.isMuted!==t&&(this.isMuted=t,this._mediaStreamTrack.enabled=!t,this.emit(t?e.TrackEvent.Muted:e.TrackEvent.Unmuted,this))}setMediaStream(t){this.mediaStream=t;const n=i=>{i.track===this._mediaStreamTrack&&(t.removeEventListener("removetrack",n),this.receiver=void 0,this._currentBitrate=0,this.emit(e.TrackEvent.Ended,this))};t.addEventListener("removetrack",n)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){var e;return bi(this,void 0,void 0,(function*(){if(null===(e=this.receiver)||void 0===e?void 0:e.getStats)return yield this.receiver.getStats()}))}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval((()=>this.monitorReceiver()),ha))}}class Ma extends Aa{constructor(e,t,n,i,r,o){super(e,t,Io.Kind.Audio,n,o),this.monitorReceiver=()=>bi(this,void 0,void 0,(function*(){if(!this.receiver)return void(this._currentBitrate=0);const e=yield this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=pa(e,this.prevStats)),this.prevStats=e})),this.audioContext=i,this.webAudioPluginNodes=[],r&&(this.sinkId=r.deviceId)}setVolume(e){var t;for(const n of this.attachedElements)this.audioContext?null===(t=this.gainNode)||void 0===t||t.gain.setTargetAtTime(e,0,.1):n.volume=e;is()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(is())return 1;let e=0;return this.attachedElements.forEach((t=>{t.volume>e&&(e=t.volume)})),e}setSinkId(e){return bi(this,void 0,void 0,(function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map((t=>{if(Xo(t))return t.setSinkId(e)})))}))}attach(e){const t=0===this.attachedElements.length;return e?super.attach(e):e=super.attach(),this.sinkId&&Xo(e)&&e.setSinkId(this.sinkId),this.audioContext&&t&&(this.log.debug("using audio context mapping",this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let t;return e?(t=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(t=super.detach(),this.disconnectWebAudio()),t}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(t,n){this.disconnectWebAudio(),this.sourceNode=t.createMediaStreamSource(n.srcObject);let i=this.sourceNode;this.webAudioPluginNodes.forEach((e=>{i.connect(e),i=e})),this.gainNode=t.createGain(),i.connect(this.gainNode),this.gainNode.connect(t.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),"running"!==t.state&&t.resume().then((()=>{"running"!==t.state&&this.emit(e.TrackEvent.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))})).catch((t=>{this.emit(e.TrackEvent.AudioPlaybackFailed,t)}))}disconnectWebAudio(){var e,t;null===(e=this.gainNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return bi(this,void 0,void 0,(function*(){if(!this.receiver||!this.receiver.getStats)return;let e;return(yield this.receiver.getStats()).forEach((t=>{"inbound-rtp"===t.type&&(e={type:"audio",timestamp:t.timestamp,jitter:t.jitter,bytesReceived:t.bytesReceived,concealedSamples:t.concealedSamples,concealmentEvents:t.concealmentEvents,silentConcealedSamples:t.silentConcealedSamples,silentConcealmentEvents:t.silentConcealmentEvents,totalAudioEnergy:t.totalAudioEnergy,totalSamplesDuration:t.totalSamplesDuration})})),e}))}}class Da extends Aa{constructor(e,t,n,i,r){super(e,t,Io.Kind.Video,n,r),this.elementInfos=[],this.monitorReceiver=()=>bi(this,void 0,void 0,(function*(){if(!this.receiver)return void(this._currentBitrate=0);const e=yield this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=pa(e,this.prevStats)),this.prevStats=e})),this.debouncedHandleResize=mo((()=>{this.updateDimensions()}),100),this.adaptiveStreamSettings=i}get isAdaptiveStream(){return void 0!==this.adaptiveStreamSettings}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach((t=>{e?Mo(this._mediaStreamTrack,t):Ao(this._mediaStreamTrack,t)}))}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&void 0===this.elementInfos.find((t=>t.element===e))){const t=new Na(e);this.observeElementInfo(t)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&void 0===this.elementInfos.find((t=>t===e))?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn("visibility resize observer not triggered",this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream)return void this.log.warn("stopObservingElementInfo ignored",this.logContext);const t=this.elementInfos.filter((t=>t===e));for(const e of t)e.stopObserving();this.elementInfos=this.elementInfos.filter((t=>t!==e)),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let t=[];if(e)return this.stopObservingElement(e),super.detach(e);t=super.detach();for(const e of t)this.stopObservingElement(e);return t}getDecoderImplementation(){var e;return null===(e=this.prevStats)||void 0===e?void 0:e.decoderImplementation}getReceiverStats(){return bi(this,void 0,void 0,(function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t,n="",i=new Map;return e.forEach((e=>{"inbound-rtp"===e.type?(n=e.codecId,t={type:"video",framesDecoded:e.framesDecoded,framesDropped:e.framesDropped,framesReceived:e.framesReceived,packetsReceived:e.packetsReceived,packetsLost:e.packetsLost,frameWidth:e.frameWidth,frameHeight:e.frameHeight,pliCount:e.pliCount,firCount:e.firCount,nackCount:e.nackCount,jitter:e.jitter,timestamp:e.timestamp,bytesReceived:e.bytesReceived,decoderImplementation:e.decoderImplementation}):"codec"===e.type&&i.set(e.id,e)})),t&&""!==n&&i.get(n)&&(t.mimeType=i.get(n).mimeType),t}))}stopObservingElement(e){const t=this.elementInfos.filter((t=>t.element===e));for(const e of t)this.stopObservingElementInfo(e)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return bi(this,void 0,void 0,(function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()}))}updateVisibility(){var t,n;const i=this.elementInfos.reduce(((e,t)=>Math.max(e,t.visibilityChangedAt||0)),0),r=!(null!==(n=null===(t=this.adaptiveStreamSettings)||void 0===t?void 0:t.pauseVideoInBackground)&&void 0!==n&&!n)&&this.isInBackground,o=this.elementInfos.some((e=>e.pictureInPicture)),s=this.elementInfos.some((e=>e.visible))&&!r||o;this.lastVisible!==s&&(!s&&Date.now()-i<100?To.setTimeout((()=>{this.updateVisibility()}),100):(this.lastVisible=s,this.emit(e.TrackEvent.VisibilityChanged,s,this)))}updateDimensions(){var t,n;let i=0,r=0;const o=this.getPixelDensity();for(const e of this.elementInfos){const t=e.width()*o,n=e.height()*o;t+n>i+r&&(i=t,r=n)}(null===(t=this.lastDimensions)||void 0===t?void 0:t.width)===i&&(null===(n=this.lastDimensions)||void 0===n?void 0:n.height)===r||(this.lastDimensions={width:i,height:r},this.emit(e.TrackEvent.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const t=null===(e=this.adaptiveStreamSettings)||void 0===e?void 0:e.pixelDensity;return"screen"===t?as():t||(as()>2?2:1)}}class Na{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,t){this.onVisibilityChanged=e=>{var t;const{target:n,isIntersecting:i}=e;n===this.element&&(this.isIntersecting=i,this.visibilityChangedAt=Date.now(),null===(t=this.handleVisibilityChanged)||void 0===t||t.call(this))},this.onEnterPiP=()=>{var e;this.isPiP=!0,null===(e=this.handleVisibilityChanged)||void 0===e||e.call(this)},this.onLeavePiP=()=>{var e;this.isPiP=!1,null===(e=this.handleVisibilityChanged)||void 0===e||e.call(this)},this.element=e,this.isIntersecting=null!=t?t:La(e),this.isPiP=ns()&&document.pictureInPictureElement===e,this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){this.isIntersecting=La(this.element),this.isPiP=document.pictureInPictureElement===this.element,this.element.handleResize=()=>{var e;null===(e=this.handleResize)||void 0===e||e.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,ms().observe(this.element),hs().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP)}stopObserving(){var e,t;null===(e=ms())||void 0===e||e.unobserve(this.element),null===(t=hs())||void 0===t||t.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP)}}function La(e){let t=e.offsetTop,n=e.offsetLeft;const i=e.offsetWidth,r=e.offsetHeight,{hidden:o}=e,{opacity:s,display:a}=getComputedStyle(e);for(;e.offsetParent;)t+=(e=e.offsetParent).offsetTop,n+=e.offsetLeft;return twindow.pageYOffset&&n+i>window.pageXOffset&&!o&&(""===s||parseFloat(s)>0)&&"none"!==a}class Ua extends Ui.EventEmitter{constructor(t,n,i,r){var o;super(),this.metadataMuted=!1,this.encryption=Ke.NONE,this.log=hi,this.handleMuted=()=>{this.emit(e.TrackEvent.Muted)},this.handleUnmuted=()=>{this.emit(e.TrackEvent.Unmuted)},this.log=mi(null!==(o=null==r?void 0:r.loggerName)&&void 0!==o?o:e.LoggerNames.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=t,this.trackSid=n,this.trackName=i,this.source=Io.Source.Unknown}setTrack(t){this.track&&(this.track.off(e.TrackEvent.Muted,this.handleMuted),this.track.off(e.TrackEvent.Unmuted,this.handleUnmuted)),this.track=t,t&&(t.on(e.TrackEvent.Muted,this.handleMuted),t.on(e.TrackEvent.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this)),Bo(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return void 0!==this.track}get isEncrypted(){return this.encryption!==Ke.NONE}get audioTrack(){if(this.track instanceof ma||this.track instanceof Ma)return this.track}get videoTrack(){if(this.track instanceof Ra||this.track instanceof Da)return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=Io.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===Io.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug("update publication info",Object.assign(Object.assign({},this.logContext),{info:e}))}}!function(e){var t,n;(t=e.SubscriptionStatus||(e.SubscriptionStatus={})).Desired="desired",t.Subscribed="subscribed",t.Unsubscribed="unsubscribed",(n=e.PermissionStatus||(e.PermissionStatus={})).Allowed="allowed",n.NotAllowed="not_allowed"}(Ua||(Ua={}));class Fa extends Ua{get isUpstreamPaused(){var e;return null===(e=this.track)||void 0===e?void 0:e.isUpstreamPaused}constructor(t,n,i,r){super(t,n.sid,n.name,r),this.track=void 0,this.handleTrackEnded=()=>{this.emit(e.TrackEvent.Ended)},this.updateInfo(n),this.setTrack(i)}setTrack(t){this.track&&this.track.off(e.TrackEvent.Ended,this.handleTrackEnded),super.setTrack(t),t&&t.on(e.TrackEvent.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}mute(){var e;return bi(this,void 0,void 0,(function*(){return null===(e=this.track)||void 0===e?void 0:e.mute()}))}unmute(){var e;return bi(this,void 0,void 0,(function*(){return null===(e=this.track)||void 0===e?void 0:e.unmute()}))}pauseUpstream(){var e;return bi(this,void 0,void 0,(function*(){yield null===(e=this.track)||void 0===e?void 0:e.pauseUpstream()}))}resumeUpstream(){var e;return bi(this,void 0,void 0,(function*(){yield null===(e=this.track)||void 0===e?void 0:e.resumeUpstream()}))}}e.ConnectionQuality=void 0,function(e){e.Excellent="excellent",e.Good="good",e.Poor="poor",e.Lost="lost",e.Unknown="unknown"}(e.ConnectionQuality||(e.ConnectionQuality={}));class ja extends Ui.EventEmitter{get logContext(){var e,t;return Object.assign({},null===(t=null===(e=this.loggerOptions)||void 0===e?void 0:e.loggerContextCb)||void 0===t?void 0:t.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every((e=>e.isEncrypted))}get isAgent(){var e,t;return null!==(t=null===(e=this.permissions)||void 0===e?void 0:e.agent)&&void 0!==t&&t}constructor(t,n,i,r,o){var s;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=e.ConnectionQuality.Unknown,this.log=hi,this.log=mi(null!==(s=null==o?void 0:o.loggerName)&&void 0!==s?s:e.LoggerNames.Participant),this.loggerOptions=o,this.setMaxListeners(100),this.sid=t,this.identity=n,this.name=i,this.metadata=r,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(const[,t]of this.trackPublications)if(t.source===e)return t}getTrackPublicationByName(e){for(const[,t]of this.trackPublications)if(t.trackName===e)return t}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrackPublication(Io.Source.Camera);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isMicrophoneEnabled(){var e;const t=this.getTrackPublication(Io.Source.Microphone);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(Io.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(1e3*Number.parseInt(this.participantInfo.joinedAt.toString())):new Date}updateInfo(e){return!(this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version||(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,this.log.trace("update participant info",Object.assign(Object.assign({},this.logContext),{info:e})),0))}_setMetadata(t){const n=this.metadata!==t,i=this.metadata;this.metadata=t,n&&this.emit(e.ParticipantEvent.ParticipantMetadataChanged,i)}_setName(t){const n=this.name!==t;this.name=t,n&&this.emit(e.ParticipantEvent.ParticipantNameChanged,t)}setPermissions(t){var n,i,r,o,s;const a=this.permissions,c=t.canPublish!==(null===(n=this.permissions)||void 0===n?void 0:n.canPublish)||t.canSubscribe!==(null===(i=this.permissions)||void 0===i?void 0:i.canSubscribe)||t.canPublishData!==(null===(r=this.permissions)||void 0===r?void 0:r.canPublishData)||t.hidden!==(null===(o=this.permissions)||void 0===o?void 0:o.hidden)||t.recorder!==(null===(s=this.permissions)||void 0===s?void 0:s.recorder)||t.canPublishSources.length!==this.permissions.canPublishSources.length||t.canPublishSources.some(((e,t)=>{var n;return e!==(null===(n=this.permissions)||void 0===n?void 0:n.canPublishSources[t])}));return this.permissions=t,c&&this.emit(e.ParticipantEvent.ParticipantPermissionsChanged,a),c}setIsSpeaking(t){t!==this.isSpeaking&&(this.isSpeaking=t,t&&(this.lastSpokeAt=new Date),this.emit(e.ParticipantEvent.IsSpeakingChanged,t))}setConnectionQuality(t){const n=this._connectionQuality;this._connectionQuality=function(t){switch(t){case Ne.EXCELLENT:return e.ConnectionQuality.Excellent;case Ne.GOOD:return e.ConnectionQuality.Good;case Ne.POOR:return e.ConnectionQuality.Poor;case Ne.LOST:return e.ConnectionQuality.Lost;default:return e.ConnectionQuality.Unknown}}(t),n!==this._connectionQuality&&this.emit(e.ParticipantEvent.ConnectionQualityChanged,this._connectionQuality)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach((t=>(t.track instanceof Ma||t.track instanceof ma)&&t.track.setAudioContext(e)))}addTrackPublication(t){t.on(e.TrackEvent.Muted,(()=>{this.emit(e.ParticipantEvent.TrackMuted,t)})),t.on(e.TrackEvent.Unmuted,(()=>{this.emit(e.ParticipantEvent.TrackUnmuted,t)}));const n=t;switch(n.track&&(n.track.sid=t.trackSid),this.trackPublications.set(t.trackSid,t),t.kind){case Io.Kind.Audio:this.audioTrackPublications.set(t.trackSid,t);break;case Io.Kind.Video:this.videoTrackPublications.set(t.trackSid,t)}}}class Va extends ja{constructor(e,t,n,i){super(e,t,void 0,void 0,{loggerName:i.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=Ke.NONE,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new bs)},this.handleReconnected=()=>{var e,t;null===(t=null===(e=this.reconnectFuture)||void 0===e?void 0:e.resolve)||void 0===t||t.call(e),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleDisconnected=()=>{var e,t;this.reconnectFuture&&(this.reconnectFuture.promise.catch((e=>this.log.warn(e.message,this.logContext))),null===(t=null===(e=this.reconnectFuture)||void 0===e?void 0:e.reject)||void 0===t||t.call(e,"Got disconnected during reconnection attempt"),this.reconnectFuture=void 0)},this.updateTrackSubscriptionPermissions=()=>{this.log.debug("updating track subscription permissions",Object.assign(Object.assign({},this.logContext),{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions})),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map((e=>function(e){var t,n,i;if(!e.participantSid&&!e.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new Mn({participantIdentity:null!==(t=e.participantIdentity)&&void 0!==t?t:"",participantSid:null!==(n=e.participantSid)&&void 0!==n?n:"",allTracks:null!==(i=e.allowAll)&&void 0!==i&&i,trackSids:e.allowedTrackSids||[]})}(e))))},this.onTrackUnmuted=e=>{this.onTrackMuted(e,e.isUpstreamPaused)},this.onTrackMuted=(e,t)=>{void 0===t&&(t=!0),e.sid?this.engine.updateMuteStatus(e.sid,t):this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),Bo(e)))},this.onTrackUpstreamPaused=e=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),Bo(e))),this.onTrackMuted(e,!0)},this.onTrackUpstreamResumed=e=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),Bo(e))),this.onTrackMuted(e,e.isMuted)},this.handleSubscribedQualityUpdate=e=>bi(this,void 0,void 0,(function*(){var t,n,i,r,o,s;if(!(null===(o=this.roomOptions)||void 0===o?void 0:o.dynacast))return;const a=this.videoTrackPublications.get(e.trackSid);if(a)if(e.subscribedCodecs.length>0){if(!a.videoTrack)return;const o=yield a.videoTrack.setPublishingCodecs(e.subscribedCodecs);try{for(var c,d=!0,l=ki(o);!(t=(c=yield l.next()).done);d=!0){r=c.value,d=!1;const e=r;wo(e)&&(this.log.debug("publish ".concat(e," for ").concat(a.videoTrack.sid),Object.assign(Object.assign({},this.logContext),Bo(a))),yield this.publishAdditionalCodecForTrack(a.videoTrack,e,a.options))}}catch(e){n={error:e}}finally{try{d||t||!(i=l.return)||(yield i.call(l))}finally{if(n)throw n.error}}}else e.subscribedQualities.length>0&&(yield null===(s=a.videoTrack)||void 0===s?void 0:s.setPublishingLayers(e.subscribedQualities));else this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:e.trackSid}))})),this.handleLocalTrackUnpublished=e=>{const t=this.trackPublications.get(e.trackSid);t?this.unpublishTrack(t.track):this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:e.trackSid}))},this.handleTrackEnded=e=>bi(this,void 0,void 0,(function*(){if(e.source===Io.Source.ScreenShare||e.source===Io.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),Bo(e))),this.unpublishTrack(e);else if(e.isUserProvided)yield e.mute();else if(e instanceof ma||e instanceof Ra)try{if(ns())try{const t=yield null===navigator||void 0===navigator?void 0:navigator.permissions.query({name:e.source===Io.Source.Camera?"camera":"microphone"});if(t&&"denied"===t.state)throw this.log.warn("user has revoked access to ".concat(e.source),Object.assign(Object.assign({},this.logContext),Bo(e))),t.onchange=()=>{"denied"!==t.state&&(e.isMuted||e.restartTrack(),t.onchange=null)},new Error("GetUserMedia Permission denied")}catch(e){}e.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),Bo(e))),yield e.restartTrack())}catch(t){this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),Bo(e))),yield e.mute()}})),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=n,this.roomOptions=i,this.setupEngine(n),this.activeDeviceMap=new Map}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==Ke.NONE}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setupEngine(t){this.engine=t,this.engine.on(e.EngineEvent.RemoteMute,((e,t)=>{const n=this.trackPublications.get(e);n&&n.track&&(t?n.mute():n.unmute())})),this.engine.on(e.EngineEvent.Connected,this.handleReconnected).on(e.EngineEvent.SignalRestarted,this.handleReconnected).on(e.EngineEvent.SignalResumed,this.handleReconnected).on(e.EngineEvent.Restarting,this.handleReconnecting).on(e.EngineEvent.Resuming,this.handleReconnecting).on(e.EngineEvent.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(e.EngineEvent.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(e.EngineEvent.Disconnected,this.handleDisconnected)}setMetadata(e){var t;this.engine.client.sendUpdateLocalMetadata(e,null!==(t=this.name)&&void 0!==t?t:"")}setName(e){var t;this.engine.client.sendUpdateLocalMetadata(null!==(t=this.metadata)&&void 0!==t?t:"",e)}setCameraEnabled(e,t,n){return this.setTrackEnabled(Io.Source.Camera,e,t,n)}setMicrophoneEnabled(e,t,n){return this.setTrackEnabled(Io.Source.Microphone,e,t,n)}setScreenShareEnabled(e,t,n){return this.setTrackEnabled(Io.Source.ScreenShare,e,t,n)}setPermissions(t){const n=this.permissions,i=super.setPermissions(t);return i&&n&&this.emit(e.ParticipantEvent.ParticipantPermissionsChanged,n),i}setE2EEEnabled(e){return bi(this,void 0,void 0,(function*(){this.encryptionType=e?Ke.GCM:Ke.NONE,yield this.republishAllTracks(void 0,!1)}))}setTrackEnabled(t,n,i,r){var o,s;return bi(this,void 0,void 0,(function*(){this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:t,enabled:n}));let a=this.getTrackPublication(t);if(n)if(a)yield a.unmute();else{let n;if(this.pendingPublishing.has(t))return void this.log.info("skipping duplicate published source",Object.assign(Object.assign({},this.logContext),{source:t}));this.pendingPublishing.add(t);try{switch(t){case Io.Source.Camera:n=yield this.createTracks({video:null===(o=i)||void 0===o||o});break;case Io.Source.Microphone:n=yield this.createTracks({audio:null===(s=i)||void 0===s||s});break;case Io.Source.ScreenShare:n=yield this.createScreenTracks(Object.assign({},i));break;default:throw new lo(t)}const e=[];for(const t of n)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),Bo(t))),e.push(this.publishTrack(t,r));const c=yield Promise.all(e);[a]=c}catch(t){throw null==n||n.forEach((e=>{e.stop()})),t instanceof Error&&!(t instanceof lo)&&this.emit(e.ParticipantEvent.MediaDevicesError,t),t}finally{this.pendingPublishing.delete(t)}}else if(a&&a.track)if(t===Io.Source.ScreenShare){a=yield this.unpublishTrack(a.track);const e=this.getTrackPublication(Io.Source.ScreenShareAudio);e&&e.track&&this.unpublishTrack(e.track)}else yield a.mute();return a}))}enableCameraAndMicrophone(){return bi(this,void 0,void 0,(function*(){if(!this.pendingPublishing.has(Io.Source.Camera)&&!this.pendingPublishing.has(Io.Source.Microphone)){this.pendingPublishing.add(Io.Source.Camera),this.pendingPublishing.add(Io.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map((e=>this.publishTrack(e))))}finally{this.pendingPublishing.delete(Io.Source.Camera),this.pendingPublishing.delete(Io.Source.Microphone)}}}))}createTracks(t){var n,i;return bi(this,void 0,void 0,(function*(){const r=Lo(Do(t,null===(n=this.roomOptions)||void 0===n?void 0:n.audioCaptureDefaults,null===(i=this.roomOptions)||void 0===i?void 0:i.videoCaptureDefaults));let o;try{o=yield navigator.mediaDevices.getUserMedia(r)}catch(e){throw e instanceof Error&&(r.audio&&(this.microphoneError=e),r.video&&(this.cameraError=e)),e}return r.audio&&(this.microphoneError=void 0,this.emit(e.ParticipantEvent.AudioStreamAcquired)),r.video&&(this.cameraError=void 0),o.getTracks().map((e=>{const n="audio"===e.kind;let i;n?t.audio:t.video;const s=n?r.audio:r.video;"boolean"!=typeof s&&(i=s);const a=fa(e,i,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});return a.kind===Io.Kind.Video?a.source=Io.Source.Camera:a.kind===Io.Kind.Audio&&(a.source=Io.Source.Microphone),a.mediaStream=o,a}))}))}createScreenTracks(t){return bi(this,void 0,void 0,(function*(){if(void 0===t&&(t={}),void 0===navigator.mediaDevices.getDisplayMedia)throw new co("getDisplayMedia not supported");void 0!==t.resolution||es()||(t.resolution=Oo.h1080fps30.resolution);const n=Fo(t),i=yield navigator.mediaDevices.getDisplayMedia(n),r=i.getVideoTracks();if(0===r.length)throw new lo("no video track found");const o=new Ra(r[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});o.source=Io.Source.ScreenShare,t.contentHint&&(o.mediaStreamTrack.contentHint=t.contentHint);const s=[o];if(i.getAudioTracks().length>0){this.emit(e.ParticipantEvent.AudioStreamAcquired);const t=new ma(i.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});t.source=Io.Source.ScreenShareAudio,s.push(t)}return s}))}publishTrack(e,t){var n,i,r,o;return bi(this,void 0,void 0,(function*(){let s,a;if(e instanceof ma&&e.setAudioContext(this.audioContext),yield null===(n=this.reconnectFuture)||void 0===n?void 0:n.promise,e instanceof ws&&this.pendingPublishPromises.has(e)&&(yield this.pendingPublishPromises.get(e)),e instanceof MediaStreamTrack)s=e.getConstraints();else{let t;switch(s=e.constraints,e.source){case Io.Source.Microphone:t="audioinput";break;case Io.Source.Camera:t="videoinput"}t&&this.activeDeviceMap.has(t)&&(s=Object.assign(Object.assign({},s),{deviceId:this.activeDeviceMap.get(t)}))}if(e instanceof MediaStreamTrack)switch(e.kind){case"audio":e=new ma(e,s,!0,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});break;case"video":e=new Ra(e,s,!0,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});break;default:throw new lo("unsupported MediaStreamTrack kind ".concat(e.kind))}else e.updateLoggerOptions({loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(this.trackPublications.forEach((t=>{t.track&&t.track===e&&(a=t)})),a)return this.log.warn("track has already been published, skipping",Object.assign(Object.assign({},this.logContext),Bo(a))),a;const c="channelCount"in e.mediaStreamTrack.getSettings()&&2===e.mediaStreamTrack.getSettings().channelCount||2===e.mediaStreamTrack.getConstraints().channelCount,d=null!==(i=null==t?void 0:t.forceStereo)&&void 0!==i?i:c;d&&(t||(t={}),void 0===t.dtx&&this.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},this.logContext),Bo(e))),void 0===t.red&&this.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),null!==(r=t.dtx)&&void 0!==r||(t.dtx=!1),null!==(o=t.red)&&void 0!==o||(t.red=!1));const l=Object.assign(Object.assign({},this.roomOptions.publishDefaults),t);Zo()&&this.roomOptions.e2ee&&(this.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari",Object.assign({},this.logContext)),l.simulcast=!1),l.source&&(e.source=l.source);const u=this.publish(e,l,d);this.pendingPublishPromises.set(e,u);try{return yield u}catch(e){throw e}finally{this.pendingPublishPromises.delete(e)}}))}publish(t,n,i){var r,o,s,a,c,d,l,u,h,p,m,f;return bi(this,void 0,void 0,(function*(){Array.from(this.trackPublications.values()).find((e=>t instanceof ws&&e.source===t.source))&&t.source!==Io.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(t.source),Object.assign(Object.assign({},this.logContext),Bo(t))),n.stopMicTrackOnMute&&t instanceof ma&&(t.stopOnMute=!0),t.source===Io.Source.ScreenShare&&$o()&&(n.simulcast=!1),"av1"!==n.videoCodec||Ko()||(n.videoCodec=void 0),"vp9"!==n.videoCodec||zo()||(n.videoCodec=void 0),void 0===n.videoCodec&&(n.videoCodec=Qs);const g=n.videoCodec;t.on(e.TrackEvent.Muted,this.onTrackMuted),t.on(e.TrackEvent.Unmuted,this.onTrackUnmuted),t.on(e.TrackEvent.Ended,this.handleTrackEnded),t.on(e.TrackEvent.UpstreamPaused,this.onTrackUpstreamPaused),t.on(e.TrackEvent.UpstreamResumed,this.onTrackUpstreamResumed);const v=new cn({cid:t.mediaStreamTrack.id,name:n.name,type:Io.kindToProto(t.kind),muted:t.isMuted,source:Io.sourceToProto(t.source),disableDtx:!(null===(r=n.dtx)||void 0===r||r),encryption:this.encryptionType,stereo:i,disableRed:this.isE2EEEnabled||!(null===(o=n.red)||void 0===o||o),stream:null==n?void 0:n.stream});let y;if(t.kind===Io.Kind.Video){let e={width:0,height:0};try{e=yield t.waitForDimensions()}catch(n){const i=null!==(a=null===(s=this.roomOptions.videoCaptureDefaults)||void 0===s?void 0:s.resolution)&&void 0!==a?a:_o.h720.resolution;e={width:i.width,height:i.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),Bo(t)),{dims:e}))}v.width=e.width,v.height=e.height,t instanceof Ra&&(Jo(g)&&(t.source===Io.Source.ScreenShare&&(n.scalabilityMode="L1T3","contentHint"in t.mediaStreamTrack&&(t.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),Bo(t))))),n.scalabilityMode=null!==(c=n.scalabilityMode)&&void 0!==c?c:"L3T3_KEY"),v.simulcastCodecs=[new an({codec:g,cid:t.mediaStreamTrack.id})],!0===n.backupCodec&&(n.backupCodec={codec:Qs}),n.backupCodec&&g!==n.backupCodec.codec&&v.encryption===Ke.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),v.simulcastCodecs.push(new an({codec:n.backupCodec.codec,cid:""})))),y=Sa(t.source===Io.Source.ScreenShare,v.width,v.height,n),v.layers=Ia(v.width,v.height,y,Jo(n.videoCodec))}else t.kind===Io.Kind.Audio&&(y=[{maxBitrate:null===(d=n.audioPreset)||void 0===d?void 0:d.maxBitrate,priority:null!==(u=null===(l=n.audioPreset)||void 0===l?void 0:l.priority)&&void 0!==u?u:"high",networkPriority:null!==(p=null===(h=n.audioPreset)||void 0===h?void 0:h.priority)&&void 0!==p?p:"high"}]);if(!this.engine||this.engine.isClosed)throw new ho("cannot publish track when not connected");const b=yield this.engine.addTrack(v);let k;if(b.codecs.forEach((e=>{void 0===k&&(k=e.mimeType)})),k&&t.kind===Io.Kind.Video){const e=jo(k);e!==g&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),Bo(t)),{codec:e})),n.videoCodec=e,y=Sa(t.source===Io.Source.ScreenShare,v.width,v.height,n))}const T=new Fa(t.kind,b,t,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(T.options=n,t.sid=b.sid,!this.engine.pcManager)throw new ho("pcManager is not ready");if(this.log.debug("publishing ".concat(t.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:y,trackInfo:b})),t.sender=yield this.engine.createSender(t,n,y),y)if($o()&&t.kind===Io.Kind.Audio){let e;for(const n of this.engine.pcManager.publisher.getTransceivers())if(n.sender===t.sender){e=n;break}e&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:e,codec:"opus",maxbr:(null===(m=y[0])||void 0===m?void 0:m.maxBitrate)?y[0].maxBitrate/1e3:0})}else t.codec&&"av1"==t.codec&&(null===(f=y[0])||void 0===f?void 0:f.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:v.cid,codec:t.codec,maxbr:y[0].maxBitrate/1e3});if(t.kind===Io.Kind.Video&&t.source===Io.Source.ScreenShare)try{this.log.debug("setting degradationPreference to maintain-resolution");const e=t.sender.getParameters();e.degradationPreference="maintain-resolution",yield t.sender.setParameters(e)}catch(e){this.log.warn("failed to set degradationPreference: ".concat(e))}return yield this.engine.negotiate(),t instanceof Ra?t.startMonitor(this.engine.client):t instanceof ma&&t.startMonitor(),this.addTrackPublication(T),this.emit(e.ParticipantEvent.LocalTrackPublished,T),T}))}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,n){var i;return bi(this,void 0,void 0,(function*(){if(this.encryptionType!==Ke.NONE)return;let r;if(this.trackPublications.forEach((t=>{t.track&&t.track===e&&(r=t)})),!r)throw new lo("track is not published");if(!(e instanceof Ra))throw new lo("track is not a video track");const o=Object.assign(Object.assign({},null===(i=this.roomOptions)||void 0===i?void 0:i.publishDefaults),n),s=function(e,t,n){var i,r,o,s;if(!n.backupCodec||!0===n.backupCodec||n.backupCodec.codec===n.videoCodec)return;t!==n.backupCodec.codec&&hi.warn("requested a different codec than specified as backup",{serverRequested:t,backup:n.backupCodec.codec}),n.videoCodec=t,n.videoEncoding=n.backupCodec.encoding;const a=e.mediaStreamTrack.getSettings(),c=null!==(i=a.width)&&void 0!==i?i:null===(r=e.dimensions)||void 0===r?void 0:r.width,d=null!==(o=a.height)&&void 0!==o?o:null===(s=e.dimensions)||void 0===s?void 0:s.height;return Sa(e.source===Io.Source.ScreenShare,c,d,n)}(e,t,o);if(!s)return void this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),Bo(e)));const a=e.addSimulcastTrack(t,s);if(!a)return;const c=new cn({cid:a.mediaStreamTrack.id,type:Io.kindToProto(e.kind),muted:e.isMuted,source:Io.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:o.videoCodec,cid:a.mediaStreamTrack.id}]});if(c.layers=Ia(c.width,c.height,s),!this.engine||this.engine.isClosed)throw new ho("cannot publish track when not connected");const d=yield this.engine.addTrack(c);yield this.engine.createSimulcastSender(e,a,o,s),yield this.engine.negotiate(),this.log.debug("published ".concat(t," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:s,trackInfo:d}))}))}unpublishTrack(t,n){var i,r;return bi(this,void 0,void 0,(function*(){const o=this.getPublicationForTrack(t),s=o?Bo(o):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),s)),!o||!o.track)return void this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),s));(t=o.track).off(e.TrackEvent.Muted,this.onTrackMuted),t.off(e.TrackEvent.Unmuted,this.onTrackUnmuted),t.off(e.TrackEvent.Ended,this.handleTrackEnded),t.off(e.TrackEvent.UpstreamPaused,this.onTrackUpstreamPaused),t.off(e.TrackEvent.UpstreamResumed,this.onTrackUpstreamResumed),void 0===n&&(n=null===(r=null===(i=this.roomOptions)||void 0===i?void 0:i.stopLocalTrackOnUnpublish)||void 0===r||r),n&&t.stop();let a=!1;const c=t.sender;if(t.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentStatethis.unpublishTrack(e))))).filter((e=>e instanceof Fa))}))}republishAllTracks(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return bi(this,void 0,void 0,(function*(){const n=[];this.trackPublications.forEach((t=>{t.track&&(e&&(t.options=Object.assign(Object.assign({},t.options),e)),n.push(t))})),yield Promise.all(n.map((e=>bi(this,void 0,void 0,(function*(){const n=e.track;yield this.unpublishTrack(n,!1),t&&!n.isMuted&&n.source!==Io.Source.ScreenShare&&n.source!==Io.Source.ScreenShareAudio&&(n instanceof ma||n instanceof Ra)&&!n.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:e.trackSid})),yield n.restartTrack()),yield this.publishTrack(n,e.options)})))))}))}publishData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return bi(this,void 0,void 0,(function*(){const n=t.reliable?Qe.RELIABLE:Qe.LOSSY,i=t.destinationIdentities,r=t.topic,o=new Ye({kind:n,value:{case:"user",value:new et({participantIdentity:this.identity,payload:e,destinationIdentities:i,topic:r})}});yield this.engine.sendDataPacket(o,n)}))}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}updateInfo(e){return e.sid===this.sid&&!!super.updateInfo(e)&&(e.tracks.forEach((e=>{var t,n;const i=this.trackPublications.get(e.sid);if(i){const r=i.isMuted||null!==(n=null===(t=i.track)||void 0===t?void 0:t.isUpstreamPaused)&&void 0!==n&&n;r!==e.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),Bo(i)),{mutedOnServer:r})),this.engine.client.sendMuteTrack(e.sid,r))}})),!0)}getPublicationForTrack(e){let t;return this.trackPublications.forEach((n=>{const i=n.track;i&&(e instanceof MediaStreamTrack?(i instanceof ma||i instanceof Ra)&&i.mediaStreamTrack===e&&(t=n):e===i&&(t=n))})),t}}class Ba extends Ua{constructor(t,n,i,r){super(t,n.sid,n.name,r),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=e.VideoQuality.HIGH,this.handleEnded=t=>{this.setTrack(void 0),this.emit(e.TrackEvent.Ended,t)},this.handleVisibilityChange=e=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(e),this.logContext),this.disabled=!e,this.emitTrackUpdate()},this.handleVideoDimensionsChange=e=>{this.log.debug("adaptivestream video dimensions ".concat(e.width,"x").concat(e.height),this.logContext),this.videoDimensions=e,this.emitTrackUpdate()},this.subscribed=i,this.updateInfo(n)}setSubscribed(t){const n=this.subscriptionStatus,i=this.permissionStatus;this.subscribed=t,t&&(this.allowed=!0);const r=new vn({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new nt({participantSid:"",trackSids:[this.trackSid]})]});this.emit(e.TrackEvent.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(n),this.emitPermissionUpdateIfChanged(i)}get subscriptionStatus(){return!1===this.subscribed?Ua.SubscriptionStatus.Unsubscribed:super.isSubscribed?Ua.SubscriptionStatus.Subscribed:Ua.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?Ua.PermissionStatus.Allowed:Ua.PermissionStatus.NotAllowed}get isSubscribed(){return!1!==this.subscribed&&super.isSubscribed}get isDesired(){return!1!==this.subscribed}get isEnabled(){return!this.disabled}setEnabled(e){this.isManualOperationAllowed()&&this.disabled!==!e&&(this.disabled=!e,this.emitTrackUpdate())}setVideoQuality(e){this.isManualOperationAllowed()&&this.currentVideoQuality!==e&&(this.currentVideoQuality=e,this.videoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var t,n;this.isManualOperationAllowed()&&((null===(t=this.videoDimensions)||void 0===t?void 0:t.width)===e.width&&(null===(n=this.videoDimensions)||void 0===n?void 0:n.height)===e.height||(this.track instanceof Da&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&this.track instanceof Da&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(t){const n=this.subscriptionStatus,i=this.permissionStatus,r=this.track;r!==t&&(r&&(r.off(e.TrackEvent.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(e.TrackEvent.VisibilityChanged,this.handleVisibilityChange),r.off(e.TrackEvent.Ended,this.handleEnded),r.detach(),r.stopMonitor(),this.emit(e.TrackEvent.Unsubscribed,r)),super.setTrack(t),t&&(t.sid=this.trackSid,t.on(e.TrackEvent.VideoDimensionsChanged,this.handleVideoDimensionsChange),t.on(e.TrackEvent.VisibilityChanged,this.handleVisibilityChange),t.on(e.TrackEvent.Ended,this.handleEnded),this.emit(e.TrackEvent.Subscribed,t)),this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(n))}setAllowed(e){const t=this.subscriptionStatus,n=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t)}setSubscriptionError(t){this.emit(e.TrackEvent.SubscriptionFailed,t)}updateInfo(t){super.updateInfo(t);const n=this.metadataMuted;this.metadataMuted=t.muted,this.track?this.track.setMuted(t.muted):n!==t.muted&&this.emit(t.muted?e.TrackEvent.Muted:e.TrackEvent.Unmuted)}emitSubscriptionUpdateIfChanged(t){const n=this.subscriptionStatus;t!==n&&this.emit(e.TrackEvent.SubscriptionStatusChanged,n,t)}emitPermissionUpdateIfChanged(t){this.permissionStatus!==t&&this.emit(e.TrackEvent.SubscriptionPermissionChanged,this.permissionStatus,t)}isManualOperationAllowed(){return this.kind===Io.Kind.Video&&this.isAdaptiveStream?(this.log.warn("adaptive stream is enabled, cannot change video track settings",this.logContext),!1):!!this.isDesired||(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return this.track instanceof Da&&this.track.isAdaptiveStream}emitTrackUpdate(){const t=new yn({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(t.width=Math.ceil(this.videoDimensions.width),t.height=Math.ceil(this.videoDimensions.height)):void 0!==this.currentVideoQuality?t.quality=this.currentVideoQuality:t.quality=e.VideoQuality.HIGH,this.emit(e.TrackEvent.UpdateSettings,t)}}class Ga extends ja{static fromParticipantInfo(e,t){return new Ga(e,t.sid,t.identity,t.name,t.metadata)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,t,n,i,r,o){super(t,n||"",i,r,o),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.volumeMap=new Map}addTrackPublication(t){super.addTrackPublication(t),t.on(e.TrackEvent.UpdateSettings,(e=>{this.log.debug("send update settings",Object.assign(Object.assign({},this.logContext),Bo(t))),this.signalClient.sendUpdateTrackSettings(e)})),t.on(e.TrackEvent.UpdateSubscription,(e=>{e.participantTracks.forEach((e=>{e.participantSid=this.sid})),this.signalClient.sendUpdateSubscription(e)})),t.on(e.TrackEvent.SubscriptionPermissionChanged,(n=>{this.emit(e.ParticipantEvent.TrackSubscriptionPermissionChanged,t,n)})),t.on(e.TrackEvent.SubscriptionStatusChanged,(n=>{this.emit(e.ParticipantEvent.TrackSubscriptionStatusChanged,t,n)})),t.on(e.TrackEvent.Subscribed,(n=>{this.emit(e.ParticipantEvent.TrackSubscribed,n,t)})),t.on(e.TrackEvent.Unsubscribed,(n=>{this.emit(e.ParticipantEvent.TrackUnsubscribed,n,t)})),t.on(e.TrackEvent.SubscriptionFailed,(n=>{this.emit(e.ParticipantEvent.TrackSubscriptionFailed,t.trackSid,n)}))}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setVolume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Io.Source.Microphone;this.volumeMap.set(t,e);const n=this.getTrackPublication(t);n&&n.track&&n.track.setVolume(e)}getVolume(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Io.Source.Microphone;const t=this.getTrackPublication(e);return t&&t.track?t.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(t,n,i,r,o,s){let a,c=this.getTrackPublicationBySid(n);return c||n.startsWith("TR")||this.trackPublications.forEach((e=>{c||t.kind!==e.kind.toString()||(c=e)})),c?"ended"===t.readyState?(this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),Bo(c))),void this.emit(e.ParticipantEvent.TrackSubscriptionFailed,n)):(a="video"===t.kind?new Da(t,n,r,o):new Ma(t,n,r,this.audioContext,this.audioOutput),a.source=c.source,a.isMuted=c.isMuted,a.setMediaStream(i),a.start(),c.setTrack(a),this.volumeMap.has(c.source)&&a instanceof Ma&&a.setVolume(this.volumeMap.get(c.source)),c):0===s?(this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:n})),void this.emit(e.ParticipantEvent.TrackSubscriptionFailed,n)):(void 0===s&&(s=20),void setTimeout((()=>{this.addSubscribedMediaTrack(t,n,i,r,o,s-1)}),150))}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(t){if(!super.updateInfo(t))return!1;const n=new Map,i=new Map;return t.tracks.forEach((e=>{var t,r;let o=this.getTrackPublicationBySid(e.sid);if(o)o.updateInfo(e);else{const n=Io.kindFromProto(e.type);if(!n)return;o=new Ba(n,e,null===(t=this.signalClient.connectOptions)||void 0===t?void 0:t.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:null===(r=this.loggerOptions)||void 0===r?void 0:r.loggerName}),o.updateInfo(e),i.set(e.sid,o);const s=Array.from(this.trackPublications.values()).find((e=>e.source===(null==o?void 0:o.source)));s&&o.source!==Io.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(o.source),Object.assign(Object.assign({},this.logContext),{oldTrack:Bo(s),newTrack:Bo(o)})),this.addTrackPublication(o)}n.set(e.sid,o)})),this.trackPublications.forEach((e=>{n.has(e.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),Bo(e))),this.unpublishTrack(e.trackSid,!0))})),i.forEach((t=>{this.emit(e.ParticipantEvent.TrackPublished,t)})),!0}unpublishTrack(t,n){const i=this.trackPublications.get(t);if(!i)return;const{track:r}=i;switch(r&&(r.stop(),i.setTrack(void 0)),this.trackPublications.delete(t),i.kind){case Io.Kind.Audio:this.audioTrackPublications.delete(t);break;case Io.Kind.Video:this.videoTrackPublications.delete(t)}n&&this.emit(e.ParticipantEvent.TrackUnpublished,i)}setAudioOutput(e){return bi(this,void 0,void 0,(function*(){this.audioOutput=e;const t=[];this.audioTrackPublications.forEach((n=>{var i;n.track instanceof Ma&&t.push(n.track.setSinkId(null!==(i=e.deviceId)&&void 0!==i?i:"default"))})),yield Promise.all(t)}))}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;ibi(this,void 0,void 0,(function*(){var r;if(!Qo())throw is()?Error("WebRTC isn't detected, have you called registerGlobals?"):Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");const o=yield this.disconnectLock.lock();if(this.state===e.ConnectionState.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),o(),Promise.resolve();if(this.connectFuture)return o(),this.connectFuture.promise;this.setAndEmitConnectionState(e.ConnectionState.Connecting),(null===(r=this.regionUrlProvider)||void 0===r?void 0:r.getServerUrl().toString())!==t&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),rs(new URL(t))&&(void 0===this.regionUrlProvider?this.regionUrlProvider=new ua(t,n):this.regionUrlProvider.updateToken(n),this.regionUrlProvider.fetchRegionSettings().catch((e=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:e}))})));const s=(e,r,a)=>bi(this,void 0,void 0,(function*(){var c;this.abortController&&this.abortController.abort();const d=new AbortController;this.abortController=d,null==o||o();try{yield this.attemptConnection(null!=a?a:t,n,i,d),this.abortController=void 0,e()}catch(t){if(this.regionUrlProvider&&t instanceof ao&&3!==t.reason&&0!==t.reason){let n=null;try{n=yield this.regionUrlProvider.getNextBestRegionUrl(null===(c=this.abortController)||void 0===c?void 0:c.signal)}catch(e){if(e instanceof ao&&(401===e.status||3===e.reason))return this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),void r(e)}n?(this.log.info("Initial connection failed with ConnectionError: ".concat(t.message,". Retrying with another region: ").concat(n),this.logContext),this.recreateEngine(),yield s(e,r,n)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),r(t))}else this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),r(t)}})),a=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new bs(((e,t)=>{s(e,t,a)}),(()=>{this.clearConnectionFutures()})),this.connectFuture.promise})),this.connectSignal=(e,t,n,i,r,o)=>bi(this,void 0,void 0,(function*(){var s,a,c;const d=yield n.join(e,t,{autoSubscribe:i.autoSubscribe,adaptiveStream:"object"==typeof r.adaptiveStream||r.adaptiveStream,maxRetries:i.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:i.websocketTimeout},o.signal);let l=d.serverInfo;if(l||(l={version:d.serverVersion,region:d.serverRegion}),this.log.debug("connected to Livekit Server ".concat(Object.entries(l).map((e=>{let[t,n]=e;return"".concat(t,": ").concat(n)})).join(", ")),{room:null===(s=d.room)||void 0===s?void 0:s.name,roomSid:null===(a=d.room)||void 0===a?void 0:a.sid,identity:null===(c=d.participant)||void 0===c?void 0:c.identity}),!d.serverVersion)throw new uo("unknown server version");return"0.15.1"===d.serverVersion&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),r.dynacast=!1),d})),this.applyJoinResponse=e=>{const t=e.participant;if(this.localParticipant.sid=t.sid,this.localParticipant.identity=t.identity,this.options.e2ee&&this.e2eeManager)try{this.e2eeManager.setSifTrailer(e.sifTrailer)}catch(e){this.log.error(e instanceof Error?e.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:e}))}this.handleParticipantUpdates([t,...e.otherParticipants]),e.room&&this.handleRoomUpdate(e.room)},this.attemptConnection=(t,n,i,r)=>bi(this,void 0,void 0,(function*(){var o,s,a;this.state===e.ConnectionState.Reconnecting||this.isResuming||(null===(o=this.engine)||void 0===o?void 0:o.pendingReconnect)?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),(null===(s=this.regionUrlProvider)||void 0===s?void 0:s.isCloud())&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},na),i),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const i=yield this.connectSignal(t,n,this.engine,this.connOptions,this.options,r);this.applyJoinResponse(i),this.setupLocalParticipantEvents(),this.emit(e.RoomEvent.SignalConnected)}catch(e){yield this.engine.close(),this.recreateEngine();const t=new ao("could not establish signal connection");throw e instanceof Error&&(t.message="".concat(t.message,": ").concat(e.message)),e instanceof ao&&(t.reason=e.reason,t.status=e.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:e})),t}if(r.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),new ao("Connection attempt aborted");try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,r)}catch(e){throw yield this.engine.close(),this.recreateEngine(),e}ns()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),ns()&&(document.addEventListener("freeze",this.onPageLeave),null===(a=navigator.mediaDevices)||void 0===a||a.addEventListener("devicechange",this.handleDeviceChange)),this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Connected),this.registerConnectionReconcile()})),this.disconnect=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return bi(n,void 0,void 0,(function*(){var n,i,r,o;const s=yield this.disconnectLock.lock();try{if(this.state===e.ConnectionState.Disconnected)return void this.log.debug("already disconnected",this.logContext);this.log.info("disconnect from room",Object.assign({},this.logContext)),(this.state===e.ConnectionState.Connecting||this.state===e.ConnectionState.Reconnecting||this.isResuming)&&(this.log.warn("abort connection attempt",this.logContext),null===(n=this.abortController)||void 0===n||n.abort(),null===(r=null===(i=this.connectFuture)||void 0===i?void 0:i.reject)||void 0===r||r.call(i,new ao("Client initiated disconnect")),this.connectFuture=void 0),(null===(o=this.engine)||void 0===o?void 0:o.client.isDisconnected)||(yield this.engine.client.sendLeave()),this.engine&&(yield this.engine.close()),this.handleDisconnect(t,Ue.CLIENT_INITIATED),this.engine=void 0}finally{s()}}))},this.onPageLeave=()=>bi(this,void 0,void 0,(function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()})),this.startAudio=()=>bi(this,void 0,void 0,(function*(){const t=[],n=vo();if(n&&"iOS"===n.os){const n="livekit-dummy-audio-el";let i=document.getElementById(n);if(!i){i=document.createElement("audio"),i.id=n,i.autoplay=!0,i.hidden=!0;const t=ys();t.enabled=!0;const r=new MediaStream([t]);i.srcObject=r,document.addEventListener("visibilitychange",(()=>{i&&(i.srcObject=document.hidden?null:r,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))})),document.body.append(i),this.once(e.RoomEvent.Disconnected,(()=>{null==i||i.remove(),i=null}))}t.push(i)}this.remoteParticipants.forEach((e=>{e.audioTrackPublications.forEach((e=>{e.track&&e.track.attachedElements.forEach((e=>{t.push(e)}))}))}));try{yield Promise.all([this.acquireAudioContext(),...t.map((e=>(e.muted=!1,e.play())))]),this.handleAudioPlaybackStarted()}catch(e){throw this.handleAudioPlaybackFailed(e),e}})),this.startVideo=()=>bi(this,void 0,void 0,(function*(){const e=[];for(const t of this.remoteParticipants.values())t.videoTrackPublications.forEach((t=>{var n;null===(n=t.track)||void 0===n||n.attachedElements.forEach((t=>{e.includes(t)||e.push(t)}))}));yield Promise.all(e.map((e=>e.play()))).then((()=>{this.handleVideoPlaybackStarted()})).catch((e=>{"NotAllowedError"===e.name?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler",this.logContext)}))})),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(const e of this.remoteParticipants.values())this.handleParticipantDisconnected(e.identity,e);this.setAndEmitConnectionState(e.ConnectionState.Reconnecting)&&this.emit(e.RoomEvent.Reconnecting)},this.handleSignalRestarted=t=>bi(this,void 0,void 0,(function*(){this.log.debug("signal reconnected to server, region ".concat(t.serverRegion),Object.assign(Object.assign({},this.logContext),{region:t.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(t);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(e){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:e}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:t.serverRegion}))}catch(e){return}this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()})),this.handleParticipantUpdates=e=>{e.forEach((e=>{var t;if(e.identity===this.localParticipant.identity)return void this.localParticipant.updateInfo(e);""===e.identity&&(e.identity=null!==(t=this.sidToIdentity.get(e.sid))&&void 0!==t?t:"");let n=this.remoteParticipants.get(e.identity);e.state===He.DISCONNECTED?this.handleParticipantDisconnected(e.identity,n):n=this.getOrCreateParticipant(e.identity,e)}))},this.handleActiveSpeakersUpdate=t=>{const n=[],i={};t.forEach((e=>{if(i[e.sid]=!0,e.sid===this.localParticipant.sid)this.localParticipant.audioLevel=e.level,this.localParticipant.setIsSpeaking(!0),n.push(this.localParticipant);else{const t=this.getRemoteParticipantBySid(e.sid);t&&(t.audioLevel=e.level,t.setIsSpeaking(!0),n.push(t))}})),i[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach((e=>{i[e.sid]||(e.audioLevel=0,e.setIsSpeaking(!1))})),this.activeSpeakers=n,this.emitWhenConnected(e.RoomEvent.ActiveSpeakersChanged,n)},this.handleSpeakersChanged=t=>{const n=new Map;this.activeSpeakers.forEach((e=>{n.set(e.sid,e)})),t.forEach((e=>{let t=this.getRemoteParticipantBySid(e.sid);e.sid===this.localParticipant.sid&&(t=this.localParticipant),t&&(t.audioLevel=e.level,t.setIsSpeaking(e.active),e.active?n.set(e.sid,t):n.delete(e.sid))}));const i=Array.from(n.values());i.sort(((e,t)=>t.audioLevel-e.audioLevel)),this.activeSpeakers=i,this.emitWhenConnected(e.RoomEvent.ActiveSpeakersChanged,i)},this.handleStreamStateUpdate=t=>{t.streamStates.forEach((t=>{const n=this.getRemoteParticipantBySid(t.participantSid);if(!n)return;const i=n.getTrackPublicationBySid(t.trackSid);i&&i.track&&(i.track.streamState=Io.streamStateFromProto(t.state),n.emit(e.ParticipantEvent.TrackStreamStateChanged,i,i.track.streamState),this.emitWhenConnected(e.RoomEvent.TrackStreamStateChanged,i,i.track.streamState,n))}))},this.handleSubscriptionPermissionUpdate=e=>{const t=this.getRemoteParticipantBySid(e.participantSid);if(!t)return;const n=t.getTrackPublicationBySid(e.trackSid);n&&n.setAllowed(e.allowed)},this.handleSubscriptionError=e=>{const t=Array.from(this.remoteParticipants.values()).find((t=>t.trackPublications.has(e.trackSid)));if(!t)return;const n=t.getTrackPublicationBySid(e.trackSid);n&&n.setSubscriptionError(e.err)},this.handleDataPacket=(t,n)=>{const i=this.remoteParticipants.get(t.participantIdentity);this.emit(e.RoomEvent.DataReceived,t.payload,i,n,t.topic),null==i||i.emit(e.ParticipantEvent.DataReceived,t.payload,n)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=t=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:t})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(e.RoomEvent.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(e.RoomEvent.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>bi(this,void 0,void 0,(function*(){this.emit(e.RoomEvent.MediaDevicesChanged)})),this.handleRoomUpdate=t=>{const n=this.roomInfo;this.roomInfo=t,n&&n.metadata!==t.metadata&&this.emitWhenConnected(e.RoomEvent.RoomMetadataChanged,t.metadata),(null==n?void 0:n.activeRecording)!==t.activeRecording&&this.emitWhenConnected(e.RoomEvent.RecordingStatusChanged,t.activeRecording)},this.handleConnectionQualityUpdate=e=>{e.updates.forEach((e=>{if(e.participantSid===this.localParticipant.sid)return void this.localParticipant.setConnectionQuality(e.quality);const t=this.getRemoteParticipantBySid(e.participantSid);t&&t.setConnectionQuality(e.quality)}))},this.onLocalParticipantMetadataChanged=t=>{this.emit(e.RoomEvent.ParticipantMetadataChanged,t,this.localParticipant)},this.onLocalParticipantNameChanged=t=>{this.emit(e.RoomEvent.ParticipantNameChanged,t,this.localParticipant)},this.onLocalTrackMuted=t=>{this.emit(e.RoomEvent.TrackMuted,t,this.localParticipant)},this.onLocalTrackUnmuted=t=>{this.emit(e.RoomEvent.TrackUnmuted,t,this.localParticipant)},this.onTrackProcessorUpdate=e=>{var t;null===(t=null==e?void 0:e.onPublish)||void 0===t||t.call(e,this)},this.onLocalTrackPublished=t=>bi(this,void 0,void 0,(function*(){var n,i,r,o,s;null===(n=t.track)||void 0===n||n.on(e.TrackEvent.TrackProcessorUpdate,this.onTrackProcessorUpdate),null===(o=null===(r=null===(i=t.track)||void 0===i?void 0:i.getProcessor())||void 0===r?void 0:r.onPublish)||void 0===o||o.call(r,this),this.emit(e.RoomEvent.LocalTrackPublished,t,this.localParticipant),t.track instanceof ma&&(yield t.track.checkForSilence())&&this.emit(e.RoomEvent.LocalAudioSilenceDetected,t);const a=yield null===(s=t.track)||void 0===s?void 0:s.getDeviceId(),c=(d=t.source)===Io.Source.Microphone?"audioinput":d===Io.Source.Camera?"videoinput":void 0;var d;c&&a&&a!==this.localParticipant.activeDeviceMap.get(c)&&(this.localParticipant.activeDeviceMap.set(c,a),this.emit(e.RoomEvent.ActiveDeviceChanged,c,a))})),this.onLocalTrackUnpublished=t=>{var n;null===(n=t.track)||void 0===n||n.off(e.TrackEvent.TrackProcessorUpdate,this.onTrackProcessorUpdate),this.emit(e.RoomEvent.LocalTrackUnpublished,t,this.localParticipant)},this.onLocalConnectionQualityChanged=t=>{this.emit(e.RoomEvent.ConnectionQualityChanged,t,this.localParticipant)},this.onMediaDevicesError=t=>{this.emit(e.RoomEvent.MediaDevicesError,t)},this.onLocalParticipantPermissionsChanged=t=>{this.emit(e.RoomEvent.ParticipantPermissionsChanged,t,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},ta),t),this.log=mi(null!==(i=this.options.loggerName)&&void 0!==i?i:e.LoggerNames.Room),this.options.audioCaptureDefaults=Object.assign(Object.assign({},Zs),null==t?void 0:t.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},ea),null==t?void 0:t.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},$s),null==t?void 0:t.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new ks,this.localParticipant=new Va("","",this.engine,this.options),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",Ts(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",Ts(this.options.audioCaptureDefaults.deviceId)),(null===(r=this.options.audioOutput)||void 0===r?void 0:r.deviceId)&&this.switchActiveDevice("audiooutput",Ts(this.options.audioOutput.deviceId)).catch((e=>this.log.warn("Could not set audio output: ".concat(e.message),this.logContext))),this.options.e2ee&&this.setupE2EE()}setE2EEEnabled(e){return bi(this,void 0,void 0,(function*(){if(!this.e2eeManager)throw Error("e2ee not configured, please set e2ee settings within the room options");yield Promise.all([this.localParticipant.setE2EEEnabled(e)]),""!==this.localParticipant.identity&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity)}))}setupE2EE(){var t;this.options.e2ee&&(this.e2eeManager=new Ps(this.options.e2ee),this.e2eeManager.on(e.EncryptionEvent.ParticipantEncryptionStatusChanged,((t,n)=>{n instanceof Va&&(this.isE2EEEnabled=t),this.emit(e.RoomEvent.ParticipantEncryptionStatusChanged,t,n)})),this.e2eeManager.on(e.EncryptionEvent.EncryptionError,(t=>this.emit(e.RoomEvent.EncryptionError,t))),null===(t=this.e2eeManager)||void 0===t||t.setup(this))}get logContext(){var e;return{room:this.name,roomID:null===(e=this.roomInfo)||void 0===e?void 0:e.sid,participant:this.localParticipant.identity,pID:this.localParticipant.sid}}get isRecording(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.activeRecording)&&void 0!==t&&t}getSid(){return bi(this,void 0,void 0,(function*(){return this.state===e.ConnectionState.Disconnected?"":this.roomInfo&&""!==this.roomInfo.sid?this.roomInfo.sid:new Promise(((t,n)=>{const i=n=>{""!==n.sid&&(this.engine.off(e.EngineEvent.RoomUpdate,i),t(n.sid))};this.engine.on(e.EngineEvent.RoomUpdate,i),this.once(e.RoomEvent.Disconnected,(()=>{this.engine.off(e.EngineEvent.RoomUpdate,i),n("Room disconnected before room server id was available")}))}))}))}get name(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.name)&&void 0!==t?t:""}get metadata(){var e;return null===(e=this.roomInfo)||void 0===e?void 0:e.metadata}get numParticipants(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.numParticipants)&&void 0!==t?t:0}get numPublishers(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.numPublishers)&&void 0!==t?t:0}maybeCreateEngine(){this.engine&&!this.engine.isClosed||(this.engine=new da(this.options),this.engine.on(e.EngineEvent.ParticipantUpdate,this.handleParticipantUpdates).on(e.EngineEvent.RoomUpdate,this.handleRoomUpdate).on(e.EngineEvent.SpeakersChanged,this.handleSpeakersChanged).on(e.EngineEvent.StreamStateChanged,this.handleStreamStateUpdate).on(e.EngineEvent.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(e.EngineEvent.SubscriptionError,this.handleSubscriptionError).on(e.EngineEvent.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(e.EngineEvent.MediaTrackAdded,((e,t,n)=>{this.onTrackAdded(e,t,n)})).on(e.EngineEvent.Disconnected,(e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)})).on(e.EngineEvent.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(e.EngineEvent.DataPacketReceived,this.handleDataPacket).on(e.EngineEvent.Resuming,(()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext)})).on(e.EngineEvent.Resumed,(()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents()})).on(e.EngineEvent.SignalResumed,(()=>{this.bufferedEvents=[],(this.state===e.ConnectionState.Reconnecting||this.isResuming)&&this.sendSyncState()})).on(e.EngineEvent.Restarting,this.handleRestarting).on(e.EngineEvent.SignalRestarted,this.handleSignalRestarted).on(e.EngineEvent.Offline,(()=>{this.setAndEmitConnectionState(e.ConnectionState.Reconnecting)&&this.emit(e.RoomEvent.Reconnecting)})).on(e.EngineEvent.DCBufferStatusChanged,((t,n)=>{this.emit(e.RoomEvent.DCBufferStatusChanged,t,n)})),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine))}static getLocalDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Cs.getInstance().getDevices(e,t)}prepareConnection(t,n){return bi(this,void 0,void 0,(function*(){if(this.state===e.ConnectionState.Disconnected){this.log.debug("prepareConnection to ".concat(t),this.logContext);try{if(rs(new URL(t))&&n){this.regionUrlProvider=new ua(t,n);const i=yield this.regionUrlProvider.getNextBestRegionUrl();i&&this.state===e.ConnectionState.Disconnected&&(this.regionUrl=i,yield fetch(Es(i),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(i),this.logContext))}else yield fetch(Es(t),{method:"HEAD"})}catch(e){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:e}))}}}))}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,t){return bi(this,void 0,void 0,(function*(){let n,i=()=>{};switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":n=new Fn({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":n=new Fn({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":n=new Fn({scenario:{case:"serverLeave",value:!0}});break;case"migration":n=new Fn({scenario:{case:"migration",value:!0}});break;case"resume-reconnect":this.engine.failNext(),yield this.engine.client.handleOnClose("simulate resume-disconnect");break;case"disconnect-signal-on-resume":i=()=>bi(this,void 0,void 0,(function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")})),n=new Fn({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":i=()=>bi(this,void 0,void 0,(function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")})),n=new Fn({scenario:{case:"disconnectSignalOnResumeNoMessages",value:!0}});break;case"full-reconnect":this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose("simulate full-reconnect");break;case"force-tcp":case"force-tls":n=new Fn({scenario:{case:"switchCandidateProtocol",value:"force-tls"===e?2:1}}),i=()=>bi(this,void 0,void 0,(function*(){const e=this.engine.client.onLeave;e&&e(new bn({reason:Ue.CLIENT_INITIATED,canReconnect:!0}))}));break;case"subscriber-bandwidth":if(void 0===t||"number"!=typeof t)throw new Error("subscriber-bandwidth requires a number as argument");n=new Fn({scenario:{case:"subscriberBandwidth",value:BigInt(t)}})}n&&(yield this.engine.client.sendSimulateScenario(n),yield i())}))}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(t,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var r,o,s,a;return bi(this,void 0,void 0,(function*(){let c=!1,d=!0;const l=i?{exact:n}:n;if("audioinput"===t){const e=this.options.audioCaptureDefaults.deviceId;this.options.audioCaptureDefaults.deviceId=l,c=e!==l;const t=Array.from(this.localParticipant.audioTrackPublications.values()).filter((e=>e.source===Io.Source.Microphone));try{d=(yield Promise.all(t.map((e=>{var t;return null===(t=e.audioTrack)||void 0===t?void 0:t.setDeviceId(l)})))).every((e=>!0===e))}catch(t){throw this.options.audioCaptureDefaults.deviceId=e,t}}else if("videoinput"===t){const e=this.options.videoCaptureDefaults.deviceId;this.options.videoCaptureDefaults.deviceId=l,c=e!==l;const t=Array.from(this.localParticipant.videoTrackPublications.values()).filter((e=>e.source===Io.Source.Camera));try{d=(yield Promise.all(t.map((e=>{var t;return null===(t=e.videoTrack)||void 0===t?void 0:t.setDeviceId(l)})))).every((e=>!0===e))}catch(t){throw this.options.videoCaptureDefaults.deviceId=e,t}}else if("audiooutput"===t){if(!Xo()&&!this.options.webAudioMix||this.options.webAudioMix&&this.audioContext&&!("setSinkId"in this.audioContext))throw new Error("cannot switch audio output, setSinkId not supported");this.options.webAudioMix&&(n=null!==(r=yield Cs.getInstance().normalizeDeviceId("audiooutput",n))&&void 0!==r?r:""),null!==(o=(a=this.options).audioOutput)&&void 0!==o||(a.audioOutput={});const e=this.options.audioOutput.deviceId;this.options.audioOutput.deviceId=n,c=e!==l;try{this.options.webAudioMix?null===(s=this.audioContext)||void 0===s||s.setSinkId(n):yield Promise.all(Array.from(this.remoteParticipants.values()).map((e=>e.setAudioOutput({deviceId:n}))))}catch(t){throw this.options.audioOutput.deviceId=e,t}}return c&&d&&(this.localParticipant.activeDeviceMap.set(t,n),this.emit(e.RoomEvent.ActiveDeviceChanged,t,n)),d}))}setupLocalParticipantEvents(){this.localParticipant.on(e.ParticipantEvent.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(e.ParticipantEvent.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(e.ParticipantEvent.TrackMuted,this.onLocalTrackMuted).on(e.ParticipantEvent.TrackUnmuted,this.onLocalTrackUnmuted).on(e.ParticipantEvent.LocalTrackPublished,this.onLocalTrackPublished).on(e.ParticipantEvent.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(e.ParticipantEvent.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(e.ParticipantEvent.MediaDevicesError,this.onMediaDevicesError).on(e.ParticipantEvent.AudioStreamAcquired,this.startAudio).on(e.ParticipantEvent.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;null===(e=this.engine)||void 0===e||e.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(t,n,i){if(this.state===e.ConnectionState.Connecting||this.state===e.ConnectionState.Reconnecting){const r=()=>{this.onTrackAdded(t,n,i),o()},o=()=>{this.off(e.RoomEvent.Reconnected,r),this.off(e.RoomEvent.Connected,r),this.off(e.RoomEvent.Disconnected,o)};return this.once(e.RoomEvent.Reconnected,r),this.once(e.RoomEvent.Connected,r),void this.once(e.RoomEvent.Disconnected,o)}if(this.state===e.ConnectionState.Disconnected)return void this.log.warn("skipping incoming track after Room disconnected",this.logContext);const r=function(e){const t=e.split("|");return t.length>1?[t[0],e.substr(t[0].length+1)]:[e,""]}(n.id),o=r[0];let s=r[1],a=t.id;if(s&&s.startsWith("TR")&&(a=s),o===this.localParticipant.sid)return void this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);const c=Array.from(this.remoteParticipants.values()).find((e=>e.sid===o));if(!c)return void this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(o),this.logContext);let d;this.options.adaptiveStream&&(d="object"==typeof this.options.adaptiveStream?this.options.adaptiveStream:{}),c.addSubscribedMediaTrack(t,a,n,i,d)}handleDisconnect(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=arguments.length>1?arguments[1]:void 0;var i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.state!==e.ConnectionState.Disconnected){this.regionUrl=void 0;try{this.remoteParticipants.forEach((e=>{e.trackPublications.forEach((t=>{e.unpublishTrack(t.trackSid)}))})),this.localParticipant.trackPublications.forEach((e=>{var n,i;e.track&&this.localParticipant.unpublishTrack(e.track,t),t&&(null===(n=e.track)||void 0===n||n.detach(),null===(i=e.track)||void 0===i||i.stop())})),this.localParticipant.off(e.ParticipantEvent.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(e.ParticipantEvent.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(e.ParticipantEvent.TrackMuted,this.onLocalTrackMuted).off(e.ParticipantEvent.TrackUnmuted,this.onLocalTrackUnmuted).off(e.ParticipantEvent.LocalTrackPublished,this.onLocalTrackPublished).off(e.ParticipantEvent.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(e.ParticipantEvent.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(e.ParticipantEvent.MediaDevicesError,this.onMediaDevicesError).off(e.ParticipantEvent.AudioStreamAcquired,this.startAudio).off(e.ParticipantEvent.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&"boolean"==typeof this.options.webAudioMix&&(this.audioContext.close(),this.audioContext=void 0),ns()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),null===(i=navigator.mediaDevices)||void 0===i||i.removeEventListener("devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(e.ConnectionState.Disconnected),this.emit(e.RoomEvent.Disconnected,n)}}}handleParticipantDisconnected(t,n){this.remoteParticipants.delete(t),n&&(n.trackPublications.forEach((e=>{n.unpublishTrack(e.trackSid,!0)})),this.emit(e.RoomEvent.ParticipantDisconnected,n))}acquireAudioContext(){var t,n;return bi(this,void 0,void 0,(function*(){if("boolean"!=typeof this.options.webAudioMix&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:this.audioContext&&"closed"!==this.audioContext.state||(this.audioContext=null!==(t=Uo())&&void 0!==t?t:void 0),this.audioContext&&"suspended"===this.audioContext.state)try{yield this.audioContext.resume()}catch(e){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:e}))}this.options.webAudioMix&&this.remoteParticipants.forEach((e=>e.setAudioContext(this.audioContext))),this.localParticipant.setAudioContext(this.audioContext);const i="running"===(null===(n=this.audioContext)||void 0===n?void 0:n.state);i!==this.canPlaybackAudio&&(this.audioEnabled=i,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,i))}))}createParticipant(e,t){var n;let i;return i=t?Ga.fromParticipantInfo(this.engine.client,t):new Ga(this.engine.client,"",e,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&i.setAudioContext(this.audioContext),(null===(n=this.options.audioOutput)||void 0===n?void 0:n.deviceId)&&i.setAudioOutput(this.options.audioOutput).catch((e=>this.log.warn("Could not set audio output: ".concat(e.message),this.logContext))),i}getOrCreateParticipant(t,n){if(this.remoteParticipants.has(t)){const e=this.remoteParticipants.get(t);return n&&e.updateInfo(n)&&this.sidToIdentity.set(n.sid,n.identity),e}const i=this.createParticipant(t,n);return this.remoteParticipants.set(t,i),this.sidToIdentity.set(n.sid,n.identity),this.emitWhenConnected(e.RoomEvent.ParticipantConnected,i),i.on(e.ParticipantEvent.TrackPublished,(t=>{this.emitWhenConnected(e.RoomEvent.TrackPublished,t,i)})).on(e.ParticipantEvent.TrackSubscribed,((t,n)=>{t.kind===Io.Kind.Audio?(t.on(e.TrackEvent.AudioPlaybackStarted,this.handleAudioPlaybackStarted),t.on(e.TrackEvent.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):t.kind===Io.Kind.Video&&(t.on(e.TrackEvent.VideoPlaybackFailed,this.handleVideoPlaybackFailed),t.on(e.TrackEvent.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(e.RoomEvent.TrackSubscribed,t,n,i)})).on(e.ParticipantEvent.TrackUnpublished,(t=>{this.emit(e.RoomEvent.TrackUnpublished,t,i)})).on(e.ParticipantEvent.TrackUnsubscribed,((t,n)=>{this.emit(e.RoomEvent.TrackUnsubscribed,t,n,i)})).on(e.ParticipantEvent.TrackSubscriptionFailed,(t=>{this.emit(e.RoomEvent.TrackSubscriptionFailed,t,i)})).on(e.ParticipantEvent.TrackMuted,(t=>{this.emitWhenConnected(e.RoomEvent.TrackMuted,t,i)})).on(e.ParticipantEvent.TrackUnmuted,(t=>{this.emitWhenConnected(e.RoomEvent.TrackUnmuted,t,i)})).on(e.ParticipantEvent.ParticipantMetadataChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantMetadataChanged,t,i)})).on(e.ParticipantEvent.ParticipantNameChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantNameChanged,t,i)})).on(e.ParticipantEvent.ConnectionQualityChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ConnectionQualityChanged,t,i)})).on(e.ParticipantEvent.ParticipantPermissionsChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantPermissionsChanged,t,i)})).on(e.ParticipantEvent.TrackSubscriptionStatusChanged,((t,n)=>{this.emitWhenConnected(e.RoomEvent.TrackSubscriptionStatusChanged,t,n,i)})).on(e.ParticipantEvent.TrackSubscriptionFailed,((t,n)=>{this.emit(e.RoomEvent.TrackSubscriptionFailed,t,i,n)})).on(e.ParticipantEvent.TrackSubscriptionPermissionChanged,((t,n)=>{this.emitWhenConnected(e.RoomEvent.TrackSubscriptionPermissionChanged,t,n,i)})),n&&i.updateInfo(n),i}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce(((e,t)=>(e.push(...t.getTrackPublications()),e)),[]),t=this.localParticipant.getTrackPublications();this.engine.sendSyncState(e,t)}updateSubscriptions(){for(const e of this.remoteParticipants.values())for(const t of e.videoTrackPublications.values())t.isSubscribed&&t instanceof Ba&&t.emitTrackUpdate()}getRemoteParticipantBySid(e){const t=this.sidToIdentity.get(e);if(t)return this.remoteParticipants.get(t)}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=To.setInterval((()=>{this.engine&&!this.engine.isClosed&&this.engine.verifyTransport()?e=0:(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:{closed:this.engine.isClosed,transportsConnected:this.engine.verifyTransport()}})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Ue.STATE_MISMATCH)))}),2e3)}clearConnectionReconcile(){this.connectionReconcileInterval&&To.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(t){return t!==this.state&&(this.state=t,this.emit(e.RoomEvent.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach((e=>{let[t,n]=e;this.emit(t,...n)})),this.bufferedEvents=[]}emitWhenConnected(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;rthis.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(t),this.localParticipant.emit(e.ParticipantEvent.LocalTrackPublished,t)}if(r.audio){const t=new Fa(Io.Kind.Audio,new Je({source:Me.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Ae.AUDIO}),new ma(r.useRealTracks?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:ys(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(t),this.localParticipant.emit(e.ParticipantEvent.LocalTrackPublished,t)}for(let e=0;e1?n-1:0),r=1;rvoid 0!==e));this.log.debug("room event ".concat(t),Object.assign(Object.assign({},this.logContext),{event:t,args:e}))}return super.emit(t,...i)}}function Ka(e){return e.map((e=>{if(e)return Array.isArray(e)?Ka(e):"object"==typeof e?"logContext"in e&&e.logContext:e}))}!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.SKIPPED=2]="SKIPPED",e[e.SUCCESS=3]="SUCCESS",e[e.FAILED=4]="FAILED"}(Ha||(Ha={}));class za extends Ui.EventEmitter{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.status=Ha.IDLE,this.logs=[],this.errorsAsWarnings=!1,this.url=e,this.token=t,this.name=this.constructor.name,this.room=new Wa(n.roomOptions),this.connectOptions=n.connectOptions,n.errorsAsWarnings&&(this.errorsAsWarnings=n.errorsAsWarnings)}run(e){return bi(this,void 0,void 0,(function*(){if(this.status!==Ha.IDLE)throw Error("check is running already");this.setStatus(Ha.RUNNING);try{yield this.perform()}catch(e){e instanceof Error&&(this.errorsAsWarnings?this.appendWarning(e.message):this.appendError(e.message))}return yield this.disconnect(),yield new Promise((e=>setTimeout(e,500))),this.status!==Ha.SKIPPED&&this.setStatus(this.isSuccess()?Ha.SUCCESS:Ha.FAILED),e&&e(),this.getInfo()}))}isSuccess(){return!this.logs.some((e=>"error"===e.level))}connect(){return bi(this,void 0,void 0,(function*(){return this.room.state===e.ConnectionState.Connected||(yield this.room.connect(this.url,this.token)),this.room}))}disconnect(){return bi(this,void 0,void 0,(function*(){this.room&&this.room.state!==e.ConnectionState.Disconnected&&(yield this.room.disconnect(),yield new Promise((e=>setTimeout(e,500))))}))}skip(){this.setStatus(Ha.SKIPPED)}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return null===(e=this.room)||void 0===e?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}function Ja(e){var t,n;return bi(this,void 0,void 0,(function*(){null!=e||(e={}),null!==(t=e.audio)&&void 0!==t||(e.audio=!0),null!==(n=e.video)&&void 0!==n||(e.video=!0);const i=Lo(Do(e,Zs,ea)),r=navigator.mediaDevices.getUserMedia(i);e.audio&&(Cs.userMediaPromiseMap.set("audioinput",r),r.catch((()=>Cs.userMediaPromiseMap.delete("audioinput")))),e.video&&(Cs.userMediaPromiseMap.set("videoinput",r),r.catch((()=>Cs.userMediaPromiseMap.delete("videoinput"))));const o=yield r;return o.getTracks().map((t=>{const n="audio"===t.kind;let r;n?e.audio:e.video;const s=n?i.audio:i.video;"boolean"!=typeof s&&(r=s),r?r.deviceId=t.getSettings().deviceId:r={deviceId:t.getSettings().deviceId};const a=fa(t,r);return a.kind===Io.Kind.Video?a.source=Io.Source.Camera:a.kind===Io.Kind.Audio&&(a.source=Io.Source.Microphone),a.mediaStream=o,a}))}))}function Xa(e){return bi(this,void 0,void 0,(function*(){return(yield Ja({audio:!1,video:e}))[0]}))}function Ya(e){return bi(this,void 0,void 0,(function*(){return(yield Ja({audio:e,video:!1}))[0]}))}class Qa extends za{get description(){return"Can publish audio"}perform(){var e;return bi(this,void 0,void 0,(function*(){const t=yield this.connect(),n=yield Ya();t.localParticipant.publishTrack(n),yield new Promise((e=>setTimeout(e,3e3)));const i=yield null===(e=n.sender)||void 0===e?void 0:e.getStats();if(!i)throw new Error("Could not get RTCStats");let r=0;if(i.forEach((e=>{"outbound-rtp"===e.type&&"audio"===e.mediaType&&(r=e.packetsSent)})),0===r)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(r," audio packets"))}))}}class $a extends za{get description(){return"Can publish video"}perform(){var e;return bi(this,void 0,void 0,(function*(){const t=yield this.connect(),n=yield Xa();t.localParticipant.publishTrack(n),yield new Promise((e=>setTimeout(e,3e3)));const i=yield null===(e=n.sender)||void 0===e?void 0:e.getStats();if(!i)throw new Error("Could not get RTCStats");let r=0;if(i.forEach((e=>{"outbound-rtp"===e.type&&"video"===e.mediaType&&(r=e.packetsSent)})),0===r)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(r," video packets"))}))}}class Za extends za{get description(){return"Resuming connection after interruption"}perform(){var t;return bi(this,void 0,void 0,(function*(){const n=yield this.connect();let i,r=!1,o=!1;const s=new Promise((e=>{setTimeout(e,5e3),i=e}));n.on(e.RoomEvent.Reconnecting,(()=>{r=!0})).on(e.RoomEvent.Reconnected,(()=>{o=!0,i(!0)})),null===(t=n.engine.client.ws)||void 0===t||t.close();const a=n.engine.client.onClose;if(a&&a(""),yield s,!r)throw new Error("Did not attempt to reconnect");if(!o||n.state!==e.ConnectionState.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}))}}class ec extends za{get description(){return"Can connect via TURN"}perform(){var e,t;return bi(this,void 0,void 0,(function*(){const n=new Is,i=yield n.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});let r=!1,o=!1,s=!1;for(let e of i.iceServers)for(let t of e.urls)t.startsWith("turn:")?(o=!0,s=!0):t.startsWith("turns:")&&(o=!0,s=!0,r=!0),t.startsWith("stun:")&&(s=!0);s?o&&!r&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield n.close(),(null===(t=null===(e=this.connectOptions)||void 0===e?void 0:e.rtcConfig)||void 0===t?void 0:t.iceServers)||o?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise((e=>setTimeout(e,0))))}))}}class tc extends za{get description(){return"Establishing WebRTC connection"}perform(){return bi(this,void 0,void 0,(function*(){let t=!1,n=!1;this.room.on(e.RoomEvent.SignalConnected,(()=>{const e=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(i,r)=>{if(i.candidate){const e=new RTCIceCandidate(i);let r="".concat(e.protocol," ").concat(e.address,":").concat(e.port," ").concat(e.type);e.address&&(function(e){const t=e.split(".");if(4===t.length){if("10"===t[0])return!0;if("192"===t[0]&&"168"===t[1])return!0;if("172"===t[0]){const e=parseInt(t[1],10);if(e>=16&&e<=31)return!0}}return!1}(e.address)?r+=" (private)":"tcp"===e.protocol&&"passive"===e.tcpType?(t=!0,r+=" (passive)"):"udp"===e.protocol&&(n=!0)),this.appendMessage(r)}e&&e(i,r)},this.room.engine.pcManager&&(this.room.engine.pcManager.subscriber.onIceCandidateError=e=>{e instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(e.errorCode," ").concat(e.errorText," ").concat(e.url))})}));try{yield this.connect(),hi.info("now the room is connected")}catch(e){throw this.appendWarning("ports need to be open on firewall in order to connect."),e}t||this.appendWarning("Server is not configured for ICE/TCP"),n||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")}))}}class nc extends za{get description(){return"Connecting to signal connection via WebSocket"}perform(){var e,t,n;return bi(this,void 0,void 0,(function*(){(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let i=new Is;const r=yield i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});this.appendMessage("Connected to server, version ".concat(r.serverVersion,".")),(null===(e=r.serverInfo)||void 0===e?void 0:e.edition)===rt.Cloud&&(null===(t=r.serverInfo)||void 0===t?void 0:t.region)&&this.appendMessage("LiveKit Cloud: ".concat(null===(n=r.serverInfo)||void 0===n?void 0:n.region)),yield i.close()}))}}class ic extends Ui.EventEmitter{constructor(e,t){super(),this.checkResults=new Map,this.url=e,this.token=t}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:Ha.IDLE,name:"",description:""}),e}updateCheck(e,t){this.checkResults.set(e,t),this.emit("checkUpdate",e,t)}isSuccess(){return Array.from(this.checkResults.values()).every((e=>e.status!==Ha.FAILED))}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return bi(this,void 0,void 0,(function*(){const t=this.getNextCheckId(),n=new e(this.url,this.token),i=e=>{this.updateCheck(t,e)};n.on("update",i);const r=yield n.run();return n.off("update",i),r}))}checkWebsocket(){return bi(this,void 0,void 0,(function*(){return this.createAndRunCheck(nc)}))}checkWebRTC(){return bi(this,void 0,void 0,(function*(){return this.createAndRunCheck(tc)}))}checkTURN(){return bi(this,void 0,void 0,(function*(){return this.createAndRunCheck(ec)}))}checkReconnect(){return bi(this,void 0,void 0,(function*(){return this.createAndRunCheck(Za)}))}checkPublishAudio(){return bi(this,void 0,void 0,(function*(){return this.createAndRunCheck(Qa)}))}checkPublishVideo(){return bi(this,void 0,void 0,(function*(){return this.createAndRunCheck($a)}))}}const rc=new Map([["obs virtual camera",{facingMode:"environment",confidence:"medium"}]]),oc=new Map([["iphone",{facingMode:"environment",confidence:"medium"}],["ipad",{facingMode:"environment",confidence:"medium"}]]);function sc(e){var t;const n=e.trim().toLowerCase();if(""!==n)return rc.has(n)?rc.get(n):null===(t=Array.from(oc.entries()).find((e=>{let[t]=e;return n.includes(t)})))||void 0===t?void 0:t[1]}e.BaseKeyProvider=oo,e.ConnectionCheck=ic,e.ConnectionError=ao,e.CriticalTimers=To,e.DataPacket_Kind=Qe,e.DefaultReconnectPolicy=yi,e.DeviceUnsupportedError=co,e.DisconnectReason=Ue,e.ExternalE2EEKeyProvider=class extends oo{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(Object.assign(Object.assign({},e),{sharedKey:!0,ratchetWindowSize:0,failureTolerance:-1}))}setKey(e){return bi(this,void 0,void 0,(function*(){const t="string"==typeof e?yield no(e):yield io(e);this.onSetEncryptionKey(t)}))}},e.LivekitError=so,e.LocalAudioTrack=ma,e.LocalParticipant=Va,e.LocalTrack=ws,e.LocalTrackPublication=Fa,e.LocalVideoTrack=Ra,e.NegotiationError=po,e.Participant=ja,e.PublishDataError=class extends so{constructor(e){super(13,null!=e?e:"unable to publish data")}},e.RemoteAudioTrack=Ma,e.RemoteParticipant=Ga,e.RemoteTrack=Aa,e.RemoteTrackPublication=Ba,e.RemoteVideoTrack=Da,e.Room=Wa,e.ScreenSharePresets=Oo,e.SubscriptionError=je,e.Track=Io,e.TrackInvalidError=lo,e.TrackPublication=Ua,e.UnexpectedConnectionState=ho,e.UnsupportedServer=uo,e.VideoPreset=Eo,e.VideoPresets=_o,e.VideoPresets43=Ro,e.attachToElement=Ao,e.createAudioAnalyser=function(e,t){const n=Object.assign({cloneTrack:!1,fftSize:2048,smoothingTimeConstant:.8,minDecibels:-100,maxDecibels:-80},t),i=Uo();if(!i)throw new Error("Audio Context not supported on this browser");const r=n.cloneTrack?e.mediaStreamTrack.clone():e.mediaStreamTrack,o=i.createMediaStreamSource(new MediaStream([r])),s=i.createAnalyser();s.minDecibels=n.minDecibels,s.maxDecibels=n.maxDecibels,s.fftSize=n.fftSize,s.smoothingTimeConstant=n.smoothingTimeConstant,o.connect(s);const a=new Uint8Array(s.frequencyBinCount);return{calculateVolume:()=>{s.getByteFrequencyData(a);let e=0;for(const t of a)e+=Math.pow(t/255,2);return Math.sqrt(e/a.length)},analyser:s,cleanup:()=>bi(this,void 0,void 0,(function*(){yield i.close(),n.cloneTrack&&r.stop()}))}},e.createE2EEKey=function(){return window.crypto.getRandomValues(new Uint8Array(32))},e.createKeyMaterialFromBuffer=io,e.createKeyMaterialFromString=no,e.createLocalAudioTrack=Ya,e.createLocalScreenTracks=function(e){return bi(this,void 0,void 0,(function*(){if(void 0===e&&(e={}),void 0!==e.resolution||es()||(e.resolution=Oo.h1080fps30.resolution),void 0===navigator.mediaDevices.getDisplayMedia)throw new co("getDisplayMedia not supported");const t=Fo(e),n=yield navigator.mediaDevices.getDisplayMedia(t),i=n.getVideoTracks();if(0===i.length)throw new lo("no video track found");const r=new Ra(i[0],void 0,!1);r.source=Io.Source.ScreenShare;const o=[r];if(n.getAudioTracks().length>0){const e=new ma(n.getAudioTracks()[0],void 0,!1);e.source=Io.Source.ScreenShareAudio,o.push(e)}return o}))},e.createLocalTracks=Ja,e.createLocalVideoTrack=Xa,e.deriveKeys=function(e,t){return bi(this,void 0,void 0,(function*(){const n=ro(e.algorithm.name,t),i=yield crypto.subtle.deriveKey(n,e,{name:qr,length:128},!1,["encrypt","decrypt"]);return{material:e,encryptionKey:i}}))},e.detachTrack=Mo,e.facingModeFromDeviceLabel=sc,e.facingModeFromLocalTrack=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const i=e instanceof ws?e.mediaStreamTrack:e,r=i.getSettings();let o={facingMode:null!==(n=t.defaultFacingMode)&&void 0!==n?n:"user",confidence:"low"};if("facingMode"in r){const e=r.facingMode;hi.trace("rawFacingMode",{rawFacingMode:e}),e&&"string"==typeof e&&function(e){return void 0===e||["user","environment","left","right"].includes(e)}(e)&&(o={facingMode:e,confidence:"high"})}if(["low","medium"].includes(o.confidence)){hi.trace("Try to get facing mode from device label: (".concat(i.label,")"));const e=sc(i.label);void 0!==e&&(o=e)}return o},e.getBrowser=vo,e.getEmptyAudioStreamTrack=ys,e.getEmptyVideoStreamTrack=function(){return fs||(fs=vs()),fs.clone()},e.getLogger=mi,e.importKey=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{name:qr},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"encrypt";return bi(this,void 0,void 0,(function*(){return crypto.subtle.importKey("raw",e,t,!1,"derive"===n?["deriveBits","deriveKey"]:["encrypt","decrypt"])}))},e.isBackupCodec=wo,e.isBrowserSupported=Qo,e.isE2EESupported=Zr,e.isInsertableStreamSupported=to,e.isScriptTransformSupported=eo,e.isVideoFrame=function(e){return"type"in e},e.needsRbspUnescaping=function(e){for(var t=0;t=3&&!e[i]&&!e[i+1]&&3==e[i+2]?(t.push(e[i++]),t.push(e[i++]),i++):t.push(e[i++]);return new Uint8Array(t)},e.protocolVersion=12,e.ratchet=function(e,t){return bi(this,void 0,void 0,(function*(){const n=ro(e.algorithm.name,t);return crypto.subtle.deriveBits(n,e,256)}))},e.setLogExtension=function(t,n){(n?[n]:pi).forEach((n=>{const i=n.methodFactory;n.methodFactory=(n,r,o)=>{const s=i(n,r,o),a=e.LogLevel[n],c=a>=r&&a{n?s(e,n):s(e),c&&t(a,e,n)}},n.setLevel(n.getLevel())}))},e.setLogLevel=function(e,t){t&&ui.getLogger(t).setLevel(e);for(const t of pi)t.setLevel(e)},e.supportsAV1=Ko,e.supportsAdaptiveStream=function(){return void 0!==typeof ResizeObserver&&void 0!==typeof IntersectionObserver},e.supportsDynacast=function(){return Ho()},e.supportsVP9=zo,e.version=ko,e.videoCodecs=Co,e.writeRbsp=function(e){const t=[];for(var n=0,i=0;i=2&&(t.push(3),n=0),t.push(r),0==r?++n:n=0}return new Uint8Array(t)}}(t)},8673:e=>{"use strict";function t(){this._types=Object.create(null),this._extensions=Object.create(null);for(let e=0;e{"use strict";let i=n(8673);e.exports=new i(n(8446))},8446:e=>{e.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]}},7503:function(e,t,n){var i;e=n.nmd(e),function(){"use strict";var r={function:!0,object:!0},o=r[typeof window]&&window||this,s=r[typeof t]&&t,a=r.object&&e&&!e.nodeType&&e,c=s&&a&&"object"==typeof n.g&&n.g;!c||c.global!==c&&c.window!==c&&c.self!==c||(o=c);var d=Math.pow(2,53)-1,l=/\bOpera/,u=Object.prototype,h=u.hasOwnProperty,p=u.toString;function m(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function f(e){return e=k(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:m(e)}function g(e,t){for(var n in e)h.call(e,n)&&t(e[n],n,e)}function v(e){return null==e?m(e):p.call(e).slice(8,-1)}function y(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function b(e,t){var n=null;return function(e,t){var n=-1,i=e?e.length:0;if("number"==typeof i&&i>-1&&i<=d)for(;++n3?"WebKit":/\bOpera\b/.test(j)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(t)&&("Mac OS"==G?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(j)&&"NetFront")&&(F=[a]),"IE"==j&&(a=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(j+=" Mobile",G="Windows Phone "+(/\+$/.test(a)?a:a+".x"),D.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(j="IE Mobile",G="Windows Phone 8.x",D.unshift("desktop mode"),U||(U=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=j&&"Trident"==F&&(a=/\brv:([\d.]+)/.exec(t))&&(j&&D.push("identifying as "+j+(U?" "+U:"")),j="IE",U=a[1]),L){if(u="global",h=null!=(d=n)?typeof d[u]:"number",/^(?:boolean|number|string|undefined)$/.test(h)||"object"==h&&!d[u])v(a=n.runtime)==E?(j="Adobe AIR",G=a.flash.system.Capabilities.os):v(a=n.phantom)==w?(j="PhantomJS",U=(a=a.version||null)&&a.major+"."+a.minor+"."+a.patch):"number"==typeof x.documentMode&&(a=/\bTrident\/(\d+)/i.exec(t))?(U=[U,x.documentMode],(a=+a[1]+4)!=U[1]&&(D.push("IE "+U[1]+" mode"),F&&(F[1]=""),U[1]=a),U="IE"==j?String(U[1].toFixed(1)):U[0]):"number"==typeof x.documentMode&&/^(?:Chrome|Firefox)\b/.test(j)&&(D.push("masking as "+j+" "+U),j="IE",U="11.0",F=["Trident"],G="Windows");else if(P&&(M=(a=P.lang.System).getProperty("os.arch"),G=G||a.getProperty("os.name")+" "+a.getProperty("os.version")),_){try{U=n.require("ringo/engine").version.join("."),j="RingoJS"}catch(e){(a=n.system)&&a.global.system==n.system&&(j="Narwhal",G||(G=a[0].os||null))}j||(j="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(a=n.process)&&("object"==typeof a.versions&&("string"==typeof a.versions.electron?(D.push("Node "+a.versions.node),j="Electron",U=a.versions.electron):"string"==typeof a.versions.nw&&(D.push("Chromium "+U,"Node "+a.versions.node),j="NW.js",U=a.versions.nw)),j||(j="Node.js",M=a.arch,G=a.platform,U=(U=/[\d.]+/.exec(a.version))?U[0]:null));G=G&&f(G)}if(U&&(a=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(U)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(L&&r.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(N=/b/i.test(a)?"beta":"alpha",U=U.replace(RegExp(a+"\\+?$"),"")+("beta"==N?O:R)+(/\d+\+?/.exec(a)||"")),"Fennec"==j||"Firefox"==j&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(G))j="Firefox Mobile";else if("Maxthon"==j&&U)U=U.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(V))"Xbox 360"==V&&(G=null),"Xbox 360"==V&&/\bIEMobile\b/.test(t)&&D.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(j)&&(!j||V||/Browser|Mobi/.test(j))||"Windows CE"!=G&&!/Mobi/i.test(t))if("IE"==j&&L)try{null===n.external&&D.unshift("platform preview")}catch(e){D.unshift("embedded")}else(/\bBlackBerry\b/.test(V)||/\bBB10\b/.test(t))&&(a=(RegExp(V.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||U)?(G=((a=[a,/BB10/.test(t)])[1]?(V=null,B="BlackBerry"):"Device Software")+" "+a[0],U=null):this!=g&&"Wii"!=V&&(L&&I||/Opera/.test(j)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==j&&/\bOS X (?:\d+\.){2,}/.test(G)||"IE"==j&&(G&&!/^Win/.test(G)&&U>5.5||/\bWindows XP\b/.test(G)&&U>8||8==U&&!/\bTrident\b/.test(t)))&&!l.test(a=e.call(g,t.replace(l,"")+";"))&&a.name&&(a="ing as "+a.name+((a=a.version)?" "+a:""),l.test(j)?(/\bIE\b/.test(a)&&"Mac OS"==G&&(G=null),a="identify"+a):(a="mask"+a,j=A?f(A.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(a)&&(G=null),L||(U=null)),F=["Presto"],D.push(a));else j+=" Mobile";(a=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(a=[parseFloat(a.replace(/\.(\d)$/,".0$1")),a],"Safari"==j&&"+"==a[1].slice(-1)?(j="WebKit Nightly",N="alpha",U=a[1].slice(0,-1)):U!=a[1]&&U!=(a[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(U=null),a[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==a[0]&&537.36==a[2]&&parseFloat(a[1])>=28&&"WebKit"==F&&(F=["Blink"]),L&&(m||a[1])?(F&&(F[1]="like Chrome"),a=a[1]||((a=a[0])<530?1:a<532?2:a<532.05?3:a<533?4:a<534.03?5:a<534.07?6:a<534.1?7:a<534.13?8:a<534.16?9:a<534.24?10:a<534.3?11:a<535.01?12:a<535.02?"13+":a<535.07?15:a<535.11?16:a<535.19?17:a<536.05?18:a<536.1?19:a<537.01?20:a<537.11?"21+":a<537.13?23:a<537.18?24:a<537.24?25:a<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),a=(a=a[0])<400?1:a<500?2:a<526?3:a<533?4:a<534?"4+":a<535?5:a<537?6:a<538?7:a<601?8:a<602?9:a<604?10:a<606?11:a<608?12:"12"),F&&(F[1]+=" "+(a+="number"==typeof a?".x":/[.+]/.test(a)?"":"+")),"Safari"==j&&(!U||parseInt(U)>45)?U=a:"Chrome"==j&&/\bHeadlessChrome/i.test(t)&&D.unshift("headless")),"Opera"==j&&(a=/\bzbov|zvav$/.exec(G))?(j+=" ",D.unshift("desktop mode"),"zvav"==a?(j+="Mini",U=null):j+="Mobile",G=G.replace(RegExp(" *"+a+"$"),"")):"Safari"==j&&/\bChrome\b/.exec(F&&F[1])?(D.unshift("desktop mode"),j="Chrome Mobile",U=null,/\bOS X\b/.test(G)?(B="Apple",G="iOS 4.3+"):G=null):/\bSRWare Iron\b/.test(j)&&!U&&(U=H("Chrome")),U&&0==U.indexOf(a=/[\d.]+$/.exec(G))&&t.indexOf("/"+a+"-")>-1&&(G=k(G.replace(a,""))),G&&-1!=G.indexOf(j)&&!RegExp(j+" OS").test(G)&&(G=G.replace(RegExp(" *"+y(j)+" *"),"")),F&&!/\b(?:Avant|Nook)\b/.test(j)&&(/Browser|Lunascape|Maxthon/.test(j)||"Safari"!=j&&/^iOS/.test(G)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(j)&&F[1])&&(a=F[F.length-1])&&D.push(a),D.length&&(D=["("+D.join("; ")+")"]),B&&V&&V.indexOf(B)<0&&D.push("on "+B),V&&D.push((/^on /.test(D[D.length-1])?"":"on ")+V),G&&(a=/ ([\d.+]+)$/.exec(G),c=a&&"/"==G.charAt(G.length-a[0].length-1),G={architecture:32,family:a&&!c?G.replace(a[0],""):G,version:a?a[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(a=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(M))&&!/\bi686\b/i.test(M)?(G&&(G.architecture=64,G.family=G.family.replace(RegExp(" *"+a),"")),j&&(/\bWOW64\b/i.test(t)||L&&/\w(?:86|32)$/.test(r.cpuClass||r.platform)&&!/\bWin64; x64\b/i.test(t))&&D.unshift("32-bit")):G&&/^OS X/.test(G.family)&&"Chrome"==j&&parseFloat(U)>=39&&(G.architecture=64),t||(t=null);var W={};return W.description=t,W.layout=F&&F[0],W.manufacturer=B,W.name=j,W.prerelease=N,W.product=V,W.ua=t,W.version=j&&U,W.os=G||{architecture:null,family:null,version:null,toString:function(){return"null"}},W.parse=e,W.toString=function(){return this.description||""},W.version&&D.unshift(U),W.name&&D.unshift(j),G&&j&&(G!=String(G).split(" ")[0]||G!=j.split(" ")[0]&&!V)&&D.push(V?"("+G+")":"on "+G),D.length&&(W.description=D.join(" ")),W}();o.platform=T,void 0===(i=function(){return T}.call(t,n,t,e))||(e.exports=i)}.call(this)},9368:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(r=i))})),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(1703)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},1703:(e,t,n)=>{e.exports=function(e){function t(e){let n,r,o,s=null;function a(...e){if(!a.enabled)return;const i=a,r=Number(new Date),o=r-(n||r);i.diff=o,i.prev=n,i.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";s++;const o=t.formatters[r];if("function"==typeof o){const t=e[s];n=o.call(i,t),e.splice(s,1),s--}return n})),t.formatArgs.call(i,e),(i.log||t.log).apply(i,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),r=i.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{var t=1e3,n=60*t,i=60*n,r=24*i,o=7*r;function s(e,t,n,i){var r=t>=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}e.exports=function(e,a){a=a||{};var c,d,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(s){var a=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*r;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===l&&isFinite(e))return a.long?(c=e,(d=Math.abs(c))>=r?s(c,d,r,"day"):d>=i?s(c,d,i,"hour"):d>=n?s(c,d,n,"minute"):d>=t?s(c,d,t,"second"):c+" ms"):function(e){var o=Math.abs(e);return o>=r?Math.round(e/r)+"d":o>=i?Math.round(e/i)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},852:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(r=i))})),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(3995)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},3995:(e,t,n)=>{e.exports=function(e){function t(e){let n,r,o,s=null;function a(...e){if(!a.enabled)return;const i=a,r=Number(new Date),o=r-(n||r);i.diff=o,i.prev=n,i.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return"%";s++;const o=t.formatters[r];if("function"==typeof o){const t=e[s];n=o.call(i,t),e.splice(s,1),s--}return n})),t.formatArgs.call(i,e),(i.log||t.log).apply(i,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=i,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function i(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),r=i.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{var t=1e3,n=60*t,i=60*n,r=24*i,o=7*r;function s(e,t,n,i){var r=t>=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}e.exports=function(e,a){a=a||{};var c,d,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(s){var a=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*r;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===l&&isFinite(e))return a.long?(c=e,(d=Math.abs(c))>=r?s(c,d,r,"day"):d>=i?s(c,d,i,"hour"):d>=n?s(c,d,n,"minute"):d>=t?s(c,d,t,"second"):c+" ms"):function(e){var o=Math.abs(e);return o>=r?Math.round(e/r)+"d":o>=i?Math.round(e/i)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},8707:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Connection=void 0;var i=n(8608),r=n(2535),o=n(4287),s=n(3853).OpenViduLogger.getInstance();t.Connection=function(e,t,n){var a,c,d,l,u,h,p,m,f="'Connection' created ";if(this.participant=t,this.session=e,this.connectionId=this.participant.identity,this.creationTime=null!==(c=null===(a=this.participant.joinedAt)||void 0===a?void 0:a.getTime())&&void 0!==c?c:-1,this.participant.metadata){var g=JSON.parse(this.participant.metadata);this.role=g.role,this.record=g.record;var v=g.clientData||"",y=g.serverData||"";this.data=v&&y?"".concat(v,"%/%").concat(y):"".concat(v||y)}else this.data="";if(this.participant instanceof i.RemoteParticipant){var b,k;f+="(remote) with 'connectionId' ["+this.connectionId+"]";var T=null==n||null!=(null===(d=n.video)||void 0===d?void 0:d.id),E=null==n||null!=(null===(l=n.audio)||void 0===l?void 0:l.id);if(this.participant.trackPublications.forEach((function(e){e.kind===i.Track.Kind.Video&&T?b=e:e.kind===i.Track.Kind.Audio&&E&&(k=e)})),b||k){var S=void 0;if(b){var C=b.dimensions;S=C?{width:C.width,height:C.height}:{width:0,height:0}}var w=t.participantInfo?1e3*Number(BigInt(t.participantInfo.joinedAt)):(new Date).getTime(),P={id:b?b.trackName:k.trackName,createdAt:w,connection:this,hasAudio:!!k,hasVideo:!!b,audioActive:!!k&&!(null===(u=k.audioTrack)||void 0===u?void 0:u.isMuted),videoActive:!!b&&!(null===(h=b.videoTrack)||void 0===h?void 0:h.isMuted),typeOfVideo:b?b.source===i.Track.Source.ScreenShare?o.TypeOfVideo.SCREEN:o.TypeOfVideo.CAMERA:void 0,frameRate:b?Number(null===(m=null===(p=b.videoTrack)||void 0===p?void 0:p.mediaStreamTrack.getConstraints().frameRate)||void 0===m?void 0:m.toString()):void 0,videoDimensions:S,filter:void 0},_=new r.Stream(this.session,P);_.connection=this,this.stream=_}}s.log(f)}},4602:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventDispatcher=void 0;var i=n(3853),r=n(2210),o=i.OpenViduLogger.getInstance(),s=function(){function e(){this.userHandlerArrowHandler=new WeakMap,this.publicEmmiter=new r}return e.prototype.onAux=function(e,t,n){var i=function(e){o.debug(t,e),n(e)};return this.userHandlerArrowHandler.set(n,i),this.publicEmmiter.on(e,i),this},e.prototype.onceAux=function(e,t,n){var i=this,r=function(e){o.debug(t,e),n(e),i.userHandlerArrowHandler.delete(n)};return this.userHandlerArrowHandler.set(n,r),this.publicEmmiter.once(e,r),this},e.prototype.offAux=function(e,t){if(t){var n=this.userHandlerArrowHandler.get(t);n&&this.publicEmmiter.off(e,n),this.userHandlerArrowHandler.delete(t)}else this.publicEmmiter.removeAllListeners(e);return this},e}();t.EventDispatcher=s},2057:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalRecorder=void 0;var i,r=n(9849),o=n(3853),s=n(5877),a=n(1133),c=o.OpenViduLogger.getInstance(),d=function(){function e(e){this.stream=e,this.chunks=[],i=s.PlatformUtils.getInstance(),this.connectionId=this.stream.connection?this.stream.connection.connectionId:"default-connection",this.id=this.stream.streamId+"_"+this.connectionId+"_localrecord",this.state=r.LocalRecorderState.READY}return e.prototype.record=function(e){var t=this;return new Promise((function(n,i){try{if("string"==typeof e||e instanceof String)return i("When calling LocalRecorder.record(options) parameter 'options' cannot be a string. Must be an object like { mimeType: \"".concat(e,'" }'));if("undefined"==typeof MediaRecorder)throw c.error("MediaRecorder not supported on your device. See compatibility in https://caniuse.com/#search=MediaRecorder"),Error("MediaRecorder not supported on your device. See compatibility in https://caniuse.com/#search=MediaRecorder");if(t.state!==r.LocalRecorderState.READY)throw Error("'LocalRecord.record()' needs 'LocalRecord.state' to be 'READY' (current value: '"+t.state+"'). Call 'LocalRecorder.clean()' or init a new LocalRecorder before");c.log("Starting local recording of stream '"+t.stream.streamId+"' of connection '"+t.connectionId+"'"),e?e.mimeType||(e.mimeType="video/webm"):e={mimeType:"video/webm"},t.mediaRecorder=new MediaRecorder(t.stream.getMediaStream(),e),t.mediaRecorder.start()}catch(e){return i(e)}return t.mediaRecorder.ondataavailable=function(e){e.data.size>0&&t.chunks.push(e.data)},t.mediaRecorder.onerror=function(e){c.error("MediaRecorder error: ",e)},t.mediaRecorder.onstart=function(){c.log("MediaRecorder started (state="+t.mediaRecorder.state+")")},t.mediaRecorder.onstop=function(){t.onStopDefault()},t.mediaRecorder.onpause=function(){c.log("MediaRecorder paused (state="+t.mediaRecorder.state+")")},t.mediaRecorder.onresume=function(){c.log("MediaRecorder resumed (state="+t.mediaRecorder.state+")")},t.state=r.LocalRecorderState.RECORDING,n()}))},e.prototype.stop=function(){var e=this;return new Promise((function(t,n){try{if(e.state===r.LocalRecorderState.READY||e.state===r.LocalRecorderState.FINISHED)throw Error("'LocalRecord.stop()' needs 'LocalRecord.state' to be 'RECORDING' or 'PAUSED' (current value: '"+e.state+"'). Call 'LocalRecorder.start()' before");e.mediaRecorder.onstop=function(){return e.onStopDefault(),t()},e.mediaRecorder.stop()}catch(e){return n(e)}}))},e.prototype.pause=function(){var e=this;return new Promise((function(t,n){try{return e.state!==r.LocalRecorderState.RECORDING?n(Error("'LocalRecord.pause()' needs 'LocalRecord.state' to be 'RECORDING' (current value: '"+e.state+"'). Call 'LocalRecorder.start()' or 'LocalRecorder.resume()' before")):(e.mediaRecorder.pause(),e.state=r.LocalRecorderState.PAUSED,t())}catch(e){return n(e)}}))},e.prototype.resume=function(){var e=this;return new Promise((function(t,n){try{if(e.state!==r.LocalRecorderState.PAUSED)throw Error("'LocalRecord.resume()' needs 'LocalRecord.state' to be 'PAUSED' (current value: '"+e.state+"'). Call 'LocalRecorder.pause()' before");return e.mediaRecorder.resume(),e.state=r.LocalRecorderState.RECORDING,t()}catch(e){return n(e)}}))},e.prototype.preview=function(e){if(this.state!==r.LocalRecorderState.FINISHED)throw Error("'LocalRecord.preview()' needs 'LocalRecord.state' to be 'FINISHED' (current value: '"+this.state+"'). Call 'LocalRecorder.stop()' before");if(this.videoPreview=document.createElement("video"),this.videoPreview.id=this.id,this.videoPreview.autoplay=!0,i.isSafariBrowser()&&(this.videoPreview.playsInline=!0),"string"==typeof e){var t=document.getElementById(e);t&&(this.videoPreview=t.appendChild(this.videoPreview))}else this.videoPreview=e.appendChild(this.videoPreview);return this.videoPreview.src=this.videoPreviewSrc,this.videoPreview},e.prototype.clean=function(){var e=this,t=function(){delete e.blob,e.chunks=[],e.state=r.LocalRecorderState.READY};this.state===r.LocalRecorderState.RECORDING||this.state===r.LocalRecorderState.PAUSED?this.stop().then((function(){return t()})).catch((function(){return t()})):t()},e.prototype.download=function(){if(this.state!==r.LocalRecorderState.FINISHED)throw Error("'LocalRecord.download()' needs 'LocalRecord.state' to be 'FINISHED' (current value: '"+this.state+"'). Call 'LocalRecorder.stop()' before");var e=document.createElement("a");e.style.display="none",document.body.appendChild(e);var t=globalThis.URL.createObjectURL(this.blob);e.href=t,e.download=this.id+"."+a.getExtension(this.blob.type),e.click(),globalThis.URL.revokeObjectURL(t),document.body.removeChild(e)},e.prototype.getBlob=function(){if(this.state!==r.LocalRecorderState.FINISHED)throw Error("Call 'LocalRecord.stop()' before getting Blob file");return this.blob},e.prototype.uploadAsBinary=function(e,t){var n=this;return new Promise((function(i,o){if(n.state!==r.LocalRecorderState.FINISHED)return o(Error("'LocalRecord.uploadAsBinary()' needs 'LocalRecord.state' to be 'FINISHED' (current value: '"+n.state+"'). Call 'LocalRecorder.stop()' before"));var s=new XMLHttpRequest;if(s.open("POST",e,!0),"object"==typeof t)for(var a=0,c=Object.keys(t);a0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]o)return clearTimeout(m),v.warn("Video dimensions have not changed in ".concat(o*n,"ms after a change in the video track (still ").concat(h,"x").concat(p,"). No event will be dispatched")),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.stream.getVideoDimensions()];case 2:return(i=r.sent()).width===h&&i.height===p||(clearTimeout(m),this.sendVideoDimensionsChangedEvent(e,t,h,p,i.width,i.height)),[3,4];case 3:return s=r.sent(),v.error("Error getting video dimensions after a change in the video track",s),[3,4];case 4:return[2]}}))}))}),n)},e.prototype.sendVideoDimensionsChangedEvent=function(e,t,n,o,s,a){return i(this,void 0,void 0,(function(){var i,c,d,l,u,h;return r(this,(function(r){switch(r.label){case 0:return i="videoDimensions",c={width:s,height:a},d={width:n,height:o},e.stream.videoDimensions={width:s||0,height:a||0},l=new p.StreamPropertyChangedEvent(this.session,e.stream,i,c,d,t),u=new p.StreamPropertyChangedEvent(e,e.stream,i,c,d,t),this.session.publicEmmiter.emitEvent("streamPropertyChanged",[l]),e.publicEmmiter.emitEvent("streamPropertyChanged",[u]),h={data:JSON.stringify({sentFromServer:!1,payload:{changedProperty:i,newValue:c,oldValue:d,reason:t,participantIdentity:this.session.room.localParticipant.identity}}),type:"".concat(m.InternalSignalType.CUSTOM_CLIENT_SIGNAL_PREFIX).concat(m.InternalSignalType.OPENVIDU_STREAM_PROPERTY_CHANGED)},this.session.isSessionConnected()?[4,this.session.signalInternal(h,!1)]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},e.prototype.generateNewMediaStream=function(e,t){var n=new MediaStream;return e&&n.addTrack(e),t&&n.addTrack(t),n},e.prototype.generateMediaConstraints=function(e){var t={audioTrack:void 0,videoTrack:void 0,constraints:{audio:void 0,video:void 0}},n=e.audioSource,i=e.videoSource;if(null!==n&&!1!==n||(t.constraints.audio=!1),null!==i&&!1!==i||(t.constraints.video=!1),!1===t.constraints.audio&&!1===t.constraints.video)throw new l.OpenViduError(l.OpenViduErrorName.NO_INPUT_SOURCE_SET,"Properties 'audioSource' and 'videoSource' cannot be set to false or null at the same time");if("undefined"!=typeof MediaStreamTrack&&n instanceof MediaStreamTrack&&(t.audioTrack=n),"undefined"!=typeof MediaStreamTrack&&i instanceof MediaStreamTrack&&(t.videoTrack=i),void 0===n&&(t.constraints.audio=!0),void 0===i&&(t.constraints.video={width:{ideal:640},height:{ideal:480}}),null!==i&&!1!==i){if(e.resolution){var r=e.resolution.toLowerCase().split("x"),o=Number(r[0]),s=Number(r[1]);t.constraints.video={width:{ideal:o},height:{ideal:s}}}e.frameRate&&(t.constraints.video.frameRate={ideal:e.frameRate})}return this.configureDeviceIdOrScreensharing(t,e)},e.prototype.setAdvancedConfiguration=function(e){this.advancedConfiguration=e},e.prototype.initLocalRecorder=function(e){return new u.LocalRecorder(e)},e.prototype.checkScreenSharingCapabilities=function(){return g.canScreenShare()},e.prototype.configureDeviceIdOrScreensharing=function(e,t){var n=t.audioSource,i=t.videoSource;if("string"==typeof n&&(e.constraints.audio={deviceId:{exact:n}}),"string"==typeof i)if(e.constraints.video&&"object"==typeof e.constraints.video?e.constraints.video.deviceId={exact:i}:void 0===e.constraints.video&&(e.constraints.video={deviceId:{exact:i}}),this.isScreenShare(i)){if(!this.checkScreenSharingCapabilities())throw new l.OpenViduError(l.OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED,"You can only screen share in desktop Chrome, Firefox, Opera, Safari (>=13.0), Edge (>= 80) or Electron. Detected client: "+g.getName()+" "+g.getVersion());if(g.isElectron()){var r=i,o=r.substr(r.indexOf("screen:")+7);e.constraints.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:o}}}}else"screen"===n&&(v.warn('Parameter "audioSource" is set to "screen", which means requesting audio from screen sharing source. But "videoSource" is not set to "screen". No audio source will be requested'),e.constraints.audio=!1);return e},e.prototype.isScreenShare=function(e){return"screen"===e||"window"===e||g.isElectron()&&e.startsWith("screen:")},e.prototype.initializeProperties=function(e){var t={},n=e&&"function"!=typeof e,i={insertMode:h.VideoInsertMode.APPEND,mirror:!0,publishAudio:!0,publishVideo:!0,resolution:"640x480"};return n?{audioSource:void 0!==(t=e).audioSource?t.audioSource:void 0,frameRate:void 0!==t.frameRate?t.frameRate:void 0,insertMode:this.getInsertMode(t),mirror:void 0===t.mirror||t.mirror,publishAudio:void 0===t.publishAudio||t.publishAudio,publishVideo:void 0===t.publishVideo||t.publishVideo,resolution:void 0!==t.resolution?t.resolution:"640x480",videoSource:void 0!==t.videoSource?t.videoSource:void 0,videoSimulcast:t.videoSimulcast,filter:t.filter}:i},e.prototype.getInsertMode=function(e){return void 0!==e.insertMode?"string"==typeof e.insertMode?h.VideoInsertMode[e.insertMode]:e.insertMode:h.VideoInsertMode.APPEND},e.prototype.isMediaTracksProvided=function(e){var t=e.videoTrack,n=e.audioTrack,i=e.constraints,r=void 0===i?{}:i,o=r.video,s=r.audio;return!(!t&&("boolean"!=typeof o||o)||!n&&("boolean"!=typeof s||s))},e.prototype.generateVideoCaptureOptionsFromContraints=function(e){var t;if("boolean"==typeof e.video)return e.video;var n=this.getResolution(e);return{deviceId:null===(t=e.video)||void 0===t?void 0:t.deviceId,resolution:{width:n.width,height:n.height,frameRate:n.frameRate}}},e.prototype.generateAudioCaptureOptionsFromContraints=function(e){var t;return"boolean"==typeof e.audio?e.audio:{deviceId:null===(t=e.audio)||void 0===t?void 0:t.deviceId}},e.prototype.generateScreenCaptureOptionsFromConstraints=function(e){var t,n,i,r=!1;return"boolean"==typeof e.audio?r=!1:"string"==typeof(null===(t=e.audio)||void 0===t?void 0:t.deviceId)?r="screen"===(null===(n=e.audio)||void 0===n?void 0:n.deviceId):(null===(i=e.audio)||void 0===i?void 0:i.deviceId)&&"object"==typeof e.audio.deviceId&&(r="screen"===e.audio.deviceId.exact),{audio:r,video:!0,systemAudio:"include"}},e.prototype.getResolution=function(e){try{var t=e.video,n=640,i=480,r=30;return"object"==typeof t?("number"==typeof t.width?n=t.width:t.width&&"object"==typeof t.width&&(n=t.width.ideal||t.width.exact||n),"number"==typeof t.height?i=t.height:t.height&&"object"==typeof t.height&&(i=t.height.ideal||t.height.exact||i),"number"==typeof t.frameRate?r=t.frameRate:t.frameRate&&"object"==typeof t.frameRate&&(r=t.frameRate.ideal||t.frameRate.exact||r)):"boolean"==typeof t&&(n=t?640:0,i=t?480:0),{width:n,height:i,frameRate:r}}catch(e){return v.warn("Invalid resolution provided in PublisherProperties. Setting default value (640x480)"),{width:640,height:480,frameRate:30}}},e}();t.OpenVidu=y},5415:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0&&this.addPlayEventToFirstVideo()},t.prototype.startAccessDialogTimer=function(){var e=this;this.accessDialogTimeout=setTimeout((function(){e.emitEvent("accessDialogOpened",[]),e.accessDialogHasBeenOpened=!0}),this.ACCESS_DIALOG_TIMEOUT)},t.prototype.stopAccessDialogTimer=function(){this.accessDialogTimeout&&(clearTimeout(this.accessDialogTimeout),this.accessDialogTimeout=void 0,this.accessDialogHasBeenOpened&&(this.accessDialogHasBeenOpened=!1,this.emitEvent("accessDialogClosed",[])))},t.prototype.runPromiseAndMuteLocalVideosIfNeeded=function(e){return o(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return t=new Map,this.videos.forEach((function(e){t.set(e.id,e.video.muted)})),[4,e()];case 1:return n.sent(),this.videos.forEach((function(e){var n=t.get(e.id);e.video.muted=null==n||n})),[2]}}))}))},t}(p.StreamManager);t.Publisher=y},8235:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,i=arguments.length;n0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0){var n=e.to.map((function(e){return e.connectionId}));t.to=n}return t},t.prototype.signal=function(e){return s(this,void 0,void 0,(function(){var t,n;return a(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.signalInternal(e,!0)];case 1:return i.sent(),t=this.parseSignalMessage(e),this.emitSignalEventIfNecessary(t,this.connection),[3,3];case 2:throw n=i.sent(),new Error("Error sending signal: "+n);case 3:return[2]}}))}))},t.prototype.signalInternal=function(e,t){var n;return s(this,void 0,void 0,(function(){var i,r,s,c,d,l;return a(this,(function(a){switch(a.label){case 0:return this.isSessionConnected()?(i=(new TextEncoder).encode(e.data),r=e.to?e.to.map((function(e){return e.connectionId})):[],s={topic:e.type,destinationIdentities:r,reliable:!0},[4,this.room.localParticipant.publishData(i,s)]):(R.error("Error sending signal: session is not connected"),[2,Promise.reject(this.notConnectedError())]);case 1:return a.sent(),t?(d=[o({},e)],l={to:r,session:this.sessionId},[4,this.room.getSid()]):[3,3];case 2:c=o.apply(void 0,d.concat([(l.uniqueSessionId=a.sent(),l.from=this.localParticipant.identity,l)])),null===(n=this.ws)||void 0===n||n.emitEvent(k.InternalSignalType.OPENVIDU_SIGNAL,c),a.label=3;case 3:return[2]}}))}))},t.prototype.emitSignalEventIfNecessary=function(e,t){if(!e.to||0===e.to.length||e.to.includes(this.localParticipant.identity)){var n="signal"===e.type?void 0:e.type.replace(/^(signal:)/,""),i=new w.SignalEvent(this,n,e.data,t);this.publicEmmiter.emitEvent("signal",[i]),n&&this.publicEmmiter.emitEvent("signal:"+n,[i])}},t.prototype.on=function(t,n){var i,r,o,s,a=this;switch(e.prototype.onAux.call(this,t,"Event '"+t+"' triggered by 'Session'",n),t){case"connectionCreated":case"connectionDestroyed":case"connectionPropertyChanged":case"sessionDisconnected":case"streamCreated":case"streamDestroyed":case"recordingStarted":case"recordingStopped":case"broadcastStarted":case"broadcastStopped":case"signal":break;case"networkQualityLevelChanged":this.room.on(c.RoomEvent.ConnectionQualityChanged,this.handleNetworkQualityLevelChanged.bind(this));break;case"reconnecting":this.room.on(c.RoomEvent.Reconnecting,(function(){return a.publicEmmiter.emitEvent("reconnecting",[])}));break;case"reconnected":this.room.on(c.RoomEvent.Reconnected,(function(){return a.publicEmmiter.emitEvent("reconnected",[])}));break;case"publisherStartSpeaking":this.remoteConnections.forEach((function(e){var t;(null===(t=e.stream)||void 0===t?void 0:t.hasAudio)&&e.stream.enableHarkSpeakingEvent()})),(null===(r=null===(i=this.connection)||void 0===i?void 0:i.stream)||void 0===r?void 0:r.hasAudio)&&this.connection.stream.enableHarkSpeakingEvent();break;case"publisherStopSpeaking":this.remoteConnections.forEach((function(e){var t;(null===(t=e.stream)||void 0===t?void 0:t.hasAudio)&&e.stream.enableHarkStoppedSpeakingEvent()})),(null===(s=null===(o=this.connection)||void 0===o?void 0:o.stream)||void 0===s?void 0:s.hasAudio)&&this.connection.stream.enableHarkStoppedSpeakingEvent()}return this},t.prototype.once=function(t,n){var i,r,o,s,a=this;switch(e.prototype.onceAux.call(this,t,"Event '"+t+"' triggered by 'Session'",n),t){case"connectionCreated":case"connectionDestroyed":case"connectionPropertyChanged":case"sessionDisconnected":case"streamCreated":case"streamDestroyed":case"recordingStarted":case"recordingStopped":case"broadcastStarted":case"broadcastStopped":case"signal":break;case"networkQualityLevelChanged":this.room.once(c.RoomEvent.ConnectionQualityChanged,this.handleNetworkQualityLevelChanged.bind(this));break;case"reconnecting":this.room.once(c.RoomEvent.Reconnecting,(function(){return a.publicEmmiter.emitEvent("reconnecting",[])}));break;case"reconnected":this.room.once(c.RoomEvent.Reconnected,(function(){return a.publicEmmiter.emitEvent("reconnected",[])}));break;case"publisherStartSpeaking":this.remoteConnections.forEach((function(e){var t;(null===(t=e.stream)||void 0===t?void 0:t.hasAudio)&&e.stream.enableOnceHarkSpeakingEvent()})),(null===(r=null===(i=this.connection)||void 0===i?void 0:i.stream)||void 0===r?void 0:r.hasAudio)&&this.connection.stream.enableOnceHarkSpeakingEvent();break;case"publisherStopSpeaking":this.remoteConnections.forEach((function(e){var t;(null===(t=e.stream)||void 0===t?void 0:t.hasAudio)&&e.stream.enableOnceHarkStoppedSpeakingEvent()})),(null===(s=null===(o=this.connection)||void 0===o?void 0:o.stream)||void 0===s?void 0:s.hasAudio)&&this.connection.stream.enableOnceHarkStoppedSpeakingEvent()}return this},t.prototype.off=function(t,n){var i,r,o,s,a=this;switch(e.prototype.offAux.call(this,t,n),t){case"connectionCreated":case"connectionDestroyed":case"connectionPropertyChanged":case"sessionDisconnected":case"streamCreated":case"streamDestroyed":case"recordingStarted":case"recordingStopped":case"broadcastStarted":case"broadcastStopped":case"signal":break;case"networkQualityLevelChanged":this.room.off(c.RoomEvent.ConnectionQualityChanged,this.handleNetworkQualityLevelChanged.bind(this));break;case"reconnecting":this.room.off(c.RoomEvent.Reconnecting,(function(){return a.publicEmmiter.emitEvent("reconnecting",[])}));break;case"reconnected":this.room.off(c.RoomEvent.Reconnected,(function(){return a.publicEmmiter.emitEvent("reconnected",[])}));break;case"publisherStartSpeaking":this.anySpeechEventListenerEnabled("publisherStartSpeaking",!1)||(this.remoteConnections.forEach((function(e){var t;(null===(t=e.stream)||void 0===t?void 0:t.streamManager)&&(e.stream.streamManager.anySpeechEventListenerEnabled("publisherStartSpeaking",!1)||e.stream.disableHarkSpeakingEvent(!1))})),(null===(r=null===(i=this.connection)||void 0===i?void 0:i.stream)||void 0===r?void 0:r.streamManager)&&(this.connection.stream.streamManager.anySpeechEventListenerEnabled("publisherStartSpeaking",!1)||this.connection.stream.disableHarkSpeakingEvent(!1)));break;case"publisherStopSpeaking":this.anySpeechEventListenerEnabled("publisherStopSpeaking",!1)||(this.remoteConnections.forEach((function(e){var t;(null===(t=e.stream)||void 0===t?void 0:t.streamManager)&&(e.stream.streamManager.anySpeechEventListenerEnabled("publisherStopSpeaking",!1)||e.stream.disableHarkStoppedSpeakingEvent(!1))})),(null===(s=null===(o=this.connection)||void 0===o?void 0:o.stream)||void 0===s?void 0:s.streamManager)&&(this.connection.stream.streamManager.anySpeechEventListenerEnabled("publisherStopSpeaking",!1)||this.connection.stream.disableHarkStoppedSpeakingEvent(!1)))}return this},t.prototype.subscribeToSpeechToText=function(e,t){throw new Error("'subscribeToSpeechToText' method is not ready yet.")},t.prototype.unsubscribeFromSpeechToText=function(e){throw new Error("'unsubscribeFromSpeechToText' method is not ready yet.")},t.prototype.extractInfoFromOpenViduToken=function(e){if(!e)throw new Error("Trying to get room metadata from an empty token");try{var t=new URL(e);this.isRecorderParticipant="true"===t.searchParams.get("recorder");var n=null;if(!(n=this.isRecorderParticipant?d.default.getAccessToken():t.searchParams.get("token")))throw new Error("Token does not contain livekit token");var i=n.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(window.atob(i).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join("")),o=JSON.parse(r);if("egress"===o.kind&&this.isRecorderParticipant){var s=o.video,a=o.sub;return{livekitUrl:d.default.getLiveKitURL(),livekitToken:n,shimUrl:"",role:"SUBSCRIBER",roomSid:s.room,roomName:s.room,participantIdentity:a}}if(!(null==o?void 0:o.metadata))throw new Error("Token does not contain metadata");var c=JSON.parse(o.metadata);return{livekitUrl:c.livekitUrl,shimUrl:c.openviduShimUrl,livekitToken:n,role:c.role,roomSid:c.roomSid,roomName:c.roomName,participantIdentity:c.participantIdentity}}catch(e){throw new Error("Error decoding and parsing token: "+e)}},t.prototype.handleMediaDevicesErrorEvent=function(e){var t,n;(null===(n=null===(t=this.connection)||void 0===t?void 0:t.stream)||void 0===n?void 0:n.streamManager)&&this.connection.stream.streamManager.emitEvent("accessDenied",[c.MediaDeviceFailure.getFailure(e)])},t.prototype.handleRoomConnectedEvent=function(e,t,n){var i,r=this;this.openvidu.finalUserId=null===(i=this.room.localParticipant)||void 0===i?void 0:i.identity,this.token=t;var o=function(){r.processSessionConnected(),e()};if(this.isRecorderParticipant)d.default.setRoom(this.room),d.default.startRecording(),o();else{var s=this.processClientMetadata(n);s?(this.room.localParticipant.on(c.ParticipantEvent.ParticipantMetadataChanged,(function(){return o()})),this.room.localParticipant.setMetadata(s)):o()}},t.prototype.handleParticipantMetadataChangedEvent=function(e,t){if(t.identity===this.room.localParticipant.identity){if(!this.connection)return;var n=(a=JSON.parse(t.metadata)).role;if(n!==this.openvidu.role){var i=this.openvidu.role;this.openvidu.role=n,this.connection.role=n;var r=new T.ConnectionPropertyChangedEvent(this,this.connection,"role",this.connection.role,i);this.publicEmmiter.emitEvent("connectionPropertyChanged",[r])}var o=a.record;if(o!==this.connection.record){var s=this.connection.record;this.connection.record=o,r=new T.ConnectionPropertyChangedEvent(this,this.connection,"record",this.connection.record,s),this.publicEmmiter.emitEvent("connectionPropertyChanged",[r])}}else{var a,c=this.remoteConnections.get(t.identity);if(!c)return void R.warn("Connection ".concat(t.identity," not found"));null!==(a=JSON.parse(t.metadata)).role&&(c.role=a.role),null!==a.record&&(c.record=a.record)}},t.prototype.processSessionConnected=function(){var e=this;this.connection?console.warn("Local connection already exists in session. Probably an unexpected ParticipantMetadataChanged event for the local participant"):(this.connection=new l.Connection(this,this.room.localParticipant),this.publicEmmiter.emitEvent("connectionCreated",[new m.ConnectionEvent(!1,this,"connectionCreated",this.connection,"")]),this.room.remoteParticipants.forEach((function(t){var n=e.remoteConnections.get(t.identity);n||(n=new l.Connection(e,t),e.remoteConnections.set(n.connectionId,n)),e.publicEmmiter.emitEvent("connectionCreated",[new m.ConnectionEvent(!1,e,"connectionCreated",n,"")]),e.publicEmmiter.emitEvent("connection-created-event-for-participant-"+n.connectionId,[]),t.trackPublications.size>0&&t.getTrackPublications().forEach((function(n){e.handleTrackPublishedEvent(n,t)}))})))},t.prototype.handleClientEvent=function(e,t,n,i){var r,o,s=this.decodeData(e);try{o=JSON.parse(s)}catch(e){o=s}if(!o.sentFromServer){var a,c=o.payload,d=null!==(r=null==t?void 0:t.identity)&&void 0!==r?r:null==c?void 0:c.participantIdentity;if(i==="".concat(k.InternalSignalType.CUSTOM_CLIENT_SIGNAL_PREFIX).concat(k.InternalSignalType.OPENVIDU_STREAM_PROPERTY_CHANGED)){var l=c.changedProperty,u=c.newValue,h=c.oldValue,p=c.reason;if(!(a=this.remoteConnections.get(d)))return void R.error("No connection found for remote participant ".concat(d," when processing streamPropertyChanged event"));var m=new C.StreamPropertyChangedEvent(a.session,a.stream,l,u,h,p);if(this.publicEmmiter.emitEvent("streamPropertyChanged",[m]),a.stream.streamManager){var f=new C.StreamPropertyChangedEvent(a.stream.streamManager,a.stream,l,u,h,p);a.stream.streamManager.emitEvent("streamPropertyChanged",[f])}}else a=this.remoteConnections.get(d),this.emitSignalEventIfNecessary({data:s,type:i||"",to:[]},a)}},t.prototype.processAndGetSubscriberProperties=function(e){var t={insertMode:y.VideoInsertMode.APPEND,subscribeToAudio:!0,subscribeToVideo:!0},n={};if(e&&"function"!=typeof e){if(!1===(n={insertMode:"string"==typeof e.insertMode?y.VideoInsertMode[e.insertMode]:t.insertMode,subscribeToAudio:void 0!==e.subscribeToAudio?e.subscribeToAudio:t.subscribeToAudio,subscribeToVideo:void 0!==e.subscribeToVideo?e.subscribeToVideo:t.subscribeToVideo}).subscribeToAudio&&!1===n.subscribeToVideo)throw new Error("You cannot subscribe to a stream with both audio and video disabled")}else n=o({},t);return n},t.prototype.handleConnectionCreatedEvent=function(e){var t=this.remoteConnections.get(e.identity);t?R.warn("Connection "+e.identity+" already exists in connections list"):(t=new l.Connection(this,e),this.remoteConnections.set(t.connectionId,t),this.publicEmmiter.emitEvent("connectionCreated",[new m.ConnectionEvent(!1,this,"connectionCreated",t,"")]),this.publicEmmiter.emitEvent("connection-created-event-for-participant-"+t.connectionId,[]))},t.prototype.handleParticipantDisconnectedEvent=function(e){R.log("Participant disconnected",e);var t=this.remoteConnections.get(e.identity);t?(this.remoteConnections.delete(t.connectionId),this.participantRemoteStreams.delete(e.identity),this.participantStreamsToSubscribe.delete(e.identity),this.publicEmmiter.emitEvent("connectionDestroyed",[new m.ConnectionEvent(!1,this,"connectionDestroyed",t,"disconnect")])):R.warn("Connection ".concat(e.identity," not found"))},t.prototype.handleServerEvent=function(e,t,n,i){var r,o=this.decodeData(e);try{r=JSON.parse(o)}catch(e){r=o}if(r.sentFromServer){var s,a=r.payload;switch(i){case"".concat(k.InternalSignalType.OPENVIDU_RECORDING_STARTED):s=new E.RecordingEvent(this,"recordingStarted",a.id,a.name),this.publicEmmiter.emitEvent("recordingStarted",[s]);break;case"".concat(k.InternalSignalType.OPENVIDU_RECORDING_STOPPED):s=new E.RecordingEvent(this,"recordingStopped",a.id,a.name,a.reason),this.publicEmmiter.emitEvent("recordingStopped",[s]);break;case"".concat(k.InternalSignalType.OPENVIDU_BROADCASTING_STARTED):this.publicEmmiter.emitEvent("broadcastStarted",[]);break;case"".concat(k.InternalSignalType.OPENVIDU_BROADCASTING_STOPPED):this.publicEmmiter.emitEvent("broadcastStopped",[]);break;case"".concat(k.InternalSignalType.OPENVIDU_UNPUBLISH_STREAM):this.ongoingForceUnpublishReason=a.reason,this.unpublish(this.connection.stream.streamManager);break;default:return void this.emitSignalEventIfNecessary({data:r.payload||"",type:i||"",to:[]},void 0)}}},t.prototype.handleTrackMutedUnmutedEvent=function(e,t){var n;if(t.identity===this.localParticipant.identity)n=this.connection;else if(!(n=this.remoteConnections.get(t.identity)))return;var i=n.stream;if(i){var r=e.kind===c.Track.Kind.Audio?"audioActive":"videoActive",o=!e.isMuted,s=e.kind===c.Track.Kind.Audio?"publishAudio":"publishVideo";i[r]=o;var a=new C.StreamPropertyChangedEvent(this,i,r,o,!o,s);if(this.publicEmmiter.emitEvent("streamPropertyChanged",[a]),n.stream.streamManager){var d=new C.StreamPropertyChangedEvent(n.stream.streamManager,i,r,o,!o,s);n.stream.streamManager.publicEmmiter.emitEvent("streamPropertyChanged",[d])}}},t.prototype.handleSessionDisconnectedEvent=function(e){var t=Object.keys(c.DisconnectReason).find((function(t){return c.DisconnectReason[t]===e}));R.debug("participant disconnected",t);var n=new h.SessionDisconnectedEvent(this,e);this.publicEmmiter.emitEvent("sessionDisconnected",[n]),n.callDefaultBehavior()},t.prototype.handleTrackPublishedEvent=function(e,t){var n,i,r=this,o=e.trackName,s=this.getTrackIdsFromStreamId(o),a=null===(n=this.participantRemoteStreams.get(t.identity))||void 0===n?void 0:n.get(o);if(null!=a){if(a[e.kind])return void console.warn("DUPLICATED TrackPublished event in participant "+this.room.localParticipant.identity+" for track "+e.trackSid+" of stream "+o+" of remote participant "+t.identity);var c={id:"".concat(e.kind,":").concat(e.source),kind:e.kind,source:e.source,trackPublishedEventReceived:!0,trackUnpublishedEventReceived:!1,trackSubscribedEventReceived:!1,localTrackUnpublishedEventReceived:!1};a[e.kind]=c}else if(a={streamId:e.trackName,videoId:s.videoTrackId,audioId:s.audioTrackId},c={id:"".concat(e.kind,":").concat(e.source),kind:e.kind,source:e.source,trackPublishedEventReceived:!0,trackUnpublishedEventReceived:!1,trackSubscribedEventReceived:!1,localTrackUnpublishedEventReceived:!1},a[e.kind]=c,this.participantRemoteStreams.has(t.identity))null===(i=this.participantRemoteStreams.get(t.identity))||void 0===i||i.set(a.streamId,a);else{var d=new Map;d.set(e.trackName,a),this.participantRemoteStreams.set(t.identity,d)}var u=!0;if(a.videoId&&(u=u&&null!=a.video&&a.video.trackPublishedEventReceived),a.audioId&&(u=u&&null!=a.audio&&a.audio.trackPublishedEventReceived),u){R.debug("Local participant ".concat(this.localParticipant.identity," received all TrackPublished events for stream ").concat(a.streamId," of remote participant ").concat(t.identity));var h=this.remoteConnections.has(t.identity),p=new l.Connection(this,t,a);if(this.remoteConnections.set(p.connectionId,p),a.stream=p.stream,h){var m=new f.StreamEvent(!1,this,"streamCreated",p.stream,"");this.publicEmmiter.emitEvent("streamCreated",[m])}else this.publicEmmiter.once("connection-created-event-for-participant-"+p.connectionId,(function(){var e=new f.StreamEvent(!1,r,"streamCreated",p.stream,"");r.publicEmmiter.emitEvent("streamCreated",[e])}))}else R.debug("Local participant ".concat(this.localParticipant.identity," waiting for the remaining TrackPublished events of stream ").concat(a.streamId," of remote participant ").concat(t.identity))},t.prototype.handleTrackUnpublishedEvent=function(e,t){var n=this.participantRemoteStreams.get(t.identity);if(n){var i=Array.from(n.values()).find((function(t){var n;return t.streamId===e.trackName&&(null===(n=t[e.kind])||void 0===n?void 0:n.id)==="".concat(e.kind,":").concat(e.source)}));if(i){i[e.kind].trackUnpublishedEventReceived=!0;var r=!0;if(i[c.Track.Kind.Video]&&(r=r&&i[c.Track.Kind.Video].trackUnpublishedEventReceived),i[c.Track.Kind.Audio]&&(r=r&&i[c.Track.Kind.Audio].trackUnpublishedEventReceived),r){R.debug("Local participant ".concat(this.localParticipant.identity," received all TrackUnpublished events for stream ").concat(i.streamId," of remote participant ").concat(t.identity)),this.participantRemoteStreams.get(t.identity).delete(i.streamId);var o=new f.StreamEvent(!0,this,"streamDestroyed",i.stream,"unpublish");this.publicEmmiter.emitEvent("streamDestroyed",[o]),o.callDefaultBehavior()}else R.debug("Local participant ".concat(this.localParticipant.identity," waiting for the remaining TrackUnpublished events of stream ").concat(i.streamId," of remote participant ").concat(t.identity))}else R.error("Local participant ".concat(t.identity," does not have associated track ").concat(e.trackSid," when handling TrackUnpublished event for remote participant ").concat(t.identity))}else R.error("Local participant ".concat(this.localParticipant.identity," does not have any associated tracks when handling TrackUnpublished event for remote participant ").concat(t.identity))},t.prototype.handleLocalTrackUnpublishedEvent=function(e,t){var n=Array.from(this.participantLocalStreams.values()).find((function(t){var n;return t.streamId===e.trackName&&(null===(n=t[e.kind])||void 0===n?void 0:n.id)==="".concat(e.kind,":").concat(e.source)}));if(n){n[e.kind].localTrackUnpublishedEventReceived=!0;var i=!0;if(n[c.Track.Kind.Video]&&(i=i&&n[c.Track.Kind.Video].localTrackUnpublishedEventReceived),n[c.Track.Kind.Audio]&&(i=i&&n[c.Track.Kind.Audio].localTrackUnpublishedEventReceived),i){R.debug("Local participant ".concat(this.localParticipant.identity," received all LocalTrackUnpublished events for stream ").concat(n.streamId)),this.participantLocalStreams.delete(n.streamId);var r=null!=this.ongoingForceUnpublishReason?this.ongoingForceUnpublishReason:"unpublish";delete this.ongoingForceUnpublishReason,this.connection.stream.ee.emitEvent("local-stream-destroyed",[r])}else R.debug("Local participant ".concat(this.localParticipant.identity," waiting for the remaining LocalTrackUnpublished events of stream ").concat(n.streamId))}else R.error("Local participant ".concat(t.identity," does not have associated track ").concat(e.trackSid))},t.prototype.handleTrackSubscribedEvent=function(e,t,n){var i,r,o=t.trackName,s=this.getTrackIdsFromStreamId(o),a=null===(i=this.participantStreamsToSubscribe.get(n.identity))||void 0===i?void 0:i.get(o);if(null!=a){var d={id:"".concat(t.kind,":").concat(t.source),kind:t.kind,source:t.source,trackPublishedEventReceived:!1,trackUnpublishedEventReceived:!1,trackSubscribedEventReceived:!0,localTrackUnpublishedEventReceived:!1};a[t.kind]=d}else if(a={streamId:t.trackName,videoId:s.videoTrackId,audioId:s.audioTrackId},d={id:"".concat(t.kind,":").concat(t.source),kind:t.kind,source:t.source,trackPublishedEventReceived:!1,trackUnpublishedEventReceived:!1,trackSubscribedEventReceived:!0,localTrackUnpublishedEventReceived:!1},a[t.kind]=d,this.participantStreamsToSubscribe.has(n.identity))null===(r=this.participantStreamsToSubscribe.get(n.identity))||void 0===r||r.set(a.streamId,a);else{var l=new Map;l.set(t.trackName,a),this.participantStreamsToSubscribe.set(n.identity,l)}var u=this.remoteConnections.get(n.identity);e.kind===c.Track.Kind.Video?u.stream.videoTrack=e:e.kind===c.Track.Kind.Audio&&(u.stream.audioTrack=e);var h=!0;a.videoId&&(h=h&&null!=a.video&&a.video.trackSubscribedEventReceived),a.audioId&&(h=h&&null!=a.audio&&a.audio.trackSubscribedEventReceived),h?(R.debug("Local participant ".concat(this.localParticipant.identity," received all TrackSubscribed events for stream ").concat(a.streamId," of remote participant ").concat(n.identity)),u.stream.streamReadyToAttach()):R.debug("Local participant ".concat(this.localParticipant.identity," waiting for the remaining TrackSubscribed events of stream ").concat(a.streamId," of remote participant ").concat(n.identity))},t.prototype.handleTrackUnsubscribedEvent=function(e,t,n){var i=this.participantStreamsToSubscribe.get(n.identity);if(i){var r=Array.from(i.values()).find((function(e){var n;return e.streamId===t.trackName&&(null===(n=e[t.kind])||void 0===n?void 0:n.id)==="".concat(t.kind,":").concat(t.source)}));r?r[e.kind].trackSubscribedEventReceived=!1:R.error("Local participant ".concat(n.identity," does not have associated track ").concat(t.trackSid," when handling TrackUnsubscribed event for remote participant ").concat(n.identity))}else R.error("Local participant ".concat(this.localParticipant.identity," does not have any associated tracks when handling TrackUnsubscribed event for remote participant ").concat(n.identity))},t.prototype.handleNetworkQualityLevelChanged=function(e,t){R.debug("Network quality changed",e);var n=this.networkQualityLevelValue;switch(e){case c.ConnectionQuality.Excellent:this.networkQualityLevelValue=5;break;case c.ConnectionQuality.Good:this.networkQualityLevelValue=3;break;case c.ConnectionQuality.Poor:this.networkQualityLevelValue=1}if(n!==this.networkQualityLevelValue){var i=t.identity===this.localParticipant.identity?this.connection:this.remoteConnections.get(t.identity),r=new S.NetworkQualityLevelChangedEvent(this,this.networkQualityLevelValue,n,i);this.publicEmmiter.emitEvent("networkQualityLevelChanged",[r])}},t.prototype.decodeData=function(e){return(new TextDecoder).decode(e)},t.prototype.generateRoomConnectOptions=function(){var e={autoSubscribe:!1,maxRetries:3,peerConnectionTimeout:15e3,websocketTimeout:15e3,rtcConfig:{}};if(this.openvidu.advancedConfiguration.iceServers){var t;t="string"==typeof this.openvidu.advancedConfiguration.iceServers?[{urls:this.openvidu.advancedConfiguration.iceServers}]:this.openvidu.advancedConfiguration.iceServers,e.rtcConfig={iceServers:t}}return e},t.prototype.notConnectedError=function(){return new v.OpenViduError(v.OpenViduErrorName.OPENVIDU_NOT_CONNECTED,"There is no connection to the session. Method 'Session.connect' must be successfully completed first")},t.prototype.anySpeechEventListenerEnabled=function(e,t){var n=this.publicEmmiter.getListeners(e);return t&&(n=n.filter((function(e){return e.once}))),n.length>0},t.prototype.processClientMetadata=function(e){if(e){var t=this.room.localParticipant.metadata,n=e;"object"==typeof e&&(n=JSON.stringify(e));var i=n;try{if(t){var r=JSON.parse(t);if(r&&"object"==typeof r){var s=o(o({},r),{clientData:n});i=JSON.stringify(s)}}return i}catch(e){return R.error("Error updating client data in the local participant metadata:"),t}}},t.prototype.getTrackIdsFromStreamId=function(e){var t,n;return{videoTrackId:(null===(t=e.match(/__V__(.*)__A__.*$/))||void 0===t?void 0:t[1])||void 0,audioTrackId:(null===(n=e.match(/__V__.*__A__(.*)$/))||void 0===n?void 0:n[1])||void 0}},t}(u.EventDispatcher);t.Session=O},2535:function(e,t,n){"use strict";var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]0},t.prototype.pushNewStreamManagerVideo=function(e){this.videos.push(e),this.initializeVideoProperties(e),this.addPlayEventToFirstVideo(),-1===this.stream.session.streamManagers.indexOf(this)&&this.stream.session.streamManagers.push(this)},t.prototype.initializeVideoProperties=function(e){this.stream.isReadyToAttach&&(this.attachTracks(e.video),this.initializeVideoPropertiesAux(e))},t.prototype.initializeVideoPropertiesAux=function(e){e.video.autoplay=!0,e.video.controls=!1,e.video.playsInline=!0,e.video.muted=!this.remote,e.video.dataset.openviduType=this.remote?"remote":"local",e.video.dataset.openviduId=this.stream.streamId+"_"+this.stream.session.localParticipant.identity,e.video.id||(e.video.id=(this.remote?"remote":"local")+"-video-"+this.stream.session.localParticipant.identity+"-"+this.stream.streamId),e.id=e.video.id,!this.id&&this.targetElement&&(this.id=e.id),this.remote&&this.isMirrored(e.video)?this.setMirror(!1,e.video):this.remote||(this.isMirrored(e.video)&&!this.stream.outboundStreamOpts.publisherProperties.mirror?this.setMirror(!1,e.video):this.stream.outboundStreamOpts.publisherProperties.mirror&&!this.stream.isSendingScreen()?this.setMirror(!0,e.video):this.stream.isSendingScreen()&&this.setMirror(!1,e.video))},t.prototype.attachTracks=function(e){var t,n;this.remote?(u.log("Initializing video for remote stream ".concat(this.stream.streamId),this.stream,e),this.stream.connection.participant.getTrackPublications().forEach((function(t){var n;u.debug("Attaching remote track to video",t),null===(n=t.track)||void 0===n||n.attach(e)}))):(u.log("Initializing video for local stream ".concat(this.stream.streamId),this.stream,e),this.stream.session.isSessionConnected()?this.stream.session.localParticipant.getTrackPublications().forEach((function(t){var n;u.debug("Attaching local track publication to video ",t),null===(n=t.track)||void 0===n||n.attach(e)})):(u.debug("Session is not connected. Attaching video and audio tracks to video element."),null===(t=this.stream.videoTrack)||void 0===t||t.attach(e),null===(n=this.stream.audioTrack)||void 0===n||n.attach(e)))},t.prototype.setMirror=function(e,t){t.style.transform=e?"scaleX(-1)":"unset"},t.prototype.isMirrored=function(e){return"scaleX(-1)"===e.style.transform},t.prototype.emitEvent=function(e,t){this.publicEmmiter.emitEvent(e,t)},t.prototype.on=function(t,n){switch(e.prototype.onAux.call(this,t,"Event '"+t+"' triggered by '"+(this.remote?"Subscriber":"Publisher")+"'",n),t){case"publisherStartSpeaking":this.stream.enableHarkSpeakingEvent();break;case"publisherStopSpeaking":this.stream.enableHarkStoppedSpeakingEvent();break;case"streamAudioVolumeChange":this.stream.enableHarkVolumeChangeEvent(!1)}return this},t.prototype.once=function(t,n){switch(e.prototype.onceAux.call(this,t,"Event '"+t+"' triggered by '"+(this.remote?"Subscriber":"Publisher")+"'",n),t){case"publisherStartSpeaking":this.stream.enableOnceHarkSpeakingEvent();break;case"publisherStopSpeaking":this.stream.enableOnceHarkStoppedSpeakingEvent();break;case"streamAudioVolumeChange":this.stream.enableOnceHarkVolumeChangeEvent(!1)}return this},t.prototype.off=function(t,n){switch(e.prototype.offAux.call(this,t,n),t){case"publisherStartSpeaking":0===this.publicEmmiter.getListeners(t).length+this.stream.session.publicEmmiter.getListeners(t).length&&this.stream.disableHarkSpeakingEvent(!1);break;case"publisherStopSpeaking":0===this.publicEmmiter.getListeners(t).length+this.stream.session.publicEmmiter.getListeners(t).length&&this.stream.disableHarkStoppedSpeakingEvent(!1);break;case"streamAudioVolumeChange":0===this.publicEmmiter.getListeners(t).length&&this.stream.disableHarkVolumeChangeEvent(!1)}return this},t.prototype.removeAllVideos=function(){for(var e=this,t=this.stream.session.streamManagers.length-1;t>=0;--t)this.stream.session.streamManagers[t]===this&&this.stream.session.streamManagers.splice(t,1);this.videos.forEach((function(t){if(t.video&&t.video.removeEventListener&&t.video.removeEventListener("canplay",e.canPlayListener),t.canplayListenerAdded=!1,t.targetElement){t.video.remove();var n=new d.VideoElementEvent(t.video,e,"videoElementDestroyed");e.emitEvent("videoElementDestroyed",[n])}t.video.srcObject=null,e.deactivateStreamPlayingEventExceptionTimeout()})),this.videos=this.videos.filter((function(e){return!e.targetElement}))},t.prototype.activateStreamPlayingEventExceptionTimeout=function(){var e=this;if(this.remote&&null==this.streamPlayingEventExceptionTimeout){var t=this.stream.session.openvidu.advancedConfiguration.noStreamPlayingEventExceptionTimeout||4e3;this.streamPlayingEventExceptionTimeout=setTimeout((function(){var n="StreamManager of Stream "+e.stream.streamId+" ("+(e.remote?"Subscriber":"Publisher")+') did not trigger "streamPlaying" event in '+t+" ms";u.warn(n),e.stream.session.publicEmmiter.emitEvent("exception",[new l.ExceptionEvent(e.stream.session,l.ExceptionEventName.NO_STREAM_PLAYING_EVENT,e,n)]),delete e.streamPlayingEventExceptionTimeout}),t)}},t.prototype.deactivateStreamPlayingEventExceptionTimeout=function(){clearTimeout(this.streamPlayingEventExceptionTimeout),delete this.streamPlayingEventExceptionTimeout},t}(a.EventDispatcher);t.StreamManager=h},9713:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.Subscriber=void 0;var o=n(7172),s=n(3853),a=n(8608),c=s.OpenViduLogger.getInstance(),d=function(e){function t(t,n,i){var r=e.call(this,t,n)||this;return r.stream=t,r.properties=i,r}return r(t,e),t.prototype.subscribeToAudio=function(e){return this.stream.connection.participant.getTrackPublications().forEach((function(t){t.kind===a.Track.Kind.Audio&&(t.setEnabled(e),t.audioTrack.mediaStreamTrack.enabled=e)})),c.info("'Subscriber' has "+(e?"enabled":"diasbled")+" its audio stream"),this.stream.audioActive=e,this},t.prototype.subscribeToVideo=function(e){return this.stream.connection.participant.getTrackPublications().forEach((function(t){t.kind===a.Track.Kind.Video&&(t.setEnabled(e),t.videoTrack.mediaStreamTrack.enabled=e)})),c.info("'Subscriber' has "+(e?"enabled":"diasbled")+" its video stream"),this.stream.videoActive=e,this},t.prototype.unsubscribe=function(){this.stream.connection.participant.getTrackPublications().forEach((function(e){e.setSubscribed(!1)})),this.stream.streamJustDestroyed()},t}(o.StreamManager);t.Subscriber=d},9849:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LocalRecorderState=void 0,(n=t.LocalRecorderState||(t.LocalRecorderState={})).READY="READY",n.RECORDING="RECORDING",n.PAUSED="PAUSED",n.FINISHED="FINISHED"},1539:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.OpenViduError=t.OpenViduErrorName=void 0,(n=t.OpenViduErrorName||(t.OpenViduErrorName={})).BROWSER_NOT_SUPPORTED="BROWSER_NOT_SUPPORTED",n.DEVICE_ACCESS_DENIED="DEVICE_ACCESS_DENIED",n.DEVICE_ALREADY_IN_USE="DEVICE_ALREADY_IN_USE",n.SCREEN_CAPTURE_DENIED="SCREEN_CAPTURE_DENIED",n.SCREEN_SHARING_NOT_SUPPORTED="SCREEN_SHARING_NOT_SUPPORTED",n.SCREEN_EXTENSION_NOT_INSTALLED="SCREEN_EXTENSION_NOT_INSTALLED",n.SCREEN_EXTENSION_DISABLED="SCREEN_EXTENSION_DISABLED",n.INPUT_VIDEO_DEVICE_NOT_FOUND="INPUT_VIDEO_DEVICE_NOT_FOUND",n.INPUT_AUDIO_DEVICE_NOT_FOUND="INPUT_AUDIO_DEVICE_NOT_FOUND",n.INPUT_AUDIO_DEVICE_GENERIC_ERROR="INPUT_AUDIO_DEVICE_GENERIC_ERROR",n.NO_INPUT_SOURCE_SET="NO_INPUT_SOURCE_SET",n.PUBLISHER_PROPERTIES_ERROR="PUBLISHER_PROPERTIES_ERROR",n.OPENVIDU_PERMISSION_DENIED="OPENVIDU_PERMISSION_DENIED",n.OPENVIDU_NOT_CONNECTED="OPENVIDU_NOT_CONNECTED",n.VIRTUAL_BACKGROUND_ERROR="VIRTUAL_BACKGROUND_ERROR",n.GENERIC_ERROR="GENERIC_ERROR";t.OpenViduError=function(e,t){this.name=e,this.message=t}},4287:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TypeOfVideo=void 0,(n=t.TypeOfVideo||(t.TypeOfVideo={})).CAMERA="CAMERA",n.SCREEN="SCREEN",n.CUSTOM="CUSTOM",n.IPCAM="IPCAM"},550:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.VideoInsertMode=void 0,(n=t.VideoInsertMode||(t.VideoInsertMode={})).AFTER="AFTER",n.APPEND="APPEND",n.BEFORE="BEFORE",n.PREPEND="PREPEND",n.REPLACE="REPLACE"},5014:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionEvent=void 0;var o=function(e){function t(t,n,i,r,o){var s=e.call(this,t,n,i)||this;return s.connection=r,s.reason=o,s}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(n(7994).Event);t.ConnectionEvent=o},4693:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionPropertyChangedEvent=void 0;var o=function(e){function t(t,n,i,r,o){var s=e.call(this,!1,t,"connectionPropertyChanged")||this;return s.connection=n,s.changedProperty=i,s.newValue=r,s.oldValue=o,s}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(n(7994).Event);t.ConnectionPropertyChangedEvent=o},7994:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;var n=function(){function e(e,t,n){this.hasBeenPrevented=!1,this.cancelable=e,this.target=t,this.type=n}return e.prototype.isDefaultPrevented=function(){return this.hasBeenPrevented},e.prototype.preventDefault=function(){this.callDefaultBehavior=function(){},this.hasBeenPrevented=!0},e}();t.Event=n},5215:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.ExceptionEvent=t.ExceptionEventName=void 0;var o,s=n(7994);(o=t.ExceptionEventName||(t.ExceptionEventName={})).ICE_CANDIDATE_ERROR="ICE_CANDIDATE_ERROR",o.ICE_CONNECTION_FAILED="ICE_CONNECTION_FAILED",o.ICE_CONNECTION_DISCONNECTED="ICE_CONNECTION_DISCONNECTED",o.NO_STREAM_PLAYING_EVENT="NO_STREAM_PLAYING_EVENT",o.SPEECH_TO_TEXT_DISCONNECTED="SPEECH_TO_TEXT_DISCONNECTED";var a=function(e){function t(t,n,i,r,o){var s=e.call(this,!1,t,"exception")||this;return s.name=n,s.origin=i,s.message=r,s.data=o,s}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(s.Event);t.ExceptionEvent=a},2597:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkQualityLevelChangedEvent=void 0;var o=function(e){function t(t,n,i,r){var o=e.call(this,!1,t,"networkQualityLevelChanged")||this;return o.newValue=n,o.oldValue=i,o.connection=r,o}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(n(7994).Event);t.NetworkQualityLevelChangedEvent=o},4838:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.PublisherSpeakingEvent=void 0;var o=function(e){function t(t,n,i,r){var o=e.call(this,!1,t,n)||this;return o.type=n,o.connection=i,o.streamId=r,o}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(n(7994).Event);t.PublisherSpeakingEvent=o},5625:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.RecordingEvent=void 0;var o=function(e){function t(t,n,i,r,o){var s=e.call(this,!1,t,n)||this;return s.id=i,r!==i&&(s.name=r),s.reason=o,s}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(n(7994).Event);t.RecordingEvent=o},129:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.SessionDisconnectedEvent=void 0;var o=n(7994),s=n(3853).OpenViduLogger.getInstance(),a=function(e){function t(t,n){var i=e.call(this,!0,t,"sessionDisconnected")||this;return i.reason=i.fromLivekitReasonToOpenviduReason(n),i}return r(t,e),t.prototype.fromLivekitReasonToOpenviduReason=function(e){switch(e){case 1:default:return"disconnect";case 2:case 4:return"forceDisconnectByServer";case 3:return"nodeCrashed";case 5:return"sessionClosedByServer"}},t.prototype.callDefaultBehavior=function(){s.info("Calling default behavior upon '"+this.type+"' event dispatched by 'Session'");var e=this.target;e.remoteConnections.forEach((function(t){var n,i,r,o=t.connectionId;(null===(n=e.remoteConnections.get(o))||void 0===n?void 0:n.stream)&&(null===(i=e.remoteConnections.get(o))||void 0===i?void 0:i.stream.streamManager)&&(null===(r=e.remoteConnections.get(o))||void 0===r||r.stream.streamManager.removeAllVideos()),e.remoteConnections.delete(o)}))},t}(o.Event);t.SessionDisconnectedEvent=a},7622:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.SignalEvent=void 0;var o=function(e){function t(t,n,i,r){var o=e.call(this,!1,t,"signal")||this;return n&&(o.type="signal:"+n),o.data=i,o.from=r,o}return r(t,e),t.prototype.callDefaultBehavior=function(){},t}(n(7994).Event);t.SignalEvent=o},4226:function(e,t,n){"use strict";var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.StreamEvent=void 0;var o=n(7994),s=n(5415),a=n(8235),c=n(3853).OpenViduLogger.getInstance(),d=function(e){function t(t,n,i,r,o){var s=e.call(this,t,n,i)||this;return s.stream=r,s.reason=o,"streamDestroyed"===s.type&&r.streamJustDestroyed(),s}return r(t,e),t.prototype.callDefaultBehavior=function(){if("streamDestroyed"===this.type){if(this.target instanceof a.Session)c.info("Calling default behavior upon '"+this.type+"' event dispatched by 'Session'");else if(this.target instanceof s.Publisher){c.info("Calling default behavior upon '"+this.type+"' event dispatched by 'Publisher'");for(var e=this.target.openvidu.publishers,t=0;t{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.InternalSignalType=void 0,(n=t.InternalSignalType||(t.InternalSignalType={})).CUSTOM_CLIENT_SIGNAL_PREFIX="custom-openvidu-client-signal:",n.CUSTOM_SERVER_SIGNAL_PREFIX="custom-openvidu-server-signal:",n.OPENVIDU_STREAM_PROPERTY_CHANGED="openvidu-stream-property-changed",n.OPENVIDU_RECORDING_STARTED="openvidu-recording-started",n.OPENVIDU_RECORDING_STOPPED="openvidu-recording-stopped",n.OPENVIDU_BROADCASTING_STARTED="openvidu-broadcasting-started",n.OPENVIDU_BROADCASTING_STOPPED="openvidu-broadcasting-stopped",n.OPENVIDU_PARTICIPANT_PUBLISHED="openvidu-participant-published",n.OPENVIDU_SIGNAL="openvidu-internal-signal",n.OPENVIDU_FORCE_DISCONNECT="openvidu-force-disconnect",n.OPENVIDU_FORCE_UNPUBLISH="openvidu-force-unpublish",n.OPENVIDU_UNPUBLISH_STREAM="openvidu-unpublish-stream"},9414:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;t.ConsoleLogger=function(e){this.logger=e,this.log=e.log,this.info=e.info,this.debug=e.debug,this.warn=e.warn,this.error=e.error}},3853:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OpenViduLogger=void 0;var i=n(9414),r=function(){function e(){this.defaultConsoleLogger=new i.ConsoleLogger(globalThis.console),this.isProdMode=!1}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.log=function(){for(var e=[],t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformUtils=void 0;var i=n(7503),r=function(){function e(){}return e.getInstance=function(){return this.instance||(this.instance=new e),e.instance},e.prototype.isChromeBrowser=function(){return"Chrome"===i.name},e.prototype.isSafariBrowser=function(){return"Safari"===i.name},e.prototype.isChromeMobileBrowser=function(){return"Chrome Mobile"===i.name},e.prototype.isFirefoxBrowser=function(){return"Firefox"===i.name},e.prototype.isFirefoxMobileBrowser=function(){return"Firefox Mobile"===i.name||"Firefox for iOS"===i.name},e.prototype.isOperaBrowser=function(){return"Opera"===i.name},e.prototype.isOperaMobileBrowser=function(){return"Opera Mobile"===i.name},e.prototype.isEdgeBrowser=function(){var e=(null==i?void 0:i.version)?parseFloat(i.version):-1;return"Microsoft Edge"===i.name&&e>=80},e.prototype.isEdgeMobileBrowser=function(){var e,t,n=(null==i?void 0:i.version)?parseFloat(i.version):-1;return"Microsoft Edge"===i.name&&("Android"===(null===(e=i.os)||void 0===e?void 0:e.family)||"iOS"===(null===(t=i.os)||void 0===t?void 0:t.family))&&n>45},e.prototype.isAndroidBrowser=function(){return"Android Browser"===i.name},e.prototype.isElectron=function(){return"Electron"===i.name},e.prototype.isNodeJs=function(){return"Node.js"===i.name},e.prototype.isSamsungBrowser=function(){return"Samsung Internet Mobile"===i.name||"Samsung Internet"===i.name},e.prototype.isMotorolaEdgeDevice=function(){var e;return(null===(e=i.product)||void 0===e?void 0:e.toLowerCase().includes("motorola edge"))||!1},e.prototype.isIPhoneOrIPad=function(){var e=i.ua?i.ua:navigator.userAgent,t="ontouchend"in document,n=/\b(\w*Macintosh\w*)\b/.test(e)&&t,r=/\b(\w*iPhone\w*)\b/.test(e)&&/\b(\w*Mobile\w*)\b/.test(e)&&t;return n||r},e.prototype.isIOSWithSafari=function(){var e=i.ua?i.ua:navigator.userAgent;return this.isIPhoneOrIPad()&&/\b(\w*Apple\w*)\b/.test(navigator.vendor)&&/\b(\w*Safari\w*)\b/.test(e)&&!/\b(\w*CriOS\w*)\b/.test(e)&&!/\b(\w*FxiOS\w*)\b/.test(e)},e.prototype.isIonicIos=function(){return this.isIPhoneOrIPad()&&-1===i.ua.indexOf("Safari")},e.prototype.isIonicAndroid=function(){return"Android"===i.os.family&&"Android Browser"==i.name},e.prototype.isMobileDevice=function(){return"iOS"===i.os.family||"Android"===i.os.family},e.prototype.isReactNative=function(){return!1},e.prototype.isChromium=function(){return this.isChromeBrowser()||this.isChromeMobileBrowser()||this.isOperaBrowser()||this.isOperaMobileBrowser()||this.isEdgeBrowser()||this.isEdgeMobileBrowser()||this.isSamsungBrowser()||this.isIonicAndroid()||this.isIonicIos()||this.isElectron()||this.isMotorolaEdgeDevice()},e.prototype.canScreenShare=function(){var e=(null==i?void 0:i.version)?parseFloat(i.version):-1;return!this.isMobileDevice()&&(this.isChromeBrowser()||this.isFirefoxBrowser()||this.isOperaBrowser()||this.isElectron()||this.isEdgeBrowser()||this.isSafariBrowser()&&e>=13)},e.prototype.getName=function(){return i.name||""},e.prototype.getVersion=function(){return i.version||""},e.prototype.getFamily=function(){return i.os.family||""},e.prototype.getDescription=function(){return i.description||""},e}();t.PlatformUtils=r},2049:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OvWebSocket=void 0;var i=n(8007),r=n(3853).OpenViduLogger.getInstance(),o=function(){function e(e,t,n,i,r){this.url=e,this.roomName=t,this.roomSid=n,this.connectionId=i,this.platform=r,this.socket=null}return e.prototype.connect=function(){var e=this;return new Promise((function(t,n){var o=e.url.startsWith("https://")||e.url.startsWith("wss://");e.socket=(0,i.io)(e.url,{path:"/openvidu/ws/",query:{roomName:e.roomName,roomSid:e.roomSid,connectionId:e.connectionId,platform:e.platform},secure:o,rejectUnauthorized:o}),e.socket.on("connect",(function(){var n;(null===(n=e.socket)||void 0===n?void 0:n.recovered)?r.log("WebSocket reconnected"):r.debug("WebSocket connected"),t()})),e.socket.on("disconnect",(function(){r.debug("WebSocket disconnected")}))}))},e.prototype.close=function(){this.socket&&this.socket.close()},e.prototype.emitEvent=function(e,t){var n;(null===(n=this.socket)||void 0===n?void 0:n.connected)?this.socket.emit(e,t):r.error("WebSocket is not connected")},e.prototype.onEvent=function(e,t){this.socket?this.socket.on(e,t):r.error("WebSocket is not connected")},e.prototype.requestAnswer=function(e,t,n){this.socket?this.socket.timeout(5e3).emit(e,t,n):r.error("WebSocket is not connected")},e}();t.OvWebSocket=o},8499:e=>{function t(){}e.exports=t,t.mixin=function(e){var t=e.prototype||e;t.isWildEmitter=!0,t.on=function(e,t,n){this.callbacks=this.callbacks||{};var i=3===arguments.length,r=i?arguments[1]:void 0,o=i?arguments[2]:arguments[1];return o._groupName=r,(this.callbacks[e]=this.callbacks[e]||[]).push(o),this},t.once=function(e,t,n){var i=this,r=3===arguments.length,o=r?arguments[1]:void 0,s=r?arguments[2]:arguments[1];return this.on(e,o,(function t(){i.off(e,t),s.apply(this,arguments)})),this},t.releaseGroup=function(e){var t,n,i,r;for(t in this.callbacks=this.callbacks||{},this.callbacks)for(n=0,i=(r=this.callbacks[t]).length;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let n=!1;try{n="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=n},8661:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0,t.encode=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){let t={},n=e.split("&");for(let e=0,i=n.length;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;const n=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.parse=function(e){if(e.length>2e3)throw"URI too long";const t=e,r=e.indexOf("["),o=e.indexOf("]");-1!=r&&-1!=o&&(e=e.substring(0,r)+e.substring(r,o).replace(/:/g,";")+e.substring(o,e.length));let s=n.exec(e||""),a={},c=14;for(;c--;)a[i[c]]=s[c]||"";return-1!=r&&-1!=o&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,a.path),a.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,i){t&&(n[t]=i)})),n}(0,a.query),a}},732:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.yeast=t.decode=t.encode=void 0;const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i={};let r,o=0,s=0;function a(e){let t="";do{t=n[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}for(t.encode=a,t.decode=function(e){let t=0;for(s=0;s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.globalThisShim=void 0,t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},4956:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.Socket=void 0;const i=n(8223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return i.Socket}}),t.protocol=i.Socket.protocol;var r=n(4689);Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return r.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return r.TransportError}});var o=n(9419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var s=n(5374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return s.installTimerFunctions}});var a=n(1015);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return a.parse}});var c=n(4087);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return c.nextTick}})},8223:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const r=n(9419),o=n(5374),s=n(8661),a=n(1015),c=i(n(6617)),d=n(7285),l=n(6376),u=n(4087),h=(0,c.default)("engine.io-client:socket");class p extends d.Emitter{constructor(e,t={}){super(),this.binaryType=u.defaultBinaryType,this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=(0,a.parse)(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=(0,a.parse)(t.host).host),(0,o.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,s.decode)(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){h('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=l.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return h("options: %j",n),new r.transports[e](n)}open(){let e;if(this.opts.rememberUpgrade&&p.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return h("error while creating transport: %s",e),this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){h("setting transport %s",e.name),this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){h('probing transport "%s"',e);let t=this.createTransport(e),n=!1;p.priorWebsocketSuccess=!1;const i=()=>{n||(h('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(i=>{if(!n)if("pong"===i.type&&"probe"===i.data){if(h('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;p.priorWebsocketSuccess="websocket"===t.name,h('pausing current transport "%s"',this.transport.name),this.transport.pause((()=>{n||"closed"!==this.readyState&&(h("changing transport and sending upgrade packet"),d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{h('probe transport "%s" failed',e);const n=new Error("probe error");n.transport=t.name,this.emitReserved("upgradeError",n)}})))};function r(){n||(n=!0,d(),t.close(),t=null)}const o=n=>{const i=new Error("probe error: "+n);i.transport=t.name,r(),h('probe transport "%s" failed because of error: %s',e,n),this.emitReserved("upgradeError",i)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&(h('"%s" works - aborting "%s"',e.name,t.name),r())}const d=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",i),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onOpen(){if(h("socket open"),this.readyState="open",p.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){h("starting upgrade probes");let e=0;const t=this.upgrades.length;for(;e{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();h("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t0&&e>this.maxPayload)return h("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return h("payload size is %d (max: %d)",e,this.maxPayload),this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,i){if("function"==typeof t&&(i=t,t=void 0),"function"==typeof n&&(i=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const r={type:e,data:t,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),h("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}onError(e){h("socket error %j",e),p.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(h('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const i=e.length;for(;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const i=n(528),r=n(8716),o=n(4480);t.transports={websocket:r.WS,webtransport:o.WT,polling:i.Polling}},528:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Request=t.Polling=void 0;const r=n(4689),o=i(n(6617)),s=n(732),a=n(6376),c=n(3519),d=n(7285),l=n(5374),u=n(6235),h=(0,o.default)("engine.io-client:polling");function p(){}const m=null!=new c.XHR({xdomain:!1}).responseType;class f extends r.Transport{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}const t=e&&e.forceBase64;this.supportsBinary=m&&!t,this.opts.withCredentials&&(this.cookieJar=(0,c.createCookieJar)())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{h("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(h("we are currently polling - waiting to pause"),e++,this.once("pollComplete",(function(){h("pre-pause polling complete"),--e||t()}))),this.writable||(h("we are currently writing - waiting to pause"),e++,this.once("drain",(function(){h("pre-pause writing complete"),--e||t()})))}else t()}poll(){h("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){h("polling got data %s",e),(0,a.decodePayload)(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this.poll():h('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{h("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(h("transport open - closing"),e()):(h("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,a.encodePayload)(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,s.yeast)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new g(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){h("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}t.Polling=f;class g extends d.Emitter{constructor(e,t){super(),(0,l.installTimerFunctions)(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=(0,l.pick)(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new c.XHR(t);try{h("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(n)),4===n.readyState&&(200===n.status||1223===n.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof n.status?n.status:0)}),0))},h("xhr data %s",this.data),n.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=g.requestsCount++,g.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=p,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete g.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(t.Request=g,g.requestsCount=0,g.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",v);else if("function"==typeof addEventListener){const e="onpagehide"in u.globalThisShim?"pagehide":"unload";addEventListener(e,v,!1)}function v(){for(let e in g.requests)g.requests.hasOwnProperty(e)&&g.requests[e].abort()}},4087:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.usingBrowserWebSocket=t.WebSocket=t.nextTick=void 0;const i=n(6235);t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.WebSocket=i.globalThisShim.WebSocket||i.globalThisShim.MozWebSocket,t.usingBrowserWebSocket=!0,t.defaultBinaryType="arraybuffer"},8716:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=void 0;const r=n(4689),o=n(732),s=n(5374),a=n(4087),c=i(n(6617)),d=n(6376),l=(0,c.default)("engine.io-client:websocket"),u="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class h extends r.Transport{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=u?{}:(0,s.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=a.usingBrowserWebSocket&&!u?t?new a.WebSocket(e,t):new a.WebSocket(e):new a.WebSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t{const t={};!a.usingBrowserWebSocket&&(n.options&&(t.compress=n.options.compress),this.opts.perMessageDeflate)&&("string"==typeof e?Buffer.byteLength(e):e.length){this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,o.yeast)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!a.WebSocket}}t.WS=h},4480:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const r=n(4689),o=n(4087),s=n(6376),a=(0,i(n(6617)).default)("engine.io-client:webtransport");class c extends r.Transport{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{a("transport closed gracefully"),this.onClose()})).catch((e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=(0,s.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),i=(0,s.createPacketEncoderStream)();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const r=()=>{n.read().then((({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),r())})).catch((e=>{a("an error occurred while reading: %s",e)}))};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t{i&&(0,o.nextTick)((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}}t.WT=c},3519:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createCookieJar=t.XHR=void 0;const i=n(4110),r=n(6235);t.XHR=function(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||i.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(r.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},t.createCookieJar=function(){}},5374:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.byteLength=t.installTimerFunctions=t.pick=void 0;const i=n(6235);t.pick=function(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})};const r=i.globalThisShim.setTimeout,o=i.globalThisShim.clearTimeout;t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=r.bind(i.globalThisShim),e.clearTimeoutFn=o.bind(i.globalThisShim)):(e.setTimeoutFn=i.globalThisShim.setTimeout.bind(i.globalThisShim),e.clearTimeoutFn=i.globalThisShim.clearTimeout.bind(i.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,n=0;for(let i=0,r=e.length;i=57344?n+=3:(i++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}},2046:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const n=Object.create(null);t.PACKET_TYPES=n,n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const i=Object.create(null);t.PACKET_TYPES_REVERSE=i,Object.keys(n).forEach((e=>{i[n[e]]=e})),t.ERROR_PACKET={type:"error",data:"parser error"}},2745:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)i[n.charCodeAt(e)]=e;t.encode=e=>{let t,i=new Uint8Array(e),r=i.length,o="";for(t=0;t>2],o+=n[(3&i[t])<<4|i[t+1]>>4],o+=n[(15&i[t+1])<<2|i[t+2]>>6],o+=n[63&i[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=e=>{let t,n,r,o,s,a=.75*e.length,c=e.length,d=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const l=new ArrayBuffer(a),u=new Uint8Array(l);for(t=0;t>4,u[d++]=(15&r)<<4|o>>2,u[d++]=(3&o)<<6|63&s;return l}},2662:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const i=n(2046),r=n(2745),o="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:s(e.substring(1),t)}:i.PACKET_TYPES_REVERSE[n]?e.length>1?{type:i.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:i.PACKET_TYPES_REVERSE[n]}:i.ERROR_PACKET};const s=(e,t)=>{if(o){const n=(0,r.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},2686:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=t.encodePacketToBinary=void 0;const i=n(2046),r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),o="function"==typeof ArrayBuffer,s=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},n,a)=>r&&t instanceof Blob?n?a(t):c(t,a):o&&(t instanceof ArrayBuffer||s(t))?n?a(t):c(new Blob([t]),a):a(i.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function d(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let l;t.encodePacketToBinary=function(e,t){return r&&e.data instanceof Blob?e.data.arrayBuffer().then(d).then(t):o&&(e.data instanceof ArrayBuffer||s(e.data))?t(d(e.data)):void a(e,!1,(e=>{l||(l=new TextEncoder),t(l.encode(e))}))}},6376:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=t.createPacketDecoderStream=t.createPacketEncoderStream=void 0;const i=n(2686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return i.encodePacket}});const r=n(2662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return r.decodePacket}});const o=n(2046),s=String.fromCharCode(30);let a;function c(e){return e.reduce(((e,t)=>e+t.length),0)}function d(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let i=0;for(let r=0;r{const n=e.length,r=new Array(n);let o=0;e.forEach(((e,a)=>{(0,i.encodePacket)(e,!1,(e=>{r[a]=e,++o===n&&t(r.join(s))}))}))},t.decodePayload=(e,t)=>{const n=e.split(s),i=[];for(let e=0;e{const i=n.length;let r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);const e=new DataView(r.buffer);e.setUint8(0,126),e.setUint16(1,i)}else{r=new Uint8Array(9);const e=new DataView(r.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(i))}e.data&&"string"!=typeof e.data&&(r[0]|=128),t.enqueue(r),t.enqueue(n)}))}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const n=[];let i=0,s=-1,l=!1;return new TransformStream({transform(u,h){for(n.push(u);;){if(0===i){if(c(n)<1)break;const e=d(n,1);l=!(128&~e[0]),s=127&e[0],i=s<126?3:126===s?1:2}else if(1===i){if(c(n)<2)break;const e=d(n,2);s=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),i=3}else if(2===i){if(c(n)<8)break;const e=d(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),r=t.getUint32(0);if(r>Math.pow(2,21)-1){h.enqueue(o.ERROR_PACKET);break}s=r*Math.pow(2,32)+t.getUint32(4),i=3}else{if(c(n)e){h.enqueue(o.ERROR_PACKET);break}}}})},t.protocol=4},7743:(e,t)=>{"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=void 0,t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},8007:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.connect=t.io=t.Socket=t.Manager=t.protocol=void 0;const r=n(6894),o=n(3776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return o.Manager}});const s=n(6214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return s.Socket}});const a=i(n(9368)).default("socket.io-client"),c={};function d(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=r.url(e,t.path||"/socket.io"),i=n.source,s=n.id,d=n.path,l=c[s]&&d in c[s].nsps;let u;return t.forceNew||t["force new connection"]||!1===t.multiplex||l?(a("ignoring socket cache for %s",i),u=new o.Manager(i,t)):(c[s]||(a("new io instance for %s",i),c[s]=new o.Manager(i,t)),u=c[s]),n.query&&!t.query&&(t.query=n.queryKey),u.socket(n.path,t)}t.io=d,t.connect=d,t.default=d,Object.assign(d,{Manager:o.Manager,Socket:s.Socket,io:d,connect:d});var l=n(4627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return l.protocol}}),e.exports=d},3776:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(4956),c=n(6214),d=o(n(4627)),l=n(5942),u=n(7743),h=n(7285),p=s(n(9368)).default("socket.io-client:manager");class m extends h.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,a.installTimerFunctions(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new u.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||d;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(p("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;p("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=l.on(t,"open",(function(){n.onopen(),e&&e()})),r=t=>{p("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=l.on(t,"error",r);if(!1!==this._timeout){const e=this._timeout;p("connect attempt will timeout after %d",e);const n=this.setTimeoutFn((()=>{p("connect attempt timed out after %d",e),i(),r(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){p("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(l.on(e,"ping",this.onping.bind(this)),l.on(e,"data",this.ondata.bind(this)),l.on(e,"error",this.onerror.bind(this)),l.on(e,"close",this.onclose.bind(this)),l.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){a.nextTick((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){p("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void p("socket %s is still active, skipping close",e);this._close()}_packet(e){p("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;ne())),this.subs.length=0,this.decoder.destroy()}_close(){p("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){p("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)p("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();p("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn((()=>{e.skipReconnect||(p("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(p("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(p("reconnect success"),e.onreconnect())})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=m},5942:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=void 0,t.on=function(e,t,n){return e.on(t,n),function(){e.off(t,n)}}},6214:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const r=n(4627),o=n(5942),s=n(7285),a=i(n(9368)).default("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class d extends s.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[o.on(e,"open",this.onopen.bind(this)),o.on(e,"packet",this.onpacket.bind(this)),o.on(e,"error",this.onerror.bind(this)),o.on(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:r.PacketType.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const i=t.pop();this._registerAckCallback(e,i),n.id=e}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return!this.flags.volatile||i&&this.connected?this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n):a("discard packet as the transport is not currently writable"),this.flags={},this}_registerAckCallback(e,t){var n;const i=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===i)return void(this.acks[e]=t);const r=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t{this.io.clearTimeoutFn(r),t.apply(this,e)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise(((n,i)=>{const r=(e,t)=>e?i(e):n(t);r.withError=!0,t.push(r),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...i)=>{if(n===this._queue[0])return null!==e?n.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:r.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach((e=>{if(!this.sendBuffer.some((t=>String(t.id)===e))){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}}))}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case r.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case r.PacketType.EVENT:case r.PacketType.BINARY_EVENT:this.onevent(e);break;case r.PacketType.ACK:case r.PacketType.BINARY_ACK:this.onack(e);break;case r.PacketType.DISCONNECT:this.ondisconnect();break;case r.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...i){n||(n=!0,a("sending ack %j",i),t.packet({type:r.PacketType.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:r.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstructPacket=t.deconstructPacket=void 0;const i=n(9133);function r(e,t){if(!e)return e;if((0,i.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let i=0;i=0&&e.num{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0;const i=n(7285),r=n(4926),o=n(9133),s=(0,n(852).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;function d(e){return"[object Object]"===Object.prototype.toString.call(e)}t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c=t.PacketType||(t.PacketType={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return s("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,o.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),s("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,r.deconstructPacket)(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}};class l extends i.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new u(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,o.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===c[n.type])throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const r=e.substring(i,t);if(r!=Number(r)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(r)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(i,t)}else n.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!l.isPayloadValid(n.type,i))throw new Error("invalid payload");n.data=i}return s("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return d(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||d(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=l;class u{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,r.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},9133:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasBinary=t.isBinary=void 0;const n="function"==typeof ArrayBuffer,i=Object.prototype.toString,r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),o="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);function s(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||r&&e instanceof Blob||o&&e instanceof File}t.isBinary=s,t.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,i=t.length;n{"use strict";n.r(t),n.d(t,{BackgroundBlur:()=>sd,BackgroundProcessor:()=>cd,BackgroundTransformer:()=>rd,ProcessorWrapper:()=>nd,VideoTransformer:()=>id,VirtualBackground:()=>ad});var i="undefined"!=typeof self?self:{};function r(e,t){e:{for(var n=["CLOSURE_FLAGS"],r=i,o=0;ot)i[n++]=t;else{if(2048>t)i[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&r=o){t=1024*(t-55296)+o-56320+65536,i[n++]=t>>18|240,i[n++]=t>>12&63|128,i[n++]=t>>6&63|128,i[n++]=63&t|128;continue}r--}t=65533}i[n++]=t>>12|224,i[n++]=t>>6&63|128}i[n++]=63&t|128}}e=n===i.length?i:i.subarray(0,n)}return e}var p,m=r(610401301,!1),f=r(572417392,!0);const g=i.navigator;function v(e){return!!m&&!!p&&p.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function y(e){var t;return(t=i.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function b(){return!!m&&!!p&&0n;n++){var i=e.concat(t[n].split(""));E[n]=i;for(var r=0;r>2];r=t[(3&r)<<4|o>>4],o=t[(15&o)<<2|s>>6],s=t[63&s],n[d++]=a+r+o+s}switch(a=0,s=i,e.length-c){case 2:s=t[(15&(a=e[c+1]))<<2]||i;case 1:e=e[c],n[d]=t[e>>2]+t[(3&e)<<4|a>>4]+s+i}return n.join("")}for(t="",n=0,i=e.length-10240;n>4),64!=s&&(t(o<<4&240|s>>2),64!=a&&t(s<<6&192|a))}}(e,(function(e){i[r++]=e})),r!==n?i.subarray(0,r):i}(e);R.test(e)&&(e=e.replace(R,x)),e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n ${e}`)}function H(e){return 0==e.length?F():new V(e,N)}function W(e){if("string"==typeof e)return{buffer:I(e),L:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),L:!1};if(e.constructor===Uint8Array)return{buffer:e,L:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),L:!1};if(e.constructor===V)return{buffer:j(e)||D(),L:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),L:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function K(){return"function"==typeof BigInt}var z=!f;let J=!f;const X="function"==typeof Uint8Array.prototype.slice;let Y,Q=0,$=0;function Z(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,i]=ae(n,e);e=i,n=t}Q=n>>>0,$=e>>>0}function ee(e){const t=Y||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),$=0,Q=t.getUint32(0,!0)}function te(e,t){return 4294967296*t+(e>>>0)}function ne(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=te(e,t),n?-e:e}function ie(e,t){if(e>>>=0,2097151>=(t>>>=0))var n=""+(4294967296*t+e);else K()?n=""+(BigInt(t)<>>24|t<<8))+6710656*(t=t>>16&65535),n+=8147497*t,t*=2,1e7<=e&&(n+=Math.floor(e/1e7),e%=1e7),1e7<=n&&(t+=Math.floor(n/1e7),n%=1e7),n=t+re(n)+re(e));return n}function re(e){return e=String(e),"0000000".slice(e.length)+e}function oe(){var e=Q,t=$;if(2147483648&t)if(K())e=""+(BigInt(0|t)<>>0));else{const[n,i]=ae(e,t);e="-"+ie(n,i)}else e=ie(e,t);return e}function se(e){if(16>e.length)Z(Number(e));else if(K())e=BigInt(e),Q=Number(e&BigInt(4294967295))>>>0,$=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);$=Q=0;const n=e.length;for(let i=t,r=(n-t)%6+t;r<=n;i=r,r+=6){const t=Number(e.slice(i,r));$*=1e6,Q=1e6*Q+t,4294967296<=Q&&($+=Math.trunc(Q/4294967296),$>>>=0,Q>>>=0)}if(t){const[e,t]=ae(Q,$);Q=e,$=t}}}function ae(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function ce(e,t){let n,i=0,r=0,o=0;const s=e.h;let a=e.g;do{n=s[a++],i|=(127&n)<o&&128&n);for(32>4),o=3;32>o&&128&n;o+=7)n=s[a++],r|=(127&n)<n)return t(i>>>0,r>>>0);throw G()}function de(e){let t=0,n=e.g;const i=n+10,r=e.h;for(;n>>0}function he(e){var t=e.h;const n=e.g,i=t[n],r=t[n+1],o=t[n+2];return t=t[n+3],ge(e,e.g+4),(i|r<<8|o<<16|t<<24)>>>0}function pe(e){var t=he(e);e=2*(t>>31)+1;const n=t>>>23&255;return t&=8388607,255==n?t?NaN:1/0*e:0==n?e*Math.pow(2,-149)*t:e*Math.pow(2,n-150)*(t+Math.pow(2,23))}function me(e){return le(e)}function fe(e,t,{aa:n=!1}={}){e.aa=n,t&&(t=W(t),e.h=t.buffer,e.m=t.L,e.j=0,e.l=e.h.length,e.g=e.j)}function ge(e,t){if(e.g=t,t>e.l)throw q(e.l,t)}function ve(e,t){if(0>t)throw Error(`Tried to read a negative byte length: ${t}`);const n=e.g,i=n+t;if(i>e.l)throw q(t,e.l-n);return e.g=i,n}function ye(e,t){if(0==t)return F();var n=ve(e,t);return e.aa&&e.m?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?D():X?e.slice(n,t):new Uint8Array(e.subarray(n,t))),H(n)}var be=[];function ke(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var n=ue(e.g);if(t=n>>>3,!(0<=(n&=7)&&5>=n))throw B(n,e.l);if(1>t)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=n,!0}function Te(e){switch(e.h){case 0:0!=e.h?Te(e):de(e.g);break;case 1:ge(e=e.g,e.g+8);break;case 2:if(2!=e.h)Te(e);else{var t=ue(e.g);ge(e=e.g,e.g+t)}break;case 5:ge(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!ke(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}Te(e)}break;default:throw B(e.h,e.l)}}function Ee(e,t,n){const i=e.g.l,r=ue(e.g),o=e.g.g+r;let s=o-i;if(0>=s&&(e.g.l=o,n(t,e,void 0,void 0,void 0),s=o-e.g.g),s)throw Error(`Message parsing ended unexpectedly. Expected to read ${r} bytes, instead read ${r-s} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=o,e.g.l=i,t}function Se(e){var t=ue(e.g),n=ve(e=e.g,t);if(e=e.h,d){var i,r=e;(i=c)||(i=c=new TextDecoder("utf-8",{fatal:!0})),t=n+t,r=0===n&&t===r.length?r:r.subarray(n,t);try{var l=i.decode(r)}catch(e){if(void 0===a){try{i.decode(new Uint8Array([128]))}catch(e){}try{i.decode(new Uint8Array([97])),a=!0}catch(e){a=!1}}throw!a&&(c=void 0),e}}else{t=(l=n)+t,n=[];let a,c=null;for(;lu?n.push(u):224>u?l>=t?o():(a=e[l++],194>u||128!=(192&a)?(l--,o()):n.push((31&u)<<6|63&a)):240>u?l>=t-1?o():(a=e[l++],128!=(192&a)||224===u&&160>a||237===u&&160<=a||128!=(192&(i=e[l++]))?(l--,o()):n.push((15&u)<<12|(63&a)<<6|63&i)):244>=u?l>=t-2?o():(a=e[l++],128!=(192&a)||a-144+(u<<28)>>30||128!=(192&(i=e[l++]))||128!=(192&(r=e[l++]))?(l--,o()):(u=(7&u)<<18|(63&a)<<12|(63&i)<<6|63&r,u-=65536,n.push(55296+(u>>10&1023),56320+(1023&u)))):o(),8192<=n.length&&(c=s(c,n),n.length=0)}l=s(c,n)}return l}function Ce(e){const t=ue(e.g);return ye(e.g,t)}function we(e,t,n){var i=ue(e.g);for(i=e.g.g+i;e.g.g>>0,this.g=t>>>0}};let Oe;function xe(e){return e?/^-?\d+$/.test(e)?(se(e),new Ie(Q,$)):null:Ae||=new Ie(0,0)}var Ie=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Ae;function Me(e,t,n){for(;0>>7|n<<25)>>>0,n>>>=7;e.g.push(t)}function De(e,t){for(;127>>=7;e.g.push(t)}function Ne(e,t){if(0<=t)De(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function Le(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function Ue(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function Fe(e,t,n){De(e.g,8*t+n)}function je(e,t){return Fe(e,t,2),t=e.g.end(),Ue(e,t),t.push(e.h),t}function Ve(e,t){var n=t.pop();for(n=e.h+e.g.length()-n;127>>=7,e.h++;t.push(n),e.h++}function Be(e,t,n){Fe(e,t,2),De(e.g,n.length),Ue(e,e.g.end()),Ue(e,n)}function Ge(e,t,n,i){null!=n&&(t=je(e,t),i(n,e),Ve(e,t))}class qe{constructor(e,t,n,i){this.g=e,this.h=t,this.l=n,this.qa=i}}function He(e){return Array.prototype.slice.call(e)}function We(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():e}var Ke=We(),ze=We("0di"),Je=Ke?(e,t)=>{e[Ke]|=t}:(e,t)=>{void 0!==e.D?e.D|=t:Object.defineProperties(e,{D:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function Xe(e){const t=$e(e);1&~t&&(Object.isFrozen(e)&&(e=He(e)),et(e,1|t))}var Ye=Ke?(e,t)=>{e[Ke]&=~t}:(e,t)=>{void 0!==e.D&&(e.D&=~t)};function Qe(e,t,n){return n?e|t:e&~t}var $e=Ke?e=>0|e[Ke]:e=>0|e.D,Ze=Ke?e=>e[Ke]:e=>e.D,et=Ke?(e,t)=>{e[Ke]=t}:(e,t)=>{void 0!==e.D?e.D=t:Object.defineProperties(e,{D:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function tt(){var e=[];return Je(e,1),e}function nt(e){return Je(e,34),e}function it(e,t){et(t,-14591&e)}function rt(e,t){et(t,-14557&e|34)}function ot(e){return 0==(e=e>>14&1023)?536870912:e}var st={},at={};function ct(e){return!(!e||"object"!=typeof e||e.Na!==at)}function dt(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}let lt=!f;function ut(e,t,n){if(null!=e)if("string"==typeof e)e=e?new V(e,N):F();else if(e.constructor!==V)if(A(e))e=n?H(e):e.length?new V(new Uint8Array(e),N):F();else{if(!t)throw Error();e=void 0}return e}function ht(e,t,n){if(!Array.isArray(e)||e.length)return!1;const i=$e(e);return!!(1&i)||!(!t||!(Array.isArray(t)?t.includes(n):t.has(n)))&&(et(e,1|i),!0)}var pt;const mt=[];function ft(e){if(2&e)throw Error()}et(mt,55),pt=Object.freeze(mt);class gt{constructor(e,t,n){this.l=0,this.g=e,this.h=t,this.m=n}next(){if(this.l>>0:void 0}function Rt(e){return"-"!==e[0]&&(20>e.length||20===e.length&&184467>Number(e.substring(0,6)))}function Ot(e){return"-"===e[0]?20>e.length||20===e.length&&-922337e.length||19===e.length&&922337>Number(e.substring(0,6))}function xt(e){return e=Math.trunc(e),Number.isSafeInteger(e)||(Z(e),e=ne(Q,$)),e}function It(e){var t=Math.trunc(Number(e));return Number.isSafeInteger(t)?String(t):(-1!==(t=e.indexOf("."))&&(e=e.substring(0,t)),Ot(e)||(se(e),e=oe()),e)}function At(e){return null==e?e:wt(e)?"number"==typeof e?xt(e):It(e):void 0}function Mt(e){if("string"!=typeof e)throw Error();return e}function Dt(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function Nt(e){return null==e||"string"==typeof e?e:void 0}function Lt(e,t,n,i){if(null!=e&&"object"==typeof e&&e.W===st)return e;if(!Array.isArray(e))return n?2&i?(e=t[ze])?t=e:(nt((e=new t).s),t=t[ze]=e):t=new t:t=void 0,t;let r=n=$e(e);return 0===r&&(r|=32&i),r|=2&i,r!==n&&et(e,r),new t(e)}function Ut(e,t,n){if(t){var i=!!i;if(!wt(t=e))throw Tt("int64");"string"==typeof t?i=It(t):i?(i=Math.trunc(t),Number.isSafeInteger(i)?i=String(i):Ot(t=String(i))?i=t:(Z(i),i=oe())):i=xt(t)}else i=At(e);return"string"==typeof(n=null==(e=i)?n?0:void 0:e)&&(i=+n,Number.isSafeInteger(i))?i:n}let Ft,jt,Vt;function Bt(e){switch(typeof e){case"boolean":return jt||=[0,void 0,!0];case"number":return 0{e.call(t,this.get(i),i,this)}))}set(e,t){return Jt(this),null==(e=this.R(e,!0,!1))?this:null==t?(super.delete(e),this):super.set(e,this.Y(t,!0,!0,this.V,!1,this.O))}Ta(e){const t=this.R(e[0],!1,!0);e=e[1],e=this.V?void 0===e?null:e:this.Y(e,!1,!0,void 0,!1,this.O),super.set(t,e)}has(e){return super.has(this.R(e,!1,!1))}get(e){e=this.R(e,!1,!1);const t=super.get(e);if(void 0!==t){var n=this.V;return n?((n=this.Y(t,!1,!0,n,this.xa,this.O))!==t&&super.set(e,n),n):t}}ma(){return Array.from(super.keys())}Ma(){return super.keys()}[Symbol.iterator](){return this.entries()}};function Yt(e,t,n,i,r,o){return e=Lt(e,i,n,o),r&&(e=an(e)),e}function Qt(e){return e}function $t(e){return[e,this.get(e)]}function Zt(e,t,n,i,r,o){if(null!=e){if(Array.isArray(e))e=r&&0==e.length&&1&$e(e)?void 0:o&&2&$e(e)?e:en(e,t,n,void 0!==i,r,o);else if(dt(e)){const s={};for(let a in e)s[a]=Zt(e[a],t,n,i,r,o);e=s}else e=t(e,i);return e}}function en(e,t,n,i,r,o){const s=i||n?$e(e):0;i=i?!!(32&s):void 0;const a=He(e);for(let e=0;ern(e,r,i))),Je(e,32|(n?2:0)),e}function an(e){const t=e.s,n=Ze(t);return 2&n?on(e,t,n,!1):e}function cn(e,t){return dn(e=e.s,Ze(e),t)}function dn(e,t,n,i){if(-1===n)return null;if(n>=ot(t)){if(256&t)return e[e.length-1][n]}else{var r=e.length;if(i&&256&t&&null!=(i=e[r-1][n]))return i;if((t=n+(+!!(512&t)-1))=o||r){if(r=t,256&t)o=e[e.length-1];else{if(null==i)return r;o=e[o+(+!!(512&t)-1)]={},r|=256}return o[n]=i,r!==t&&et(e,r),r}return e[n+(+!!(512&t)-1)]=i,256&t&&n in(e=e[e.length-1])&&delete e[n],t}function hn(e,t,n,i,r){var o=2&t;let s=dn(e,t,n,r);Array.isArray(s)||(s=pt);const a=!(2&i);i=!(1&i);const c=!!(32&t);let d=$e(s);return 0!==d||!c||o||a?1&d||(d|=1,et(s,d)):(d|=33,et(s,d)),o?(e=!1,2&d||(nt(s),e=!!(4&d)),(i||e)&&Object.freeze(s)):(o=!!(2&d)||!!(2048&d),i&&o?(s=He(s),i=1,c&&!a&&(i|=32),et(s,i),un(e,t,n,s,r)):a&&32&d&&!o&&Ye(s,32)),s}function pn(e,t){e=e.s;let n=Ze(e);const i=dn(e,n,t),r=Et(i);return null!=r&&r!==i&&un(e,n,t,r),r}function mn(e){e=e.s;let t=Ze(e);const n=dn(e,t,1),i=ut(n,!0,!!(34&t));return null!=i&&i!==n&&un(e,t,1,i),i}function fn(e,t,n){e=e.s;let i=Ze(e);const r=2&i?1:2;let o=gn(e,i,t);var s=$e(o);if(!(4&s)){(4&s||Object.isFrozen(o))&&(o=He(o),s=Dn(s,i,!1),i=un(e,i,t,o));var a=0;let r=0;for(;a=o){Object.assign(t[t.length-1]={},a);break}s=!0}var c;o=t,n=!n,e=ot(a=Ze(e.s)),a=+!!(512&a)-1;for(let t=0;tr(e,t,i):(e,t)=>{for(;ke(t)&&4!=t.h;){var r=t.m,o=i[r];if(!o){var s=i.ha;s&&(s=s[r])&&(o=i[r]=Yn(s))}o&&o(t,e,r)||(r=(o=t).l,Te(o),o.ga?o=void 0:(s=o.g.g-r,o.g.g=r,o=ye(o.g,s)),r=e,o&&(yt||=Symbol(),(s=r[yt])?s.push(o):r[yt]=[o]))}n===Qn||n===$n||n.Oa||(e[bt||=Symbol()]=n)},e[Jn]=t}return t}function Yn(e){const t=(e=Kn(e))[0].g;if(e=e[1]){const n=Xn(e),i=mi(e).S;return(e,r,o)=>t(e,r,o,i,n)}return t}let Qn,$n;const Zn=Symbol();function ei(e,t,n){const i=n[1];let r;if(i){const n=i[Zn];r=n?n.S:Bt(i[0]),e[t]=n??i}r&&r===jt?(e.na||(e.na=[])).push(t):n[0]&&(e.oa||(e.oa=[])).push(t)}function ti(e,t){return[e.l,!t||0s&&(l-=s,s=e[++o]);cgi(e,t,n),e[oi]=t}return t}const ai=Symbol();function ci(e){return e.h}function di(e,t){let n,i;const r=e.h;return(e,o,s)=>r(e,o,s,i||=li(t).S,n||=si(t))}function li(e){let t=e[ai];return t||(t=ri(e,e[ai]={},ci,di),ui in e&&ai in e&&(e.length=0),t)}const ui=Symbol();function hi(e,t){const n=e.g;return t?(e,i,r)=>n(e,i,r,t):n}function pi(e,t,n){const i=e.g;let r,o;return(e,s,a)=>i(e,s,a,o||=mi(t).S,r||=Xn(t),n)}function mi(e){let t=e[ui];return t||(ni(e),t=ri(e,e[ui]={},hi,pi),ui in e&&ai in e&&(e.length=0),t)}function fi(e,t){var n=e[t];if(n)return n;if((n=e.ha)&&(n=n[t])){var i=(n=Kn(n))[0].h;if(n=n[1]){const t=si(n),r=li(n).S;n=(n=e.h)?n(r,t):(e,n,o)=>i(e,n,o,r,t)}else n=i;return e[t]=n}}function gi(e,t,n){for(var i=Ze(e),r=+!!(512&i)-1,o=e.length,s=512&i?1:0,a=o+(256&i?-1:0);s{Ge(e,n,Gt([o,t],i),r)}));else if(Array.isArray(t))for(let o=0;o>31)+1;const o=r>>>20&2047;return e=4294967296*(1048575&r)+e,ki(t,n,2047==o?e?NaN:1/0*i:0==o?i*Math.pow(2,-1074)*e:i*Math.pow(2,o-1075)*(e+4503599627370496)),!0}),(function(e,t,n){null!=(t=Et(t))&&(Fe(e,n,1),e=e.g,(n=Y||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),Q=n.getUint32(0,!0),$=n.getUint32(4,!0),Le(e,Q),Le(e,$))})),Ii=vi((function(e,t,n){return 5===e.h&&(ki(t,n,pe(e.g)),!0)}),(function(e,t,n){null!=(t=Et(t))&&(Fe(e,n,5),e=e.g,ee(t),Le(e,Q))})),Ai=yi(Ri,(function(e,t,n){if(null!=(t=zn(Et,t)))for(let s=0;se){Z(e);const t=ie(Q,$);return e=Number(t),Number.isSafeInteger(e)?e:t}return Rt(String(e))?e:(Z(e),te(Q,$))}(t);break e}}t=void 0}null!=t&&("string"==typeof t&&_e(t),null!=t&&(Fe(e,n,0),"number"==typeof t?(e=e.g,Z(t),Me(e,Q,$)):(n=_e(t),Me(e.g,n.h,n.g))))})),Ui=vi((function(e,t,n){return 0===e.h&&(ki(t,n,le(e.g)),!0)}),Si),Fi=yi((function(e,t,n){return(0===e.h||2===e.h)&&(t=hn(t,Ze(t),n,2,!1),2==e.h?we(e,le,t):t.push(le(e.g)),!0)}),(function(e,t,n){if(null!=(t=zn(Pt,t))&&t.length){n=je(e,n);for(let n=0;n{e:{if(Pe.length){const e=Pe.pop();e.o(i),fe(e.g,n,i),n=e}else n=new class{constructor(e,t){if(be.length){const n=be.pop();fe(n,e,t),e=n}else e=new class{constructor(e,t){this.h=null,this.m=!1,this.g=this.l=this.j=0,fe(this,e,t)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.aa=!1}}(e,t);this.g=e,this.l=this.g.g,this.h=this.m=-1,this.o(t)}o({ga:e=!1}={}){this.ga=e}}(n,i);try{const i=new e,o=i.s;Xn(t)(o,n),bt&&delete o[bt];var r=i;break e}finally{n.g.clear(),n.m=-1,n.h=-1,100>Pe.length&&Pe.push(n)}r=void 0}return r}}function tr(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const e=this.g;return this.g=[],e}}}};gi(this.s,t,li(e)),Ue(t,t.g.end());const n=new Uint8Array(t.h),i=t.l,r=i.length;let o=0;for(let e=0;e({index:Fn(Ln(e,1))??-1,score:jn(e,2)??0,categoryName:Un(e,3)??""??"",displayName:Un(e,4)??""??""}))),headIndex:t,headName:n}}function _s(e){var t=fn(e,3,Et),n=fn(e,2,Pt),i=fn(e,1,Nt),r=fn(e,9,Nt);const o={categories:[],keypoints:[]};for(let e=0;e127=i||0>=r)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(i*r)}let As;pr[516587230]=Ss;const Ms=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Ds(){if(void 0===As)try{await WebAssembly.instantiate(Ms),As=!0}catch{As=!1}return As}async function Ns(e,t=""){const n=await Ds()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}}var Ls=class{};function Us(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function Fs(e){if("function"!=typeof importScripts){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((e,n)=>{t.addEventListener("load",(()=>{e()}),!1),t.addEventListener("error",(e=>{n(e)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function js(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function Vs(e,t,n){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(n?e.i._bindTextureToStream(n):e.i._bindTextureToCanvas(),!(n=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");return e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),t.videoWidth?(n=t.videoWidth,t=t.videoHeight):t.naturalWidth?(n=t.naturalWidth,t=t.naturalHeight):(n=t.width,t=t.height),!e.l||n===e.i.canvas.width&&t===e.i.canvas.height||(e.i.canvas.width=n,e.i.canvas.height=t),[n,t]}function Bs(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let n=0;n>2),n(t);for(const t of i)e.i._free(t);e.i._free(t)}function Gs(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function qs(e,t,n){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,r)=>{t?(n(i,r),i=[]):i.push(e)}}function Hs(e,t){const n=On(e.baseOptions,_o,1)||new _o;"string"==typeof t?(ln(n,2,Dt(t)),ln(n,1)):t instanceof Uint8Array&&(ln(n,1,ut(t,!1,!1)),ln(n,2)),An(e.baseOptions,0,1,n)}function Ws(e){try{const t=e.F.length;if(1===t)throw Error(e.F[0].message);if(1e.message)).join(", "))}finally{e.F=[]}}function Ks(e,t){e.I=Math.max(e.I,t)}function zs(e,t){e.C=new Sr,kr(e.C,"PassThroughCalculator"),Tr(e.C,"free_memory"),Er(e.C,"free_memory_unused_out"),xr(t,"free_memory"),Or(t,e.C)}function Js(e,t){Tr(e.C,t),Er(e.C,t+"_unused_out")}function Xs(e){e.g.addBoolToStream(!0,"free_memory",e.I)}Ls.forVisionTasks=function(e){return Ns("vision",e)},Ls.forTextTasks=function(e){return Ns("text",e)},Ls.forAudioTasks=function(e){return Ns("audio",e)},Ls.isSimdSupported=function(){return Ds()};var Ys=class{constructor(e){this.g=e,this.F=[],this.I=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){if(t){const t=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(On(this.baseOptions,_o,1)?.g()||On(this.baseOptions,_o,1)?.h()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(e,t){let n=On(e.baseOptions,wo,3);if(!n){var i=n=new wo,r=new dr;Mn(i,4,Po,r)}"delegate"in t&&("GPU"===t.delegate?(t=n,i=new sr,Mn(t,2,Po,i)):(t=n,i=new dr,Mn(t,4,Po,i))),An(e.baseOptions,0,3,n)}(this,t),t.modelAssetPath)return fetch(t.modelAssetPath.toString()).then((e=>{if(e.ok)return e.arrayBuffer();throw Error(`Failed to fetch model: ${t.modelAssetPath} (${e.status})`)})).then((e=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(e),!0,!1,!1),Hs(this,"/model.dat"),this.m(),this.N()}));Hs(this,t.modelAssetBuffer)}return this.m(),this.N(),Promise.resolve()}N(){}da(){let e;if(this.g.da((t=>{e=Dr(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((e,t)=>{this.F.push(Error(t))})),this.g.Ra(),this.g.setGraph(e,t),this.C=void 0,Ws(this)}finishProcessing(){this.g.finishProcessing(),Ws(this)}close(){this.C=void 0,this.g.closeGraph()}};function Qs(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Ys.prototype.close=Ys.prototype.close;class $s{constructor(e,t,n,i){this.g=e,this.h=t,this.m=n,this.l=i}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Zs(e,t,n){const i=e.g;if(n=Qs(i.createShader(n),"Failed to create WebGL shader"),i.shaderSource(n,t),i.compileShader(n),!i.getShaderParameter(n,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(n)}`);return i.attachShader(e.h,n),n}function ea(e,t){const n=e.g,i=Qs(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(i);const r=Qs(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,r),n.enableVertexAttribArray(e.N),n.vertexAttribPointer(e.N,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const o=Qs(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,o),n.enableVertexAttribArray(e.M),n.vertexAttribPointer(e.M,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new $s(n,i,r,o)}function ta(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function na(e,t,n,i){return ta(e,t),e.h||(e.m(),e.F()),n?(e.u||(e.u=ea(e,!0)),n=e.u):(e.v||(e.v=ea(e,!1)),n=e.v),t.useProgram(e.h),n.bind(),e.l(),e=i(),n.g.bindVertexArray(null),e}function ia(e,t,n){return ta(e,t),e=Qs(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),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,n??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function ra(e,t,n){ta(e,t),e.C||(e.C=Qs(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.C),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}function oa(e){e.g?.bindFramebuffer(e.g.FRAMEBUFFER,null)}var sa=class{I(){return"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D inputTexture;\n void main() {\n gl_FragColor = texture2D(inputTexture, vTex);\n }\n "}m(){const e=this.g;if(this.h=Qs(e.createProgram(),"Failed to create WebGL program"),this.ta=Zs(this,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",e.VERTEX_SHADER),this.sa=Zs(this,this.I(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.N=e.getAttribLocation(this.h,"aVertex"),this.M=e.getAttribLocation(this.h,"aTex")}F(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.ta),e.deleteShader(this.sa)}this.C&&this.g.deleteFramebuffer(this.C),this.v&&this.v.close(),this.u&&this.u.close()}},aa=class extends sa{I(){return"\n precision mediump float;\n uniform sampler2D backgroundTexture;\n uniform sampler2D maskTexture;\n uniform sampler2D colorMappingTexture;\n varying vec2 vTex;\n void main() {\n vec4 backgroundColor = texture2D(backgroundTexture, vTex);\n float category = texture2D(maskTexture, vTex).r;\n vec4 categoryColor = texture2D(colorMappingTexture, vec2(category, 0.0));\n gl_FragColor = mix(backgroundColor, categoryColor, categoryColor.a);\n }\n "}F(){const e=this.g;e.activeTexture(e.TEXTURE1),this.B=ia(this,e,e.LINEAR),e.activeTexture(e.TEXTURE2),this.j=ia(this,e,e.NEAREST)}m(){super.m();const e=this.g;this.U=Qs(e.getUniformLocation(this.h,"backgroundTexture"),"Uniform location"),this.ra=Qs(e.getUniformLocation(this.h,"colorMappingTexture"),"Uniform location"),this.T=Qs(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();const e=this.g;e.uniform1i(this.T,0),e.uniform1i(this.U,1),e.uniform1i(this.ra,2)}close(){this.B&&this.g.deleteTexture(this.B),this.j&&this.g.deleteTexture(this.j),super.close()}},ca=class extends sa{I(){return"\n precision mediump float;\n uniform sampler2D maskTexture;\n uniform sampler2D defaultTexture;\n uniform sampler2D overlayTexture;\n varying vec2 vTex;\n void main() {\n float confidence = texture2D(maskTexture, vTex).r;\n vec4 defaultColor = texture2D(defaultTexture, vTex);\n vec4 overlayColor = texture2D(overlayTexture, vTex);\n // Apply the alpha from the overlay and merge in the default color\n overlayColor = mix(defaultColor, overlayColor, overlayColor.a);\n gl_FragColor = mix(defaultColor, overlayColor, confidence);\n }\n "}F(){const e=this.g;e.activeTexture(e.TEXTURE1),this.j=ia(this,e),e.activeTexture(e.TEXTURE2),this.B=ia(this,e)}m(){super.m();const e=this.g;this.T=Qs(e.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.U=Qs(e.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.J=Qs(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();const e=this.g;e.uniform1i(this.J,0),e.uniform1i(this.T,1),e.uniform1i(this.U,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function da(e,t){switch(t){case 0:return e.g.find((e=>e instanceof Uint8Array));case 1:return e.g.find((e=>e instanceof Float32Array));case 2:return e.g.find((e=>"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function la(e){var t=da(e,1);if(!t){if(t=da(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const i=ha(e);var n=ma(e);if(ra(n,i,ua(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in self.document){n=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,n);for(let e=0,i=0;e255*e))),this.g.push(e)),e;var e}ia(){return la(this)}K(){return ua(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof Uint8Array)n=new Uint8Array(t);else if(t instanceof Float32Array)n=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const e=ha(this),t=ma(this);e.activeTexture(e.TEXTURE1),n=ia(t,e,this.m?e.LINEAR:e.NEAREST),e.bindTexture(e.TEXTURE_2D,n);const i=pa(this);e.texImage2D(e.TEXTURE_2D,0,i,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),ra(t,e,n),na(t,e,!1,(()=>{fa(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),ga(this)})),oa(t),ga(this)}}e.push(n)}return new ya(e,this.m,this.P(),this.canvas,this.l,this.width,this.height)}close(){this.j&&ha(this).deleteTexture(da(this,2)),ba=-1}};ya.prototype.close=ya.prototype.close,ya.prototype.clone=ya.prototype.clone,ya.prototype.getAsWebGLTexture=ya.prototype.K,ya.prototype.getAsFloat32Array=ya.prototype.ia,ya.prototype.getAsUint8Array=ya.prototype.ja,ya.prototype.hasWebGLTexture=ya.prototype.P,ya.prototype.hasFloat32Array=ya.prototype.ka,ya.prototype.hasUint8Array=ya.prototype.La;var ba=250;const ka={color:"white",lineWidth:4,radius:6};function Ta(e){return{...ka,fillColor:(e=e||{}).color,...e}}function Ea(e,t){return e instanceof Function?e(t):e}function Sa(e,t,n){return Math.max(Math.min(t,n),Math.min(Math.max(t,n),e))}function Ca(e){if(!e.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return e.l}function wa(e){if(!e.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return e.j}function Pa(e,t,n){if(t.P())n(t.K());else{const i=t.ka()?t.ia():t.ja();e.m=e.m??new sa;const r=wa(e);n((e=new ya([i],t.m,!1,r.canvas,e.m,t.width,t.height)).K()),e.close()}}function _a(e,t,n,i){const r=function(e){return e.g||(e.g=new aa),e.g}(e),o=wa(e),s=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;na(r,o,!0,(()=>{!function(e,t,n,i){const r=e.g;if(r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,t),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,e.B),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),e.J&&function(e,t){if(e!==t)return!1;e=e.entries(),t=t.entries();for(const[i,r]of e){e=i;const o=r;var n=t.next();if(n.done)return!1;const[s,a]=n.value;if(n=a,e!==s||o[0]!==n[0]||o[1]!==n[1]||o[2]!==n[2]||o[3]!==n[3])return!1}return!!t.next().done}(e.J,i))r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,e.j);else{e.J=i;const t=Array(1024).fill(0);i.forEach(((e,n)=>{if(4!==e.length)throw Error(`Color at index ${n} is not a four-channel value.`);t[4*n]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]})),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,e.j),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,256,1,0,r.RGBA,r.UNSIGNED_BYTE,new Uint8Array(t))}}(r,t,s,i),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_FAN,0,4);const e=r.g;e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,null)}))}function Ra(e,t,n,i){const r=wa(e),o=function(e){return e.h||(e.h=new ca),e.h}(e),s=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n,a=Array.isArray(i)?new ImageData(new Uint8ClampedArray(i),1,1):i;na(o,r,!0,(()=>{var e=o.g;e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,o.j),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,s),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,o.B),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.drawArrays(r.TRIANGLE_FAN,0,4),r.bindTexture(r.TEXTURE_2D,null),(e=o.g).activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,null)}))}var Oa=class{constructor(e,t){e instanceof CanvasRenderingContext2D||e instanceof OffscreenCanvasRenderingContext2D?(this.l=e,this.j=t):this.j=e}Ea(e,t){if(e){var n=Ca(this);t=Ta(t),n.save();var i=n.canvas,r=0;for(const o of e)n.fillStyle=Ea(t.fillColor,{index:r,from:o}),n.strokeStyle=Ea(t.color,{index:r,from:o}),n.lineWidth=Ea(t.lineWidth,{index:r,from:o}),(e=new Path2D).arc(o.x*i.width,o.y*i.height,Ea(t.radius,{index:r,from:o}),0,2*Math.PI),n.fill(e),n.stroke(e),++r;n.restore()}}Da(e,t,n){if(e&&t){var i=Ca(this);n=Ta(n),i.save();var r=i.canvas,o=0;for(const s of t){i.beginPath(),t=e[s.start];const a=e[s.end];t&&a&&(i.strokeStyle=Ea(n.color,{index:o,from:t,to:a}),i.lineWidth=Ea(n.lineWidth,{index:o,from:t,to:a}),i.moveTo(t.x*r.width,t.y*r.height),i.lineTo(a.x*r.width,a.y*r.height)),++o,i.stroke()}i.restore()}}Aa(e,t){const n=Ca(this);t=Ta(t),n.save(),n.beginPath(),n.lineWidth=Ea(t.lineWidth,{}),n.strokeStyle=Ea(t.color,{}),n.fillStyle=Ea(t.fillColor,{}),n.moveTo(e.originX,e.originY),n.lineTo(e.originX+e.width,e.originY),n.lineTo(e.originX+e.width,e.originY+e.height),n.lineTo(e.originX,e.originY+e.height),n.lineTo(e.originX,e.originY),n.stroke(),n.fill(),n.restore()}Ba(e,t,n=[0,0,0,255]){this.l?function(e,t,n,i){const r=wa(e);Pa(e,t,(t=>{_a(e,t,n,i),(t=Ca(e)).drawImage(r.canvas,0,0,t.canvas.width,t.canvas.height)}))}(this,e,n,t):_a(this,e.K(),n,t)}Ca(e,t,n){this.l?function(e,t,n,i){const r=wa(e);Pa(e,t,(t=>{Ra(e,t,n,i),(t=Ca(e)).drawImage(r.canvas,0,0,t.canvas.width,t.canvas.height)}))}(this,e,t,n):Ra(this,e.K(),t,n)}close(){this.g?.close(),this.g=void 0,this.h?.close(),this.h=void 0,this.m?.close(),this.m=void 0}};function xa(e,t){switch(t){case 0:return e.g.find((e=>e instanceof ImageData));case 1:return e.g.find((e=>"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap));case 2:return e.g.find((e=>"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function Ia(e){var t=xa(e,0);if(!t){t=Ma(e);const n=Da(e),i=new Uint8Array(e.width*e.height*4);ra(n,t,Aa(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,i),oa(n),t=new ImageData(new Uint8ClampedArray(i.buffer),e.width,e.height),e.g.push(t)}return t}function Aa(e){let t=xa(e,2);if(!t){const n=Ma(e);t=Na(e);const i=xa(e,1)||Ia(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,i),La(e)}return t}function Ma(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return e.h||(e.h=Qs(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Da(e){return e.l||(e.l=new sa),e.l}function Na(e){const t=Ma(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=xa(e,2);return n||(n=ia(Da(e),t),e.g.push(n),e.m=!0),t.bindTexture(t.TEXTURE_2D,n),n}function La(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Ua(e){const t=Ma(e);return na(Da(e),t,!0,(()=>function(e,t){const n=e.canvas;if(n.width===e.width&&n.height===e.height)return t();const i=n.width,r=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=i,n.height=r,e}(e,(()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))))}Oa.prototype.close=Oa.prototype.close,Oa.prototype.drawConfidenceMask=Oa.prototype.Ca,Oa.prototype.drawCategoryMask=Oa.prototype.Ba,Oa.prototype.drawBoundingBox=Oa.prototype.Aa,Oa.prototype.drawConnectors=Oa.prototype.Da,Oa.prototype.drawLandmarks=Oa.prototype.Ea,Oa.lerp=function(e,t,n,i,r){return Sa(i*(1-(e-t)/(n-t))+r*(1-(n-e)/(n-t)),i,r)},Oa.clamp=Sa;var Fa=class{constructor(e,t,n,i,r,o,s){this.g=e,this.j=t,this.m=n,this.canvas=i,this.l=r,this.width=o,this.height=s,(this.j||this.m)&&0==--ja&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Ka(){return!!xa(this,0)}la(){return!!xa(this,1)}P(){return!!xa(this,2)}Ia(){return Ia(this)}Ha(){var e=xa(this,1);return e||(Aa(this),Na(this),e=Ua(this),La(this),this.g.push(e),this.j=!0),e}K(){return Aa(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof ImageData)n=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){const e=Ma(this),t=Da(this);e.activeTexture(e.TEXTURE1),n=ia(t,e),e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindTexture(e.TEXTURE_2D,null),ra(t,e,n),na(t,e,!1,(()=>{Na(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),La(this)})),oa(t),La(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);Aa(this),Na(this),n=Ua(this),La(this)}e.push(n)}return new Fa(e,this.la(),this.P(),this.canvas,this.l,this.width,this.height)}close(){this.j&&xa(this,1).close(),this.m&&Ma(this).deleteTexture(xa(this,2)),ja=-1}};Fa.prototype.close=Fa.prototype.close,Fa.prototype.clone=Fa.prototype.clone,Fa.prototype.getAsWebGLTexture=Fa.prototype.K,Fa.prototype.getAsImageBitmap=Fa.prototype.Ha,Fa.prototype.getAsImageData=Fa.prototype.Ia,Fa.prototype.hasWebGLTexture=Fa.prototype.P,Fa.prototype.hasImageBitmap=Fa.prototype.la,Fa.prototype.hasImageData=Fa.prototype.Ka;var ja=250;function Va(...e){return e.map((([e,t])=>({start:e,end:t})))}const Ba=function(e){return class extends e{Ra(){this.i._registerModelResourcesGraphService()}}}((Ga=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m="function"==typeof this.i._addIntToInputStream,void 0!==t?this.i.canvas=t:"undefined"==typeof OffscreenCanvas||Us()?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas")):this.i.canvas=new OffscreenCanvas(1,1)}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph((new TextEncoder).encode(e),!1)}setGraph(e,t){const n=e.length,i=this.i._malloc(n);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(n,i):this.i._changeTextGraph(n,i),this.i._free(i)}configureAudio(e,t,n,i,r){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),js(this,i||"input_audio",(i=>{js(this,r=r||"audio_header",(r=>{this.i._configureAudio(i,r,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}da(e){Gs(this,"__graph_config__",(t=>{e(t)})),js(this,"__graph_config__",(e=>{this.i._getGraphConfig(e,void 0)})),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,n){this.addAudioToStreamWithShape(e,0,0,t,n)}addAudioToStreamWithShape(e,t,n,i,r){const o=4*e.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(e,this.g/4),js(this,i,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,r)}))}addGpuBufferToStream(e,t,n){js(this,t,(t=>{const[i,r]=Vs(this,e,t);this.i._addBoundTextureToStream(t,i,r,n)}))}addBoolToStream(e,t,n){js(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){js(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){js(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){js(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){js(this,t,(t=>{js(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){js(this,t,(t=>{Bs(this,Object.keys(e),(i=>{Bs(this,Object.values(e),(r=>{this.i._addFlatHashMapToInputStream(i,r,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,i){js(this,n,(n=>{js(this,t,(t=>{const r=this.i._malloc(e.length);this.i.HEAPU8.set(e,r),this.i._addProtoToInputStream(r,e.length,t,n,i),this.i._free(r)}))}))}addEmptyPacketToStream(e,t){js(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolVectorToStream(e,t,n){js(this,t,(t=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const t of e)this.i._addBoolVectorEntry(i,t);this.i._addBoolVectorToInputStream(i,t,n)}))}addDoubleVectorToStream(e,t,n){js(this,t,(t=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const t of e)this.i._addDoubleVectorEntry(i,t);this.i._addDoubleVectorToInputStream(i,t,n)}))}addFloatVectorToStream(e,t,n){js(this,t,(t=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const t of e)this.i._addFloatVectorEntry(i,t);this.i._addFloatVectorToInputStream(i,t,n)}))}addIntVectorToStream(e,t,n){js(this,t,(t=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const t of e)this.i._addIntVectorEntry(i,t);this.i._addIntVectorToInputStream(i,t,n)}))}addStringVectorToStream(e,t,n){js(this,t,(t=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const t of e)js(this,t,(e=>{this.i._addStringVectorEntry(i,e)}));this.i._addStringVectorToInputStream(i,t,n)}))}addBoolToInputSidePacket(e,t){js(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){js(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){js(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){js(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){js(this,t,(t=>{js(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){js(this,n,(n=>{js(this,t,(t=>{const i=this.i._malloc(e.length);this.i.HEAPU8.set(e,i),this.i._addProtoToInputSidePacket(i,e.length,t,n),this.i._free(i)}))}))}addBoolVectorToInputSidePacket(e,t){js(this,t,(t=>{const n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const t of e)this.i._addBoolVectorEntry(n,t);this.i._addBoolVectorToInputSidePacket(n,t)}))}addDoubleVectorToInputSidePacket(e,t){js(this,t,(t=>{const n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const t of e)this.i._addDoubleVectorEntry(n,t);this.i._addDoubleVectorToInputSidePacket(n,t)}))}addFloatVectorToInputSidePacket(e,t){js(this,t,(t=>{const n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const t of e)this.i._addFloatVectorEntry(n,t);this.i._addFloatVectorToInputSidePacket(n,t)}))}addIntVectorToInputSidePacket(e,t){js(this,t,(t=>{const n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const t of e)this.i._addIntVectorEntry(n,t);this.i._addIntVectorToInputSidePacket(n,t)}))}addStringVectorToInputSidePacket(e,t){js(this,t,(t=>{const n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const t of e)js(this,t,(e=>{this.i._addStringVectorEntry(n,e)}));this.i._addStringVectorToInputSidePacket(n,t)}))}attachBoolListener(e,t){Gs(this,e,t),js(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){qs(this,e,t),js(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){Gs(this,e,t),js(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){qs(this,e,t),js(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){Gs(this,e,t),js(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){qs(this,e,t),js(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){Gs(this,e,t),js(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){qs(this,e,t),js(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){Gs(this,e,t),js(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){qs(this,e,t),js(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){Gs(this,e,t),js(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){qs(this,e,t),js(this,e,(e=>{this.i._attachProtoVectorListener(e,n||!1)}))}attachAudioListener(e,t,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Gs(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),js(this,e,(e=>{this.i._attachAudioListener(e,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Ga{get fa(){return this.i}va(e,t,n){js(this,t,(t=>{const[i,r]=Vs(this,e,t);this.fa._addBoundTextureAsImageToStream(t,i,r,n)}))}ba(e,t){Gs(this,e,t),js(this,e,(e=>{this.fa._attachImageListener(e)}))}ca(e,t){qs(this,e,t),js(this,e,(e=>{this.fa._attachImageVectorListener(e)}))}}));var Ga,qa=class extends Ba{};async function Ha(e,t,n){return async function(e,t,n,i){return async function(e,t,n,i){return e=await(async(e,t,n,i,r)=>{if(t&&await Fs(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await Fs(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new e(r,i)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile:e=>e.endsWith(".wasm")?n.wasmBinaryPath.toString():n.assetBinaryPath&&e.endsWith(".data")?n.assetBinaryPath.toString():e}),await e.o(i),e}(e,t,n,i)}(e,n.canvas??("undefined"==typeof OffscreenCanvas||Us()?document.createElement("canvas"):void 0),t,n)}function Wa(e,t,n,i){if(e.J){const o=new co;if(n?.regionOfInterest){if(!e.U)throw Error("This task doesn't support region-of-interest.");var r=n.regionOfInterest;if(r.left>=r.right||r.top>=r.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>r.left||0>r.top||1{for(const t of e)e=Qr(t),this.j.detections.push(_s(e));Ks(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ya.prototype.detectForVideo=Ya.prototype.H,Ya.prototype.detect=Ya.prototype.G,Ya.prototype.setOptions=Ya.prototype.o,Ya.createFromModelPath=async function(e,t){return Ha(Ya,e,{baseOptions:{modelAssetPath:t}})},Ya.createFromModelBuffer=function(e,t){return Ha(Ya,e,{baseOptions:{modelAssetBuffer:t}})},Ya.createFromOptions=function(e,t){return Ha(Ya,e,t)};var Qa=Va([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),$a=Va([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),Za=Va([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),ec=Va([474,475],[475,476],[476,477],[477,474]),tc=Va([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),nc=Va([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),ic=Va([469,470],[470,471],[471,472],[472,469]),rc=Va([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),oc=[...Qa,...$a,...Za,...tc,...nc,...rc],sc=Va([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function ac(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var cc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,An(e=this.h=new Vo,0,1,t=new Oo),this.v=new Fo,An(this.h,0,3,this.v),this.u=new Io,An(this.h,0,2,this.u),Bn(this.u,4,1),Gn(this.u,2,.5),Gn(this.v,2,.5),Gn(this.h,4,.5)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){return"numFaces"in e&&Bn(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&Gn(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&Gn(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&Gn(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}G(e,t){return ac(this),Ka(this,e,t),this.j}H(e,t,n){return ac(this),za(this,e,n,t),this.j}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect"),Ir(e,"face_landmarks");const t=new hr;qn(t,Go,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),Or(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=oo(t),this.j.faceLandmarks.push(Rs(e));Ks(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{Ks(this,e)})),this.outputFaceBlendshapes&&(Ir(e,"blendshapes"),Er(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=Vr(t),this.j.faceBlendshapes.push(Ps(e.g()??[]));Ks(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{Ks(this,e)}))),this.outputFacialTransformationMatrixes&&(Ir(e,"face_geometry"),Er(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=On(Lo(t),so,2))&&this.j.facialTransformationMatrixes.push({rows:Fn(Ln(e,1))??0,columns:Fn(Ln(e,2))??0,data:fn(e,3,Et)??[]});Ks(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{Ks(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};cc.prototype.detectForVideo=cc.prototype.H,cc.prototype.detect=cc.prototype.G,cc.prototype.setOptions=cc.prototype.o,cc.createFromModelPath=function(e,t){return Ha(cc,e,{baseOptions:{modelAssetPath:t}})},cc.createFromModelBuffer=function(e,t){return Ha(cc,e,{baseOptions:{modelAssetBuffer:t}})},cc.createFromOptions=function(e,t){return Ha(cc,e,t)},cc.FACE_LANDMARKS_LIPS=Qa,cc.FACE_LANDMARKS_LEFT_EYE=$a,cc.FACE_LANDMARKS_LEFT_EYEBROW=Za,cc.FACE_LANDMARKS_LEFT_IRIS=ec,cc.FACE_LANDMARKS_RIGHT_EYE=tc,cc.FACE_LANDMARKS_RIGHT_EYEBROW=nc,cc.FACE_LANDMARKS_RIGHT_IRIS=ic,cc.FACE_LANDMARKS_FACE_OVAL=rc,cc.FACE_LANDMARKS_CONTOURS=oc,cc.FACE_LANDMARKS_TESSELATION=sc;var dc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!0),An(e=this.j=new qo,0,1,t=new Oo)}get baseOptions(){return On(this.j,Oo,1)}set baseOptions(e){An(this.j,0,1,e)}o(e){return super.l(e)}Ua(e,t,n){const i="function"!=typeof t?t:{};if(this.h="function"==typeof t?t:n,Ka(this,e,i??{}),!this.h)return this.u}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect"),Ir(e,"stylized_image");const t=new hr;qn(t,Ho,this.j);const n=new Sr;kr(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),Or(e,n),this.g.ba("stylized_image",((e,t)=>{var n=!this.h,i=e.data,r=e.width;const o=r*(e=e.height);if(i instanceof Uint8Array)if(i.length===3*o){const t=new Uint8ClampedArray(4*o);for(let e=0;e{this.u=null,this.h&&this.h(null),Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};dc.prototype.stylize=dc.prototype.Ua,dc.prototype.setOptions=dc.prototype.o,dc.createFromModelPath=function(e,t){return Ha(dc,e,{baseOptions:{modelAssetPath:t}})},dc.createFromModelBuffer=function(e,t){return Ha(dc,e,{baseOptions:{modelAssetBuffer:t}})},dc.createFromOptions=function(e,t){return Ha(dc,e,t)};var lc=Va([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function uc(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function hc(e){return 0===e.gestures.length?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function pc(e,t=!0){const n=[];for(const r of e){var i=Vr(r);e=[];for(const n of i.g())i=t&&null!=Ln(n,1)?Fn(Ln(n,1)):-1,e.push({score:jn(n,2)??0,index:i,categoryName:Un(n,3)??""??"",displayName:Un(n,4)??""??""});n.push(e)}return n}var mc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],An(e=this.v=new ns,0,1,t=new Oo),this.B=new es,An(this.v,0,2,this.B),this.u=new $o,An(this.B,0,3,this.u),this.h=new Yo,An(this.B,0,2,this.h),this.j=new Jo,An(this.v,0,3,this.j),Gn(this.h,2,.5),Gn(this.B,4,.5),Gn(this.u,2,.5)}get baseOptions(){return On(this.v,Oo,1)}set baseOptions(e){An(this.v,0,1,e)}o(e){if(Bn(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&Gn(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&Gn(this.B,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&Gn(this.u,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Wo,n=t,i=ws(e.cannedGesturesClassifierOptions,On(this.j,Wo,3)?.h());An(n,0,2,i),An(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&On(this.j,Wo,3)?.g();return e.customGesturesClassifierOptions?(An(n=t=new Wo,0,2,i=ws(e.customGesturesClassifierOptions,On(this.j,Wo,4)?.h())),An(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&On(this.j,Wo,4)?.g(),this.l(e)}Pa(e,t){return uc(this),Ka(this,e,t),hc(this)}Qa(e,t,n){return uc(this),za(this,e,n,t),hc(this)}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect"),Ir(e,"hand_gestures"),Ir(e,"hand_landmarks"),Ir(e,"world_hand_landmarks"),Ir(e,"handedness");const t=new hr;qn(t,os,this.v);const n=new Sr;kr(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"HAND_GESTURES:hand_gestures"),Er(n,"LANDMARKS:hand_landmarks"),Er(n,"WORLD_LANDMARKS:world_hand_landmarks"),Er(n,"HANDEDNESS:handedness"),n.o(t),Or(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=oo(t);const n=[];for(const t of In(e,no,1))n.push({x:jn(t,1)??0,y:jn(t,2)??0,z:jn(t,3)??0});this.landmarks.push(n)}Ks(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{Ks(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=to(t);const n=[];for(const t of In(e,$r,1))n.push({x:jn(t,1)??0,y:jn(t,2)??0,z:jn(t,3)??0});this.worldLandmarks.push(n)}Ks(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{Ks(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...pc(e,!1)),Ks(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{Ks(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...pc(e)),Ks(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function fc(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}mc.prototype.recognizeForVideo=mc.prototype.Qa,mc.prototype.recognize=mc.prototype.Pa,mc.prototype.setOptions=mc.prototype.o,mc.createFromModelPath=function(e,t){return Ha(mc,e,{baseOptions:{modelAssetPath:t}})},mc.createFromModelBuffer=function(e,t){return Ha(mc,e,{baseOptions:{modelAssetBuffer:t}})},mc.createFromOptions=function(e,t){return Ha(mc,e,t)},mc.HAND_CONNECTIONS=lc;var gc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],An(e=this.j=new es,0,1,t=new Oo),this.u=new $o,An(this.j,0,3,this.u),this.h=new Yo,An(this.j,0,2,this.h),Bn(this.h,3,1),Gn(this.h,2,.5),Gn(this.u,2,.5),Gn(this.j,4,.5)}get baseOptions(){return On(this.j,Oo,1)}set baseOptions(e){An(this.j,0,1,e)}o(e){return"numHands"in e&&Bn(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&Gn(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&Gn(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&Gn(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}G(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Ka(this,e,t),fc(this)}H(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],za(this,e,n,t),fc(this)}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect"),Ir(e,"hand_landmarks"),Ir(e,"world_hand_landmarks"),Ir(e,"handedness");const t=new hr;qn(t,rs,this.j);const n=new Sr;kr(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"LANDMARKS:hand_landmarks"),Er(n,"WORLD_LANDMARKS:world_hand_landmarks"),Er(n,"HANDEDNESS:handedness"),n.o(t),Or(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=oo(t),this.landmarks.push(Rs(e));Ks(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{Ks(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=to(t),this.worldLandmarks.push(Os(e));Ks(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{Ks(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,i=n.push;const r=[];for(const t of e){e=Vr(t);const n=[];for(const t of e.g())n.push({score:jn(t,2)??0,index:Fn(Ln(t,1))??-1,categoryName:Un(t,3)??""??"",displayName:Un(t,4)??""??""});r.push(n)}i.call(n,...r),Ks(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};gc.prototype.detectForVideo=gc.prototype.H,gc.prototype.detect=gc.prototype.G,gc.prototype.setOptions=gc.prototype.o,gc.createFromModelPath=function(e,t){return Ha(gc,e,{baseOptions:{modelAssetPath:t}})},gc.createFromModelBuffer=function(e,t){return Ha(gc,e,{baseOptions:{modelAssetBuffer:t}})},gc.createFromOptions=function(e,t){return Ha(gc,e,t)},gc.HAND_CONNECTIONS=lc;var vc=class extends Xa{constructor(e,t){super(new qa(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},An(e=this.h=new ss,0,1,t=new Oo)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){return An(this.h,0,2,ws(e,On(this.h,To,2))),this.l(e)}ya(e,t){return this.j={classifications:[]},Ka(this,e,t),this.j}za(e,t,n){return this.j={classifications:[]},za(this,e,n,t),this.j}m(){var e=new Ar;xr(e,"input_image"),xr(e,"norm_rect"),Ir(e,"classifications");const t=new hr;qn(t,as,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Tr(n,"IMAGE:input_image"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"CLASSIFICATIONS:classifications"),n.o(t),Or(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:In(e,lo,1).map((e=>Ps(On(e,Fr,4)?.g()??[],Fn(Ln(e,2)),Un(e,3)??"")))};return null!=At(cn(e,2))&&(t.timestampMs=Fn(At(cn(e,2)))),t}(po(e)),Ks(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};vc.prototype.classifyForVideo=vc.prototype.za,vc.prototype.classify=vc.prototype.ya,vc.prototype.setOptions=vc.prototype.o,vc.createFromModelPath=function(e,t){return Ha(vc,e,{baseOptions:{modelAssetPath:t}})},vc.createFromModelBuffer=function(e,t){return Ha(vc,e,{baseOptions:{modelAssetBuffer:t}})},vc.createFromOptions=function(e,t){return Ha(vc,e,t)};var yc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!0),this.h=new cs,this.embeddings={embeddings:[]},An(e=this.h,0,1,t=new Oo)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){var t=this.h,n=On(this.h,So,2);return n=n?n.clone():new So,void 0!==e.l2Normalize?Vn(n,1,e.l2Normalize):"l2Normalize"in e&&ln(n,1),void 0!==e.quantize?Vn(n,2,e.quantize):"quantize"in e&&ln(n,2),An(t,0,2,n),this.l(e)}Fa(e,t){return Ka(this,e,t),this.embeddings}Ga(e,t,n){return za(this,e,n,t),this.embeddings}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect"),Ir(e,"embeddings_out");const t=new hr;qn(t,ds,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"EMBEDDINGS:embeddings_out"),n.o(t),Or(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=ko(e),this.embeddings=function(e){return{embeddings:In(e,go,1).map((e=>{const t={headIndex:Fn(Ln(e,3))??-1,headName:Un(e,4)??""??""};if(void 0!==Rn(e,mo,wn(e,1)))e=fn(e=On(e,mo,wn(e,1)),1,Et),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=On(e,fo,wn(e,2))?.ua()?.wa()??n}return t})),timestampMs:Fn(At(cn(e,2)))}}(e),Ks(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};yc.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Is(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Is(xs(e.quantizedEmbedding),xs(t.quantizedEmbedding))}return e},yc.prototype.embedForVideo=yc.prototype.Ga,yc.prototype.embed=yc.prototype.Fa,yc.prototype.setOptions=yc.prototype.o,yc.createFromModelPath=function(e,t){return Ha(yc,e,{baseOptions:{modelAssetPath:t}})},yc.createFromModelBuffer=function(e,t){return Ha(yc,e,{baseOptions:{modelAssetBuffer:t}})},yc.createFromOptions=function(e,t){return Ha(yc,e,t)};var bc=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};function kc(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Tc(e){try{const t=new bc(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{Xs(e)}}bc.prototype.close=bc.prototype.close;var Ec=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ms,this.v=new ls,An(this.h,0,3,this.v),An(e=this.h,0,1,t=new Oo)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?ln(this.h,2,Dt(e.displayNamesLocale)):"displayNamesLocale"in e&&ln(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}N(){!function(e){const t=In(e.da(),Sr,1).filter((e=>(Un(e,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(e.u=[],1{e.u[Number(n)]=Un(t,1)??""}))}(this)}ea(e,t,n){const i="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,kc(this),Ka(this,e,i),Tc(this)}Sa(e,t,n,i){const r="function"!=typeof n?n:{};return this.j="function"==typeof n?n:i,kc(this),za(this,e,r,t),Tc(this)}Ja(){return this.u}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect");const t=new hr;qn(t,fs,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),n.o(t),Or(e,n),zs(this,e),this.outputConfidenceMasks&&(Ir(e,"confidence_masks"),Er(n,"CONFIDENCE_MASKS:confidence_masks"),Js(this,"confidence_masks"),this.g.ca("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>Ja(this,e,!0,!this.j))),Ks(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],Ks(this,e)}))),this.outputCategoryMask&&(Ir(e,"category_mask"),Er(n,"CATEGORY_MASK:category_mask"),Js(this,"category_mask"),this.g.ba("category_mask",((e,t)=>{this.categoryMask=Ja(this,e,!1,!this.j),Ks(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,Ks(this,e)}))),Ir(e,"quality_scores"),Er(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,Ks(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ec.prototype.getLabels=Ec.prototype.Ja,Ec.prototype.segmentForVideo=Ec.prototype.Sa,Ec.prototype.segment=Ec.prototype.ea,Ec.prototype.setOptions=Ec.prototype.o,Ec.createFromModelPath=function(e,t){return Ha(Ec,e,{baseOptions:{modelAssetPath:t}})},Ec.createFromModelBuffer=function(e,t){return Ha(Ec,e,{baseOptions:{modelAssetBuffer:t}})},Ec.createFromOptions=function(e,t){return Ha(Ec,e,t)};var Sc=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};Sc.prototype.close=Sc.prototype.close;var Cc=class extends Hn{constructor(e){super(e)}},wc=[0,Ui,-2],Pc=[0,xi,-3,Vi],_c=[0,xi,-3,Vi,xi,-1],Rc=[0,_c],Oc=[0,Rc,wc],xc=[0,_c,wc],Ic=[0,_c,Ui,-1],Ac=[0,Ic,wc],Mc=[0,xi,-3,Vi,wc,-1],Dc=[0,xi,-3,Vi,Yi],Nc=class extends Hn{constructor(e){super(e)}},Lc=[0,xi,-1,Vi],Uc=class extends Hn{constructor(){super()}};Uc.A=[1];var Fc=class extends Hn{constructor(e){super(e)}},jc=[1,2,3,4,5,6,7,8,9,10,14,15],Vc=[0,jc,zi,_c,zi,xc,zi,Rc,zi,Oc,zi,Lc,zi,Dc,zi,Pc,zi,[0,Hi,xi,-2,Vi,Ui,Vi,-1,2,xi,wc],zi,Ic,zi,Ac,xi,wc,Hi,zi,Mc,zi,[0,Oi,Lc]],Bc=[0,Hi,Ui,-1,Vi],Gc=class extends Hn{constructor(){super()}};Gc.A=[1],Gc.prototype.g=tr([0,Oi,Vc,Hi,Bc]);var qc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ms,this.v=new ls,An(this.h,0,3,this.v),An(e=this.h,0,1,t=new Oo)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}ea(e,t,n,i){const r="function"!=typeof n?n:{};this.j="function"==typeof n?n:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.I+1,i=new Gc;const o=new Fc;var s=new Cc;if(Bn(s,1,255),An(o,0,12,s),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var a=new Nc;Vn(a,3,!0),Gn(a,1,t.keypoint.x),Gn(a,2,t.keypoint.y),Mn(o,5,jc,a)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(a of(s=new Uc,t.scribble))Vn(t=new Nc,3,!0),Gn(t,1,a.x),Gn(t,2,a.y),Nn(s,Nc,t);Mn(o,15,jc,s)}Nn(i,Fc,o),this.g.addProtoToStream(i.g(),"drishti.RenderData","roi_in",n),Ka(this,e,r);e:{try{const e=new Sc(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=e;break e}this.j(e)}finally{Xs(this)}c=void 0}return c}m(){var e=new Ar;xr(e,"image_in"),xr(e,"roi_in"),xr(e,"norm_rect_in");const t=new hr;qn(t,fs,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"ROI:roi_in"),Tr(n,"NORM_RECT:norm_rect_in"),n.o(t),Or(e,n),zs(this,e),this.outputConfidenceMasks&&(Ir(e,"confidence_masks"),Er(n,"CONFIDENCE_MASKS:confidence_masks"),Js(this,"confidence_masks"),this.g.ca("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>Ja(this,e,!0,!this.j))),Ks(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],Ks(this,e)}))),this.outputCategoryMask&&(Ir(e,"category_mask"),Er(n,"CATEGORY_MASK:category_mask"),Js(this,"category_mask"),this.g.ba("category_mask",((e,t)=>{this.categoryMask=Ja(this,e,!1,!this.j),Ks(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,Ks(this,e)}))),Ir(e,"quality_scores"),Er(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,Ks(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};qc.prototype.segment=qc.prototype.ea,qc.prototype.setOptions=qc.prototype.o,qc.createFromModelPath=function(e,t){return Ha(qc,e,{baseOptions:{modelAssetPath:t}})},qc.createFromModelBuffer=function(e,t){return Ha(qc,e,{baseOptions:{modelAssetBuffer:t}})},qc.createFromOptions=function(e,t){return Ha(qc,e,t)};var Hc=class extends Xa{constructor(e,t){super(new qa(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},An(e=this.h=new gs,0,1,t=new Oo)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?ln(this.h,2,Dt(e.displayNamesLocale)):"displayNamesLocale"in e&&ln(this.h,2),void 0!==e.maxResults?Bn(this.h,3,e.maxResults):"maxResults"in e&&ln(this.h,3),void 0!==e.scoreThreshold?Gn(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&ln(this.h,4),void 0!==e.categoryAllowlist?En(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&ln(this.h,5),void 0!==e.categoryDenylist?En(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&ln(this.h,6),this.l(e)}G(e,t){return this.j={detections:[]},Ka(this,e,t),this.j}H(e,t,n){return this.j={detections:[]},za(this,e,n,t),this.j}m(){var e=new Ar;xr(e,"input_frame_gpu"),xr(e,"norm_rect"),Ir(e,"detections");const t=new hr;qn(t,vs,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),Tr(n,"IMAGE:input_frame_gpu"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"DETECTIONS:detections"),n.o(t),Or(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=Qr(t),this.j.detections.push(_s(e));Ks(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{Ks(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Wc(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function Kc(e){try{const t=new class{constructor(e,t,n){this.landmarks=e,this.worldLandmarks=t,this.g=n}close(){this.g?.forEach((e=>{e.close()}))}}(e.landmarks,e.worldLandmarks,e.v);if(!e.u)return t;e.u(t)}finally{Xs(e)}}Hc.prototype.detectForVideo=Hc.prototype.H,Hc.prototype.detect=Hc.prototype.G,Hc.prototype.setOptions=Hc.prototype.o,Hc.createFromModelPath=async function(e,t){return Ha(Hc,e,{baseOptions:{modelAssetPath:t}})},Hc.createFromModelBuffer=function(e,t){return Ha(Hc,e,{baseOptions:{modelAssetBuffer:t}})},Hc.createFromOptions=function(e,t){return Ha(Hc,e,t)};var zc=class extends Xa{constructor(e,t){super(new qa(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,An(e=this.h=new Es,0,1,t=new Oo),this.B=new ks,An(this.h,0,3,this.B),this.j=new ys,An(this.h,0,2,this.j),Bn(this.j,4,1),Gn(this.j,2,.5),Gn(this.B,2,.5),Gn(this.h,4,.5)}get baseOptions(){return On(this.h,Oo,1)}set baseOptions(e){An(this.h,0,1,e)}o(e){return"numPoses"in e&&Bn(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&Gn(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&Gn(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&Gn(this.B,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}G(e,t,n){const i="function"!=typeof t?t:{};return this.u="function"==typeof t?t:n,Wc(this),Ka(this,e,i),Kc(this)}H(e,t,n,i){const r="function"!=typeof n?n:{};return this.u="function"==typeof n?n:i,Wc(this),za(this,e,r,t),Kc(this)}m(){var e=new Ar;xr(e,"image_in"),xr(e,"norm_rect"),Ir(e,"normalized_landmarks"),Ir(e,"world_landmarks"),Ir(e,"segmentation_masks");const t=new hr;qn(t,Cs,this.h);const n=new Sr;kr(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Tr(n,"IMAGE:image_in"),Tr(n,"NORM_RECT:norm_rect"),Er(n,"NORM_LANDMARKS:normalized_landmarks"),Er(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),Or(e,n),zs(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=oo(t),this.landmarks.push(Rs(e));Ks(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],Ks(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=to(t),this.worldLandmarks.push(Os(e));Ks(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],Ks(this,e)})),this.outputSegmentationMasks&&(Er(n,"SEGMENTATION_MASK:segmentation_masks"),Js(this,"segmentation_masks"),this.g.ca("segmentation_masks",((e,t)=>{this.v=e.map((e=>Ja(this,e,!0,!this.u))),Ks(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],Ks(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};zc.prototype.detectForVideo=zc.prototype.H,zc.prototype.detect=zc.prototype.G,zc.prototype.setOptions=zc.prototype.o,zc.createFromModelPath=function(e,t){return Ha(zc,e,{baseOptions:{modelAssetPath:t}})},zc.createFromModelBuffer=function(e,t){return Ha(zc,e,{baseOptions:{modelAssetBuffer:t}})},zc.createFromOptions=function(e,t){return Ha(zc,e,t)},zc.POSE_CONNECTIONS=Va([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);var Jc=Object.defineProperty,Xc=Object.defineProperties,Yc=Object.getOwnPropertyDescriptors,Qc=Object.getOwnPropertySymbols,$c=Object.prototype.hasOwnProperty,Zc=Object.prototype.propertyIsEnumerable,ed=(e,t,n)=>t in e?Jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,td=(e,t)=>{for(var n in t||(t={}))$c.call(t,n)&&ed(e,n,t[n]);if(Qc)for(var n of Qc(t))Zc.call(t,n)&&ed(e,n,t[n]);return e},nd=class{static get isSupported(){return"undefined"!=typeof MediaStreamTrackGenerator&&"undefined"!=typeof MediaStreamTrackProcessor}constructor(e,t){this.name=t,this.transformer=e,this.transformer.restart}async setup(e){var t,n,i,r;this.source=e.track;const o=this.source.getConstraints();if(await this.source.applyConstraints(((e,t)=>Xc(e,Yc({resizeMode:"none"})))(td({},o))),this.sourceSettings=this.source.getSettings(),this.sourceDummy=e.element,this.sourceDummy instanceof HTMLVideoElement&&(this.sourceDummy.height=null!=(t=this.sourceSettings.height)?t:300,this.sourceDummy.width=null!=(n=this.sourceSettings.width)?n:300),!(this.sourceDummy instanceof HTMLVideoElement))throw TypeError("Currently only video transformers are supported");this.processor=new MediaStreamTrackProcessor({track:this.source}),this.trackGenerator=new MediaStreamTrackGenerator({kind:"video",signalTarget:this.source}),this.canvas=new OffscreenCanvas(null!=(i=this.sourceSettings.width)?i:300,null!=(r=this.sourceSettings.height)?r:300)}async init(e){if(await this.setup(e),!this.canvas||!this.processor||!this.trackGenerator)throw new TypeError("Expected both canvas and processor to be defined after setup");let t=this.processor.readable;await this.transformer.init({outputCanvas:this.canvas,inputElement:this.sourceDummy}),t=t.pipeThrough(this.transformer.transformer),t.pipeTo(this.trackGenerator.writable).catch((e=>console.error("error when trying to pipe",e))).finally((()=>this.destroy())),this.processedTrack=this.trackGenerator}async restart(e){return await this.destroy(),this.init(e)}async restartTransformer(...e){this.transformer.restart(e[0])}async updateTransformerOptions(...e){this.transformer.update(e[0])}async destroy(){var e;await this.transformer.destroy(),null==(e=this.trackGenerator)||e.stop()}},id=class{constructor(){this.isDisabled=!1}async init({outputCanvas:e,inputElement:t}){var n;if(!(t instanceof HTMLVideoElement))throw TypeError("Video transformer needs a HTMLVideoElement as input");this.transformer=new TransformStream({transform:(e,t)=>this.transform(e,t)}),this.canvas=e||null,e&&(this.ctx=(null==(n=this.canvas)?void 0:n.getContext("2d"))||void 0),this.inputVideo=t,this.isDisabled=!1}async restart({outputCanvas:e,inputElement:t}){this.canvas=e||null,this.ctx=this.canvas.getContext("2d")||void 0,this.inputVideo=t,this.isDisabled=!1}async destroy(){this.isDisabled=!0,this.canvas=void 0,this.ctx=void 0}},rd=class extends id{constructor(e){super(),this.backgroundImage=null,this.options=e,this.update(e)}static get isSupported(){return"undefined"!=typeof OffscreenCanvas}async init({outputCanvas:e,inputElement:t}){var n,i,r,o;await super.init({outputCanvas:e,inputElement:t});const s=await Ls.forVisionTasks(null!=(i=null==(n=this.options.assetPaths)?void 0:n.tasksVisionFileSet)?i:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.9/wasm");this.imageSegmenter=await Ec.createFromOptions(s,{baseOptions:td({modelAssetPath:null!=(o=null==(r=this.options.assetPaths)?void 0:r.modelAssetPath)?o:"https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_segmenter/float16/latest/selfie_segmenter.tflite",delegate:"GPU"},this.options.segmenterOptions),runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!1})}async destroy(){var e;await super.destroy(),await(null==(e=this.imageSegmenter)?void 0:e.close()),this.backgroundImage=null}async loadBackground(e){const t=new Image;await new Promise(((n,i)=>{t.crossOrigin="Anonymous",t.onload=()=>n(t),t.onerror=e=>i(e),t.src=e}));const n=await createImageBitmap(t);this.backgroundImage=n}async transform(e,t){var n;try{if(this.isDisabled)return void t.enqueue(e);if(!this.canvas)throw TypeError("Canvas needs to be initialized first");let i=performance.now();null==(n=this.imageSegmenter)||n.segmentForVideo(this.inputVideo,i,(e=>this.segmentationResults=e)),this.blurRadius?await this.blurBackground(e):await this.drawVirtualBackground(e);const r=new VideoFrame(this.canvas,{timestamp:e.timestamp||Date.now()});t.enqueue(r)}finally{e.close()}}async update(e){this.options=e,e.blurRadius?this.blurRadius=e.blurRadius:e.imagePath&&await this.loadBackground(e.imagePath)}async drawVirtualBackground(e){var t;if(this.canvas&&this.ctx&&this.segmentationResults&&this.inputVideo){if(null==(t=this.segmentationResults)?void 0:t.categoryMask){this.ctx.filter="blur(10px)",this.ctx.globalCompositeOperation="copy";const e=await od(this.segmentationResults.categoryMask,this.segmentationResults.categoryMask.width,this.segmentationResults.categoryMask.height);this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height),this.ctx.filter="none",this.ctx.globalCompositeOperation="source-in",this.backgroundImage?this.ctx.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,this.canvas.width,this.canvas.height):(this.ctx.fillStyle="#00FF00",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)),this.ctx.globalCompositeOperation="destination-over"}this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height)}}async blurBackground(e){var t,n;if(!(this.ctx&&this.canvas&&(null==(n=null==(t=this.segmentationResults)?void 0:t.categoryMask)?void 0:n.canvas)&&this.inputVideo))return;this.ctx.save(),this.ctx.globalCompositeOperation="copy";const i=await od(this.segmentationResults.categoryMask,this.segmentationResults.categoryMask.width,this.segmentationResults.categoryMask.height);this.ctx.filter="blur(3px)",this.ctx.globalCompositeOperation="copy",this.ctx.drawImage(i,0,0,this.canvas.width,this.canvas.height),this.ctx.filter="none",this.ctx.globalCompositeOperation="source-out",this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height),this.ctx.globalCompositeOperation="destination-over",this.ctx.filter=`blur(${this.blurRadius}px)`,this.ctx.drawImage(e,0,0,this.canvas.width,this.canvas.height),this.ctx.restore()}};function od(e,t,n){const i=new Uint8ClampedArray(t*n*4),r=e.getAsUint8Array();for(let e=0;ecd({blurRadius:e,segmenterOptions:t},"background-blur"),ad=(e,t)=>cd({imagePath:e,segmenterOptions:t},"virtual-background"),cd=(e,t="background-processor")=>{if(!nd.isSupported||!rd.isSupported)throw new Error("processor is not supported in this browser");return new nd(new rd(e),t)}},7285:(e,t,n)=>{"use strict";function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}n.r(t),n.d(t,{Emitter:()=>i}),i.prototype.on=i.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},i.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0;r{"use strict";e.exports=JSON.parse('{"author":"OpenVidu","dependencies":{"@livekit/egress-sdk":"^0.2.0","@livekit/track-processors":"^0.3.1","@mediapipe/tasks-vision":"0.10.12","events":"3.3.0","hark":"^1.2.3","inherits":"2.0.4","livekit-client":"2.1.0","mime":"3.0.0","platform":"1.3.6","rxjs":"7.8.1","semver":"7.6.0","socket.io-client":"^4.7.5","uuid":"9.0.1","wolfy87-eventemitter":"5.2.9"},"description":"OpenVidu Browser","devDependencies":{"@types/dom-mediacapture-transform":"0.1.7","@types/dom-webcodecs":"0.1.4","@types/node":"^18.11.9","@types/platform":"1.3.4","browserify":"17.0.0","grunt":"1.5.3","grunt-cli":"1.4.3","grunt-contrib-copy":"1.0.0","grunt-contrib-sass":"2.0.0","grunt-contrib-uglify":"5.2.2","grunt-contrib-watch":"1.1.0","grunt-postcss":"0.9.0","grunt-string-replace":"1.3.3","grunt-ts":"6.0.0-beta.22","terser":"5.15.1","ts-loader":"^9.5.1","tsify":"5.0.4","tslint":"6.1.3","typedoc":"0.23.21","typescript":"4.9.3","webpack":"^5.91.0","webpack-cli":"^5.1.4"},"license":"Apache-2.0","main":"lib/index.js","name":"openvidu-browser","repository":{"type":"git","url":"git://github.com/OpenVidu/openvidu"},"scripts":{"dev:watch":"cd src/OpenVidu && ./../../node_modules/typescript/bin/tsc && cd ../.. && ./node_modules/typescript/bin/tsc -w --declaration src/index.ts --outDir ./lib --sourceMap --target es5 --lib dom,es5,es2015.promise,scripthost && rm -rf ./ts4.4 && mkdir -p ./ts4.4/lib && cp -r ./lib ./ts4.4 && find ./ts4.4/lib -type f ! -iname \'*.d.ts\' -delete && ./config/replace_for_ts44.sh","browserify":"./scripts/build.sh --version=dev --configuration=development","browserify-prod":"./scripts/build.sh --version=${VERSION:-dev} --configuration=production","build":"cd src/OpenVidu && ./../../node_modules/typescript/bin/tsc && cd ../.. && ./node_modules/typescript/bin/tsc --declaration src/index.ts --outDir ./lib --sourceMap --target es5 --lib dom,es5,es2015.promise,scripthost && rm -rf ./ts4.4 && mkdir -p ./ts4.4/lib && cp -r ./lib ./ts4.4 && find ./ts4.4/lib -type f ! -iname \'*.d.ts\' -delete && ./config/replace_for_ts44.sh","docs":"./generate-docs.sh"},"types":"lib/index.d.ts","typesVersions":{"<4.4":{"*":["ts4.4/*"]}},"version":"3.0.0-beta.1"}')}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e=n(177);"undefined"!=typeof globalThis&&(globalThis.OpenVidu=e.OpenVidu)})()})(); \ No newline at end of file diff --git a/pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js.LICENSE.txt b/pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js.LICENSE.txt new file mode 100644 index 0000000..f0074ff --- /dev/null +++ b/pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js.LICENSE.txt @@ -0,0 +1,13 @@ +/*! + * EventEmitter v5.2.9 - git.io/ee + * Unlicense - http://unlicense.org/ + * Oliver Caldwell - https://oli.me.uk/ + * @preserve + */ + +/*! + * Platform.js v1.3.6 + * Copyright 2014-2020 Benjamin Tan + * Copyright 2011-2013 John-David Dalton + * Available under MIT license + */